subscription.vue 17 KB

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