subscription.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <!--
  2. Page 'Mon abonnement'
  3. @see https://ressources.opentalent.fr/display/SPEC/Mon+abonnement
  4. -->
  5. <template>
  6. <LayoutContainer>
  7. <v-expansion-panels v-model="openedPanels" :multiple="true">
  8. <UiExpansionPanel :title="$t('subscription_page')" icon="fas fa-info">
  9. <v-container fluid class="container">
  10. <v-row>
  11. <v-col cols="12" lg="6" sm="12">
  12. {{ $t('version') }} : <strong>{{ dolibarrAccount ? $t(dolibarrAccount.product) : '-' }}</strong>
  13. <span v-if="organizationProfile.isTrialActive"> - En cours d'essai: <strong>{{$t('PRODUCT_ARTIST_PREMIUM')}} - J-{{organizationProfile.trialCountDown}}</strong></span>
  14. </v-col>
  15. <v-col cols="12" lg="6" sm="12">
  16. {{ $t('client_id') }} : {{ dolibarrAccount ? dolibarrAccount.clientNumber : '-' }}
  17. </v-col>
  18. </v-row>
  19. </v-container>
  20. </UiExpansionPanel>
  21. <UiExpansionPanel :title="$t('service_detail')" icon="fas fa-info"
  22. v-if="dolibarrAccount && dolibarrAccount.contract"
  23. >
  24. <v-container fluid class="container">
  25. <v-row>
  26. <v-col cols="12"
  27. lg="12"
  28. v-for="line in dolibarrAccount.contract.lines"
  29. :key="line.id"
  30. >
  31. <strong>{{ line.serviceLabel }}</strong> - {{ $t('until') }} : {{ $d(line.dateEnd) }}
  32. </v-col>
  33. <v-col cols="12" lg="12" v-if="ability.can('manage', 'texto')">
  34. <strong>{{ $t('remaining_sms_credit') }}</strong> -
  35. <span v-if="!mobytPending && mobytStatus !== null && mobytStatus.active">
  36. {{
  37. mobytStatus.money.toLocaleString($i18n.locale, {
  38. style: 'currency',
  39. currency: 'EUR',
  40. })
  41. }}
  42. {{
  43. i18n.t('convert_price_to_sms', {
  44. nb_sms: mobytStatus.amount,
  45. })
  46. }}
  47. </span>
  48. </v-col>
  49. </v-row>
  50. </v-container>
  51. </UiExpansionPanel>
  52. <UiExpansionPanel
  53. v-if="showDolibarrPanel"
  54. title="bills"
  55. icon="fas fa-file"
  56. >
  57. <v-container :fluid="true" class="container">
  58. <v-row>
  59. <v-table v-if="dolibarrAccount !== null">
  60. <thead>
  61. <tr>
  62. <th>{{ $t('reference') }}</th>
  63. <th>{{ $t('date') }}</th>
  64. <th>{{ $t('taxExcludedAmount') }}</th>
  65. <th>{{ $t('status') }}</th>
  66. </tr>
  67. </thead>
  68. <tbody>
  69. <tr v-for="bill in dolibarrAccount.bills" :key="bill.id">
  70. <td>{{ bill.ref }}</td>
  71. <td>{{ $d(bill.date) }}</td>
  72. <td>
  73. {{
  74. bill.taxExcludedAmount.toLocaleString($i18n.locale, {
  75. style: 'currency',
  76. currency: 'EUR',
  77. })
  78. }}
  79. </td>
  80. <td>
  81. {{ bill.paid === true ? $t('paid') : $t('unpaid') }}
  82. </td>
  83. </tr>
  84. </tbody>
  85. </v-table>
  86. </v-row>
  87. </v-container>
  88. </UiExpansionPanel>
  89. <UiExpansionPanel :title="$t('opentalent_offer')" icon="fas fa-plus" v-if="!organizationProfile.isManagerProduct">
  90. <v-container fluid class="container">
  91. <v-row class="offer_title" v-if="!md && mdAndUp && !organizationProfile.isSchool">
  92. <v-col cols="12" :lg="organizationProfile.isArtistPremiumProduct ? 3 : 6" sm="12">
  93. <span class="theme-artist">Pour les orchestres, chorales, compagnies et troupes artistiques</span>
  94. </v-col>
  95. <v-col cols="12" :lg="organizationProfile.isArtistPremiumProduct ? 3 : 5" sm="12" :offset="organizationProfile.isArtistPremiumProduct ? 0 : 1">
  96. <span class="theme-school">Pour les établissements d'enseignements artistiques*</span>
  97. </v-col>
  98. </v-row>
  99. <v-row class="card-container">
  100. <v-col lg="3" sm="12" md="6" v-if="organizationProfile.isArtistProduct">
  101. <PagesSubscriptionCard
  102. class="artistCard"
  103. title="Logiciel Artist Standard"
  104. :extraHeader="organizationProfile.isArtistProduct ? 'Votre version' : false"
  105. color="artist"
  106. :list="listCheck.artist"
  107. >
  108. <template #card.subTitle>
  109. <div class="priceBlock">
  110. <span class="price">{{formatCurrency(11, 'EUR')}}</span> TTC/mois
  111. </div>
  112. </template>
  113. <template #card.action>
  114. <v-btn
  115. class="theme-artist btn"
  116. href="https://logiciels.opentalent.fr/opentalent-artist"
  117. target="_blank"
  118. >
  119. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  120. </v-btn>
  121. </template>
  122. </PagesSubscriptionCard>
  123. </v-col>
  124. <v-col lg="3" sm="12" md="6" v-if="organizationProfile.isArtist">
  125. <PagesSubscriptionCard
  126. class="artistCard"
  127. title="Logiciel Artist Premium*"
  128. :extraHeader="organizationProfile.isArtistPremiumProduct ? 'Votre version' : '1 mois d\'essai offert'"
  129. color="artist"
  130. :list="listCheck.artistPremium"
  131. >
  132. <template #card.subTitle>
  133. <div class="priceBlock">
  134. <span class="price">{{organizationProfile.isCmf ? formatCurrency(7.5, 'EUR') : formatCurrency(18.0, 'EUR')}}</span> TTC/mois
  135. </div>
  136. </template>
  137. <template #card.action>
  138. <v-row >
  139. <v-col cols="12" v-if="!organizationProfile.isArtistPremiumProduct && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  140. <v-btn
  141. class="btn trialBtn"
  142. @click="startTrial"
  143. >
  144. Essayer la version premium <i class="fa-solid fa-greater-than small"></i>
  145. </v-btn>
  146. </v-col>
  147. <v-col cols="12" v-if="(!organizationProfile.isArtistPremiumProduct || organizationProfile.isTrialActive) && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  148. <v-btn
  149. class="theme-artist btn"
  150. @click="subscription"
  151. >
  152. Souscrire à l'offre <i class="fa-solid fa-greater-than small"></i>
  153. </v-btn>
  154. </v-col>
  155. <v-col cols="12">
  156. <v-btn
  157. class="theme-artist btn"
  158. href="https://logiciels.opentalent.fr/opentalent-artist"
  159. target="_blank"
  160. >
  161. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  162. </v-btn>
  163. </v-col>
  164. <v-col cols="12">
  165. <span class="special_conditions">
  166. *Convient aux petites écoles sans besoins spécifiques de gestion pédagogique, de facturation, etc.
  167. Pour une solution complète optez pour Opentalent School
  168. </span>
  169. </v-col>
  170. </v-row>
  171. </template>
  172. </PagesSubscriptionCard>
  173. </v-col>
  174. <v-col lg="3" sm="12" md="6" :offset="!md && mdAndUp ? (organizationProfile.isSchool ? 4 : (organizationProfile.isArtistPremiumProduct ? 0 : 2)) : 0">
  175. <PagesSubscriptionCard
  176. class="schoolCard"
  177. :title="!organizationProfile.isSchool ? 'Logiciel School Standard / Premium' : (
  178. organizationProfile.isSchoolPremiumProduct ? 'Logiciel School Premium' : 'Logiciel School Standard'
  179. )"
  180. :subTitle="!organizationProfile.isSchool ? 'Sur devis' : ''"
  181. :extraHeader="organizationProfile.isSchool ? 'Votre version' : false"
  182. color="school"
  183. :list="listCheck.school"
  184. >
  185. <template #card.action>
  186. <v-row>
  187. <v-col cols="12">
  188. <v-btn
  189. class="theme-school btn"
  190. href="https://logiciels.opentalent.fr/opentalent-school"
  191. target="_blank"
  192. >
  193. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  194. </v-btn>
  195. </v-col>
  196. <v-col cols="12">
  197. <span class="special_conditions">
  198. *Extranet disponible uniquement dans la version Opentalent School Premium
  199. </span>
  200. </v-col>
  201. </v-row>
  202. </template>
  203. </PagesSubscriptionCard>
  204. </v-col>
  205. </v-row>
  206. </v-container>
  207. </UiExpansionPanel>
  208. <UiExpansionPanel :title="$t('opentalent_options')" icon="fas fa-plus">
  209. <v-container fluid class="container card-container">
  210. <v-row cols="12" >
  211. <v-col lg="3" sm="12" md="6">
  212. <PagesSubscriptionCard
  213. class="optionsCard"
  214. title="SMS"
  215. sub-title="Option payante"
  216. color="primary"
  217. :list="listCheck.sms"
  218. >
  219. <template #card.action>
  220. <v-btn
  221. class="theme-primary btn"
  222. :href="
  223. runtimeConfig.public.fileStorageBaseUrl +
  224. (organizationProfile.isCmf ? '/Bon_de_commande/Achat_SMS_CMF.pdf' : '/Bon_de_commande/Achat_SMS_Public.pdf')
  225. "
  226. target="_blank"
  227. >
  228. acheter des credits SMS <i class="fa-solid fa-greater-than small"></i>
  229. </v-btn>
  230. </template>
  231. </PagesSubscriptionCard>
  232. </v-col>
  233. <v-col lg="3" sm="12" md="6">
  234. <PagesSubscriptionCard
  235. class="optionsCard"
  236. title="Nom de domaine"
  237. sub-title="Option payante"
  238. color="primary"
  239. :list="listCheck.domain"
  240. >
  241. <template #card.action>
  242. <v-btn
  243. class="theme-primary btn"
  244. :href="
  245. runtimeConfig.public.fileStorageBaseUrl +
  246. '/Bon_de_commande/Nom_de_domaine.pdf'
  247. "
  248. target="_blank"
  249. >
  250. souscrire à l'option <i class="fa-solid fa-greater-than small"></i>
  251. </v-btn>
  252. </template>
  253. </PagesSubscriptionCard>
  254. </v-col>
  255. </v-row>
  256. </v-container>
  257. </UiExpansionPanel>
  258. </v-expansion-panels>
  259. </LayoutContainer>
  260. <DialogTrialAllReadyDid
  261. :show="showDialog"
  262. @closeDialog = "showDialog = false"
  263. />
  264. </template>
  265. <script setup lang="ts">
  266. import {useAbility} from '@casl/vue'
  267. import type {Ref} from 'vue'
  268. import {useDisplay} from 'vuetify'
  269. import type {AsyncData} from '#app'
  270. import {useOrganizationProfileStore} from '~/stores/organizationProfile'
  271. import {useEntityFetch} from '~/composables/data/useEntityFetch'
  272. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  273. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  274. import UrlUtils from "~/services/utils/urlUtils";
  275. import {useAp2iRequestService} from "~/composables/data/useAp2iRequestService";
  276. //meta
  277. definePageMeta({
  278. name: 'subscription_page',
  279. })
  280. //Get composables
  281. const ability = useAbility()
  282. const runtimeConfig = useRuntimeConfig()
  283. const {mdAndUp, md} = useDisplay()
  284. const {fetch} = useEntityFetch()
  285. const i18n = useI18n()
  286. const { apiRequestService } = useAp2iRequestService()
  287. //Init ref
  288. const showDialog: Ref<boolean> = ref(false)
  289. const openedPanels: Ref<Array<string>> = initPanel()
  290. const organizationProfile = getOrganizationProfile()
  291. const accessProfileStore = useAccessProfileStore()
  292. const {mobytStatus, mobytPending}: Record<Ref<MobytUserStatus | null>, Ref<boolean>> = getMobytInformations()
  293. const {data: dolibarrAccount, pending: dolibarrPending} = fetch(
  294. DolibarrAccount,
  295. organizationProfile.id,
  296. )
  297. const showDolibarrPanel = computed(
  298. () =>
  299. !dolibarrPending.value &&
  300. dolibarrAccount.value &&
  301. dolibarrAccount.value.bills.length > 0,
  302. )
  303. const formatCurrency = (value: number, currency: string): string => {
  304. return value.toLocaleString(i18n.locale.value, {
  305. style: 'currency',
  306. currency,
  307. })
  308. }
  309. const listCheck: Record<string, Array<string>> = {
  310. 'artist' : [
  311. '100 Mo de stockage',
  312. '75 comptes utilisateurs',
  313. 'Gestion de la structure',
  314. 'Site internet restreint',
  315. 'Options disponibles',
  316. ],
  317. 'artistPremium' : [
  318. '1Go de stockage',
  319. '150 comptes utilisateurs',
  320. 'Gestion de la structure',
  321. 'Site internet illimité',
  322. 'Options disponibles',
  323. ],
  324. 'school' : [
  325. '500 Mo ou 1Go de stockage',
  326. '3 comptes administrateurs',
  327. 'Extranet élèves, tuteurs, professeurs*',
  328. 'Gestion de la structure',
  329. 'Suivi pédagogique, facturation, ...',
  330. 'Site internet complet',
  331. 'Options adaptées à chaque structure',
  332. ],
  333. 'sms': [
  334. 'Envoyez des SMS depuis votre logiciel',
  335. 'Choisissez le nombre de crédits'
  336. ],
  337. 'domain':[
  338. 'Bénéficiez de votre propre nom de domaine',
  339. 'Et d\'une adresse mail personnalisée'
  340. ]
  341. }
  342. /**
  343. * Initialisation des panels ouverts
  344. */
  345. function initPanel(): Ref<Array<string>> {
  346. // On déplie les expansion panels dans le onMounted en attendant la résolution du bug : https://github.com/vuetifyjs/vuetify/issues/16427#issuecomment-1380927133
  347. // TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref(['informations', 'bills', 'more_features'])`
  348. const openedPanels: Ref<Array<string>> = ref([])
  349. onMounted(() => {
  350. openedPanels.value = [i18n.t('subscription_page'), i18n.t('opentalent_offer'), i18n.t('opentalent_options')]
  351. })
  352. return openedPanels
  353. }
  354. /**
  355. * Récupération de l'organization profile
  356. */
  357. function getOrganizationProfile() {
  358. const organizationProfile = useOrganizationProfileStore()
  359. if (organizationProfile.id === null) {
  360. throw new Error("Missing organization's id")
  361. }
  362. return organizationProfile
  363. }
  364. /**
  365. * Récupération des informations Mobyt
  366. */
  367. function getMobytInformations(): Record<Ref<MobytUserStatus | null>, Ref<boolean>> {
  368. let mobytStatus: Ref<MobytUserStatus | null> = ref(null)
  369. let mobytPending: Ref<boolean> = ref(false)
  370. if (ability.can('manage', 'texto')) {
  371. const {data, pending} = fetch(
  372. MobytUserStatus,
  373. organizationProfile!.id!,
  374. ) as AsyncData<MobytUserStatus | null, Error | null>
  375. mobytStatus = data
  376. mobytPending = pending
  377. }
  378. return {mobytStatus, mobytPending}
  379. }
  380. /**
  381. * Action lorsque l'on souhaite démarrer l'essai
  382. */
  383. async function startTrial(){
  384. try{
  385. const apiV1BaseURL = runtimeConfig.baseUrlLegacy || runtimeConfig.public.baseUrlLegacy
  386. await apiRequestService.get(
  387. UrlUtils.join(apiV1BaseURL, '/api/trial/is_available')
  388. )
  389. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  390. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  391. external: true
  392. })
  393. }catch(error){
  394. showDialog.value = true
  395. }
  396. }
  397. /**
  398. * Action lorsque l'on souhaite souscrire à artist premium
  399. */
  400. async function subscription(){
  401. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  402. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial/subscribe'), {
  403. external: true
  404. })
  405. }
  406. </script>
  407. <style scoped lang="scss">
  408. .offer_title{
  409. span{
  410. border-radius: 5px;
  411. display: block;
  412. font-weight: bold;
  413. text-align: center;
  414. padding: 5px;
  415. }
  416. }
  417. .card-container{
  418. .v-row {
  419. display: -webkit-box;
  420. display: -webkit-flex;
  421. display: -ms-flexbox;
  422. display: flex;
  423. flex-wrap: wrap;
  424. }
  425. .v-row > [class*='v-col-'] {
  426. display: flex;
  427. flex-direction: column;
  428. }
  429. .small{
  430. font-size:6px;
  431. padding-top: 5px;
  432. padding-left: 5px;
  433. }
  434. .priceBlock{
  435. text-align: center;
  436. font-size: 15px;
  437. font-weight: normal;
  438. .price{
  439. font-size: 30px;
  440. font-weight: bold;
  441. }
  442. }
  443. }
  444. .artistCard{
  445. :deep(.v-card-title){
  446. text-align: center;
  447. }
  448. }
  449. .special_conditions{
  450. font-size: 10px;
  451. }
  452. .trialBtn{
  453. color: #000;
  454. border: 1px solid rgb(var(--v-theme-artist));
  455. }
  456. .optionsCard{
  457. :deep(.margin-sup){
  458. margin-top: 0px;
  459. }
  460. }
  461. </style>