subscription.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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="stopTrial"
  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. />
  284. </template>
  285. <script setup lang="ts">
  286. import {useAbility} from '@casl/vue'
  287. import type {Ref} from 'vue'
  288. import {useDisplay} from 'vuetify'
  289. import type {AsyncData} from '#app'
  290. import {useOrganizationProfileStore} from '~/stores/organizationProfile'
  291. import {useEntityFetch} from '~/composables/data/useEntityFetch'
  292. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  293. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  294. import UrlUtils from '~/services/utils/urlUtils';
  295. import {useDownloadFromRoute} from '~/composables/utils/useDownloadFromRoute';
  296. import {useApiLegacyRequestService} from "~/composables/data/useApiLegacyRequestService";
  297. //meta
  298. definePageMeta({
  299. name: 'subscription_page',
  300. })
  301. //Get composables
  302. const ability = useAbility()
  303. const runtimeConfig = useRuntimeConfig()
  304. const {mdAndUp, md} = useDisplay()
  305. const {fetch} = useEntityFetch()
  306. const i18n = useI18n()
  307. const { apiRequestService } = useApiLegacyRequestService()
  308. //Init ref
  309. const showDialogTrialAllReadyDid: Ref<boolean> = ref(false)
  310. const showDialogTrialStopConfirmation: Ref<boolean> = ref(false)
  311. const openedPanels: Ref<Array<string>> = initPanel()
  312. const organizationProfile = getOrganizationProfile()
  313. const accessProfileStore = useAccessProfileStore()
  314. const {mobytStatus, mobytPending}: Record<Ref<MobytUserStatus | null>, Ref<boolean>> = getMobytInformations()
  315. const {data: dolibarrAccount, pending: dolibarrPending} = fetch(
  316. DolibarrAccount,
  317. organizationProfile.id,
  318. )
  319. const showDolibarrPanel = computed(
  320. () =>
  321. !dolibarrPending.value &&
  322. dolibarrAccount.value &&
  323. dolibarrAccount.value.bills.length > 0,
  324. )
  325. const formatCurrency = (value: number, currency: string): string => {
  326. return value.toLocaleString(i18n.locale.value, {
  327. style: 'currency',
  328. currency,
  329. })
  330. }
  331. const listCheck: Record<string, Array<string>> = {
  332. 'artist' : [
  333. '100 Mo de stockage',
  334. '75 comptes utilisateurs',
  335. 'Gestion de la structure',
  336. 'Site internet restreint',
  337. 'Options disponibles',
  338. ],
  339. 'artistPremium' : [
  340. '1Go de stockage',
  341. '150 comptes utilisateurs',
  342. 'Gestion de la structure',
  343. 'Site internet illimité',
  344. 'Options disponibles',
  345. ],
  346. 'school' : [
  347. '500 Mo ou 1Go de stockage',
  348. '3 comptes administrateurs',
  349. 'Extranet élèves, tuteurs, professeurs*',
  350. 'Gestion de la structure',
  351. 'Suivi pédagogique, facturation, ...',
  352. 'Site internet complet',
  353. 'Options adaptées à chaque structure',
  354. ],
  355. 'sms': [
  356. 'Envoyez des SMS depuis votre logiciel',
  357. 'Choisissez le nombre de crédits'
  358. ],
  359. 'domain':[
  360. 'Bénéficiez de votre propre nom de domaine',
  361. 'Et d\'une adresse mail personnalisée'
  362. ]
  363. }
  364. /**
  365. * Initialisation des panels ouverts
  366. */
  367. function initPanel(): Ref<Array<string>> {
  368. // 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
  369. // TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref(['informations', 'bills', 'more_features'])`
  370. const openedPanels: Ref<Array<string>> = ref([])
  371. onMounted(() => {
  372. openedPanels.value = [i18n.t('subscription_page'), i18n.t('opentalent_offer'), i18n.t('opentalent_options')]
  373. })
  374. return openedPanels
  375. }
  376. /**
  377. * Récupération de l'organization profile
  378. */
  379. function getOrganizationProfile() {
  380. const organizationProfile = useOrganizationProfileStore()
  381. if (organizationProfile.id === null) {
  382. throw new Error("Missing organization's id")
  383. }
  384. return organizationProfile
  385. }
  386. /**
  387. * Récupération des informations Mobyt
  388. */
  389. function getMobytInformations(): Record<Ref<MobytUserStatus | null>, Ref<boolean>> {
  390. let mobytStatus: Ref<MobytUserStatus | null> = ref(null)
  391. let mobytPending: Ref<boolean> = ref(false)
  392. if (ability.can('manage', 'texto')) {
  393. const {data, pending} = fetch(
  394. MobytUserStatus,
  395. organizationProfile!.id!,
  396. ) as AsyncData<MobytUserStatus | null, Error | null>
  397. mobytStatus = data
  398. mobytPending = pending
  399. }
  400. return {mobytStatus, mobytPending}
  401. }
  402. /**
  403. * Action lorsque l'on souhaite démarrer l'essai
  404. */
  405. async function startTrial(){
  406. try{
  407. await apiRequestService.get('/trial/is_available')
  408. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  409. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  410. external: true
  411. })
  412. }catch(error){
  413. showDialogTrialAllReadyDid.value = true
  414. }
  415. }
  416. /**
  417. * Action lorsque l'on souhaite souscrire à artist premium
  418. */
  419. async function subscription(){
  420. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  421. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial/subscribe'), {
  422. external: true
  423. })
  424. }
  425. /**
  426. * Action lorsque l'on souhaite stopper l'essai
  427. */
  428. function stopTrial(){
  429. showDialogTrialStopConfirmation.value = true
  430. }
  431. const downloadDolibarrBill = (ref: string): void => {
  432. const route = UrlUtils.join('api/dolibarr/download/invoice', ref)
  433. useDownloadFromRoute(route, `${ref}.pdf`)
  434. }
  435. </script>
  436. <style scoped lang="scss">
  437. .clickable {
  438. cursor: pointer;
  439. text-decoration: underline;
  440. }
  441. .offer_title{
  442. span{
  443. border-radius: 5px;
  444. display: block;
  445. font-weight: bold;
  446. text-align: center;
  447. padding: 5px;
  448. }
  449. }
  450. .card-container{
  451. .v-row {
  452. display: -webkit-box;
  453. display: -webkit-flex;
  454. display: -ms-flexbox;
  455. display: flex;
  456. flex-wrap: wrap;
  457. }
  458. .v-row > [class*='v-col-'] {
  459. display: flex;
  460. flex-direction: column;
  461. }
  462. .small{
  463. font-size:6px;
  464. padding-top: 5px;
  465. padding-left: 5px;
  466. }
  467. .priceBlock{
  468. text-align: center;
  469. font-size: 15px;
  470. font-weight: normal;
  471. .price{
  472. font-size: 30px;
  473. font-weight: bold;
  474. }
  475. }
  476. }
  477. .artistCard{
  478. :deep(.v-card-title){
  479. text-align: center;
  480. }
  481. }
  482. .special_conditions{
  483. font-size: 10px;
  484. }
  485. .trialBtn{
  486. color: #000;
  487. border: 1px solid rgb(var(--v-theme-artist));
  488. }
  489. .optionsCard{
  490. :deep(.margin-sup){
  491. margin-top: 0px;
  492. }
  493. }
  494. .stop_btn{
  495. color: rgb(var(--v-theme-danger));
  496. }
  497. </style>