subscription.vue 23 KB

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