subscription.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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="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') }} :
  13. <strong>{{
  14. dolibarrAccount ? $t(dolibarrAccount.product) : '-'
  15. }}</strong>
  16. </v-col>
  17. <v-col cols="12" lg="6" sm="12">
  18. {{ $t('client_id') }} :
  19. {{ dolibarrAccount ? dolibarrAccount.clientNumber : '-' }}
  20. </v-col>
  21. </v-row>
  22. </v-container>
  23. </UiExpansionPanel>
  24. <UiExpansionPanel
  25. v-if="dolibarrAccount && dolibarrAccount.contract"
  26. title="service_detail"
  27. icon="fas fa-info"
  28. >
  29. <v-container fluid class="container">
  30. <v-row>
  31. <v-col
  32. v-for="line in dolibarrAccount.contract.lines"
  33. :key="line.id"
  34. cols="12"
  35. lg="12"
  36. >
  37. <strong>{{ line.serviceLabel }}</strong> - {{ $t('until') }} :
  38. {{ $d(line.dateEnd) }}
  39. </v-col>
  40. <v-col v-if="ability.can('manage', 'texto')" cols="12" lg="12">
  41. <strong>{{ $t('remaining_sms_credit') }}</strong> -
  42. <span
  43. v-if="
  44. !mobytPending && mobytStatus !== null && mobytStatus.active
  45. "
  46. >
  47. {{
  48. mobytStatus.money.toLocaleString($i18n.locale, {
  49. style: 'currency',
  50. currency: 'EUR',
  51. })
  52. }}
  53. {{
  54. i18n.t('convert_price_to_sms', {
  55. nb_sms: mobytStatus.amount,
  56. })
  57. }}
  58. </span>
  59. </v-col>
  60. </v-row>
  61. </v-container>
  62. </UiExpansionPanel>
  63. <UiExpansionPanel
  64. v-if="showDolibarrPanel"
  65. title="bills"
  66. icon="fas fa-file"
  67. >
  68. <v-container :fluid="true" class="container">
  69. <v-row>
  70. <v-table v-if="dolibarrAccount !== null">
  71. <thead>
  72. <tr>
  73. <th>{{ $t('reference') }}</th>
  74. <th>{{ $t('date') }}</th>
  75. <th>{{ $t('taxExcludedAmount') }}</th>
  76. <th>{{ $t('status') }}</th>
  77. <th/>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. <tr v-for="bill in dolibarrAccount.bills" :key="bill.id">
  82. <td>{{ bill.ref }}</td>
  83. <td>{{ $d(bill.date) }}</td>
  84. <td>
  85. {{
  86. bill.taxExcludedAmount.toLocaleString($i18n.locale, {
  87. style: 'currency',
  88. currency: 'EUR',
  89. })
  90. }}
  91. </td>
  92. <td>
  93. {{ bill.paid === true ? $t('paid') : $t('unpaid') }}
  94. </td>
  95. <td>
  96. <a
  97. class="clickable"
  98. @click="downloadDolibarrBill(bill.ref)"
  99. >
  100. {{ $t('download') }}
  101. </a>
  102. </td>
  103. </tr>
  104. </tbody>
  105. </v-table>
  106. </v-row>
  107. </v-container>
  108. </UiExpansionPanel>
  109. <UiExpansionPanel
  110. v-if="!organizationProfile.isManagerProduct"
  111. title="opentalent_offers"
  112. icon="fas fa-plus"
  113. >
  114. <v-container fluid class="container">
  115. <v-row
  116. v-if="!md && mdAndUp && !organizationProfile.isSchool"
  117. class="offer_title"
  118. >
  119. <v-col
  120. cols="12"
  121. :lg="
  122. organizationProfile.isArtistPremiumProduct &&
  123. !organizationProfile.isTrialActive
  124. ? 4
  125. : 8
  126. "
  127. sm="12"
  128. >
  129. <span class="theme-artist"
  130. >Pour les orchestres, chorales, <br >compagnies et troupes
  131. artistiques</span
  132. >
  133. </v-col>
  134. <v-col cols="12" lg="4" sm="12">
  135. <span class="theme-school"
  136. >Pour les établissements d'enseignements <br >
  137. artistiques*</span
  138. >
  139. </v-col>
  140. </v-row>
  141. <v-row class="card-container">
  142. <v-col
  143. v-if="
  144. organizationProfile.isArtistProduct ||
  145. organizationProfile.isTrialActive
  146. "
  147. lg="4"
  148. sm="12"
  149. md="6"
  150. >
  151. <LayoutPagesSubscriptionCard
  152. class="artistCard"
  153. title="Logiciel Artist Standard"
  154. :extra-header="
  155. organizationProfile.isArtistProduct
  156. ? 'Votre version actuelle'
  157. : undefined
  158. "
  159. color="artist"
  160. :list="listCheck.artist"
  161. >
  162. <template #card.subTitle>
  163. <div class="priceBlock">
  164. <span v-if="organizationProfile.isCmf"
  165. ><strong>{{ $t('price_include_cmf') }}*</strong></span
  166. >
  167. <span v-else
  168. ><span class="price">{{
  169. formatCurrency(14.0, 'EUR')
  170. }}</span>
  171. TTC/mois*</span
  172. >
  173. </div>
  174. </template>
  175. <template #card.action>
  176. <v-row>
  177. <v-col
  178. v-if="
  179. !organizationProfile.isArtistProduct &&
  180. !organizationProfile.isTrialActive
  181. "
  182. cols="12"
  183. >
  184. <v-btn
  185. class="theme-artist btn"
  186. href="https://logiciels.opentalent.fr/opentalent-artist"
  187. target="_blank"
  188. >
  189. {{ $t('to_know_more') }}
  190. <i class="fa-solid fa-greater-than small"/>
  191. </v-btn>
  192. </v-col>
  193. <v-col cols="12">
  194. <span
  195. v-if="organizationProfile.isCmf"
  196. class="special_conditions"
  197. >
  198. *En cas de non-réadhésion, il reste accessible au tarif
  199. public de 14€ TTC/mois (Tarif 2025. Abonnement payable
  200. annuellement).
  201. </span>
  202. <span v-else class="special_conditions">
  203. *Tarif public 2025. Abonnement payable annuellement.
  204. </span>
  205. </v-col>
  206. </v-row>
  207. </template>
  208. </LayoutPagesSubscriptionCard>
  209. </v-col>
  210. <v-col v-if="organizationProfile.isArtist" lg="4" sm="12" md="6">
  211. <LayoutPagesSubscriptionCard
  212. class="artistCard"
  213. title="Logiciel Artist Premium*"
  214. :extra-header="
  215. organizationProfile.isArtistPremiumProduct
  216. ? organizationProfile.isTrialActive
  217. ? `Version en cours d'essai J-${organizationProfile.trialCountDown}`
  218. : 'Votre version actuelle'
  219. : '1 mois d\'essai offert'
  220. "
  221. color="artist"
  222. :list="listCheck.artistPremium"
  223. >
  224. <template #card.subTitle>
  225. <div
  226. v-if="
  227. !organizationProfile.isArtistPremiumProduct ||
  228. organizationProfile.isTrialActive
  229. "
  230. class="priceBlock"
  231. >
  232. <span class="price">{{
  233. organizationProfile.isCmf
  234. ? formatCurrency(7.5, 'EUR')
  235. : formatCurrency(18.0, 'EUR')
  236. }}</span>
  237. TTC/mois**
  238. </div>
  239. </template>
  240. <template #card.action>
  241. <v-row>
  242. <v-col
  243. v-if="
  244. !organizationProfile.isArtistPremiumProduct &&
  245. (accessProfileStore.isAdmin ||
  246. accessProfileStore.isCaMember)
  247. "
  248. cols="12"
  249. >
  250. <v-btn class="btn trialBtn" @click="startTrial">
  251. {{ $t('try_premium_version') }}
  252. <i class="fa-solid fa-greater-than small"/>
  253. </v-btn>
  254. </v-col>
  255. <v-col
  256. v-if="
  257. (!organizationProfile.isArtistPremiumProduct ||
  258. organizationProfile.isTrialActive) &&
  259. (accessProfileStore.isAdmin ||
  260. accessProfileStore.isCaMember)
  261. "
  262. cols="12"
  263. >
  264. <v-btn class="theme-artist btn" @click="subscription">
  265. {{ $t('subscribe_to_the_offer') }}
  266. <i class="fa-solid fa-greater-than small"/>
  267. </v-btn>
  268. </v-col>
  269. <v-col
  270. v-if="
  271. organizationProfile.isTrialActive &&
  272. (accessProfileStore.isAdmin ||
  273. accessProfileStore.isCaMember)
  274. "
  275. cols="12"
  276. >
  277. <v-btn class="stop_btn" @click="showStopTrialDialog">
  278. {{ $t('stop_trial') }}
  279. </v-btn>
  280. </v-col>
  281. <v-col cols="12">
  282. <span class="special_conditions">
  283. *Convient aux petites écoles sans besoins spécifiques de
  284. gestion pédagogique, de facturation, etc. Pour une
  285. solution complète optez pour Opentalent School
  286. <span
  287. v-if="
  288. !organizationProfile.isArtistPremiumProduct ||
  289. organizationProfile.isTrialActive
  290. "
  291. >
  292. <br >
  293. **Tarif
  294. <span v-if="organizationProfile.isCmf"
  295. >adhérent CMF</span
  296. ><span v-else>public</span> 2025. Abonnement payable
  297. annuellement.
  298. </span>
  299. </span>
  300. </v-col>
  301. </v-row>
  302. </template>
  303. </LayoutPagesSubscriptionCard>
  304. </v-col>
  305. <v-col
  306. lg="4"
  307. sm="12"
  308. md="6"
  309. :offset="
  310. !md && mdAndUp ? (organizationProfile.isSchool ? 4 : 0) : 0
  311. "
  312. >
  313. <LayoutPagesSubscriptionCard
  314. class="schoolCard"
  315. :title="
  316. !organizationProfile.isSchool
  317. ? 'Logiciel School Standard / Premium'
  318. : organizationProfile.isSchoolPremiumProduct
  319. ? 'Logiciel School Premium'
  320. : 'Logiciel School Standard'
  321. "
  322. :sub-title="!organizationProfile.isSchool ? 'Sur devis' : ''"
  323. :extra-header="
  324. organizationProfile.isSchool
  325. ? 'Votre version actuelle'
  326. : undefined
  327. "
  328. color="school"
  329. :list="listCheck.school"
  330. >
  331. <template #card.action>
  332. <v-row>
  333. <v-col cols="12">
  334. <v-btn
  335. v-if="!organizationProfile.isSchool"
  336. class="theme-school btn"
  337. href="https://logiciels.opentalent.fr/opentalent-school"
  338. target="_blank"
  339. >
  340. {{ $t('to_know_more') }}
  341. <i class="fa-solid fa-greater-than small"/>
  342. </v-btn>
  343. </v-col>
  344. <v-col cols="12">
  345. <span class="special_conditions">
  346. *Extranet disponible uniquement dans la version
  347. Opentalent School Premium
  348. </span>
  349. </v-col>
  350. </v-row>
  351. </template>
  352. </LayoutPagesSubscriptionCard>
  353. </v-col>
  354. </v-row>
  355. </v-container>
  356. </UiExpansionPanel>
  357. <UiExpansionPanel title="opentalent_options" icon="fas fa-plus">
  358. <v-container fluid class="container card-container">
  359. <v-row cols="12">
  360. <v-col lg="3" sm="12" md="6">
  361. <LayoutPagesSubscriptionCard
  362. class="optionsCard"
  363. title="SMS"
  364. sub-title="Option payante"
  365. color="primary"
  366. :list="listCheck.sms"
  367. >
  368. <template #card.action>
  369. <v-btn
  370. class="theme-primary btn"
  371. :href="
  372. runtimeConfig.public.fileStorageBaseUrl +
  373. (organizationProfile.isCmf
  374. ? '/Bon_de_commande/Achat_SMS_CMF.pdf'
  375. : '/Bon_de_commande/Achat_SMS_Public.pdf')
  376. "
  377. target="_blank"
  378. >
  379. acheter des credits SMS
  380. <i class="fa-solid fa-greater-than small"/>
  381. </v-btn>
  382. </template>
  383. </LayoutPagesSubscriptionCard>
  384. </v-col>
  385. <v-col lg="3" sm="12" md="6">
  386. <LayoutPagesSubscriptionCard
  387. class="optionsCard"
  388. title="Nom de domaine"
  389. sub-title="Option payante"
  390. color="primary"
  391. :list="listCheck.domain"
  392. >
  393. <template #card.action>
  394. <v-btn
  395. class="theme-primary btn"
  396. :href="
  397. runtimeConfig.public.fileStorageBaseUrl +
  398. '/Bon_de_commande/Nom_de_domaine.pdf'
  399. "
  400. target="_blank"
  401. >
  402. souscrire à l'option
  403. <i class="fa-solid fa-greater-than small"/>
  404. </v-btn>
  405. </template>
  406. </LayoutPagesSubscriptionCard>
  407. </v-col>
  408. </v-row>
  409. </v-container>
  410. </UiExpansionPanel>
  411. </v-expansion-panels>
  412. </LayoutContainer>
  413. <LayoutDialogTrialAlreadyDid
  414. :show="showDialogTrialAllReadyDid"
  415. @close-dialog="showDialogTrialAllReadyDid = false"
  416. />
  417. <LayoutDialogTrialStopConfirmation
  418. :show="showDialogTrialStopConfirmation"
  419. @close-dialog="showDialogTrialStopConfirmation = false"
  420. @stop-trial="stopTrial"
  421. />
  422. </template>
  423. <script setup lang="ts">
  424. import { useAbility } from '@casl/vue'
  425. import type { Ref } from 'vue'
  426. import { useDisplay } from 'vuetify'
  427. import type { AsyncData } from '#app'
  428. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  429. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  430. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  431. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  432. import UrlUtils from '~/services/utils/urlUtils'
  433. import { useDownloadFromRoute } from '~/composables/utils/useDownloadFromRoute'
  434. import { useApiLegacyRequestService } from '~/composables/data/useApiLegacyRequestService'
  435. import { usePageStore } from '~/stores/page'
  436. // meta
  437. definePageMeta({
  438. name: 'subscription_page',
  439. })
  440. // Get composables
  441. const ability = useAbility()
  442. const runtimeConfig = useRuntimeConfig()
  443. const { mdAndUp, md } = useDisplay()
  444. const { fetch } = useEntityFetch()
  445. const i18n = useI18n()
  446. const { apiRequestService } = useApiLegacyRequestService()
  447. // Init ref
  448. const showDialogTrialAllReadyDid: Ref<boolean> = ref(false)
  449. const showDialogTrialStopConfirmation: Ref<boolean> = ref(false)
  450. const openedPanels: Ref<Array<string>> = initPanel()
  451. const organizationProfile = getOrganizationProfile()
  452. const accessProfileStore = useAccessProfileStore()
  453. const { mobytStatus, mobytPending } = getMobytInformations()
  454. const { data: dolibarrAccount, pending: dolibarrPending } = fetch(
  455. DolibarrAccount,
  456. organizationProfile.id,
  457. )
  458. const showDolibarrPanel = computed(
  459. () =>
  460. !dolibarrPending.value &&
  461. dolibarrAccount.value &&
  462. dolibarrAccount.value.bills.length > 0,
  463. )
  464. const formatCurrency = (value: number, currency: string): string => {
  465. return value.toLocaleString(i18n.locale.value, {
  466. style: 'currency',
  467. currency,
  468. })
  469. }
  470. const listCheck: Record<string, Array<string>> = {
  471. artist: [
  472. '100 Mo de stockage',
  473. '75 comptes utilisateurs',
  474. 'Gestion de la structure',
  475. 'Site internet restreint',
  476. 'Options disponibles',
  477. ],
  478. artistPremium: [
  479. '1Go de stockage',
  480. '150 comptes utilisateurs',
  481. 'Gestion de la structure',
  482. 'Module de communication',
  483. 'Site internet illimité',
  484. 'Options disponibles',
  485. ],
  486. school: [
  487. '500 Mo ou 1Go de stockage',
  488. '3 comptes administrateurs',
  489. 'Extranet élèves, tuteurs, professeurs*',
  490. 'Gestion de la structure',
  491. 'Suivi pédagogique, facturation, ...',
  492. 'Site internet complet',
  493. 'Options adaptées à chaque structure',
  494. ],
  495. sms: [
  496. 'Envoyez des SMS depuis votre logiciel',
  497. 'Choisissez le nombre de crédits',
  498. ],
  499. domain: [
  500. 'Bénéficiez de votre propre nom de domaine',
  501. "Et d'une adresse mail personnalisée",
  502. ],
  503. }
  504. /**
  505. * Initialisation des panels ouverts
  506. */
  507. function initPanel(): Ref<Array<string>> {
  508. // 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
  509. // TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref([...])`
  510. const openedPanels: Ref<Array<string>> = ref([])
  511. onMounted(() => {
  512. openedPanels.value = [
  513. 'subscription_page',
  514. 'service_detail',
  515. 'bills',
  516. 'opentalent_offers',
  517. 'opentalent_options',
  518. ]
  519. })
  520. return openedPanels
  521. }
  522. /**
  523. * Récupération de l'organization profile
  524. */
  525. function getOrganizationProfile() {
  526. const organizationProfile = useOrganizationProfileStore()
  527. if (organizationProfile.id === null) {
  528. throw new Error("Missing organization's id")
  529. }
  530. return organizationProfile
  531. }
  532. /**
  533. * Récupération des informations Mobyt
  534. */
  535. function getMobytInformations(): {
  536. mobytStatus: Ref<MobytUserStatus | null>
  537. mobytPending: Ref<boolean>
  538. } {
  539. const mobytStatus: Ref<MobytUserStatus | null> = ref(null)
  540. const mobytPending: Ref<boolean> = ref(false)
  541. if (ability.can('manage', 'texto')) {
  542. const { data, pending } = fetch(
  543. MobytUserStatus,
  544. organizationProfile!.id!,
  545. ) as AsyncData<MobytUserStatus | null, Error | null>
  546. mobytStatus.value = data
  547. mobytPending.value = pending
  548. }
  549. return { mobytStatus, mobytPending }
  550. }
  551. /**
  552. * Action lorsque l'on souhaite démarrer l'essai
  553. */
  554. async function startTrial() {
  555. try {
  556. await apiRequestService.get('/trial/is_available')
  557. const v1BaseURL =
  558. runtimeConfig.baseUrlAdminLegacy ||
  559. runtimeConfig.public.baseUrlAdminLegacy
  560. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  561. external: true,
  562. })
  563. } catch (error) {
  564. showDialogTrialAllReadyDid.value = true
  565. }
  566. }
  567. /**
  568. * Action lorsque l'on souhaite souscrire à artist premium
  569. */
  570. async function subscription() {
  571. const v1BaseURL =
  572. runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  573. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'subscribe'), {
  574. external: true,
  575. })
  576. }
  577. /**
  578. * Action lorsque l'on souhaite afficher la modal de confirmation pour stopper
  579. */
  580. function showStopTrialDialog() {
  581. showDialogTrialStopConfirmation.value = true
  582. }
  583. /**
  584. * Action lorsque l'on souhaite stopper l'essai
  585. */
  586. async function stopTrial() {
  587. usePageStore().loading = true
  588. await apiRequestService.post('/trial/stop')
  589. const v1BaseURL =
  590. runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  591. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'dashboard'), {
  592. external: true,
  593. })
  594. }
  595. const downloadDolibarrBill = (ref: string): void => {
  596. const route = UrlUtils.join('api/dolibarr/download/invoice', ref)
  597. useDownloadFromRoute(route, `${ref}.pdf`)
  598. }
  599. </script>
  600. <style scoped lang="scss">
  601. .clickable {
  602. cursor: pointer;
  603. text-decoration: underline;
  604. }
  605. .offer_title {
  606. span {
  607. border-radius: 5px;
  608. display: block;
  609. font-weight: bold;
  610. text-align: center;
  611. padding: 5px;
  612. }
  613. }
  614. .card-container {
  615. .v-row {
  616. display: -webkit-box;
  617. display: -webkit-flex;
  618. display: -ms-flexbox;
  619. display: flex;
  620. flex-wrap: wrap;
  621. }
  622. .v-row > [class*='v-col-'] {
  623. display: flex;
  624. flex-direction: column;
  625. }
  626. .small {
  627. font-size: 6px;
  628. padding-top: 5px;
  629. padding-left: 5px;
  630. }
  631. .priceBlock {
  632. font-size: 15px;
  633. font-weight: normal;
  634. text-transform: none;
  635. .price {
  636. text-transform: uppercase;
  637. font-size: 30px;
  638. font-weight: bold;
  639. }
  640. }
  641. }
  642. .special_conditions {
  643. font-size: 10px;
  644. font-style: italic;
  645. }
  646. .trialBtn {
  647. color: #000;
  648. border: 1px solid rgb(var(--v-theme-artist));
  649. }
  650. .btn {
  651. font-size: 12px;
  652. }
  653. .optionsCard {
  654. :deep(.margin-sup) {
  655. margin-top: 0;
  656. }
  657. }
  658. .stop_btn {
  659. color: rgb(var(--v-theme-danger));
  660. }
  661. .plus_btn {
  662. color: rgb(var(--v-theme-on-neutral));
  663. }
  664. </style>