subscription.vue 19 KB

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