index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <!--
  2. Contenu de la page pages/organization.vue
  3. Contient toutes les informations sur l'organization courante
  4. -->
  5. <template>
  6. <LayoutContainer>
  7. <UiForm :model="model" :entity="organization">
  8. <template #form.input="{model, entity}">
  9. <v-expansion-panels :value="panel" focusable accordion>
  10. <!-- Description -->
  11. <UiExpansionPanel id="description" icon="fa-info">
  12. <v-container fluid class="container">
  13. <v-row>
  14. <v-col cols="12" sm="6">
  15. <UiInputText field="name" :data="entity['name']" @update="updateRepository" :rules="rules().nameRules" />
  16. </v-col>
  17. <v-col cols="12" sm="6">
  18. <UiInputText field="acronym" :data="entity['acronym']" @update="updateRepository" />
  19. </v-col>
  20. <v-col v-if="organizationProfile.isInsideNetwork()" cols="12" sm="6">
  21. <UiInputText :label="organizationProfile.isCmf() ? 'identifierCmf' : 'identifierFfec'" field="identifier" :data="entity['identifier']" @update="updateRepository" />
  22. </v-col>
  23. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  24. <UiInputText field="ffecApproval" :data="entity['ffecApproval']" @update="updateRepository" />
  25. </v-col>
  26. <v-col cols="12" sm="6">
  27. <UiInputText field="description" :data="entity['description']" @update="updateRepository" />
  28. </v-col>
  29. <v-col cols="12" sm="6">
  30. <div>
  31. <span>{{ $t('logo') }}</span>
  32. <UiHelp right>
  33. <p v-html="$t('logo_upload')" />
  34. </UiHelp>
  35. </div>
  36. <UiImage
  37. :id="getIdFromUri(entity['logo'])"
  38. :upload="true"
  39. :width="200"
  40. field="logo"
  41. :ownerId="id"
  42. @update="updateRepository"
  43. ></UiImage>
  44. </v-col>
  45. <v-col v-if="!organizationProfile.isManagerProduct()" cols="12" sm="6">
  46. <UiInputEnum field="principalType" :data="entity['principalType']" enum-type="organization_principal_type" @update="updateRepository" />
  47. </v-col>
  48. <v-col v-if="!organizationProfile.isFfec() && !organizationProfile.isManagerProduct() && !organizationProfile.isArtist()" cols="12" sm="6">
  49. <UiInputEnum field="schoolCategory" :data="entity['schoolCategory']" enum-type="organization_school_cat" @update="updateRepository" />
  50. </v-col>
  51. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  52. <UiInputEnum field="typeEstablishment" :data="entity['typeEstablishment']" enum-type="organization_type_establishment" @update="updateRepository" />
  53. </v-col>
  54. <v-col v-if="entity.typeEstablishment === 'MULTIPLE'" cols="12" sm="6">
  55. <UiInputEnum field="typeEstablishmentDetail" :data="entity['typeEstablishmentDetail']" enum-type="organization_type_establishment_detail" @update="updateRepository" />
  56. </v-col>
  57. <v-col cols="12" sm="6" v-if="organizationProfile.isCmf()">
  58. <div class="d-flex flex-row">
  59. <UiInputAutocomplete
  60. field="typeOfPractices"
  61. :items="typeOfPractices"
  62. :isLoading="typeOfPracticesFetchingState.pending"
  63. :item-text="['name']"
  64. :data="getIdsFromUris(entity['typeOfPractices'])"
  65. :translate="true"
  66. :multiple="true"
  67. group="category"
  68. :rules="rules().typeOfPractice"
  69. @update="updateRepository($event.map((id) => `/api/type_of_practices/${id}`), 'typeOfPractices')"
  70. class="flex"
  71. />
  72. <UiHelp>
  73. {{ $t('type_of_practices_autocomplete') }}
  74. </UiHelp>
  75. </div>
  76. </v-col>
  77. <v-col cols="12" sm="6" v-if="getIdsFromUris(entity['typeOfPractices']).indexOf(37) >= 0">
  78. <UiInputTextArea field="otherPractice" :data="entity['otherPractice']" @update="updateRepository" />
  79. </v-col>
  80. </v-row>
  81. </v-container>
  82. </UiExpansionPanel>
  83. <!-- Adresses -->
  84. <UiExpansionPanel id="address_postal" icon="fa-globe-europe">
  85. <v-container fluid class="container">
  86. <v-row>
  87. <v-col cols="12" sm="12">
  88. <UiCollection
  89. :model="models().OrganizationAddressPostal"
  90. :parent="organization"
  91. loaderType="image"
  92. newLink="/organization/address/new"
  93. >
  94. <template #list.item="{items}">
  95. <v-container fluid>
  96. <v-row dense>
  97. <v-col
  98. v-for="item in items"
  99. :key="item.id"
  100. cols="4"
  101. >
  102. <UiCard
  103. :id="item.id"
  104. :link="`/organization/address/${item.id}`"
  105. :model="models().OrganizationAddressPostal"
  106. >
  107. <template #card.title>
  108. {{ $t(item.type) }}
  109. </template>
  110. <template #card.text>
  111. {{ item.addressPostal.streetAddress }} <br>
  112. <span v-if="item.addressPostal.streetAddressSecond">{{ item.addressPostal.streetAddressSecond }} <br></span>
  113. <span v-if="item.addressPostal.streetAddressThird">{{ item.addressPostal.streetAddressThird }} <br></span>
  114. {{ item.addressPostal.postalCode }} {{ item.addressPostal.addressCity }}<br>
  115. <span v-if="item.addressPostal.addressCountry">
  116. <UiItemFromUri
  117. :model="models().Country"
  118. :query="repositories().countryRepository.query()"
  119. :uri="item.addressPostal.addressCountry"
  120. >
  121. <template #item.text="{item}">
  122. {{item.name}}
  123. </template>
  124. </UiItemFromUri>
  125. </span>
  126. </template>
  127. </UiCard>
  128. </v-col>
  129. </v-row>
  130. </v-container>
  131. </template>
  132. </UiCollection>
  133. </v-col>
  134. </v-row>
  135. </v-container>
  136. </UiExpansionPanel>
  137. <!-- Point de Contact-->
  138. <UiExpansionPanel id="contact_point" icon="fa-phone">
  139. <v-container class="container">
  140. <v-row>
  141. <v-col cols="12" sm="12">
  142. <UiCollection
  143. :model="models().ContactPoint"
  144. :parent="organization"
  145. loaderType="image"
  146. newLink="/organization/contact_points/new"
  147. >
  148. <template #list.item="{items}">
  149. <v-container fluid>
  150. <v-row :dense="true">
  151. <v-col
  152. v-for="item in items"
  153. :key="item.id"
  154. cols="4"
  155. >
  156. <UiCard
  157. :id="item.id"
  158. :link="`/organization/contact_points/${item.id}`"
  159. :model="models().ContactPoint"
  160. >
  161. <template #card.title>
  162. {{ $t(item.contactType) }}
  163. </template>
  164. <template #card.text>
  165. <span v-if="item.email"><strong>{{ $t('email') }}</strong> : {{ item.email }} <br></span>
  166. <span v-if="item.emailInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('emailInvalid') }}</strong> : {{ item.emailInvalid }} <br></span>
  167. <span v-if="item.telphone"><strong>{{ $t('telphone') }}</strong> : {{ formatPhoneNumber(item.telphone) }} <br></span>
  168. <span v-if="item.telphoneInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('telphoneInvalid') }}</strong> : {{ formatPhoneNumber(item.telphoneInvalid) }} <br></span>
  169. <span v-if="item.mobilPhone"><strong>{{ $t('mobilPhone') }}</strong> : {{ formatPhoneNumber(item.mobilPhone) }} <br></span>
  170. <span v-if="item.mobilPhoneInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('mobilPhoneInvalid') }}</strong> : {{ formatPhoneNumber(item.mobilPhoneInvalid) }} </span>
  171. </template>
  172. </UiCard>
  173. </v-col>
  174. </v-row>
  175. </v-container>
  176. </template>
  177. </UiCollection>
  178. </v-col>
  179. </v-row>
  180. </v-container>
  181. </UiExpansionPanel>
  182. <!-- Informations légales -->
  183. <UiExpansionPanel id="legalInformation" icon="fa-gavel">
  184. <v-container fluid class="container">
  185. <v-row>
  186. <v-col cols="12" sm="6">
  187. <UiInputText
  188. field="siretNumber"
  189. :data="entity['siretNumber']"
  190. :error="siretError"
  191. :error-message="siretErrorMessage"
  192. :rules="rules().siretRule"
  193. @update="checkSiretHook($event, 'siretNumber', updateRepository)"
  194. />
  195. </v-col>
  196. <v-col cols="12" sm="6">
  197. <UiInputText field="apeNumber" :data="entity['apeNumber']" @update="updateRepository" />
  198. </v-col>
  199. <v-col v-if="entity['legalStatus'] === 'ASSOCIATION_LAW_1901'" cols="12" sm="6">
  200. <UiInputText field="waldecNumber" :data="entity['waldecNumber']" @update="updateRepository" />
  201. </v-col>
  202. <v-col cols="12" sm="6">
  203. <UiInputDatePicker field="creationDate" :data="entity['creationDate']" @update="updateRepository" />
  204. </v-col>
  205. <v-col cols="12" sm="6">
  206. <UiInputText field="prefectureName" :data="entity['prefectureName']" @update="updateRepository" />
  207. </v-col>
  208. <v-col cols="12" sm="6">
  209. <UiInputText field="prefectureNumber" :data="entity['prefectureNumber']" @update="updateRepository" />
  210. </v-col>
  211. <v-col cols="12" sm="6">
  212. <UiInputDatePicker field="declarationDate" :data="entity['declarationDate']" @update="updateRepository" />
  213. </v-col>
  214. <v-col cols="12" sm="6">
  215. <UiInputText field="tvaNumber" :data="entity['tvaNumber']" @update="updateRepository" />
  216. </v-col>
  217. <v-col cols="12" sm="6">
  218. <UiInputEnum field="legalStatus" :data="entity['legalStatus']" enum-type="organization_legal" @update="updateRepository" />
  219. </v-col>
  220. </v-row>
  221. </v-container>
  222. </UiExpansionPanel>
  223. <!-- Agréments -->
  224. <UiExpansionPanel id="agrements" icon="fa-certificate">
  225. <v-container class="container">
  226. <v-row>
  227. <v-col cols="12" sm="6">
  228. <UiInputText field="youngApproval" :data="entity['youngApproval']" @update="updateRepository" />
  229. </v-col>
  230. <v-col cols="12" sm="6">
  231. <UiInputText field="trainingApproval" :data="entity['trainingApproval']" @update="updateRepository" />
  232. </v-col>
  233. <v-col cols="12" sm="6">
  234. <UiInputText field="otherApproval" :data="entity['otherApproval']" @update="updateRepository" />
  235. </v-col>
  236. </v-row>
  237. </v-container>
  238. </UiExpansionPanel>
  239. <!-- Salariés -->
  240. <UiExpansionPanel id="salary" icon="fa-users">
  241. <v-container class="container">
  242. <v-row>
  243. <v-col cols="12" sm="6">
  244. <UiInputText field="collectiveAgreement" :data="entity['collectiveAgreement']" @update="updateRepository" />
  245. </v-col>
  246. <v-col cols="12" sm="6">
  247. <UiInputEnum field="opca" :data="entity['opca']" enum-type="organization_opca" @update="updateRepository" />
  248. </v-col>
  249. <v-col cols="12" sm="6">
  250. <UiInputText field="icomNumber" :data="entity['icomNumber']" @update="updateRepository" />
  251. </v-col>
  252. <v-col cols="12" sm="6">
  253. <UiInputText field="urssafNumber" :data="entity['urssafNumber']" @update="updateRepository" />
  254. </v-col>
  255. </v-row>
  256. </v-container>
  257. </UiExpansionPanel>
  258. <!-- Réseaux -->
  259. <UiExpansionPanel v-if="organizationProfile.isInsideNetwork()" id="network" icon="fa-share-alt">
  260. <v-container class="container">
  261. <v-row>
  262. <v-col cols="12" sm="12">
  263. <UiCollection
  264. :model="models().NetworkOrganization"
  265. :parent="organization"
  266. loaderType="text"
  267. >
  268. <template #list.item="{items}">
  269. <div v-for="item in items" :key="item.id">
  270. <span>{{ item.network.name }}</span> - <span>{{$t('first_subscription')}} : <UiTemplateDate :data="item.startDate" /></span>
  271. </div>
  272. </template>
  273. </UiCollection>
  274. </v-col>
  275. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  276. <UiInputText field="budget" :data="entity['budget']" type="number" @update="updateRepository" />
  277. </v-col>
  278. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  279. <UiInputCheckbox field="isPedagogicIsPrincipalActivity" :data="entity['isPedagogicIsPrincipalActivity']" @update="updateRepository" />
  280. </v-col>
  281. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  282. <UiInputText field="pedagogicBudget" :data="entity['pedagogicBudget']" type="number" @update="updateRepository" />
  283. </v-col>
  284. </v-row>
  285. </v-container>
  286. </UiExpansionPanel>
  287. <!-- Communication -->
  288. <UiExpansionPanel id="communication" icon="fa-rss">
  289. <v-container class="container">
  290. <v-row>
  291. <v-col cols="12" sm="6">
  292. <UiInputText field="twitter" :data="entity['twitter']" @update="updateRepository" />
  293. </v-col>
  294. <v-col cols="12" sm="6">
  295. <UiInputText field="youtube" :data="entity['youtube']" @update="updateRepository" />
  296. </v-col>
  297. <v-col cols="12" sm="6">
  298. <UiInputText field="facebook" :data="entity['facebook']" @update="updateRepository" />
  299. </v-col>
  300. <v-col cols="12" sm="6">
  301. <UiInputText field="instagram" :data="entity['instagram']" @update="updateRepository" />
  302. </v-col>
  303. <v-col cols="12" sm="6">
  304. <UiInputCheckbox field="portailVisibility" :data="entity['portailVisibility']" @update="updateRepository" />
  305. </v-col>
  306. <v-col cols="12" sm="6">
  307. <div class="d-flex flex-column">
  308. <UiHelp class="d-flex flex-row">
  309. <span>{{ $t('image') }}</span>
  310. <p v-html="$t('communication_image_upload')" />
  311. </UiHelp>
  312. <UiImage
  313. :id="getIdFromUri(entity['image'])"
  314. :upload="true"
  315. :width="200"
  316. field="image"
  317. :ownerId="id"
  318. @update="updateRepository"
  319. ></UiImage>
  320. </div>
  321. </v-col>
  322. <v-col cols="12" sm="12">
  323. <UiCollection
  324. :model="models().OrganizationArticle"
  325. :parent="organization"
  326. loaderType="text"
  327. >
  328. <template #list.item="{items}">
  329. <h4 class="ot_grey--text font-weight-regular">{{$t('organizationArticle')}}</h4>
  330. <UiTemplateDataTable
  331. :headers="[
  332. { text: $t('title'), value: 'title' },
  333. { text: $t('link'), value: 'link' },
  334. { text: $t('date'), value: 'date' },
  335. ]"
  336. :items="items"
  337. >
  338. <template #item.date="{item}">
  339. <UiTemplateDate :data="item.date" />
  340. </template>
  341. </UiTemplateDataTable>
  342. </template>
  343. </UiCollection>
  344. </v-col>
  345. </v-row>
  346. </v-container>
  347. </UiExpansionPanel>
  348. <!-- IBAN -->
  349. <UiExpansionPanel id="bank_account" icon="fa-euro-sign">
  350. <v-container class="container">
  351. <v-row>
  352. <v-col cols="12" sm="12">
  353. <UiCollection
  354. :model="models().BankAccount"
  355. :parent="organization"
  356. loaderType="image"
  357. newLink="/organization/bank_account/new"
  358. >
  359. <template #list.item="{items}">
  360. <v-container fluid>
  361. <v-row :dense="true">
  362. <v-col
  363. v-for="item in items"
  364. :key="item.id"
  365. cols="4"
  366. >
  367. <UiCard
  368. :id="item.id"
  369. :link="`/organization/bank_account/${item.id}`"
  370. :model="models().BankAccount"
  371. >
  372. <template #card.text>
  373. <span v-if="item.bankName"><strong>{{ $t('bankName') }}</strong> : {{ item.bankName }} <br></span>
  374. <span v-if="item.bic"><strong>{{ $t('bic') }}</strong> : {{ item.bic }} <br></span>
  375. <span v-if="item.bicInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('bicInvalid') }}</strong> : {{ item.bicInvalid }} <br></span>
  376. <span v-if="item.iban"><strong>{{ $t('iban') }}</strong> : {{ item.iban }} <br></span>
  377. <span v-if="item.ibanInvalid" class="ot_danger--text"><v-icon class="ot_danger--text">mdi-alert</v-icon> <strong>{{ $t('ibanInvalid') }}</strong> : {{ item.ibanInvalid }} <br></span>
  378. </template>
  379. </UiCard>
  380. </v-col>
  381. </v-row>
  382. </v-container>
  383. </template>
  384. </UiCollection>
  385. </v-col>
  386. </v-row>
  387. </v-container>
  388. </UiExpansionPanel>
  389. </v-expansion-panels>
  390. </template>
  391. </UiForm>
  392. </LayoutContainer>
  393. </template>
  394. <script lang="ts">
  395. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  396. import {TypeOfPractice} from "~/models/Organization/TypeOfPractice";
  397. import {reactive, ref} from "@vue/reactivity";
  398. import {$organizationProfile} from "~/services/profile/organizationProfile";
  399. import {useProfileOrganizationStore} from "~/store/profile/organization";
  400. import {useExtensionPanel} from "~/composables/layout/useExtensionPanel";
  401. import {useRoute} from "#app";
  402. import { useValidation } from "~/composables/form/useValidation";
  403. import {useEntityManager} from "~/composables/data/useEntityManager";
  404. import Url from "~/services/utils/url";
  405. import {Organization} from "~/models/Organization/Organization";
  406. import {useI18nUtils} from "~/composables/utils/useI18nUtils";
  407. import {ContactPoint} from "~/models/Core/ContactPoint";
  408. import {BankAccount} from "~/models/Core/BankAccount";
  409. import {OrganizationAddressPostal} from "~/models/Organization/OrganizationAddressPostal";
  410. import {Country} from "~/models/Core/Country";
  411. import {NetworkOrganization} from "~/models/Network/NetworkOrganization";
  412. import {OrganizationArticle} from "~/models/Organization/OrganizationArticle";
  413. const id: number | null = useProfileOrganizationStore().id
  414. if (id === null) {
  415. throw new Error('Missing organization id')
  416. }
  417. const { em } = useEntityManager()
  418. const organizationProfile = reactive($organizationProfile())
  419. const { fetch, fetchCollection } = useEntityFetch()
  420. const model = Organization
  421. const { data: organization, pending: organizationPending } = fetch(Organization, id)
  422. const { data: typeOfPractices, pending: typeOfPracticesPending } = fetchCollection(TypeOfPractice)
  423. const route = ref(useRoute())
  424. const { panel } = useExtensionPanel(route)
  425. const { siretError, siretErrorMessage, validateSiret } = useValidation().useValidateSiret()
  426. const validateSiretHook = async (siret: string, field: string, updateRepository: any) => {
  427. await validateSiret(siret)
  428. if (organization.value !== null && !siretError.value) {
  429. em.save(Organization, organization.value)
  430. }
  431. }
  432. const formatPhoneNumber = (number: string): string => {
  433. return useI18nUtils().formatPhoneNumber(number)
  434. }
  435. const getIdsFromUris = (uris: Array<string>) => {
  436. const ids:Array<any> = []
  437. for(const uri of uris){
  438. ids.push(Url.extractIdFromUri(uri))
  439. }
  440. return ids
  441. }
  442. const getIdFromUri = (uri: string) => Url.extractIdFromUri(uri)
  443. function getValidationRules (i18n: any, $organizationProfile:any) {
  444. return {
  445. nameRules: [
  446. (nameValue: string) => !!nameValue || i18n.t('required'),
  447. (nameValue: string) => (nameValue || '').length <= 128 || i18n.t('name_length_rule')
  448. ],
  449. siretRule: [
  450. (siretValue: string) => /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error')
  451. ],
  452. typeOfPractice: [
  453. (typeOfPracticeValue: Array<number>) => {
  454. if(!$organizationProfile.isManagerProduct())
  455. return typeOfPracticeValue.length > 0 || i18n.t('required')
  456. return true
  457. }
  458. ]
  459. }
  460. }
  461. const models = () => {
  462. return {
  463. Organization,
  464. ContactPoint,
  465. BankAccount,
  466. OrganizationAddressPostal,
  467. Country,
  468. NetworkOrganization,
  469. OrganizationArticle
  470. }
  471. }
  472. </script>
  473. <style scoped>
  474. .v-icon.v-icon {
  475. font-size: 14px;
  476. }
  477. </style>