index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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 :id="id" :model="models().Organization" :query="repositories().organizationRepository.query()">
  8. <template #form.input="{entry, updateRepository}">
  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="entry['name']" @update="updateRepository" :rules="rules().nameRules" />
  16. </v-col>
  17. <v-col cols="12" sm="6">
  18. <UiInputText field="acronym" :data="entry['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="entry['identifier']" @update="updateRepository" />
  22. </v-col>
  23. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  24. <UiInputText field="ffecApproval" :data="entry['ffecApproval']" @update="updateRepository" />
  25. </v-col>
  26. <v-col cols="12" sm="6">
  27. <UiInputText field="description" :data="entry['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(entry['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="entry['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="entry['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="entry['typeEstablishment']" enum-type="organization_type_establishment" @update="updateRepository" />
  53. </v-col>
  54. <v-col v-if="entry.typeEstablishment === 'MULTIPLE'" cols="12" sm="6">
  55. <UiInputEnum field="typeEstablishmentDetail" :data="entry['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(entry['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(entry['typeOfPractices']).indexOf(37) >= 0">
  78. <UiInputTextArea field="otherPractice" :data="entry['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. <UiSubResource
  89. :query="repositories().addressRepository.with('addressPostal')"
  90. :root-model="models().Organization"
  91. :root-id="id"
  92. :model="models().OrganizationAddressPostal"
  93. loaderType="image"
  94. newLink="/organization/address/new"
  95. >
  96. <template #list.item="{items}">
  97. <v-container fluid>
  98. <v-row dense>
  99. <v-col
  100. v-for="item in items"
  101. :key="item.id"
  102. cols="4"
  103. >
  104. <UiCard
  105. :id="item.id"
  106. :link="`/organization/address/${item.id}`"
  107. :model="models().OrganizationAddressPostal"
  108. >
  109. <template #card.title>
  110. {{ $t(item.type) }}
  111. </template>
  112. <template #card.text>
  113. {{ item.addressPostal.streetAddress }} <br>
  114. <span v-if="item.addressPostal.streetAddressSecond">{{ item.addressPostal.streetAddressSecond }} <br></span>
  115. <span v-if="item.addressPostal.streetAddressThird">{{ item.addressPostal.streetAddressThird }} <br></span>
  116. {{ item.addressPostal.postalCode }} {{ item.addressPostal.addressCity }}<br>
  117. <span v-if="item.addressPostal.addressCountry">
  118. <UiItemFromUri
  119. :model="models().Country"
  120. :query="repositories().countryRepository.query()"
  121. :uri="item.addressPostal.addressCountry"
  122. >
  123. <template #item.text="{item}">
  124. {{item.name}}
  125. </template>
  126. </UiItemFromUri>
  127. </span>
  128. </template>
  129. </UiCard>
  130. </v-col>
  131. </v-row>
  132. </v-container>
  133. </template>
  134. </UiSubResource>
  135. </v-col>
  136. </v-row>
  137. </v-container>
  138. </UiExpansionPanel>
  139. <!-- Point de Contact-->
  140. <UiExpansionPanel id="contact_point" icon="fa-phone">
  141. <v-container class="container">
  142. <v-row>
  143. <v-col cols="12" sm="12">
  144. <UiSubResource
  145. :query="repositories().contactPointRepository.query()"
  146. :root-model="models().Organization"
  147. :root-id="id"
  148. :model="models().ContactPoint"
  149. loaderType="image"
  150. newLink="/organization/contact_points/new"
  151. >
  152. <template #list.item="{items}">
  153. <v-container fluid>
  154. <v-row dense>
  155. <v-col
  156. v-for="item in items"
  157. :key="item.id"
  158. cols="4"
  159. >
  160. <UiCard
  161. :id="item.id"
  162. :link="`/organization/contact_points/${item.id}`"
  163. :model="models().ContactPoint"
  164. >
  165. <template #card.title>
  166. {{ $t(item.contactType) }}
  167. </template>
  168. <template #card.text>
  169. <span v-if="item.email"><strong>{{ $t('email') }}</strong> : {{ item.email }} <br></span>
  170. <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>
  171. <span v-if="item.telphone"><strong>{{ $t('telphone') }}</strong> : {{ formatPhoneNumber(item.telphone) }} <br></span>
  172. <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>
  173. <span v-if="item.mobilPhone"><strong>{{ $t('mobilPhone') }}</strong> : {{ formatPhoneNumber(item.mobilPhone) }} <br></span>
  174. <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>
  175. </template>
  176. </UiCard>
  177. </v-col>
  178. </v-row>
  179. </v-container>
  180. </template>
  181. </UiSubResource>
  182. </v-col>
  183. </v-row>
  184. </v-container>
  185. </UiExpansionPanel>
  186. <!-- Informations légales -->
  187. <UiExpansionPanel id="legalInformation" icon="fa-gavel">
  188. <v-container fluid class="container">
  189. <v-row>
  190. <v-col cols="12" sm="6">
  191. <UiInputText
  192. field="siretNumber"
  193. :data="entry['siretNumber']"
  194. :error="siretError"
  195. :error-message="siretErrorMessage"
  196. :rules="rules().siretRule"
  197. @update="checkSiretHook($event, 'siretNumber', updateRepository)"
  198. />
  199. </v-col>
  200. <v-col cols="12" sm="6">
  201. <UiInputText field="apeNumber" :data="entry['apeNumber']" @update="updateRepository" />
  202. </v-col>
  203. <v-col v-if="entry['legalStatus'] === 'ASSOCIATION_LAW_1901'" cols="12" sm="6">
  204. <UiInputText field="waldecNumber" :data="entry['waldecNumber']" @update="updateRepository" />
  205. </v-col>
  206. <v-col cols="12" sm="6">
  207. <UiInputDatePicker field="creationDate" :data="entry['creationDate']" @update="updateRepository" />
  208. </v-col>
  209. <v-col cols="12" sm="6">
  210. <UiInputText field="prefectureName" :data="entry['prefectureName']" @update="updateRepository" />
  211. </v-col>
  212. <v-col cols="12" sm="6">
  213. <UiInputText field="prefectureNumber" :data="entry['prefectureNumber']" @update="updateRepository" />
  214. </v-col>
  215. <v-col cols="12" sm="6">
  216. <UiInputDatePicker field="declarationDate" :data="entry['declarationDate']" @update="updateRepository" />
  217. </v-col>
  218. <v-col cols="12" sm="6">
  219. <UiInputText field="tvaNumber" :data="entry['tvaNumber']" @update="updateRepository" />
  220. </v-col>
  221. <v-col cols="12" sm="6">
  222. <UiInputEnum field="legalStatus" :data="entry['legalStatus']" enum-type="organization_legal" @update="updateRepository" />
  223. </v-col>
  224. </v-row>
  225. </v-container>
  226. </UiExpansionPanel>
  227. <!-- Agréments -->
  228. <UiExpansionPanel id="agrements" icon="fa-certificate">
  229. <v-container class="container">
  230. <v-row>
  231. <v-col cols="12" sm="6">
  232. <UiInputText field="youngApproval" :data="entry['youngApproval']" @update="updateRepository" />
  233. </v-col>
  234. <v-col cols="12" sm="6">
  235. <UiInputText field="trainingApproval" :data="entry['trainingApproval']" @update="updateRepository" />
  236. </v-col>
  237. <v-col cols="12" sm="6">
  238. <UiInputText field="otherApproval" :data="entry['otherApproval']" @update="updateRepository" />
  239. </v-col>
  240. </v-row>
  241. </v-container>
  242. </UiExpansionPanel>
  243. <!-- Salariés -->
  244. <UiExpansionPanel id="salary" icon="fa-users">
  245. <v-container class="container">
  246. <v-row>
  247. <v-col cols="12" sm="6">
  248. <UiInputText field="collectiveAgreement" :data="entry['collectiveAgreement']" @update="updateRepository" />
  249. </v-col>
  250. <v-col cols="12" sm="6">
  251. <UiInputEnum field="opca" :data="entry['opca']" enum-type="organization_opca" @update="updateRepository" />
  252. </v-col>
  253. <v-col cols="12" sm="6">
  254. <UiInputText field="icomNumber" :data="entry['icomNumber']" @update="updateRepository" />
  255. </v-col>
  256. <v-col cols="12" sm="6">
  257. <UiInputText field="urssafNumber" :data="entry['urssafNumber']" @update="updateRepository" />
  258. </v-col>
  259. </v-row>
  260. </v-container>
  261. </UiExpansionPanel>
  262. <!-- Réseaux -->
  263. <UiExpansionPanel v-if="organizationProfile.isInsideNetwork()" id="network" icon="fa-share-alt">
  264. <v-container class="container">
  265. <v-row>
  266. <v-col cols="12" sm="12">
  267. <UiSubResource
  268. :query="repositories().netWorkOrganizationRepository.with('network')"
  269. :root-model="models().Organization"
  270. :root-id="id"
  271. :model="models().NetworkOrganization"
  272. loaderType="text"
  273. >
  274. <template #list.item="{items}">
  275. <div v-for="item in items" :key="item.id">
  276. <span>{{ item.network.name }}</span> - <span>{{$t('first_subscription')}} : <UiTemplateDate :data="item.startDate" /></span>
  277. </div>
  278. </template>
  279. </UiSubResource>
  280. </v-col>
  281. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  282. <UiInputText field="budget" :data="entry['budget']" type="number" @update="updateRepository" />
  283. </v-col>
  284. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  285. <UiInputCheckbox field="isPedagogicIsPrincipalActivity" :data="entry['isPedagogicIsPrincipalActivity']" @update="updateRepository" />
  286. </v-col>
  287. <v-col v-if="organizationProfile.isFfec()" cols="12" sm="6">
  288. <UiInputText field="pedagogicBudget" :data="entry['pedagogicBudget']" type="number" @update="updateRepository" />
  289. </v-col>
  290. </v-row>
  291. </v-container>
  292. </UiExpansionPanel>
  293. <!-- Communication -->
  294. <UiExpansionPanel id="communication" icon="fa-rss">
  295. <v-container class="container">
  296. <v-row>
  297. <v-col cols="12" sm="6">
  298. <UiInputText field="twitter" :data="entry['twitter']" @update="updateRepository" />
  299. </v-col>
  300. <v-col cols="12" sm="6">
  301. <UiInputText field="youtube" :data="entry['youtube']" @update="updateRepository" />
  302. </v-col>
  303. <v-col cols="12" sm="6">
  304. <UiInputText field="facebook" :data="entry['facebook']" @update="updateRepository" />
  305. </v-col>
  306. <v-col cols="12" sm="6">
  307. <UiInputText field="instagram" :data="entry['instagram']" @update="updateRepository" />
  308. </v-col>
  309. <v-col cols="12" sm="6">
  310. <UiInputCheckbox field="portailVisibility" :data="entry['portailVisibility']" @update="updateRepository" />
  311. </v-col>
  312. <v-col cols="12" sm="6">
  313. <div class="d-flex flex-column">
  314. <UiHelp class="d-flex flex-row">
  315. <span>{{ $t('image') }}</span>
  316. <p v-html="$t('communication_image_upload')" />
  317. </UiHelp>
  318. <UiImage
  319. :id="getIdFromUri(entry['image'])"
  320. :upload="true"
  321. :width="200"
  322. field="image"
  323. :ownerId="id"
  324. @update="updateRepository"
  325. ></UiImage>
  326. </div>
  327. </v-col>
  328. <v-col cols="12" sm="12">
  329. <UiSubResource
  330. :query="repositories().organizationArticleRepository.query()"
  331. :root-model="models().Organization"
  332. :root-id="id"
  333. :model="models().OrganizationArticle"
  334. loaderType="text"
  335. >
  336. <template #list.item="{items}">
  337. <h4 class="ot_grey--text font-weight-regular">{{$t('organizationArticle')}}</h4>
  338. <UiTemplateDataTable
  339. :headers="[
  340. { text: $t('title'), value: 'title' },
  341. { text: $t('link'), value: 'link' },
  342. { text: $t('date'), value: 'date' },
  343. ]"
  344. :items="items"
  345. >
  346. <template #item.date="{item}"><UiTemplateDate :data="item.date" /></template>
  347. </UiTemplateDataTable>
  348. </template>
  349. </UiSubResource>
  350. </v-col>
  351. </v-row>
  352. </v-container>
  353. </UiExpansionPanel>
  354. <!-- IBAN -->
  355. <UiExpansionPanel id="bank_account" icon="fa-euro-sign">
  356. <v-container class="container">
  357. <v-row>
  358. <v-col cols="12" sm="12">
  359. <UiSubResource
  360. :query="repositories().bankAccountRepository.query()"
  361. :root-model="models().Organization"
  362. :root-id="id"
  363. :model="models().BankAccount"
  364. loaderType="image"
  365. newLink="/organization/bank_account/new"
  366. >
  367. <template #list.item="{items}">
  368. <v-container fluid>
  369. <v-row dense>
  370. <v-col
  371. v-for="item in items"
  372. :key="item.id"
  373. cols="4"
  374. >
  375. <UiCard
  376. :id="item.id"
  377. :link="`/organization/bank_account/${item.id}`"
  378. :model="models().BankAccount"
  379. >
  380. <template #card.text>
  381. <span v-if="item.bankName"><strong>{{ $t('bankName') }}</strong> : {{ item.bankName }} <br></span>
  382. <span v-if="item.bic"><strong>{{ $t('bic') }}</strong> : {{ item.bic }} <br></span>
  383. <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>
  384. <span v-if="item.iban"><strong>{{ $t('iban') }}</strong> : {{ item.iban }} <br></span>
  385. <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>
  386. </template>
  387. </UiCard>
  388. </v-col>
  389. </v-row>
  390. </v-container>
  391. </template>
  392. </UiSubResource>
  393. </v-col>
  394. </v-row>
  395. </v-container>
  396. </UiExpansionPanel>
  397. </v-expansion-panels>
  398. </template>
  399. </UiForm>
  400. </LayoutContainer>
  401. </template>
  402. <script lang="ts">
  403. import {defineComponent, useContext, reactive} from '@nuxtjs/composition-api'
  404. import { $organizationProfile } from '~/services/profile/organizationProfile'
  405. import { Organization } from '@/models/Organization/Organization'
  406. import { OrganizationAddressPostal } from '~/models/Organization/OrganizationAddressPostal'
  407. import { ContactPoint } from '~/models/Core/ContactPoint'
  408. import { BankAccount } from '~/models/Core/BankAccount'
  409. import { repositoryHelper } from '~/services/store/repository'
  410. import {useValidator} from "~/composables/form/useValidator";
  411. import {useNavigationHelpers} from '~/composables/form/useNavigationHelpers'
  412. import I18N from '~/services/utils/i18n'
  413. import {Country} from "~/models/Core/Country";
  414. import {useTypeOfPracticeProvider} from "~/composables/data/useTypeOfPracticeProvider";
  415. import ModelsUtils from "~/services/utils/modelsUtils";
  416. import {NetworkOrganization} from "~/models/Network/NetworkOrganization";
  417. import {OrganizationArticle} from "~/models/Organization/OrganizationArticle";
  418. export default defineComponent({
  419. name: 'OrganizationParent',
  420. setup () {
  421. const { store, app: { i18n }, $dataProvider, route } = useContext()
  422. const {typeOfPractices, fetchState:typeOfPracticesFetchingState} = useTypeOfPracticeProvider($dataProvider)
  423. const { panel } = useNavigationHelpers(route)
  424. const { siretError, siretErrorMessage, checkSiret } = useValidator($dataProvider, i18n).useHandleSiret()
  425. const organizationProfile = reactive($organizationProfile(store))
  426. const id: number = store.state.profile.organization.id
  427. const checkSiretHook = async (siret: string, field: string, updateRepository: any) => {
  428. await checkSiret(siret)
  429. if (!siretError.value) { updateRepository(siret, field) }
  430. }
  431. const formatPhoneNumber = (number: string): string => {
  432. return I18N.formatPhoneNumber(number)
  433. }
  434. const getIdsFromUris = (uris: Array<string>) => {
  435. const ids:Array<any> = []
  436. for(const uri of uris){
  437. ids.push(ModelsUtils.extractIdFromUri(uri))
  438. }
  439. return ids
  440. }
  441. const getIdFromUri = (uri: string) => ModelsUtils.extractIdFromUri(uri)
  442. return {
  443. repositories: () => getRepositories(),
  444. id,
  445. organizationProfile,
  446. models: () => { return { Organization, ContactPoint, BankAccount, OrganizationAddressPostal, Country, NetworkOrganization, OrganizationArticle } },
  447. rules: () => getRules(i18n, organizationProfile),
  448. siretError,
  449. siretErrorMessage,
  450. checkSiretHook,
  451. formatPhoneNumber,
  452. typeOfPractices,
  453. typeOfPracticesFetchingState,
  454. panel,
  455. getIdFromUri,
  456. getIdsFromUris
  457. }
  458. }
  459. })
  460. function getRules (i18n: any, $organizationProfile:any) {
  461. return {
  462. nameRules: [
  463. (nameValue: string) => !!nameValue || i18n.t('required'),
  464. (nameValue: string) => (nameValue || '').length <= 128 || i18n.t('name_length_rule')
  465. ],
  466. siretRule: [
  467. (siretValue: string) => /^([0-9]{9}|[0-9]{14})$/.test(siretValue) || i18n.t('siret_error')
  468. ],
  469. typeOfPractice: [
  470. (typeOfPracticeValue: Array<number>) => {
  471. if(!$organizationProfile.isManagerProduct())
  472. return typeOfPracticeValue.length > 0 || i18n.t('required')
  473. return true
  474. }
  475. ]
  476. }
  477. }
  478. function getRepositories () {
  479. return {
  480. organizationRepository: repositoryHelper.getRepository(Organization),
  481. contactPointRepository: repositoryHelper.getRepository(ContactPoint),
  482. bankAccountRepository: repositoryHelper.getRepository(BankAccount),
  483. addressRepository: repositoryHelper.getRepository(OrganizationAddressPostal),
  484. countryRepository: repositoryHelper.getRepository(Country),
  485. netWorkOrganizationRepository: repositoryHelper.getRepository(NetworkOrganization),
  486. organizationArticleRepository: repositoryHelper.getRepository(OrganizationArticle),
  487. }
  488. }
  489. </script>
  490. <style scoped>
  491. .v-icon.v-icon {
  492. font-size: 14px;
  493. }
  494. </style>