subscription.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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. title="service_detail"
  26. icon="fas fa-info"
  27. v-if="dolibarrAccount && dolibarrAccount.contract"
  28. >
  29. <v-container fluid class="container">
  30. <v-row>
  31. <v-col
  32. cols="12"
  33. lg="12"
  34. v-for="line in dolibarrAccount.contract.lines"
  35. :key="line.id"
  36. >
  37. <strong>{{ line.serviceLabel }}</strong> - {{ $t('until') }} :
  38. {{ $d(line.dateEnd) }}
  39. </v-col>
  40. <v-col cols="12" lg="12" v-if="ability.can('manage', 'texto')">
  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></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. @click="downloadDolibarrBill(bill.ref)"
  98. class="clickable"
  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. title="opentalent_offers"
  111. icon="fas fa-plus"
  112. v-if="!organizationProfile.isManagerProduct"
  113. >
  114. <v-container fluid class="container">
  115. <v-row
  116. class="offer_title"
  117. v-if="!md && mdAndUp && !organizationProfile.isSchool"
  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. lg="4"
  144. sm="12"
  145. md="6"
  146. v-if="
  147. organizationProfile.isArtistProduct ||
  148. organizationProfile.isTrialActive
  149. "
  150. >
  151. <LayoutPagesSubscriptionCard
  152. class="artistCard"
  153. title="Logiciel Artist Standard"
  154. :extraHeader="
  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. cols="12"
  179. v-if="
  180. !organizationProfile.isArtistProduct &&
  181. !organizationProfile.isTrialActive
  182. "
  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"></i>
  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 lg="4" sm="12" md="6" v-if="organizationProfile.isArtist">
  211. <LayoutPagesSubscriptionCard
  212. class="artistCard"
  213. title="Logiciel Artist Premium*"
  214. :extraHeader="
  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. class="priceBlock"
  227. v-if="
  228. !organizationProfile.isArtistPremiumProduct ||
  229. organizationProfile.isTrialActive
  230. "
  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. cols="12"
  244. v-if="
  245. !organizationProfile.isArtistPremiumProduct &&
  246. (accessProfileStore.isAdmin ||
  247. accessProfileStore.isCaMember)
  248. "
  249. >
  250. <v-btn class="btn trialBtn" @click="startTrial">
  251. {{ $t('try_premium_version') }}
  252. <i class="fa-solid fa-greater-than small"></i>
  253. </v-btn>
  254. </v-col>
  255. <v-col
  256. cols="12"
  257. v-if="
  258. (!organizationProfile.isArtistPremiumProduct ||
  259. organizationProfile.isTrialActive) &&
  260. (accessProfileStore.isAdmin ||
  261. accessProfileStore.isCaMember)
  262. "
  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"></i>
  267. </v-btn>
  268. </v-col>
  269. <v-col
  270. cols="12"
  271. v-if="
  272. organizationProfile.isTrialActive &&
  273. (accessProfileStore.isAdmin ||
  274. accessProfileStore.isCaMember)
  275. "
  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. <br />
  287. **Tarif
  288. <span v-if="organizationProfile.isCmf"
  289. >adhérent CMF</span
  290. ><span v-else>public</span> 2025. Abonnement payable
  291. annuellement.
  292. </span>
  293. </v-col>
  294. </v-row>
  295. </template>
  296. </LayoutPagesSubscriptionCard>
  297. </v-col>
  298. <v-col
  299. lg="4"
  300. sm="12"
  301. md="6"
  302. :offset="
  303. !md && mdAndUp ? (organizationProfile.isSchool ? 4 : 0) : 0
  304. "
  305. >
  306. <LayoutPagesSubscriptionCard
  307. class="schoolCard"
  308. :title="
  309. !organizationProfile.isSchool
  310. ? 'Logiciel School Standard / Premium'
  311. : organizationProfile.isSchoolPremiumProduct
  312. ? 'Logiciel School Premium'
  313. : 'Logiciel School Standard'
  314. "
  315. :subTitle="!organizationProfile.isSchool ? 'Sur devis' : ''"
  316. :extraHeader="
  317. organizationProfile.isSchool
  318. ? 'Votre version actuelle'
  319. : undefined
  320. "
  321. color="school"
  322. :list="listCheck.school"
  323. >
  324. <template #card.action>
  325. <v-row>
  326. <v-col cols="12">
  327. <v-btn
  328. v-if="!organizationProfile.isSchool"
  329. class="theme-school btn"
  330. href="https://logiciels.opentalent.fr/opentalent-school"
  331. target="_blank"
  332. >
  333. {{ $t('to_know_more') }}
  334. <i class="fa-solid fa-greater-than small"></i>
  335. </v-btn>
  336. </v-col>
  337. <v-col cols="12">
  338. <span class="special_conditions">
  339. *Extranet disponible uniquement dans la version
  340. Opentalent School Premium
  341. </span>
  342. </v-col>
  343. </v-row>
  344. </template>
  345. </LayoutPagesSubscriptionCard>
  346. </v-col>
  347. </v-row>
  348. </v-container>
  349. </UiExpansionPanel>
  350. <UiExpansionPanel title="opentalent_options" icon="fas fa-plus">
  351. <v-container fluid class="container card-container">
  352. <v-row cols="12">
  353. <v-col lg="3" sm="12" md="6">
  354. <LayoutPagesSubscriptionCard
  355. class="optionsCard"
  356. title="SMS"
  357. sub-title="Option payante"
  358. color="primary"
  359. :list="listCheck.sms"
  360. >
  361. <template #card.action>
  362. <v-btn
  363. class="theme-primary btn"
  364. :href="
  365. runtimeConfig.public.fileStorageBaseUrl +
  366. (organizationProfile.isCmf
  367. ? '/Bon_de_commande/Achat_SMS_CMF.pdf'
  368. : '/Bon_de_commande/Achat_SMS_Public.pdf')
  369. "
  370. target="_blank"
  371. >
  372. acheter des credits SMS
  373. <i class="fa-solid fa-greater-than small"></i>
  374. </v-btn>
  375. </template>
  376. </LayoutPagesSubscriptionCard>
  377. </v-col>
  378. <v-col lg="3" sm="12" md="6">
  379. <LayoutPagesSubscriptionCard
  380. class="optionsCard"
  381. title="Nom de domaine"
  382. sub-title="Option payante"
  383. color="primary"
  384. :list="listCheck.domain"
  385. >
  386. <template #card.action>
  387. <v-btn
  388. class="theme-primary btn"
  389. :href="
  390. runtimeConfig.public.fileStorageBaseUrl +
  391. '/Bon_de_commande/Nom_de_domaine.pdf'
  392. "
  393. target="_blank"
  394. >
  395. souscrire à l'option
  396. <i class="fa-solid fa-greater-than small"></i>
  397. </v-btn>
  398. </template>
  399. </LayoutPagesSubscriptionCard>
  400. </v-col>
  401. </v-row>
  402. </v-container>
  403. </UiExpansionPanel>
  404. </v-expansion-panels>
  405. </LayoutContainer>
  406. <LayoutDialogTrialAlreadyDid
  407. :show="showDialogTrialAllReadyDid"
  408. @closeDialog="showDialogTrialAllReadyDid = false"
  409. />
  410. <LayoutDialogTrialStopConfirmation
  411. :show="showDialogTrialStopConfirmation"
  412. @closeDialog="showDialogTrialStopConfirmation = false"
  413. @stopTrial="stopTrial"
  414. />
  415. </template>
  416. <script setup lang="ts">
  417. import { useAbility } from '@casl/vue'
  418. import type { Ref } from 'vue'
  419. import { useDisplay } from 'vuetify'
  420. import type { AsyncData } from '#app'
  421. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  422. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  423. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  424. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  425. import UrlUtils from '~/services/utils/urlUtils'
  426. import { useDownloadFromRoute } from '~/composables/utils/useDownloadFromRoute'
  427. import { useApiLegacyRequestService } from '~/composables/data/useApiLegacyRequestService'
  428. import { usePageStore } from '~/stores/page'
  429. //meta
  430. definePageMeta({
  431. name: 'subscription_page',
  432. })
  433. //Get composables
  434. const ability = useAbility()
  435. const runtimeConfig = useRuntimeConfig()
  436. const { mdAndUp, md } = useDisplay()
  437. const { fetch } = useEntityFetch()
  438. const i18n = useI18n()
  439. const { apiRequestService } = useApiLegacyRequestService()
  440. //Init ref
  441. const showDialogTrialAllReadyDid: Ref<boolean> = ref(false)
  442. const showDialogTrialStopConfirmation: Ref<boolean> = ref(false)
  443. const openedPanels: Ref<Array<string>> = initPanel()
  444. const organizationProfile = getOrganizationProfile()
  445. const accessProfileStore = useAccessProfileStore()
  446. const { mobytStatus, mobytPending } = getMobytInformations()
  447. const { data: dolibarrAccount, pending: dolibarrPending } = fetch(
  448. DolibarrAccount,
  449. organizationProfile.id,
  450. )
  451. const showDolibarrPanel = computed(
  452. () =>
  453. !dolibarrPending.value &&
  454. dolibarrAccount.value &&
  455. dolibarrAccount.value.bills.length > 0,
  456. )
  457. const formatCurrency = (value: number, currency: string): string => {
  458. return value.toLocaleString(i18n.locale.value, {
  459. style: 'currency',
  460. currency,
  461. })
  462. }
  463. const listCheck: Record<string, Array<string>> = {
  464. artist: [
  465. '100 Mo de stockage',
  466. '75 comptes utilisateurs',
  467. 'Gestion de la structure',
  468. 'Site internet restreint',
  469. 'Options disponibles',
  470. ],
  471. artistPremium: [
  472. '1Go de stockage',
  473. '150 comptes utilisateurs',
  474. 'Gestion de la structure',
  475. 'Module de communication',
  476. 'Site internet illimité',
  477. 'Options disponibles',
  478. ],
  479. school: [
  480. '500 Mo ou 1Go de stockage',
  481. '3 comptes administrateurs',
  482. 'Extranet élèves, tuteurs, professeurs*',
  483. 'Gestion de la structure',
  484. 'Suivi pédagogique, facturation, ...',
  485. 'Site internet complet',
  486. 'Options adaptées à chaque structure',
  487. ],
  488. sms: [
  489. 'Envoyez des SMS depuis votre logiciel',
  490. 'Choisissez le nombre de crédits',
  491. ],
  492. domain: [
  493. 'Bénéficiez de votre propre nom de domaine',
  494. "Et d'une adresse mail personnalisée",
  495. ],
  496. }
  497. /**
  498. * Initialisation des panels ouverts
  499. */
  500. function initPanel(): Ref<Array<string>> {
  501. // 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
  502. // TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref([...])`
  503. const openedPanels: Ref<Array<string>> = ref([])
  504. onMounted(() => {
  505. openedPanels.value = [
  506. 'subscription_page',
  507. 'service_detail',
  508. 'bills',
  509. 'opentalent_offers',
  510. 'opentalent_options',
  511. ]
  512. })
  513. return openedPanels
  514. }
  515. /**
  516. * Récupération de l'organization profile
  517. */
  518. function getOrganizationProfile() {
  519. const organizationProfile = useOrganizationProfileStore()
  520. if (organizationProfile.id === null) {
  521. throw new Error("Missing organization's id")
  522. }
  523. return organizationProfile
  524. }
  525. /**
  526. * Récupération des informations Mobyt
  527. */
  528. function getMobytInformations(): {
  529. mobytStatus: Ref<MobytUserStatus | null>
  530. mobytPending: Ref<boolean>
  531. } {
  532. let mobytStatus: Ref<MobytUserStatus | null> = ref(null)
  533. let mobytPending: Ref<boolean> = ref(false)
  534. if (ability.can('manage', 'texto')) {
  535. const { data, pending } = fetch(
  536. MobytUserStatus,
  537. organizationProfile!.id!,
  538. ) as AsyncData<MobytUserStatus | null, Error | null>
  539. mobytStatus = data
  540. mobytPending = pending
  541. }
  542. return { mobytStatus, mobytPending }
  543. }
  544. /**
  545. * Action lorsque l'on souhaite démarrer l'essai
  546. */
  547. async function startTrial() {
  548. try {
  549. await apiRequestService.get('/trial/is_available')
  550. const v1BaseURL =
  551. runtimeConfig.baseUrlAdminLegacy ||
  552. runtimeConfig.public.baseUrlAdminLegacy
  553. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  554. external: true,
  555. })
  556. } catch (error) {
  557. showDialogTrialAllReadyDid.value = true
  558. }
  559. }
  560. /**
  561. * Action lorsque l'on souhaite souscrire à artist premium
  562. */
  563. async function subscription() {
  564. const v1BaseURL =
  565. runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  566. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'subscribe'), {
  567. external: true,
  568. })
  569. }
  570. /**
  571. * Action lorsque l'on souhaite afficher la modal de confirmation pour stopper
  572. */
  573. function showStopTrialDialog() {
  574. showDialogTrialStopConfirmation.value = true
  575. }
  576. /**
  577. * Action lorsque l'on souhaite stopper l'essai
  578. */
  579. async function stopTrial() {
  580. usePageStore().loading = true
  581. await apiRequestService.post('/trial/stop')
  582. const v1BaseURL =
  583. runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  584. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'dashboard'), {
  585. external: true,
  586. })
  587. }
  588. const downloadDolibarrBill = (ref: string): void => {
  589. const route = UrlUtils.join('api/dolibarr/download/invoice', ref)
  590. useDownloadFromRoute(route, `${ref}.pdf`)
  591. }
  592. </script>
  593. <style scoped lang="scss">
  594. .clickable {
  595. cursor: pointer;
  596. text-decoration: underline;
  597. }
  598. .offer_title {
  599. span {
  600. border-radius: 5px;
  601. display: block;
  602. font-weight: bold;
  603. text-align: center;
  604. padding: 5px;
  605. }
  606. }
  607. .card-container {
  608. .v-row {
  609. display: -webkit-box;
  610. display: -webkit-flex;
  611. display: -ms-flexbox;
  612. display: flex;
  613. flex-wrap: wrap;
  614. }
  615. .v-row > [class*='v-col-'] {
  616. display: flex;
  617. flex-direction: column;
  618. }
  619. .small {
  620. font-size: 6px;
  621. padding-top: 5px;
  622. padding-left: 5px;
  623. }
  624. .priceBlock {
  625. font-size: 15px;
  626. font-weight: normal;
  627. text-transform: none;
  628. .price {
  629. text-transform: uppercase;
  630. font-size: 30px;
  631. font-weight: bold;
  632. }
  633. }
  634. }
  635. .special_conditions {
  636. font-size: 10px;
  637. font-style: italic;
  638. }
  639. .trialBtn {
  640. color: #000;
  641. border: 1px solid rgb(var(--v-theme-artist));
  642. }
  643. .optionsCard {
  644. :deep(.margin-sup) {
  645. margin-top: 0;
  646. }
  647. }
  648. .stop_btn {
  649. color: rgb(var(--v-theme-danger));
  650. }
  651. .plus_btn {
  652. color: rgb(var(--v-theme-on-neutral));
  653. }
  654. </style>