Skip to content
Snippets Groups Projects
Commit 811a2d94 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Merge branch 'v0.0.11' into 'master'

Système de notification des observateurs (en cours)

See merge request !7
parents 60c8b142 3dd95f6e
No related branches found
No related tags found
1 merge request!7Système de notification des observateurs (en cours)
Pipeline #27929 passed
File mode changed from 100644 to 100755
...@@ -57,6 +57,8 @@ CREATE TABLE public.unicaen_signature_signature ( ...@@ -57,6 +57,8 @@ CREATE TABLE public.unicaen_signature_signature (
CONSTRAINT unicaen_signature_signature_pkey PRIMARY KEY (id) CONSTRAINT unicaen_signature_signature_pkey PRIMARY KEY (id)
); );
CREATE TABLE public.unicaen_signature_signatureflow ( CREATE TABLE public.unicaen_signature_signatureflow (
id int4 NOT NULL, id int4 NOT NULL,
"label" varchar(255) NULL DEFAULT NULL::character varying, "label" varchar(255) NULL DEFAULT NULL::character varying,
...@@ -117,6 +119,9 @@ CREATE TABLE public.unicaen_signature_signatureflowstep ( ...@@ -117,6 +119,9 @@ CREATE TABLE public.unicaen_signature_signatureflowstep (
allrecipientssign bool NOT NULL DEFAULT true, allrecipientssign bool NOT NULL DEFAULT true,
notificationsrecipients bool NOT NULL DEFAULT false, notificationsrecipients bool NOT NULL DEFAULT false,
editablerecipients bool NOT NULL DEFAULT false, editablerecipients bool NOT NULL DEFAULT false,
observers_options TEXT DEFAULT NULL,
observersMethod VARCHAR(64) DEFAULT NULL,
CONSTRAINT unicaen_signature_signatureflowstep_pkey PRIMARY KEY (id), CONSTRAINT unicaen_signature_signatureflowstep_pkey PRIMARY KEY (id),
CONSTRAINT fk_a575dc3eb4090c8a FOREIGN KEY (signatureflow_id) REFERENCES unicaen_signature_signatureflow(id) CONSTRAINT fk_a575dc3eb4090c8a FOREIGN KEY (signatureflow_id) REFERENCES unicaen_signature_signatureflow(id)
); );
......
import{a as v,r as C,c as i,b as e,d,t as a,e as f,w as c,v as m,f as w,F as p,g,h as b,o as s,i as N,j as O}from"../vendor.js";import{_ as E,R as x}from"../vendor2.js";const D={components:{Recipients:x},props:{entrypoint:{required:!0,type:String}},data(){return{signatureflows:[],letterfiles:[],get_recipients_methods:null,editStep:null,editedStep:null,editSignatureFlow:null,editedSignatureFlow:null,error:""}},methods:{handlerRecipientsChange(n){console.log("handlerRecipientsChange",n)},handlerUp(n){console.log("handlerUp"),this.moveStep(n,-1)},handlerDown(n){console.log("handlerDown"),this.moveStep(n,1)},moveStep(n,t){let u=this.editSignatureFlow.steps.indexOf(n);if(u==this.editSignatureFlow.steps.length&&t==1||u==0&&t==-1)return;let _=this.editSignatureFlow.steps[u];this.editSignatureFlow.steps.splice(u,1),this.editSignatureFlow.steps.splice(u+t,0,_),this.updateOrder()},updateOrder(){console.log("Update order");let n=1;this.editSignatureFlow.steps.forEach(t=>{t.order=n++})},handlerEditSignatureFlow(n){this.editedSignatureFlow=n,this.editSignatureFlow=JSON.parse(JSON.stringify(n))},handlerDeleteSignatureFlow(n){this.remoteDelete(n)},handlerEditSignatureFlowCancel(){this.editedStep=null,this.editStep=null,this.editSignatureFlow=null,this.editedSignatureFlow=null},handlerEditSignatureFlowSave(){if(this.editedSignatureFlow){let n=this.signatureflows.indexOf(this.editSignatureFlow);this.signatureflows[n]=JSON.parse(JSON.stringify(this.editSignatureFlow))}else this.signatureflows.push(JSON.parse(JSON.stringify(this.editSignatureFlow)));this.remoteSave(this.editSignatureFlow),this.editSignatureFlow=null},handlerNewSignatureFlow(){this.editSignatureFlow={id:null,label:"Nouvelle procédure",description:"",letterfile:"",level:"",steps:[],options:null}},handlerNewStep(){let n=this.editSignatureFlow.steps.length+1;this.editSignatureFlow.steps.push({id:null,label:"Nouvelle étape",order:n,letterfile:null,level:null,allValid:!1,getReceipedMethd:"todo"})},handlerEditStepCancel(){this.editStep=null,this.editedStep=null},handlerEditStepSave(){let n=this.editSignatureFlow.steps.indexOf(this.editedStep);this.editSignatureFlow.steps[n]=JSON.parse(JSON.stringify(this.editStep)),this.editStep=null,this.editedStep=null},handlerEditStep(n){this.editStep=JSON.parse(JSON.stringify(n)),this.editedStep=n;let t=this.getStepOptions(n);console.log("options",t)},handlerDeleteStep(n){let t=this.editSignatureFlow.steps.indexOf(n);this.editSignatureFlow.steps.splice(t,1),this.updateOrder()},getLevels(n){for(let t=0;t<this.letterfiles.length;t++)if(this.letterfiles[t].name==n)return this.letterfiles[t].levels;return[]},getLevelsLabel(n){if(n.level)if(n.letterfile){let _=this.getLevels(n.letterfile);for(let o=0;o<_.length;o++)if(_[o].key==n.level)return _[o].label;return"inconnue"}else return"Pas de parapheur";else return"Non configuré"},handlerChangeMethod(n){let t=this.getMethodOptions(this.editStep.method);(!this.editStep.options||Array.isArray(this.editStep.options))&&(this.editStep.options={}),t.forEach(u=>{this.editStep.options.hasOwnProperty(u.key)||(this.editStep.options[u.key]=[])})},getMethod(n){for(let t=0;t<this.get_recipients_methods.length;t++)if(this.get_recipients_methods[t].key==n)return this.get_recipients_methods[t];return null},getMethodLabel(n){let t=this.getMethod(n);return t?t.label:"N.D"},getMethodOptions(n){let t=this.getMethod(n);return t?t.options:null},getMethodOptionsDefaultValue(n){return this.getMethod(n)?[]:null},getStepOptions(n){let t=this.getMethod(n.method);return t?t.options:null},stepHasOptions(n){return this.getStepOptions(n)!=null},getLetterfile(n){for(let t=0;t<this.letterfiles.length;t++)if(this.letterfiles[t].name==n)return this.letterfiles[t];return null},getLetterfileLabel(n){let t=this.getLetterfile(n);return t?t.label:"N.D"},fetch(){this.loading="Chargement des processus",v.get(this.entrypoint).then(n=>{this.signatureflows=n.data.signatureflows,this.letterfiles=n.data.letterfiles,this.get_recipients_methods=n.data.get_recipients_methods,this.loading=""},n=>{this.error=""})},remoteDelete(n){this.loading="Suppression";let t=new FormData;t.append("action","delete"),t.append("json",JSON.stringify(n)),v.post(this.entrypoint,t).then(u=>{this.loading="",this.fetch()},u=>{this.loading="";try{this.error=u.response.data.error}catch{this.error="Une erreur inconnue est survenue côté serveur"}})},remoteSave(n){this.loading="Enregistement";let t=new FormData;t.append("action","save"),t.append("json",JSON.stringify(n)),v.post(this.entrypoint,t).then(u=>{this.loading="",this.fetch()},u=>{console.log(u),this.loading="",u.response.data.error?this.error=u.response.data.error:this.error="Une erreur inconnue est survenue côté serveur"})}},mounted(){this.fetch()}},M={class:"signatureflows"},L={key:0,class:"overlay error"},U={class:"overlay-content"},V=e("hr",null,null,-1),R={key:1,class:"overlay"},J={class:"overlay-content"},A=e("i",{class:"icon-spinner animate-spin"},null,-1),P={class:"row"},T={class:"col-md-12"},I={key:0,class:"step-edit"},j=e("label",{for:"letterfile"},"Parapheur",-1),B=["value"],q=e("label",{for:"level"},"Type de validation",-1),H=["value"],K={for:"notifications"},z=e("br",null,null,-1),G={for:"allSign"},Q={for:"editable"},W={class:"row"},X={class:"col-md-6"},Y=e("h4",null,"Destinataires",-1),Z=e("label",{for:"method"},"Méthode d'obtention des destinataires",-1),$=["value"],ee={key:0,class:"options"},te=e("h3",null,"Paramètres de récupération des destinataires",-1),le={key:0},ne=["for"],ie=["onUpdate:modelValue","value","id"],se={key:1},oe=e("div",{class:"col-md-6"},[e("h4",null,"Observateurs"),e("div",{class:"alert alert-info"}," A venir ")],-1),re={key:1,class:"signatureflows-edit"},de=e("h2",null,"Edition de la procédure",-1),ae=e("label",{for:"label"}," Intitulé ",-1),ue=e("label",{for:"description"}," Description ",-1),he={class:""},ce=e("h3",null,"étapes",-1),pe={class:"steps"},ge={class:"step"},_e=e("i",{class:"icon-location"},null,-1),Se=e("br",null,null,-1),fe=e("br",null,null,-1),be=e("br",null,null,-1),ve={key:0},me={key:1},we=e("br",null,null,-1),ye={key:2},ke={key:3},Fe=e("br",null,null,-1),Ce={key:4},Ne={key:5},Oe={class:"buttons-bar"},Ee=["onClick"],xe=["onClick"],De=["onClick"],Me=["onClick"],Le={class:"buttons-bar"},Ue=e("i",{class:"icon-location"},null,-1),Ve={class:"buttons-bar"},Re={key:2},Je={class:"signatureflow"},Ae={key:0,class:"steps"},Pe={class:"step"},Te={key:0},Ie=e("i",{class:"icon-users"},null,-1),je={key:1},Be=e("i",{class:"icon-user-1"},null,-1),qe={key:0},He={key:1},Ke={key:2},ze={key:3},Ge={key:4},Qe={class:"recipient"},We=e("i",{class:"icon-mail-alt"},null,-1),Xe={key:1,class:"alert alert-info"},Ye={class:"buttons-bar"},Ze=["onClick"],$e=["onClick"],et=e("hr",null,null,-1);function tt(n,t,u,_,o,r){const k=C("recipients");return s(),i("section",M,[o.error?(s(),i("div",L,[e("div",U,[d(a(o.error)+" ",1),V,e("a",{href:"#",class:"btn btn-default",onClick:t[0]||(t[0]=l=>o.error="")},"Fermer")])])):f("",!0),n.loading?(s(),i("div",R,[e("div",J,[A,d(" "+a(n.loading),1)])])):f("",!0),e("section",P,[e("div",T,[o.editStep?(s(),i("article",I,[e("h3",null,[d(" Modification de l'étape "),e("strong",null,a(o.editStep.label),1)]),c(e("input",{type:"text","onUpdate:modelValue":t[1]||(t[1]=l=>o.editStep.label=l),class:"form-control"},null,512),[[m,o.editStep.label]]),j,c(e("select",{"onUpdate:modelValue":t[2]||(t[2]=l=>o.editStep.letterfile=l),id:"letterfile",class:"form-control"},[(s(!0),i(p,null,g(o.letterfiles,l=>(s(),i("option",{value:l.name},a(l.label),9,B))),256))],512),[[w,o.editStep.letterfile]]),q,o.editStep.letterfile?c((s(),i("select",{key:0,"onUpdate:modelValue":t[3]||(t[3]=l=>o.editStep.level=l),id:"level",class:"form-control"},[(s(!0),i(p,null,g(r.getLevels(o.editStep.letterfile),l=>(s(),i("option",{value:l.key},a(l.label),9,H))),256))],512)),[[w,o.editStep.level]]):f("",!0),e("label",K,[c(e("input",{type:"checkbox","onUpdate:modelValue":t[4]||(t[4]=l=>o.editStep.notificationsRecipients=l),id:"notifications"},null,512),[[b,o.editStep.notificationsRecipients]]),d(" Notifications des destinataires ? ")]),z,e("label",G,[c(e("input",{type:"checkbox","onUpdate:modelValue":t[5]||(t[5]=l=>o.editStep.allRecipientsSign=l),id:"allSign"},null,512),[[b,o.editStep.allRecipientsSign]]),d(" Tous les destinataires doivent signer ? ")]),e("label",Q,[c(e("input",{type:"checkbox","onUpdate:modelValue":t[6]||(t[6]=l=>o.editStep.editable=l),id:"editable"},null,512),[[b,o.editStep.editable]]),d(" Autoriser la modification des destinataires ")]),e("div",W,[e("div",X,[Y,Z,c(e("select",{"onUpdate:modelValue":t[7]||(t[7]=l=>o.editStep.method=l),id:"method",class:"form-control",onChange:t[8]||(t[8]=(...l)=>r.handlerChangeMethod&&r.handlerChangeMethod(...l))},[(s(!0),i(p,null,g(o.get_recipients_methods,l=>(s(),i("option",{value:l.key},a(l.label),9,$))),256))],544),[[w,o.editStep.method]]),r.stepHasOptions(o.editStep)?(s(),i("section",ee,[te,(s(!0),i(p,null,g(r.getStepOptions(o.editStep),l=>(s(),i("section",null,[e("h4",null,a(l.label),1),e("p",null,a(l.description),1),l.type=="checkbox"?(s(),i("section",le,[(s(!0),i(p,null,g(l.values,(h,S)=>(s(),i("label",{for:l.key+"_"+S,class:"form-control"},[c(e("input",{"onUpdate:modelValue":F=>o.editStep.options[l.key]=F,type:"checkbox",value:S,id:l.key+"_"+S},null,8,ie),[[b,o.editStep.options[l.key]]]),d(" "+a(h),1)],8,ne))),256))])):f("",!0),l.type=="recipients"?(s(),i("section",se,[N(k,{recipients:o.editStep.options[l.key],editable:!0,onChange:r.handlerRecipientsChange},null,8,["recipients","onChange"])])):f("",!0)]))),256))])):f("",!0)]),oe]),e("nav",null,[e("button",{onClick:t[9]||(t[9]=(...l)=>r.handlerEditStepSave&&r.handlerEditStepSave(...l)),class:"btn btn-success"},"Terminer"),e("button",{onClick:t[10]||(t[10]=(...l)=>r.handlerEditStepCancel&&r.handlerEditStepCancel(...l)),class:"btn btn-danger"},"Annuler")])])):o.editSignatureFlow?(s(),i("article",re,[de,e("div",null,[ae,c(e("input",{"onUpdate:modelValue":t[11]||(t[11]=l=>o.editSignatureFlow.label=l),id:"label",type:"text",name:"label",placeholder:"Intitulé",class:"form-control input-lg"},null,512),[[m,o.editSignatureFlow.label]])]),e("div",null,[ue,c(e("textarea",{"onUpdate:modelValue":t[12]||(t[12]=l=>o.editSignatureFlow.description=l),id:"description",type:"text",name:"description",placeholder:"Une description",class:"form-control input-lg"},null,512),[[m,o.editSignatureFlow.description]])]),e("section",he,[e("section",null,[ce,e("section",pe,[(s(!0),i(p,null,g(o.editSignatureFlow.steps,l=>(s(),i("article",ge,[e("h4",null,[_e,d(" Etape "+a(l.order)+" - "+a(l.label),1)]),e("div",null,[d(" Niveau de validation : "),e("strong",null,a(r.getLevelsLabel(l)),1),Se,d(" Parapheur : "),e("strong",null,a(r.getLetterfileLabel(l.letterfile)),1),fe,d(" Destinataires : "),e("strong",null,a(r.getMethodLabel(l.method)),1),be,d(" Tous signent ? : "),l.allRecipientsSign?(s(),i("strong",ve,"Oui")):(s(),i("strong",me,"Non")),we,d(" Notifications : "),l.notificationsRecipients?(s(),i("strong",ye,"Oui")):(s(),i("strong",ke,"Non")),Fe,d(" Destinataires modifiables : "),l.editable?(s(),i("strong",Ce,"Oui")):(s(),i("strong",Ne,"Non"))]),e("nav",Oe,[e("button",{class:"btn btn-default btn-xs",onClick:h=>r.handlerEditStep(l)},"Modifier",8,Ee),e("button",{class:"btn btn-default btn-xs",onClick:h=>r.handlerDeleteStep(l)},"Supprimer",8,xe),e("button",{onClick:h=>r.handlerUp(l)},"up",8,De),e("button",{onClick:h=>r.handlerDown(l)},"down",8,Me)])]))),256)),e("nav",Le,[e("button",{onClick:t[13]||(t[13]=(...l)=>r.handlerNewStep&&r.handlerNewStep(...l)),class:"btn btn-default"},[Ue,d(" Nouvelle étape ")])])]),e("nav",Ve,[e("button",{onClick:t[14]||(t[14]=(...l)=>r.handlerEditSignatureFlowSave&&r.handlerEditSignatureFlowSave(...l)),class:"btn btn-large btn-success"}," Enregistrer la procédure "),e("button",{onClick:t[15]||(t[15]=(...l)=>r.handlerEditSignatureFlowCancel&&r.handlerEditSignatureFlowCancel(...l)),class:"btn btn-danger"}," Annuler les modifications ")])])])])):(s(),i("section",Re,[(s(!0),i(p,null,g(o.signatureflows,l=>(s(),i("article",Je,[e("h3",null,[d("Procédure : "),e("strong",null,a(l.label),1),d(),e("small",null," (ID: "+a(l.id)+")",1)]),e("p",null,[e("small",null,a(l.description),1)]),l.steps.length?(s(),i("section",Ae,[(s(!0),i(p,null,g(l.steps,h=>(s(),i("article",Pe,[e("h4",null,[d(" Etape "+a(h.order)+" - ",1),e("strong",null,a(h.label),1),h.allRecipientsSign?(s(),i("span",Te,[d(" ("),Ie,d(" Tous les destinataires doivent signer) ")])):(s(),i("span",je,[d(" ("),Be,d(" Un des destinataires doit signer) ")]))]),e("small",null,[d(" Parapheur : "),e("strong",null,a(r.getLetterfileLabel(h.letterfile)),1),d(" - Niveau de validation : "),e("strong",null,a(r.getLevelsLabel(h)),1),d(" - Destinataires : "),e("strong",null,a(r.getMethodLabel(h.method)),1),d(" - Notifications : "),h.notificationsRecipients?(s(),i("strong",qe,"OUI")):(s(),i("strong",He,"non")),d(" - Editable : "),h.editable?(s(),i("strong",Ke,"OUI")):(s(),i("strong",ze,"non")),h.method=="recipients_fixed"?(s(),i("div",Ge,[(s(!0),i(p,null,g(h.options.recipients,S=>(s(),i("span",Qe,[e("strong",null,a(S.firstname)+" "+a(S.lastname),1),e("em",null,[We,d(" "+a(S.email),1)])]))),256))])):f("",!0)])]))),256))])):(s(),i("section",Xe," Aucune étape configurée ")),e("nav",Ye,[e("button",{class:"btn btn-xs",onClick:h=>r.handlerEditSignatureFlow(l)},"Modifier la procédure",8,Ze),e("button",{class:"btn btn-xs",onClick:h=>r.handlerDeleteSignatureFlow(l)},"Supprimer la procédure",8,$e)])]))),256)),e("nav",null,[e("button",{class:"btn btn-success",onClick:t[16]||(t[16]=(...l)=>r.handlerNewSignatureFlow&&r.handlerNewSignatureFlow(...l))}," Nouvelle procédure ")])])),et])])])}const lt=E(D,[["render",tt]]);let y="#signatureflows",nt=document.querySelector(y);const it=O(lt,{entrypoint:nt.dataset.entrypoint});it.mount(y);
import{a as y,r as C,c as s,b as t,d as a,t as d,e as S,w as p,v as w,f as v,F as c,g,h as f,o as i,i as F,j as N}from"../vendor.js";import{_ as M,R as x}from"../vendor2.js";const E={components:{Recipients:x},props:{entrypoint:{required:!0,type:String}},data(){return{signatureflows:[],letterfiles:[],get_recipients_methods:null,editStep:null,editedStep:null,editSignatureFlow:null,editedSignatureFlow:null,error:""}},methods:{handlerRecipientsChange(n){console.log("handlerRecipientsChange",n)},handlerUp(n){console.log("handlerUp"),this.moveStep(n,-1)},handlerDown(n){console.log("handlerDown"),this.moveStep(n,1)},moveStep(n,e){let u=this.editSignatureFlow.steps.indexOf(n);if(u==this.editSignatureFlow.steps.length&&e==1||u==0&&e==-1)return;let b=this.editSignatureFlow.steps[u];this.editSignatureFlow.steps.splice(u,1),this.editSignatureFlow.steps.splice(u+e,0,b),this.updateOrder()},updateOrder(){console.log("Update order");let n=1;this.editSignatureFlow.steps.forEach(e=>{e.order=n++})},handlerEditSignatureFlow(n){this.editedSignatureFlow=n,this.editSignatureFlow=JSON.parse(JSON.stringify(n))},handlerDeleteSignatureFlow(n){this.remoteDelete(n)},handlerEditSignatureFlowCancel(){this.editedStep=null,this.editStep=null,this.editSignatureFlow=null,this.editedSignatureFlow=null},handlerEditSignatureFlowSave(){if(this.editedSignatureFlow){let n=this.signatureflows.indexOf(this.editSignatureFlow);this.signatureflows[n]=JSON.parse(JSON.stringify(this.editSignatureFlow))}else this.signatureflows.push(JSON.parse(JSON.stringify(this.editSignatureFlow)));this.remoteSave(this.editSignatureFlow),this.editSignatureFlow=null},handlerNewSignatureFlow(){this.editSignatureFlow={id:null,label:"Nouvelle procédure",description:"",letterfile:"",level:"",steps:[],options:null}},handlerNewStep(){let n=this.editSignatureFlow.steps.length+1;this.editSignatureFlow.steps.push({id:null,label:"Nouvelle étape",order:n,letterfile:null,level:null,allValid:!1,getReceipedMethod:"todo",method:null,options:null,observers_method:null,observers_options:null})},handlerEditStepCancel(){this.editStep=null,this.editedStep=null},handlerEditStepSave(){let n=this.editSignatureFlow.steps.indexOf(this.editedStep);this.editSignatureFlow.steps[n]=JSON.parse(JSON.stringify(this.editStep)),this.editStep=null,this.editedStep=null},handlerEditStep(n){this.editStep=JSON.parse(JSON.stringify(n)),this.editedStep=n},handlerDeleteStep(n){let e=this.editSignatureFlow.steps.indexOf(n);this.editSignatureFlow.steps.splice(e,1),this.updateOrder()},getLevels(n){for(let e=0;e<this.letterfiles.length;e++)if(this.letterfiles[e].name==n)return this.letterfiles[e].levels;return[]},getLevelsLabel(n){if(n.level)if(n.letterfile){let b=this.getLevels(n.letterfile);for(let o=0;o<b.length;o++)if(b[o].key==n.level)return b[o].label;return"inconnue"}else return"Pas de parapheur";else return"Non configuré"},handlerChangeMethod(n){let e=this.getMethodOptions(this.editStep.method);(!this.editStep.options||Array.isArray(this.editStep.options))&&(this.editStep.options={}),e.forEach(u=>{this.editStep.options.hasOwnProperty(u.key)||(this.editStep.options[u.key]=[])})},handlerChangeObserversMethod(n){let e=this.getMethodOptions(this.editStep.observers_method);(!this.editStep.observers_options||Array.isArray(this.editStep.observers_options))&&(this.editStep.observers_options={}),e.forEach(u=>{this.editStep.observers_options.hasOwnProperty(u.key)||(this.editStep.observers_options[u.key]=[])})},getMethod(n){for(let e=0;e<this.get_recipients_methods.length;e++)if(this.get_recipients_methods[e].key==n)return this.get_recipients_methods[e];return null},getMethodLabel(n){let e=this.getMethod(n);return e?e.label:"N.D"},getMethodOptions(n){let e=this.getMethod(n);return e?e.options:null},getMethodOptionsDefaultValue(n){return this.getMethod(n)?[]:null},stepHasObserversOptions(n){let e=this.getStepObserversOptions(n);return e!=null&&e.length>0},getStepObserversOptions(n){let e=this.getMethod(n.observers_method);return e?e.options:null},getStepOptions(n){let e=this.getMethod(n.method);return e?e.options:null},stepHasOptions(n){let e=this.getStepOptions(n);return e!=null&&e.length>0},getLetterfile(n){for(let e=0;e<this.letterfiles.length;e++)if(this.letterfiles[e].name==n)return this.letterfiles[e];return null},getLetterfileLabel(n){let e=this.getLetterfile(n);return e?e.label:"N.D"},fetch(){this.loading="Chargement des processus",y.get(this.entrypoint).then(n=>{this.signatureflows=n.data.signatureflows,this.letterfiles=n.data.letterfiles,this.get_recipients_methods=n.data.get_recipients_methods,this.loading=""},n=>{this.error=""})},remoteDelete(n){this.loading="Suppression";let e=new FormData;e.append("action","delete"),e.append("json",JSON.stringify(n)),y.post(this.entrypoint,e).then(u=>{this.loading="",this.fetch()},u=>{this.loading="";try{this.error=u.response.data.error}catch{this.error="Une erreur inconnue est survenue côté serveur"}})},remoteSave(n){this.loading="Enregistement";let e=new FormData;e.append("action","save"),e.append("json",JSON.stringify(n)),y.post(this.entrypoint,e).then(u=>{this.loading="",this.fetch()},u=>{console.log(u),this.loading="",u.response.data.error?this.error=u.response.data.error:this.error="Une erreur inconnue est survenue côté serveur"})}},mounted(){this.fetch()}},U={class:"signatureflows"},D={key:0,class:"overlay error"},L={class:"overlay-content"},V=t("hr",null,null,-1),R={key:1,class:"overlay"},J={class:"overlay-content"},A=t("i",{class:"icon-spinner animate-spin"},null,-1),P={class:"row"},T={class:"col-md-12"},I={key:0,class:"step-edit"},H=t("label",{for:"letterfile"},"Parapheur",-1),j=["value"],B=t("label",{for:"level"},"Type de validation",-1),q=["value"],K={for:"notifications"},z=t("br",null,null,-1),G={for:"allSign"},Q={for:"editable"},W={class:"row"},X={class:"col-md-6"},Y=t("h4",null,"Destinataires",-1),Z=t("label",{for:"method"},"Méthode d'obtention des destinataires",-1),$=["value"],ee={key:0,class:"options"},te=t("h3",null,"Paramètres de récupération des destinataires",-1),le={key:0},ne=["for"],se=["onUpdate:modelValue","value","id"],ie={key:1},oe={class:"col-md-6"},re=t("h4",null,"Observateurs",-1),de=t("label",{for:"method"},"Méthode d'obtention des observateurs",-1),ae=["value"],ue={key:0,class:"options"},he=t("h3",null,"Paramètres de récupération des personnes",-1),pe={key:0},ce=["for"],ge=["onUpdate:modelValue","value","id"],_e={key:1},Se={key:1,class:"signatureflows-edit"},be=t("h2",null,"Edition de la procédure",-1),fe=t("label",{for:"label"}," Intitulé ",-1),ve=t("label",{for:"description"}," Description ",-1),me={class:""},ye=t("h3",null,"étapes",-1),we={class:"steps"},ke={class:"step"},Fe=t("i",{class:"icon-location"},null,-1),Oe=t("br",null,null,-1),Ce=t("br",null,null,-1),Ne=t("br",null,null,-1),Me={key:0},xe={key:1},Ee=t("br",null,null,-1),Ue={key:2},De={key:3},Le=t("br",null,null,-1),Ve={key:4},Re={key:5},Je={class:"buttons-bar"},Ae=["onClick"],Pe=["onClick"],Te=["onClick"],Ie=["onClick"],He={class:"buttons-bar"},je=t("i",{class:"icon-location"},null,-1),Be={class:"buttons-bar"},qe={key:2},Ke={class:"signatureflow"},ze={key:0,class:"steps"},Ge={class:"step"},Qe={key:0},We=t("i",{class:"icon-users"},null,-1),Xe={key:1},Ye=t("i",{class:"icon-user-1"},null,-1),Ze={key:0},$e={key:1},et={key:2},tt={key:3},lt={key:4},nt={class:"recipient"},st=t("i",{class:"icon-mail-alt"},null,-1),it={key:1,class:"alert alert-info"},ot={class:"buttons-bar"},rt=["onClick"],dt=["onClick"],at=t("hr",null,null,-1);function ut(n,e,u,b,o,r){const k=C("recipients");return i(),s("section",U,[o.error?(i(),s("div",D,[t("div",L,[a(d(o.error)+" ",1),V,t("a",{href:"#",class:"btn btn-default",onClick:e[0]||(e[0]=l=>o.error="")},"Fermer")])])):S("",!0),n.loading?(i(),s("div",R,[t("div",J,[A,a(" "+d(n.loading),1)])])):S("",!0),t("section",P,[t("div",T,[o.editStep?(i(),s("article",I,[t("h3",null,[a(" Modification de l'étape "),t("strong",null,d(o.editStep.label),1)]),p(t("input",{type:"text","onUpdate:modelValue":e[1]||(e[1]=l=>o.editStep.label=l),class:"form-control"},null,512),[[w,o.editStep.label]]),H,p(t("select",{"onUpdate:modelValue":e[2]||(e[2]=l=>o.editStep.letterfile=l),id:"letterfile",class:"form-control"},[(i(!0),s(c,null,g(o.letterfiles,l=>(i(),s("option",{value:l.name},d(l.label),9,j))),256))],512),[[v,o.editStep.letterfile]]),B,o.editStep.letterfile?p((i(),s("select",{key:0,"onUpdate:modelValue":e[3]||(e[3]=l=>o.editStep.level=l),id:"level",class:"form-control"},[(i(!0),s(c,null,g(r.getLevels(o.editStep.letterfile),l=>(i(),s("option",{value:l.key},d(l.label),9,q))),256))],512)),[[v,o.editStep.level]]):S("",!0),t("label",K,[p(t("input",{type:"checkbox","onUpdate:modelValue":e[4]||(e[4]=l=>o.editStep.notificationsRecipients=l),id:"notifications"},null,512),[[f,o.editStep.notificationsRecipients]]),a(" Notifications des destinataires ? ")]),z,t("label",G,[p(t("input",{type:"checkbox","onUpdate:modelValue":e[5]||(e[5]=l=>o.editStep.allRecipientsSign=l),id:"allSign"},null,512),[[f,o.editStep.allRecipientsSign]]),a(" Tous les destinataires doivent signer ? ")]),t("label",Q,[p(t("input",{type:"checkbox","onUpdate:modelValue":e[6]||(e[6]=l=>o.editStep.editable=l),id:"editable"},null,512),[[f,o.editStep.editable]]),a(" Autoriser la modification des destinataires ")]),t("div",W,[t("div",X,[Y,Z,p(t("select",{"onUpdate:modelValue":e[7]||(e[7]=l=>o.editStep.method=l),id:"method",class:"form-control",onChange:e[8]||(e[8]=(...l)=>r.handlerChangeMethod&&r.handlerChangeMethod(...l))},[(i(!0),s(c,null,g(o.get_recipients_methods,l=>(i(),s("option",{value:l.key},d(l.label),9,$))),256))],544),[[v,o.editStep.method]]),r.stepHasOptions(o.editStep)?(i(),s("section",ee,[te,(i(!0),s(c,null,g(r.getStepOptions(o.editStep),l=>(i(),s("section",null,[t("h4",null,d(l.label),1),t("p",null,d(l.description),1),l.type=="checkbox"?(i(),s("section",le,[(i(!0),s(c,null,g(l.values,(h,_)=>(i(),s("label",{for:l.key+"_"+_,class:"form-control"},[p(t("input",{"onUpdate:modelValue":m=>o.editStep.options[l.key]=m,type:"checkbox",value:_,id:l.key+"_"+_},null,8,se),[[f,o.editStep.options[l.key]]]),a(" "+d(h),1)],8,ne))),256))])):S("",!0),l.type=="recipients"?(i(),s("section",ie,[F(k,{recipients:o.editStep.options[l.key],editable:!0,onChange:r.handlerRecipientsChange},null,8,["recipients","onChange"])])):S("",!0)]))),256))])):S("",!0)]),t("div",oe,[re,de,p(t("select",{"onUpdate:modelValue":e[9]||(e[9]=l=>o.editStep.observers_method=l),id:"method",class:"form-control",onChange:e[10]||(e[10]=(...l)=>r.handlerChangeObserversMethod&&r.handlerChangeObserversMethod(...l))},[(i(!0),s(c,null,g(o.get_recipients_methods,l=>(i(),s("option",{value:l.key},d(l.label),9,ae))),256))],544),[[v,o.editStep.observers_method]]),r.stepHasObserversOptions(o.editStep)?(i(),s("section",ue,[he,(i(!0),s(c,null,g(r.getStepObserversOptions(o.editStep),l=>(i(),s("section",null,[t("h4",null,d(l.label),1),t("p",null,d(l.description),1),l.type=="checkbox"?(i(),s("section",pe,[(i(!0),s(c,null,g(l.values,(h,_)=>(i(),s("label",{for:l.key+"_obs_"+_,class:"form-control"},[p(t("input",{"onUpdate:modelValue":m=>o.editStep.observers_options[l.key]=m,type:"checkbox",value:_,id:l.key+"_obs_"+_},null,8,ge),[[f,o.editStep.observers_options[l.key]]]),a(" "+d(h),1)],8,ce))),256))])):S("",!0),l.type=="recipients"?(i(),s("section",_e,[F(k,{recipients:o.editStep.observers_options[l.key],editable:!0,onChange:r.handlerRecipientsChange},null,8,["recipients","onChange"])])):S("",!0)]))),256))])):S("",!0)])]),t("small",null,d(o.editStep),1),t("nav",null,[t("button",{onClick:e[11]||(e[11]=(...l)=>r.handlerEditStepSave&&r.handlerEditStepSave(...l)),class:"btn btn-success"},"Terminer"),t("button",{onClick:e[12]||(e[12]=(...l)=>r.handlerEditStepCancel&&r.handlerEditStepCancel(...l)),class:"btn btn-danger"},"Annuler")])])):o.editSignatureFlow?(i(),s("article",Se,[be,t("div",null,[fe,p(t("input",{"onUpdate:modelValue":e[13]||(e[13]=l=>o.editSignatureFlow.label=l),id:"label",type:"text",name:"label",placeholder:"Intitulé",class:"form-control input-lg"},null,512),[[w,o.editSignatureFlow.label]])]),t("div",null,[ve,p(t("textarea",{"onUpdate:modelValue":e[14]||(e[14]=l=>o.editSignatureFlow.description=l),id:"description",type:"text",name:"description",placeholder:"Une description",class:"form-control input-lg"},null,512),[[w,o.editSignatureFlow.description]])]),t("section",me,[t("section",null,[ye,t("section",we,[(i(!0),s(c,null,g(o.editSignatureFlow.steps,l=>(i(),s("article",ke,[t("h4",null,[Fe,a(" Etape "+d(l.order)+" - "+d(l.label),1)]),t("div",null,[a(" Niveau de validation : "),t("strong",null,d(r.getLevelsLabel(l)),1),Oe,a(" Parapheur : "),t("strong",null,d(r.getLetterfileLabel(l.letterfile)),1),Ce,a(" Destinataires : "),t("strong",null,d(r.getMethodLabel(l.method)),1),Ne,a(" Tous signent ? : "),l.allRecipientsSign?(i(),s("strong",Me,"Oui")):(i(),s("strong",xe,"Non")),Ee,a(" Notifications : "),l.notificationsRecipients?(i(),s("strong",Ue,"Oui")):(i(),s("strong",De,"Non")),Le,a(" Destinataires modifiables : "),l.editable?(i(),s("strong",Ve,"Oui")):(i(),s("strong",Re,"Non"))]),t("nav",Je,[t("button",{class:"btn btn-default btn-xs",onClick:h=>r.handlerEditStep(l)},"Modifier",8,Ae),t("button",{class:"btn btn-default btn-xs",onClick:h=>r.handlerDeleteStep(l)},"Supprimer",8,Pe),t("button",{onClick:h=>r.handlerUp(l)},"up",8,Te),t("button",{onClick:h=>r.handlerDown(l)},"down",8,Ie)])]))),256)),t("nav",He,[t("button",{onClick:e[15]||(e[15]=(...l)=>r.handlerNewStep&&r.handlerNewStep(...l)),class:"btn btn-default"},[je,a(" Nouvelle étape ")])])]),t("nav",Be,[t("button",{onClick:e[16]||(e[16]=(...l)=>r.handlerEditSignatureFlowSave&&r.handlerEditSignatureFlowSave(...l)),class:"btn btn-large btn-success"}," Enregistrer la procédure "),t("button",{onClick:e[17]||(e[17]=(...l)=>r.handlerEditSignatureFlowCancel&&r.handlerEditSignatureFlowCancel(...l)),class:"btn btn-danger"}," Annuler les modifications ")])])])])):(i(),s("section",qe,[(i(!0),s(c,null,g(o.signatureflows,l=>(i(),s("article",Ke,[t("h3",null,[a("Procédure : "),t("strong",null,d(l.label),1),a(),t("small",null," (ID: "+d(l.id)+")",1)]),t("p",null,[t("small",null,d(l.description),1)]),l.steps.length?(i(),s("section",ze,[(i(!0),s(c,null,g(l.steps,h=>(i(),s("article",Ge,[t("h4",null,[a(" Etape "+d(h.order)+" - ",1),t("strong",null,d(h.label),1),h.allRecipientsSign?(i(),s("span",Qe,[a(" ("),We,a(" Tous les destinataires doivent signer) ")])):(i(),s("span",Xe,[a(" ("),Ye,a(" Un des destinataires doit signer) ")]))]),t("small",null,[a(" Parapheur : "),t("strong",null,d(r.getLetterfileLabel(h.letterfile)),1),a(" - Niveau de validation : "),t("strong",null,d(r.getLevelsLabel(h)),1),a(" - Destinataires : "),t("strong",null,d(r.getMethodLabel(h.method)),1),a(" - Notifications : "),h.notificationsRecipients?(i(),s("strong",Ze,"OUI")):(i(),s("strong",$e,"non")),a(" - Editable : "),h.editable?(i(),s("strong",et,"OUI")):(i(),s("strong",tt,"non")),h.method=="recipients_fixed"?(i(),s("div",lt,[(i(!0),s(c,null,g(h.options.recipients,_=>(i(),s("span",nt,[t("strong",null,d(_.firstname)+" "+d(_.lastname),1),t("em",null,[st,a(" "+d(_.email),1)])]))),256))])):S("",!0)])]))),256))])):(i(),s("section",it," Aucune étape configurée ")),t("nav",ot,[t("button",{class:"btn btn-xs",onClick:h=>r.handlerEditSignatureFlow(l)},"Modifier la procédure",8,rt),t("button",{class:"btn btn-xs",onClick:h=>r.handlerDeleteSignatureFlow(l)},"Supprimer la procédure",8,dt)])]))),256)),t("nav",null,[t("button",{class:"btn btn-success",onClick:e[18]||(e[18]=(...l)=>r.handlerNewSignatureFlow&&r.handlerNewSignatureFlow(...l))}," Nouvelle procédure ")])])),at])])])}const ht=M(E,[["render",ut]]);let O="#signatureflows",pt=document.querySelector(O);const ct=N(ht,{entrypoint:pt.dataset.entrypoint});ct.mount(O);
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
"css": [ "css": [
"assets/SignatureFlows-8341230d.css" "assets/SignatureFlows-8341230d.css"
], ],
"file": "assets/signatureflows-7c5d56b8.js", "file": "assets/signatureflows-9eb993f8.js",
"imports": [ "imports": [
"_vendor.js", "_vendor.js",
"_vendor2.js" "_vendor2.js"
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
<select v-model="editStep.method" id="method" class="form-control" @change="handlerChangeMethod"> <select v-model="editStep.method" id="method" class="form-control" @change="handlerChangeMethod">
<option v-for="l in get_recipients_methods" :value="l.key">{{ l.label }}</option> <option v-for="l in get_recipients_methods" :value="l.key">{{ l.label }}</option>
</select> </select>
<section class="options" v-if="stepHasOptions(editStep)"> <section class="options" v-if="stepHasOptions(editStep)">
<h3>Paramètres de récupération des destinataires</h3> <h3>Paramètres de récupération des destinataires</h3>
<section v-for="o in getStepOptions(editStep)"> <section v-for="o in getStepOptions(editStep)">
...@@ -82,13 +81,32 @@ ...@@ -82,13 +81,32 @@
<div class="col-md-6"> <div class="col-md-6">
<h4>Observateurs</h4> <h4>Observateurs</h4>
<div class="alert alert-info"> <label for="method">Méthode d'obtention des observateurs</label>
A venir <select v-model="editStep.observers_method" id="method" class="form-control" @change="handlerChangeObserversMethod">
</div> <option v-for="l in get_recipients_methods" :value="l.key">{{ l.label }}</option>
</select>
<section class="options" v-if="stepHasObserversOptions(editStep)">
<h3>Paramètres de récupération des personnes</h3>
<section v-for="o in getStepObserversOptions(editStep)">
<h4>{{ o.label }}</h4>
<p>{{ o.description }}</p>
<section v-if="o.type == 'checkbox'">
<label :for="o.key +'_obs_'+ id" v-for="v,id in o.values" class="form-control">
<input v-model="editStep.observers_options[o.key]" type="checkbox" :value="id" :id="o.key +'_obs_'+ id"/>
{{ v }}
</label>
</section>
<section v-if="o.type == 'recipients'">
<recipients :recipients="editStep.observers_options[o.key]" :editable="true" @change="handlerRecipientsChange"/>
</section>
</section>
</section>
</div> </div>
</div> </div>
<small>{{ editStep }}</small>
<nav> <nav>
<button @click="handlerEditStepSave" class="btn btn-success">Terminer</button> <button @click="handlerEditStepSave" class="btn btn-success">Terminer</button>
...@@ -335,7 +353,11 @@ export default { ...@@ -335,7 +353,11 @@ export default {
letterfile: null, letterfile: null,
level: null, level: null,
allValid: false, allValid: false,
getReceipedMethd: "todo" getReceipedMethod: "todo",
method: null,
options: null,
observers_method: null,
observers_options: null
}); });
}, },
handlerEditStepCancel() { handlerEditStepCancel() {
...@@ -351,9 +373,6 @@ export default { ...@@ -351,9 +373,6 @@ export default {
handlerEditStep(step) { handlerEditStep(step) {
this.editStep = JSON.parse(JSON.stringify(step)); this.editStep = JSON.parse(JSON.stringify(step));
this.editedStep = step; this.editedStep = step;
let options = this.getStepOptions(step);
console.log("options", options);
}, },
handlerDeleteStep(step) { handlerDeleteStep(step) {
let i = this.editSignatureFlow.steps.indexOf(step); let i = this.editSignatureFlow.steps.indexOf(step);
...@@ -405,6 +424,18 @@ export default { ...@@ -405,6 +424,18 @@ export default {
}); });
}, },
handlerChangeObserversMethod(evt) {
let methodConfig = this.getMethodOptions(this.editStep.observers_method);
if (!this.editStep.observers_options || Array.isArray(this.editStep.observers_options)) {
this.editStep.observers_options = {};
}
methodConfig.forEach(opt => {
if (!this.editStep.observers_options.hasOwnProperty(opt.key)) {
this.editStep.observers_options[opt.key] = [];
}
});
},
getMethod(methodKey) { getMethod(methodKey) {
for (let i = 0; i < this.get_recipients_methods.length; i++) { for (let i = 0; i < this.get_recipients_methods.length; i++) {
if (this.get_recipients_methods[i].key == methodKey) { if (this.get_recipients_methods[i].key == methodKey) {
...@@ -441,6 +472,20 @@ export default { ...@@ -441,6 +472,20 @@ export default {
} }
}, },
stepHasObserversOptions(step) {
let options = this.getStepObserversOptions(step);
return options != null && options.length > 0;
},
getStepObserversOptions(step) {
let method = this.getMethod(step.observers_method);
if (method) {
return method.options;
} else {
return null;
}
},
getStepOptions(step) { getStepOptions(step) {
let method = this.getMethod(step.method); let method = this.getMethod(step.method);
if (method) { if (method) {
...@@ -452,7 +497,7 @@ export default { ...@@ -452,7 +497,7 @@ export default {
stepHasOptions(step) { stepHasOptions(step) {
let options = this.getStepOptions(step); let options = this.getStepOptions(step);
return options != null; return options != null && options.length > 0;
}, },
getLetterfile(letterFileKey) { getLetterfile(letterFileKey) {
......
...@@ -149,6 +149,10 @@ class ProcessStep ...@@ -149,6 +149,10 @@ class ProcessStep
foreach ($this->getRecipients() as $recipient){ foreach ($this->getRecipients() as $recipient){
$recipients[] = $recipient->toArray(); $recipients[] = $recipient->toArray();
} }
$observers = [];
foreach ($this->getSignature()->getObservers() as $observer){
$observers[] = $observer->toArray();
}
return [ return [
'label' => $this->getLabel(), 'label' => $this->getLabel(),
'letterfile' => $this->getLetterfileName(), 'letterfile' => $this->getLetterfileName(),
...@@ -156,7 +160,8 @@ class ProcessStep ...@@ -156,7 +160,8 @@ class ProcessStep
'order' => $this->getOrder(), 'order' => $this->getOrder(),
'status' => $this->getStatus(), 'status' => $this->getStatus(),
'status_text' => $this->getStatusText(), 'status_text' => $this->getStatusText(),
'recipients' => $recipients 'recipients' => $recipients,
'observers' => $observers
]; ];
} }
......
...@@ -31,6 +31,7 @@ class Signature ...@@ -31,6 +31,7 @@ class Signature
public function __construct() public function __construct()
{ {
$this->recipients = new ArrayCollection(); $this->recipients = new ArrayCollection();
$this->observers = new ArrayCollection();
$this->document_path = ""; $this->document_path = "";
$this->status = self::STATUS_SIGNATURE_DRAFT; $this->status = self::STATUS_SIGNATURE_DRAFT;
$this->type = ""; $this->type = "";
...@@ -444,6 +445,33 @@ class Signature ...@@ -444,6 +445,33 @@ class Signature
return $this; return $this;
} }
/**
* @return SignatureObserver[]
*/
public function getObservers()
{
return $this->observers;
}
/**
* @param array $recipients
* @return Signature
*/
public function setObservers(array $observers): self
{
$this->observers = new ArrayCollection($observers);
return $this;
}
/**
* @return Signature
*/
public function addObserver(SignatureObserver $observer): self
{
$this->observers->add($observer);
return $this;
}
/** /**
* @return string * @return string
*/ */
......
...@@ -78,6 +78,18 @@ class SignatureFlowStep implements IObjectFormattable ...@@ -78,6 +78,18 @@ class SignatureFlowStep implements IObjectFormattable
*/ */
private ?string $options = null; private ?string $options = null;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
private ?string $observers_options = null;
/**
* @var string|null
* @ORM\Column(type="string", length=64, nullable=true)
*/
private ?string $observersMethod;
/** /**
* @return int * @return int
*/ */
...@@ -114,6 +126,52 @@ class SignatureFlowStep implements IObjectFormattable ...@@ -114,6 +126,52 @@ class SignatureFlowStep implements IObjectFormattable
return $this; return $this;
} }
/**
* @return array
*/
public function getObserversOptions(): array
{
if ($this->observers_options) {
return json_decode($this->observers_options, true);
}
else {
return [];
}
}
/**
* @param array|null $observers_options
* @return SignatureFlowStep
*/
public function setObserversOptions(?array $observers_options): self
{
if ($observers_options) {
$this->observers_options = json_encode($observers_options);
}
else {
$this->observers_options = "";
}
return $this;
}
/**
* @return string|null
*/
public function getObserversMethod(): ?string
{
return $this->observersMethod;
}
/**
* @param string|null $observersMethod
* @return SignatureFlowStep
*/
public function setObserversMethod(?string $observersMethod): self
{
$this->observersMethod = $observersMethod;
return $this;
}
/** /**
* @return bool * @return bool
*/ */
...@@ -275,7 +333,9 @@ class SignatureFlowStep implements IObjectFormattable ...@@ -275,7 +333,9 @@ class SignatureFlowStep implements IObjectFormattable
"notificationsRecipients" => $this->isNotificationsRecipients(), "notificationsRecipients" => $this->isNotificationsRecipients(),
"editable" => $this->isEditableRecipients(), "editable" => $this->isEditableRecipients(),
"method" => $this->getRecipientsMethod(), "method" => $this->getRecipientsMethod(),
"options" => $this->getOptions() "options" => $this->getOptions(),
"observers_method" => $this->getObserversMethod(),
"observers_options" => $this->getObserversOptions()
]; ];
} }
......
...@@ -8,6 +8,7 @@ use UnicaenSignature\Entity\Db\Process; ...@@ -8,6 +8,7 @@ use UnicaenSignature\Entity\Db\Process;
use UnicaenSignature\Entity\Db\ProcessStep; use UnicaenSignature\Entity\Db\ProcessStep;
use UnicaenSignature\Entity\Db\Signature; use UnicaenSignature\Entity\Db\Signature;
use UnicaenSignature\Entity\Db\SignatureFlow; use UnicaenSignature\Entity\Db\SignatureFlow;
use UnicaenSignature\Entity\Db\SignatureObserver;
use UnicaenSignature\Entity\Db\SignatureRecipient; use UnicaenSignature\Entity\Db\SignatureRecipient;
use UnicaenSignature\Entity\Repository\ProcessRepository; use UnicaenSignature\Entity\Repository\ProcessRepository;
use UnicaenSignature\Entity\Repository\SignatureFlowRepository; use UnicaenSignature\Entity\Repository\SignatureFlowRepository;
...@@ -213,6 +214,16 @@ class ProcessService ...@@ -213,6 +214,16 @@ class ProcessService
->setEmail($recipientData['email']); ->setEmail($recipientData['email']);
$signature->getRecipients()->add($signatureRecipient); $signature->getRecipients()->add($signatureRecipient);
} }
foreach ($stepData['observers'] as $observerData) {
$signatureObserver = new SignatureObserver();
$this->getObjectManager()->persist($signatureObserver);
$signatureObserver->setSignature($signature)
->setLastname($observerData['lastname'])
->setFirstname($observerData['firstname'])
->setEmail($observerData['email']);
$signature->getObservers()->add($signatureObserver);
}
} }
try { try {
$this->getObjectManager()->flush(); $this->getObjectManager()->flush();
......
...@@ -257,6 +257,7 @@ class SignatureService ...@@ -257,6 +257,7 @@ class SignatureService
foreach ($signatureFlow->getSteps() as $step) { foreach ($signatureFlow->getSteps() as $step) {
$letterfile = $letterfiles[$step->getLetterfileName()]; $letterfile = $letterfiles[$step->getLetterfileName()];
$levels = $letterfile['levels_infos']; $levels = $letterfile['levels_infos'];
$method = $this->getSignatureConfigurationService()->getMethodByKey($step->getRecipientsMethod()); $method = $this->getSignatureConfigurationService()->getMethodByKey($step->getRecipientsMethod());
$currentStep = []; $currentStep = [];
...@@ -274,9 +275,24 @@ class SignatureService ...@@ -274,9 +275,24 @@ class SignatureService
$currentStep['missing_recipients'] = false; $currentStep['missing_recipients'] = false;
$currentStep['dynamicRecipients'] = is_callable($method['getRecipients']); $currentStep['dynamicRecipients'] = is_callable($method['getRecipients']);
$currentStep['recipients'] = []; $currentStep['recipients'] = [];
$currentStep['observers'] = [];
$recipients = []; if ($step->getObserversMethod()) {
$methodObservers = $this->getSignatureConfigurationService()->getMethodByKey(
$step->getObserversMethod()
);
if (is_callable($methodObservers['getRecipients'])) {
$options = array_merge_recursive($extrasOptions, $step->getObserversOptions());
$observersDatas = $methodObservers['getRecipients']($this->getServiceContainer(), $options);
$observers = array_values($observersDatas);
}
else {
$observers = $step->getOptions()['observers'];
}
}
else {
$observers = [];
}
if (is_callable($method['getRecipients'])) { if (is_callable($method['getRecipients'])) {
$options = array_merge_recursive($extrasOptions, $step->getOptions()); $options = array_merge_recursive($extrasOptions, $step->getOptions());
$recipientsDatas = $method['getRecipients']($this->getServiceContainer(), $options); $recipientsDatas = $method['getRecipients']($this->getServiceContainer(), $options);
...@@ -290,9 +306,13 @@ class SignatureService ...@@ -290,9 +306,13 @@ class SignatureService
foreach ($recipients as &$recipient) { foreach ($recipients as &$recipient) {
$recipient['selected'] = true; $recipient['selected'] = true;
} }
foreach ($observers as &$observer) {
$observer['selected'] = true;
}
} }
$currentStep['recipients'] = $recipients; $currentStep['recipients'] = $recipients;
$currentStep['observers'] = $observers;
if (count($currentStep['recipients']) == 0) { if (count($currentStep['recipients']) == 0) {
$missing_recipients = true; $missing_recipients = true;
...@@ -302,7 +322,6 @@ class SignatureService ...@@ -302,7 +322,6 @@ class SignatureService
$out['signatureflow']['steps'][] = $currentStep; $out['signatureflow']['steps'][] = $currentStep;
} }
$out['signatureflow']['missing_recipients'] = $missing_recipients; $out['signatureflow']['missing_recipients'] = $missing_recipients;
return $out; return $out;
...@@ -418,6 +437,8 @@ class SignatureService ...@@ -418,6 +437,8 @@ class SignatureService
->setEditableRecipients($stepData['editable'] && $stepData['editable'] == true) ->setEditableRecipients($stepData['editable'] && $stepData['editable'] == true)
->setOptions($stepData['options'] ? $stepData['options'] : []) ->setOptions($stepData['options'] ? $stepData['options'] : [])
->setLetterfileName($stepData['letterfile']) ->setLetterfileName($stepData['letterfile'])
->setObserversMethod($stepData['observers_method'])
->setObserversOptions($stepData['observers_options'])
->setRecipientsMethod($stepData['method']) ->setRecipientsMethod($stepData['method'])
->setLevel($stepData['level']); ->setLevel($stepData['level']);
} }
...@@ -553,7 +574,6 @@ class SignatureService ...@@ -553,7 +574,6 @@ class SignatureService
$this->getLoggerService()->debug("Actualisation du statut pour '$signature'"); $this->getLoggerService()->debug("Actualisation du statut pour '$signature'");
try { try {
if (!$signature->isFinished()) { if (!$signature->isFinished()) {
$documentSrc = $this->getSignatureConfigurationService()->getDocumentsLocation() $documentSrc = $this->getSignatureConfigurationService()->getDocumentsLocation()
. DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
. $signature->getDocumentPath(); . $signature->getDocumentPath();
...@@ -572,12 +592,14 @@ class SignatureService ...@@ -572,12 +592,14 @@ class SignatureService
$status = $infos->getStatus(); $status = $infos->getStatus();
$status_remote = $infos->getStatusRemote(); $status_remote = $infos->getStatusRemote();
$currentStatus = $signature->getStatusText(); $currentStatus = $signature->getStatusText();
$this->getLoggerService()->debug("Statut en cours '$currentStatus', statut reçu > '$status' ($status_remote)"); $this->getLoggerService()->debug(
"Statut en cours '$currentStatus', statut reçu > '$status' ($status_remote)"
);
$statusChanged = $signature->getStatus() !== $status; $statusChanged = $signature->getStatus() !== $status;
if( $statusChanged ){ if (!$statusChanged) {
$this->getLoggerService()->debug("Le statut a changé > '$status'"); return false;
} }
$signature->setStatus($status) $signature->setStatus($status)
...@@ -598,9 +620,9 @@ class SignatureService ...@@ -598,9 +620,9 @@ class SignatureService
} }
$this->getObjectManager()->flush(); $this->getObjectManager()->flush();
if ($signature->getStatus() == Signature::STATUS_SIGNATURE_SIGNED) { if ($signature->getStatus() == Signature::STATUS_SIGNATURE_SIGNED) {
$this->getLoggerService()->debug("Transfert du document"); $this->getLoggerService()->debug("Transfert du document");
$docFromLetterfile = $this->getDocumentSignedSignature($signature);
$documentSrc = $this->getSignatureConfigurationService()->getDocumentsLocation() $documentSrc = $this->getSignatureConfigurationService()->getDocumentsLocation()
. DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
...@@ -617,6 +639,10 @@ class SignatureService ...@@ -617,6 +639,10 @@ class SignatureService
} }
} }
// Notification
if( $signature->getObservers() ){
$this->notificationsObserversStatut($signature);
}
if ($callProcessStep && $signature->getProcessStep()) { if ($callProcessStep && $signature->getProcessStep()) {
/** @var ProcessService $processService */ /** @var ProcessService $processService */
...@@ -797,9 +823,7 @@ class SignatureService ...@@ -797,9 +823,7 @@ class SignatureService
->setStatus(Signature::STATUS_SIGNATURE_WAIT); ->setStatus(Signature::STATUS_SIGNATURE_WAIT);
foreach ($signature->getRecipients() as $recipient) { foreach ($signature->getRecipients() as $recipient) {
$recipient->setStatus(Signature::STATUS_SIGNATURE_WAIT) $recipient->setStatus(Signature::STATUS_SIGNATURE_WAIT)
->setDateUpdate(new \DateTime()) ->setDateUpdate(new \DateTime());
;
} }
$this->getObjectManager()->flush(); $this->getObjectManager()->flush();
$this->notifications($signature); $this->notifications($signature);
...@@ -816,15 +840,53 @@ class SignatureService ...@@ -816,15 +840,53 @@ class SignatureService
} }
} }
protected function notificationsTrigger( array $datas ) :void
{
$notificationsCaller = $this->getSignatureConfigurationService()->getNotificationsCaller();
foreach ($datas as $data){
foreach ($notificationsCaller as $caller) {
$body = $data['body'];
$subject = $data['subject'];
$recipient = $data['recipient'];
try {
$caller($this->getServiceContainer(), $recipient, $subject, $body);
} catch (\Exception $e) {
$this->getLoggerService()->error(
"Un problème est survenu lors de l'envois des notifications"
);
}
}
}
}
public function notificationsObserversStatut(Signature $signature, string $body = null) :void
{
$this->getLoggerService()->info("notificationsObserversStatut($signature)");
if( $body == null ){
$body = sprintf(
"L'étape de signature '%s' est passé au statut : %s",
$signature->getLabel(),
$signature->getStatusText()
);
}
$datas = [];
foreach ($signature->getObservers() as $observer) {
$datas[] = [
'body' => $body,
'subject' => "Info procédure de signature (" . $signature->getStatusText() . ")",
'recipient' => $observer
];
}
$this->notificationsTrigger($datas);
}
public function notifications(Signature $signature): void public function notifications(Signature $signature): void
{ {
$this->getLoggerService()->info("notifications($signature)");
if ($signature->isNotifiable()) { if ($signature->isNotifiable()) {
$notificationsCaller = $this->getSignatureConfigurationService()->getNotificationsCaller(); $notificationsCaller = $this->getSignatureConfigurationService()->getNotificationsCaller();
// if (count($notificationsCaller) == 0) {
// $msg = "Aucune procédure de notification configurée";
// $this->getLoggerService()->error($msg);
// throw new SignatureException($msg);
// }
// Pour générer les URLs dans les messages // Pour générer les URLs dans les messages
$urlBuilder = $this->getServiceContainer() $urlBuilder = $this->getServiceContainer()
...@@ -846,7 +908,7 @@ class SignatureService ...@@ -846,7 +908,7 @@ class SignatureService
$messageBody = $this->getSignatureConfigurationService()->getNotificationsBody(); $messageBody = $this->getSignatureConfigurationService()->getNotificationsBody();
$find = ["{FULLNAME}", "{ACTION}", "{URL}"]; $find = ["{FULLNAME}", "{ACTION}", "{URL}"];
$datas = [];
foreach ($signature->getRecipients() as $recipient) { foreach ($signature->getRecipients() as $recipient) {
if ($action == 'viser') { if ($action == 'viser') {
// TODO Pose problème !!! // TODO Pose problème !!!
...@@ -858,7 +920,7 @@ class SignatureService ...@@ -858,7 +920,7 @@ class SignatureService
else { else {
$link = "Dans le parapheur"; $link = "Dans le parapheur";
} }
foreach ($notificationsCaller as $caller) {
$fullname = $recipient->getFullname(); $fullname = $recipient->getFullname();
$url = $link; $url = $link;
$replace = [$fullname, $action, $url]; $replace = [$fullname, $action, $url];
...@@ -866,18 +928,13 @@ class SignatureService ...@@ -866,18 +928,13 @@ class SignatureService
$body = str_ireplace($find, $replace, $messageBody); $body = str_ireplace($find, $replace, $messageBody);
$subject = str_ireplace($find, $replace, $messageSubject); $subject = str_ireplace($find, $replace, $messageSubject);
if( is_callable($caller) ){ $datas[] = [
$this->getLoggerService()->error("Un procédé de notification n'est pas 'callable'"); 'subject' => $subject,
} else { 'body' => $body,
try { 'recipient' => $recipient,
$caller($this->getServiceContainer(), $recipient, $subject, $body); ];
} catch (\Exception $e) {
$this->getLoggerService()->error("Un problème est survenu lors de l'envois des notifications");
}
}
}
} }
$this->notificationsTrigger($datas);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment