subscription.vue 23 KB

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