subscription.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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. </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. </tr>
  84. </tbody>
  85. </v-table>
  86. </v-row>
  87. </v-container>
  88. </UiExpansionPanel>
  89. <UiExpansionPanel :title="$t('opentalent_offer')" icon="fas fa-plus" v-if="!organizationProfile.isManagerProduct">
  90. <v-container fluid class="container">
  91. <v-row class="offer_title" v-if="!md && mdAndUp && !organizationProfile.isSchool">
  92. <v-col cols="12" :lg="organizationProfile.isArtistPremiumProduct ? 3 : 6" sm="12">
  93. <span class="theme-artist">Pour les orchestres, chorales, compagnies et troupes artistiques</span>
  94. </v-col>
  95. <v-col cols="12" :lg="organizationProfile.isArtistPremiumProduct ? 3 : 5" sm="12" :offset="organizationProfile.isArtistPremiumProduct ? 0 : 1">
  96. <span class="theme-school">Pour les établissements d'enseignements artistiques*</span>
  97. </v-col>
  98. </v-row>
  99. <v-row class="card-container">
  100. <v-col lg="3" sm="12" md="6" v-if="organizationProfile.isArtistProduct">
  101. <PagesSubscriptionCard
  102. class="artistCard"
  103. title="Logiciel Artist Standard"
  104. :extraHeader="organizationProfile.isArtistProduct ? 'Votre version' : false"
  105. color="artist"
  106. :list="listCheck.artist"
  107. >
  108. <template #card.subTitle>
  109. <div class="priceBlock">
  110. <span class="price">{{formatCurrency(11, 'EUR')}}</span> TTC/mois
  111. </div>
  112. </template>
  113. <template #card.action>
  114. <v-btn
  115. v-if="!organizationProfile.isArtistProduct"
  116. class="theme-artist btn"
  117. href="https://logiciels.opentalent.fr/opentalent-artist"
  118. target="_blank"
  119. >
  120. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  121. </v-btn>
  122. </template>
  123. </PagesSubscriptionCard>
  124. </v-col>
  125. <v-col lg="3" sm="12" md="6" v-if="organizationProfile.isArtist">
  126. <PagesSubscriptionCard
  127. class="artistCard"
  128. title="Logiciel Artist Premium*"
  129. :extraHeader="organizationProfile.isArtistPremiumProduct ? 'Votre version' : '1 mois d\'essai offert'"
  130. color="artist"
  131. :list="listCheck.artistPremium"
  132. >
  133. <template #card.subTitle>
  134. <div class="priceBlock">
  135. <span class="price">{{organizationProfile.isCmf ? formatCurrency(7.5, 'EUR') : formatCurrency(18.0, 'EUR')}}</span> TTC/mois
  136. </div>
  137. </template>
  138. <template #card.action>
  139. <v-row >
  140. <v-col cols="12" v-if="!organizationProfile.isArtistPremiumProduct && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  141. <v-btn
  142. class="btn trialBtn"
  143. @click="startTrial"
  144. >
  145. Essayer la version premium <i class="fa-solid fa-greater-than small"></i>
  146. </v-btn>
  147. </v-col>
  148. <v-col cols="12" v-if="(!organizationProfile.isArtistPremiumProduct || organizationProfile.isTrialActive) && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  149. <v-btn
  150. class="theme-artist btn"
  151. @click="subscription"
  152. >
  153. Souscrire à l'offre <i class="fa-solid fa-greater-than small"></i>
  154. </v-btn>
  155. </v-col>
  156. <v-col cols="12" v-if="!organizationProfile.isArtistPremiumProduct" >
  157. <v-btn
  158. class="theme-artist btn"
  159. href="https://logiciels.opentalent.fr/opentalent-artist"
  160. target="_blank"
  161. >
  162. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  163. </v-btn>
  164. </v-col>
  165. <v-col cols="12" v-if="organizationProfile.isTrialActive && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
  166. <v-btn
  167. class="stop_btn"
  168. @click="stopTrial"
  169. >
  170. Arrêter l'essai
  171. </v-btn>
  172. </v-col>
  173. <v-col cols="12">
  174. <span class="special_conditions">
  175. *Convient aux petites écoles sans besoins spécifiques de gestion pédagogique, de facturation, etc.
  176. Pour une solution complète optez pour Opentalent School
  177. </span>
  178. </v-col>
  179. </v-row>
  180. </template>
  181. </PagesSubscriptionCard>
  182. </v-col>
  183. <v-col lg="3" sm="12" md="6" :offset="!md && mdAndUp ? (organizationProfile.isSchool ? 4 : (organizationProfile.isArtistPremiumProduct ? 0 : 2)) : 0">
  184. <PagesSubscriptionCard
  185. class="schoolCard"
  186. :title="!organizationProfile.isSchool ? 'Logiciel School Standard / Premium' : (
  187. organizationProfile.isSchoolPremiumProduct ? 'Logiciel School Premium' : 'Logiciel School Standard'
  188. )"
  189. :subTitle="!organizationProfile.isSchool ? 'Sur devis' : ''"
  190. :extraHeader="organizationProfile.isSchool ? 'Votre version' : false"
  191. color="school"
  192. :list="listCheck.school"
  193. >
  194. <template #card.action>
  195. <v-row>
  196. <v-col cols="12">
  197. <v-btn
  198. v-if="!organizationProfile.isSchool"
  199. class="theme-school btn"
  200. href="https://logiciels.opentalent.fr/opentalent-school"
  201. target="_blank"
  202. >
  203. En savoir plus <i class="fa-solid fa-greater-than small"></i>
  204. </v-btn>
  205. </v-col>
  206. <v-col cols="12">
  207. <span class="special_conditions">
  208. *Extranet disponible uniquement dans la version Opentalent School Premium
  209. </span>
  210. </v-col>
  211. </v-row>
  212. </template>
  213. </PagesSubscriptionCard>
  214. </v-col>
  215. </v-row>
  216. </v-container>
  217. </UiExpansionPanel>
  218. <UiExpansionPanel :title="$t('opentalent_options')" icon="fas fa-plus">
  219. <v-container fluid class="container card-container">
  220. <v-row cols="12" >
  221. <v-col lg="3" sm="12" md="6">
  222. <PagesSubscriptionCard
  223. class="optionsCard"
  224. title="SMS"
  225. sub-title="Option payante"
  226. color="primary"
  227. :list="listCheck.sms"
  228. >
  229. <template #card.action>
  230. <v-btn
  231. class="theme-primary btn"
  232. :href="
  233. runtimeConfig.public.fileStorageBaseUrl +
  234. (organizationProfile.isCmf ? '/Bon_de_commande/Achat_SMS_CMF.pdf' : '/Bon_de_commande/Achat_SMS_Public.pdf')
  235. "
  236. target="_blank"
  237. >
  238. acheter des credits SMS <i class="fa-solid fa-greater-than small"></i>
  239. </v-btn>
  240. </template>
  241. </PagesSubscriptionCard>
  242. </v-col>
  243. <v-col lg="3" sm="12" md="6">
  244. <PagesSubscriptionCard
  245. class="optionsCard"
  246. title="Nom de domaine"
  247. sub-title="Option payante"
  248. color="primary"
  249. :list="listCheck.domain"
  250. >
  251. <template #card.action>
  252. <v-btn
  253. class="theme-primary btn"
  254. :href="
  255. runtimeConfig.public.fileStorageBaseUrl +
  256. '/Bon_de_commande/Nom_de_domaine.pdf'
  257. "
  258. target="_blank"
  259. >
  260. souscrire à l'option <i class="fa-solid fa-greater-than small"></i>
  261. </v-btn>
  262. </template>
  263. </PagesSubscriptionCard>
  264. </v-col>
  265. </v-row>
  266. </v-container>
  267. </UiExpansionPanel>
  268. </v-expansion-panels>
  269. </LayoutContainer>
  270. <DialogTrialAllReadyDid
  271. :show="showDialogTrialAllReadyDid"
  272. @closeDialog = "showDialogTrialAllReadyDid = false"
  273. />
  274. <DialogTrialStopConfirmation
  275. :show="showDialogTrialStopConfirmation"
  276. @closeDialog = "showDialogTrialStopConfirmation = false"
  277. />
  278. </template>
  279. <script setup lang="ts">
  280. import {useAbility} from '@casl/vue'
  281. import type {Ref} from 'vue'
  282. import {useDisplay} from 'vuetify'
  283. import type {AsyncData} from '#app'
  284. import {useOrganizationProfileStore} from '~/stores/organizationProfile'
  285. import {useEntityFetch} from '~/composables/data/useEntityFetch'
  286. import DolibarrAccount from '~/models/Organization/DolibarrAccount'
  287. import MobytUserStatus from '~/models/Organization/MobytUserStatus'
  288. import UrlUtils from "~/services/utils/urlUtils";
  289. import {useApiLegacyRequestService} from "~/composables/data/useApiLegacyRequestService";
  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. '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_offer'), 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(): Record<Ref<MobytUserStatus | null>, 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, '#', 'trial/subscribe'), {
  415. external: true
  416. })
  417. }
  418. /**
  419. * Action lorsque l'on souhaite stopper l'essai
  420. */
  421. function stopTrial(){
  422. showDialogTrialStopConfirmation.value = true
  423. }
  424. </script>
  425. <style scoped lang="scss">
  426. .offer_title{
  427. span{
  428. border-radius: 5px;
  429. display: block;
  430. font-weight: bold;
  431. text-align: center;
  432. padding: 5px;
  433. }
  434. }
  435. .card-container{
  436. .v-row {
  437. display: -webkit-box;
  438. display: -webkit-flex;
  439. display: -ms-flexbox;
  440. display: flex;
  441. flex-wrap: wrap;
  442. }
  443. .v-row > [class*='v-col-'] {
  444. display: flex;
  445. flex-direction: column;
  446. }
  447. .small{
  448. font-size:6px;
  449. padding-top: 5px;
  450. padding-left: 5px;
  451. }
  452. .priceBlock{
  453. text-align: center;
  454. font-size: 15px;
  455. font-weight: normal;
  456. .price{
  457. font-size: 30px;
  458. font-weight: bold;
  459. }
  460. }
  461. }
  462. .artistCard{
  463. :deep(.v-card-title){
  464. text-align: center;
  465. }
  466. }
  467. .special_conditions{
  468. font-size: 10px;
  469. }
  470. .trialBtn{
  471. color: #000;
  472. border: 1px solid rgb(var(--v-theme-artist));
  473. }
  474. .optionsCard{
  475. :deep(.margin-sup){
  476. margin-top: 0px;
  477. }
  478. }
  479. .stop_btn{
  480. color: rgb(var(--v-theme-danger));
  481. }
  482. </style>