subscription.vue 19 KB

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