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="$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 ? (organizationProfile.isTrialActive ? `Version en cours d'essai J-${organizationProfile.trialCountDown}` : '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.isTrialActive && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  163. <v-btn
  164. class="stop_btn"
  165. @click="showStopTrialDialog"
  166. >
  167. Arrêter l'essai
  168. </v-btn>
  169. </v-col>
  170. <v-col cols="12">
  171. <span class="special_conditions">
  172. *Convient aux petites écoles sans besoins spécifiques de gestion pédagogique, de facturation, etc.
  173. Pour une solution complète optez pour Opentalent School
  174. </span>
  175. </v-col>
  176. </v-row>
  177. </template>
  178. </PagesSubscriptionCard>
  179. </v-col>
  180. <v-col lg="3" sm="12" md="6" :offset="!md && mdAndUp ? (organizationProfile.isSchool ? 4 : (organizationProfile.isArtistPremiumProduct ? 0 : 2)) : 0">
  181. <PagesSubscriptionCard
  182. class="schoolCard"
  183. :title="!organizationProfile.isSchool ? 'Logiciel School Standard / Premium' : (
  184. organizationProfile.isSchoolPremiumProduct ? 'Logiciel School Premium' : 'Logiciel School Standard'
  185. )"
  186. :subTitle="!organizationProfile.isSchool ? 'Sur devis' : ''"
  187. :extraHeader="organizationProfile.isSchool ? 'Votre version' : false"
  188. color="school"
  189. :list="listCheck.school"
  190. >
  191. <template #card.action>
  192. <v-row>
  193. <v-col cols="12">
  194. <v-btn
  195. v-if="!organizationProfile.isSchool"
  196. class="theme-school btn"
  197. href="https://logiciels.opentalent.fr/opentalent-school"
  198. target="_blank"
  199. >
  200. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  201. </v-btn>
  202. </v-col>
  203. <v-col cols="12">
  204. <span class="special_conditions">
  205. *Extranet disponible uniquement dans la version Opentalent School Premium
  206. </span>
  207. </v-col>
  208. </v-row>
  209. </template>
  210. </PagesSubscriptionCard>
  211. </v-col>
  212. </v-row>
  213. </v-container>
  214. </UiExpansionPanel>
  215. <UiExpansionPanel :title="$t('opentalent_options')" icon="fas fa-plus">
  216. <v-container fluid class="container card-container">
  217. <v-row cols="12" >
  218. <v-col lg="3" sm="12" md="6">
  219. <PagesSubscriptionCard
  220. class="optionsCard"
  221. title="SMS"
  222. sub-title="Option payante"
  223. color="primary"
  224. :list="listCheck.sms"
  225. >
  226. <template #card.action>
  227. <v-btn
  228. class="theme-primary btn"
  229. :href="
  230. runtimeConfig.public.fileStorageBaseUrl +
  231. (organizationProfile.isCmf ? '/Bon_de_commande/Achat_SMS_CMF.pdf' : '/Bon_de_commande/Achat_SMS_Public.pdf')
  232. "
  233. target="_blank"
  234. >
  235. acheter des credits SMS <i class="fa-solid fa-greater-than small"></i>
  236. </v-btn>
  237. </template>
  238. </PagesSubscriptionCard>
  239. </v-col>
  240. <v-col lg="3" sm="12" md="6">
  241. <PagesSubscriptionCard
  242. class="optionsCard"
  243. title="Nom de domaine"
  244. sub-title="Option payante"
  245. color="primary"
  246. :list="listCheck.domain"
  247. >
  248. <template #card.action>
  249. <v-btn
  250. class="theme-primary btn"
  251. :href="
  252. runtimeConfig.public.fileStorageBaseUrl +
  253. '/Bon_de_commande/Nom_de_domaine.pdf'
  254. "
  255. target="_blank"
  256. >
  257. souscrire à l'option <i class="fa-solid fa-greater-than small"></i>
  258. </v-btn>
  259. </template>
  260. </PagesSubscriptionCard>
  261. </v-col>
  262. </v-row>
  263. </v-container>
  264. </UiExpansionPanel>
  265. </v-expansion-panels>
  266. </LayoutContainer>
  267. <DialogTrialAllReadyDid
  268. :show="showDialogTrialAllReadyDid"
  269. @closeDialog = "showDialogTrialAllReadyDid = false"
  270. />
  271. <DialogTrialStopConfirmation
  272. :show="showDialogTrialStopConfirmation"
  273. @closeDialog = "showDialogTrialStopConfirmation = false"
  274. @stopTrial = "stopTrial"
  275. />
  276. </template>
  277. <script setup lang="ts">
  278. import {useAbility} from '@casl/vue'
  279. import type {Ref} from 'vue'
  280. import {useDisplay} from 'vuetify'
  281. import type {AsyncData} from '#app'
  282. import {useOrganizationProfileStore} from '~/stores/organizationProfile'
  283. import {useEntityFetch} from '~/composables/data/useEntityFetch'
  284. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  285. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  286. import UrlUtils from '~/services/utils/urlUtils';
  287. import {useDownloadFromRoute} from '~/composables/utils/useDownloadFromRoute';
  288. import {useApiLegacyRequestService} from "~/composables/data/useApiLegacyRequestService";
  289. import {usePageStore} from "~/stores/page";
  290. //meta
  291. definePageMeta({
  292. name: 'subscription_page',
  293. })
  294. //Get composables
  295. const ability = useAbility()
  296. const runtimeConfig = useRuntimeConfig()
  297. const {mdAndUp, md} = useDisplay()
  298. const {fetch} = useEntityFetch()
  299. const i18n = useI18n()
  300. const { apiRequestService } = useApiLegacyRequestService()
  301. //Init ref
  302. const showDialogTrialAllReadyDid: Ref<boolean> = ref(false)
  303. const showDialogTrialStopConfirmation: Ref<boolean> = ref(false)
  304. const openedPanels: Ref<Array<string>> = initPanel()
  305. const organizationProfile = getOrganizationProfile()
  306. const accessProfileStore = useAccessProfileStore()
  307. const {mobytStatus, mobytPending}: Record<Ref<MobytUserStatus | null>, Ref<boolean>> = getMobytInformations()
  308. const {data: dolibarrAccount, pending: dolibarrPending} = fetch(
  309. DolibarrAccount,
  310. organizationProfile.id,
  311. )
  312. const showDolibarrPanel = computed(
  313. () =>
  314. !dolibarrPending.value &&
  315. dolibarrAccount.value &&
  316. dolibarrAccount.value.bills.length > 0,
  317. )
  318. const formatCurrency = (value: number, currency: string): string => {
  319. return value.toLocaleString(i18n.locale.value, {
  320. style: 'currency',
  321. currency,
  322. })
  323. }
  324. const listCheck: Record<string, Array<string>> = {
  325. 'artist' : [
  326. '100 Mo de stockage',
  327. '75 comptes utilisateurs',
  328. 'Gestion de la structure',
  329. 'Site internet restreint',
  330. 'Options disponibles',
  331. ],
  332. 'artistPremium' : [
  333. '1Go de stockage',
  334. '150 comptes utilisateurs',
  335. 'Gestion de la structure',
  336. 'Module de communication',
  337. 'Site internet illimité',
  338. 'Options disponibles',
  339. ],
  340. 'school' : [
  341. '500 Mo ou 1Go de stockage',
  342. '3 comptes administrateurs',
  343. 'Extranet élèves, tuteurs, professeurs*',
  344. 'Gestion de la structure',
  345. 'Suivi pédagogique, facturation, ...',
  346. 'Site internet complet',
  347. 'Options adaptées à chaque structure',
  348. ],
  349. 'sms': [
  350. 'Envoyez des SMS depuis votre logiciel',
  351. 'Choisissez le nombre de crédits'
  352. ],
  353. 'domain':[
  354. 'Bénéficiez de votre propre nom de domaine',
  355. 'Et d\'une adresse mail personnalisée'
  356. ]
  357. }
  358. /**
  359. * Initialisation des panels ouverts
  360. */
  361. function initPanel(): Ref<Array<string>> {
  362. // 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
  363. // TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref(['informations', 'bills', 'more_features'])`
  364. const openedPanels: Ref<Array<string>> = ref([])
  365. onMounted(() => {
  366. openedPanels.value = [i18n.t('subscription_page'), i18n.t('opentalent_offer'), i18n.t('opentalent_options')]
  367. })
  368. return openedPanels
  369. }
  370. /**
  371. * Récupération de l'organization profile
  372. */
  373. function getOrganizationProfile() {
  374. const organizationProfile = useOrganizationProfileStore()
  375. if (organizationProfile.id === null) {
  376. throw new Error("Missing organization's id")
  377. }
  378. return organizationProfile
  379. }
  380. /**
  381. * Récupération des informations Mobyt
  382. */
  383. function getMobytInformations(): Record<Ref<MobytUserStatus | null>, Ref<boolean>> {
  384. let mobytStatus: Ref<MobytUserStatus | null> = ref(null)
  385. let mobytPending: Ref<boolean> = ref(false)
  386. if (ability.can('manage', 'texto')) {
  387. const {data, pending} = fetch(
  388. MobytUserStatus,
  389. organizationProfile!.id!,
  390. ) as AsyncData<MobytUserStatus | null, Error | null>
  391. mobytStatus = data
  392. mobytPending = pending
  393. }
  394. return {mobytStatus, mobytPending}
  395. }
  396. /**
  397. * Action lorsque l'on souhaite démarrer l'essai
  398. */
  399. async function startTrial(){
  400. try{
  401. await apiRequestService.get('/trial/is_available')
  402. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  403. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  404. external: true
  405. })
  406. }catch(error){
  407. showDialogTrialAllReadyDid.value = true
  408. }
  409. }
  410. /**
  411. * Action lorsque l'on souhaite souscrire à artist premium
  412. */
  413. async function subscription(){
  414. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  415. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'subscribe'), {
  416. external: true
  417. })
  418. }
  419. /**
  420. * Action lorsque l'on souhaite afficher la modal de confirmation pour stopper
  421. */
  422. function showStopTrialDialog(){
  423. showDialogTrialStopConfirmation.value = true
  424. }
  425. /**
  426. * Action lorsque l'on souhaite stopper l'essai
  427. */
  428. async function stopTrial() {
  429. usePageStore().loading = true
  430. await apiRequestService.post('/trial/stop')
  431. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  432. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'dashboard'), {
  433. external: true
  434. })
  435. }
  436. const downloadDolibarrBill = (ref: string): void => {
  437. const route = UrlUtils.join('api/dolibarr/download/invoice', ref)
  438. useDownloadFromRoute(route, `${ref}.pdf`)
  439. }
  440. </script>
  441. <style scoped lang="scss">
  442. .clickable {
  443. cursor: pointer;
  444. text-decoration: underline;
  445. }
  446. .offer_title{
  447. span{
  448. border-radius: 5px;
  449. display: block;
  450. font-weight: bold;
  451. text-align: center;
  452. padding: 5px;
  453. }
  454. }
  455. .card-container{
  456. .v-row {
  457. display: -webkit-box;
  458. display: -webkit-flex;
  459. display: -ms-flexbox;
  460. display: flex;
  461. flex-wrap: wrap;
  462. }
  463. .v-row > [class*='v-col-'] {
  464. display: flex;
  465. flex-direction: column;
  466. }
  467. .small{
  468. font-size:6px;
  469. padding-top: 5px;
  470. padding-left: 5px;
  471. }
  472. .priceBlock{
  473. text-align: center;
  474. font-size: 15px;
  475. font-weight: normal;
  476. .price{
  477. font-size: 30px;
  478. font-weight: bold;
  479. }
  480. }
  481. }
  482. .artistCard{
  483. :deep(.v-card-title){
  484. text-align: center;
  485. }
  486. }
  487. .special_conditions{
  488. font-size: 10px;
  489. }
  490. .trialBtn{
  491. color: #000;
  492. border: 1px solid rgb(var(--v-theme-artist));
  493. }
  494. .optionsCard{
  495. :deep(.margin-sup){
  496. margin-top: 0px;
  497. }
  498. }
  499. .stop_btn{
  500. color: rgb(var(--v-theme-danger));
  501. }
  502. .plus_btn{
  503. color: rgb(var(--v-theme-on-neutral));
  504. }
  505. </style>