PageSourceSearch

https://www.blgcloud.com/dist/modules/Extranet-ContractView-js-ContractView-js.js

js blgcloud.com collected 2026-10-01 15:07:47 UTC 20,456 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[1450,4228,4543],{90405(t,e,a){a.d(e,{FD:()=>m,Nl:()=>l,Os:()=>r,Tq:()=>d,gW:()=>u,hR:()=>i,ht:()=>o,x6:()=>s});var n=a(42689);async function o(t,e,a=null,o=null){const c="document-generatedDocument-"+r();try{const r=await async function(t,e,a=null){const o=n().toISOString().substr(0,19)+"Z";let i=e.mainObject.id;const{objectName:c}=e.mainObject;["part","contract"].includes(c)&&(i=parseInt(i));const r={id:i,options:{fullDate:o,shortDate:o,showSignatureAnnotation:!!e.customerValidation,showCustomerValidation:!!e.customerValidation,extranetCall:"sale"===c},utcOffset:n().utcOffset()},s=(await t.getFirstObjectBy("system/parameters",{field:["useExtranetSaleTemplate"]}))?.useExtranetSaleTemplate,l=a??e.templateName;return"purchaseDocument"===c||"sale"===c&&!s?t.documentGenerator.generateStream(l,r):t.htmlPdfDocumentGenerator.generateStream(c,l,r)}(t,e,o),s=await async function(t,e,a,n,o,c=null){const r=await async function(t,e){const a=await t.getOneObjectBy("document/template",{filter:{name:e.templateName},join:["templateModel"],field:["title","templateModel"]});return a.title||a.templateModel?.defaultOptions?.title}(t,a);let s=`${r} #${a.mainObject.reference}`;if(c){const t=a?.fileName?.split(".")[0];t&&(s=t)}const l={destPath:e,location:"document/generatedDocument",title:s,type:{"@name":a.documentType},filename:a.fileName,linkField:"attachment",contentType:"application/pdf",customerValidation:c};return await i(t,n,l,o)}(t,c,e,r,a,e?.customerValidation);a||await async function(t,e,a){"contract"===e.mainObject.objectName?await t.putObject("contract/contractDocument",{document:{"@id":a},contract:{"@id":parseInt(e.mainObject.id)}}):"sale"===e.mainObject.objectName?await t.patchObject("sale/saleDocument",e.mainObject.id,{documents:{$push:[{"@id":a}]}}):"part"===e.mainObject.objectName?await t.putObject("article/articleDocument",{document:{"@id":a},article:{"@id":parseInt(e.mainObject.id)}}):"equipment"===e.mainObject.objectName?await t.patchObject("repository/equipment",e.mainObject.id,{document:{"@id":a}}):"purchaseDocument"===e.mainObject.objectName&&await t.patchObject("purchase/purchaseDocument",e.mainObject.id,{documents:[{"@id":a}]})}(t,e,s)}catch(t){throw console.error(t),t}}async function i(t,e,a,n=null){let o=null;try{const i={title:a.title,type:a.type,extranetDiffusion:"private"};let c;"document/importedDocument"===a.location&&(i.mimeType=e.type??a.mimeType),o=await t.putObject(a.location,i),a.customerValidation&&await t.putObject("document/validation",{...a.customerValidation,validator:"customer",document:{"@id":o.id}}),n&&(c=await t.putObject("mail/mailAttachment",{numOrder:(new Date).getTime(),mail:{"@id":n}}));const r={stream:e,contentType:a.contentType??i.mimeType,title:a.filename??e.name},s={linkLoc:n?"mail/mailAttachment":a.location,linkField:a.linkField,linkId:n?c.id:o.id};await t.putFileStream(r,a.destPath,s)}catch(e){throw o&&await t.deleteObject(a.location,o.id),e}return o.id}function c(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function r(){return c()+c()+"-"+c()+"-"+c()+"-"+c()+"-"+c()+c()+c()}async function s(t,e,a,n,o="documentGenerator"){const i=await l(t,e,a,n,o);return d(i),i}async function l(t,e,a,n,o="documentGenerator"){try{const i=await async function(t,e,a={}){const n=await t.getOneObjectBy("document/template",{filter:{name:e},join:["templateModel.fields"]}),o=new Date(Date.now()).toISOString();let i=null;a.equipmentMongoId&&(i=await t.getFirstObjectBy("system/history",{filter:{mainObjectId:a.equipmentMongoId,mainObject:{path:"repository/equipment"},field:"location"},field:["date"],order:["date","desc"]}));const c=i?i.date.split("T")[0]:a.inFleetDate;return{...Object.fromEntries(n.templateModel.fields.map(t=>[[t.name],void 0!==t.options?.value?t.options?.value:null])),...n.templateModel.defaultOptions,...n.userOptions,dateMinimum:c??null,fullDate:o,shortDate:o}}(t,a,n);return"documentGenerator"===o?await async function(t,e,a,n){return await t.documentGenerator.generate(a,{...n,options:e})}(t,i,a,n):await async function(t,e,a,n,o){return await t.htmlPdfDocumentGenerator.generate(a,n,{utcOffset:120,options:e,...o},t.language)}(t,i,e,a,n)}catch(t){return console.error(t),null}}function d(t){const e=window.open();null!==e?e.location=URL.createObjectURL(t):window.location=URL.createObjectURL(t)}function m(t,e){return t.filter(t=>t.document.type.name===e)}async function u(t){return"boolean"===(await t.getObjectDef("document/document")).fields.extranetDiffusion.type}},40508(t,e,a){a.r(e),a.d(e,{WELL_KNOWN_ENDPOINT:()=>l,hasWellKnown:()=>w,idToBase64:()=>d,makeBarCode:()=>u,makeGlobalWellKnown:()=>y,makeLongWellKnown:()=>f,makeShortBarCode:()=>h,makeShortWellKnown:()=>p,makeWellKnownObject:()=>g});
1const n={activity:{baseActivity:{short:"ab"},global:{short:"ag"},message:{short:"am"},meeting:{short:"aM"},reminder:{short:"ar"},recommendation:{short:"aR"},phoneCall:{short:"ac"}},opportunity:{opportunity:{short:"ao"}},article:{part:{short:"ap"},partStock:{short:"as"},warehouse:{short:"aw"}},cms:{catalogCollection:{short:"sc"},contentBlock:{short:"sb"},dynamicPage:{short:"sp"},makePage:{short:"sm"},news:{short:"sn"},picture:{short:"si"},rangePage:{short:"sr"},recruitment:{short:"sR"},slideShow:{short:"ss"},storePage:{short:"sS"},video:{short:"sv"},websiteContact:{short:"sC"}},crm:{baseActivity:{short:"ca"},coOwnership:{short:"cc"},company:{short:"cp"},contact:{short:"ct"},opportunity:{short:"co"}},invoice:{invoice:{short:"iI"},invoiceDocument:{short:"ii"},invoiceLine:{short:"il"},payment:{short:"ip"}},movement:{deliveryOrder:{short:"md"},movementLine:{short:"ml"},transferRequest:{short:"mt"},movement:{short:"Mm"}},mail:{mail:{short:"mm"},model:{short:"mM"}},maintenance:{time:{short:"mT"}},nomenclature:{nomenclature:{short:"nn"}},purchase:{purchaseContractDueDate:{short:"pc"},purchaseDocument:{short:"pd"},purchase:{short:"pp"}},repository:{equipment:{short:"re"}},sale:{quote:{short:"sq"},saleQuoteLine:{short:"sl"},purchaseQuoteLine:{short:"pl"},contractProductQuoteLine:{short:"cP"},saleDocument:{short:"sd"},sale:{short:"qs"}},shop:{store:{short:"Ss"}},user:{user:{short:"uu"}},contract:{contract:{short:"cC"},contractLine:{short:"cl"},contractProvisionalInvoiceLine:{short:"ci"},requirementType:{short:"cr"}},equipment:{checkDocument:{short:"eC"},equipment:{short:"ee"},equipmentLife:{short:"eL"}},subscription:{subscription:{short:"su"}}},o=new Map;for(const t in n)for(const e in n[t])o.set(n[t][e].short,{namespace:t,objectName:e});const i=new Map([["0","view"],["1","list"],["2","edit"],["3","public"]]),c=new Map([...i].map(([t,e])=>[e,t]));function r(t,e,a){if(!(e in n)||!(a in n[e]))throw Error(`Unknown object "${e}/${a}"`);const o=c.get(t);if(void 0!==o)return o;const i=n[e][a].actions;if(i)for(const e in i)if(t===i[e])return e;throw Error(`Unknown action "${t}" for object ${e}/${a}`)}const s=[[0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],[4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],[6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],[5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],[9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0]];const l="https://wk.blg.cloud/";function d(t){return"number"==typeof t&&(t=("000000000000000000000000"+t.toString(16)).slice(-24)),function(t){let e="";for(let a=0;a<t.length;a+=2)e+=String.fromCharCode(parseInt(t.slice(a,a+2),16));return btoa(e)}(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function m(t,e,a,n){if(t&&"object"==typeof t)return t;if("string"!=typeof e)throw new Error("objectPath must be a string");const[o,i]=e.split("/").filter(Boolean),c={target:{namespace:o,objectName:i},action:t};return"number"!=typeof a&&"string"!=typeof a||(c.id=a),"string"==typeof n&&(c.filter=n),c}function u(t,e,a){const o=m(t,e,a);let i=r(o.action,o.target.namespace,o.target.objectName)+n[o.target.namespace][o.target.objectName].short;var c;return o.id?i+=d(o.id):o.filter&&(i+=(c=o.filter,btoa(c).replaceAll("+","-").replaceAll("/","_").replaceAll("=",""))),i}function h(t,e,a){const o=m(t,e,a),i=function(t){const e=t+"";let a="";for(let t=0;t<4-e.length;++t)a+="0";return a+e}(o.id);return r(o.action,o.target.namespace,o.target.objectName)+n[o.target.namespace][o.target.objectName].short+i+function(t){let e=0;for(let a=0;a<t.length;a++){const n=parseInt(t.charAt(a));e=s[e][n]}return e.toString()}(i)}function p(t,e,a,n){return"/wk/"+u(m(t,e,a,n))}function f(t,e,a){const n=m(t,e,a);return r(n.action,n.target.namespace,n.target.objectName),"/wk/"+n.action+"/"+n.target.namespace+"/"+n.target.objectName+"/"+(n.id??n.filter)}function g(t,e,a,n){return{target:{namespace:e,objectName:a}
1,action:t,id:n}}function w(t){const[e,a]=t.split("/").filter(Boolean);return e in n&&a in n[e]}function y(t,e,a,n){return l+t+"/"+u(e,a,n)}},3305(t,e,a){a.r(e),a.d(e,{default:()=>m});var n=a(17243),o=a(20188),i=a(978),c=a(14848),r=a(78762),s=a(90405),l=a(54266);class d extends o.A{async initialize(){super.initialize(),this.rentConfig=this.getConfigByKey("defaultRentConfig"),this._domHelper=this._serviceHandler.getDomHelper();const t=this._serviceHandler.getTwigHelper();let e=!0;try{this.apiClient=this._serviceHandler.getApiClient()}catch{e=!1}if(t.register(this._data.templates),e&&await this.getData(),this._data.contract&&this._data.interaction&&(this._fillBreadcrumb(),this._generateActionBlock(t),this._generateContactButton(t),this._generateCustomerValidationBlock(t),this._generateContractValidationBlock(t),this._generateDocumentBlock(t),e&&(this._setupEvents(),await this._generateProjectedConsumptionBlock(t))),this._root.find(".js-copyPaste-trigger").on("click",()=>this._domHelper.clipboardCopy(this._root)),this._root.removeClass("loading"),e){const t=this._data.contract??this._data.jsData.contract;await i.z0(this.apiClient,"contract",t.id)}}async getData(){try{const t=(new Intl.DateTimeFormat)?.resolvedOptions()?.timeZone,e=t&&"Etc/Unknown"!==t?t:"Europe/Paris",a={documentType:"contract",templateName:this._data.templateOptions.name,type:["htmlCssData"],data:{id:this._data.itemId,verySameDateValidation:this.rentConfig.verySameDateValidation,data:{timezone:e}},extranetUrl:this._data.siteUrls.extranetUrl,options:{language:this.apiClient.language,headers:{"accept-language":this.apiClient.language}}},n=await c.cM(this._serviceHandler.getApiClient(),a);if(!n){const t=location.pathname.split("/");return t.pop(),void(location.href=t.join("/"))}this._data.contract=n.data,c.XX(n,this._root.find(".js-contract"))}catch(t){console.error(t)}}_fillBreadcrumb(){const t=this._serviceHandler.getTemplateHelper(),e=this._data.contract.status,a=new Date(this._data.contract.startDate).getTime()<=(new Date).getTime();let n=e;["validated","contractValidated","toPrepare"].includes(e)||"inProgress"===e&&!a?n="validated":"inProgress"===e&&a?n="inProgress":["completed","completedInvoiced","waintingReturn"].includes(e)&&(n="completed"),t.addBreadCrumbContractStep({translation:this._translations["contractView.filter."+n],status:n,contractType:this._data.contract.type}),t.addBreadCrumbLastStep(this._translations["contractView.contractNumber."+n]+this._data.contract.reference)}_generateActionBlock(t){const e=this.renderTwig(t,"content/elements/actions",{...this._data,moduleConfig:this.config,configs:{defaultRentConfig:this.rentConfig}},this._translations);l(this._root).find(".contractHeader").append(e);for(const[t,e]of Object.entries(this.rentConfig.display.availableActions))e&&this._setupBtn(t)}_setupBtn(t){const e=this._getFormData(t);l(this._root).find(`.${t}.js-display-form-modal`).attr("js-form-modal",e.jsFormModal).attr("js-form-modal-custom-data",JSON.stringify(e.jsFormModalCustomData)).attr("js-form-modal-title",e.jsFormModalTitle).attr("js-form-value",JSON.stringify(e.jsFormValue)).attr("js-form-object",JSON.stringify(e.jsFormObject))}_getFormData(t){const e=JSON.parse(this._data.userInfo),a={websiteContact:this._data.websiteContext.websiteContact,emitterSmtp:this._data.emitterSmtp,contractId:this._data.contract.id,startDate:this._data.contract.startDate,endDate:this._data.contract.endDate,template:this._data.contactRequestTemplate,subjectName:n.capitalize(t)},o={contract:{id:this._data.contract.id,reference:this._data.contract.reference,startDate:this._data.contract.startDate,endDate:this._data.contract.endDate,title:this._data.contract.title,emitterContact:this._data.contract.emitterContact,requirementType:this._data.contract.equipmentRequirements[0]?.requirementType?.title??null,salespersonContact:this._data.contract.salespersonContact},contact:{firstName:e.contact?.firstName??"",lastName:e.contact?.lastName??""},company:{companyName:e.company.companyName},mail:{to:[this._data.mailContact],subject:this._translations[`contractView.action.${t}.title.${this._data.contract.status}`]||this._translations[`contractView.action.${t}`]||""}};return"contact"===t&&(o.mail.subject=this._translations["contractView.action.contactModalTitle"]??""),{jsFormModal:`contractContactRequest${"contact"!==t?n.capitalize(t):""}`,jsFormModalCustomData:a,jsFormModalTitle:o.mail.subject,jsFormValue:o,jsFormObject:{contract:o.contract.id}}}_generateContactButton(t){if("cart"===this._data.contract.status)return;const e=this.renderTwig(t,"header/contactButton",{},this._translations),a=l(this._root).find(".js-directContact-hook");a.length?a.append(e):l(this._root).find(".js-emitterBlock-hook").append(e),this._setupBtn("contact")}_generateCustomerValidationBlock(t){if(this._data.validations.quote||this._data.validations.contract){const e={validation:this._data.validations.contract??this._data.validations.quote,cgvPage:this._data.cgvPage},a=this.renderTwig(t,"content/elements/customerValidationBlock",e,this._translations);l(this._root).find(".contractFooter").prepend(a)}}_generateContractValidationBlock(t){const{userBlocked:e,contract:a,everythingIsAssigned:n}=this._data,o={userBlocked:e,contract:a,everythingIsAssigned:n};if(!a.hasExpired&&("quote"===a.status||"validated"===a.status&&n)){const e=this.renderTwig(t,"content/elements/contractValidationBlock",o,this._translations);l(this._root).find(".validationBlock").append(e)}}async _getLastSignedDocument(t){const e=await(0,s.gW)(this.apiClient);return await this.apiClient.getFirstObjectBy("contract/contractDocument",{filter:{$and:[{contract:{id:t}},{document:{extranetDiffusion:!!e||{$ne:"no"},type:{name:"contract"},signedDocuments:{$empty:!1}}}]},filteredJoin:{document:{baseJoin:"document",filteredJoin:{signedDocuments:{baseJoin:"signedDocuments",join:["attachment"],order:["signedDocuments.createdAt","desc"],limit:1}}}},order:["document.id","desc"]})}async _generateDocumentBlock(t){const e=this._data.contract,a=await this._getLastSignedDocument(e.id);if(a&&a.document.signedDocuments?.length)a&&(e.mainDocument={title:a.document.title,document:{title:a.document.title??a.document.signedDocuments[0].attachment.title,attachments:[a.document.signedDocuments[0].attachment.pathWeb]}});else{const t=await this._getMainDocument(e.id);t&&(e.mainDocument=t)}if(e.mainDocument){const a=this.renderTwig(t,"content/elements/documentBlock",e,this._translations);l(this._root).find(".contract").append(a)}}async _generateProjectedConsumptionBlock(t){if(this.rentConfig.display.projectedConsumption){await(0,r.I3)(this._data.contract);for(const e of this._data.contract.equipmentRequirements)for(const a of e.assignments){const n={class:"contractView",requirement:e},o=this.renderTwig(t,"projectedConsumption",n,this._translations),i=document.getElementsByClassName("equipmentLink");Array.prototype.map.call(i,function(t){l(t).attr("data-target")===a.equipment.equipmentId&&l(t).closest(".equipmentTable").append(o)})}}}_setupEvents(){this._data.templateData&&this._data.templateData.pdfViewer&&window.blg.getServiceOnLoad("pdfViewer",t=>{t.setupEvents()}),this._data.templateData&&this._data.templateData.contractContactRequest&&window.blg.getServiceOnLoad("formModal",t=>{t.setupEvents()}
1),l(this._root).find("a.documentRow").off("click").on("click",async t=>{await i.rm(t,this.apiClient,"contract",this._data.contract.id)}),l(".js-validate-order-action").off("click").on("click",()=>{const t=this._data.contract,e=t.status;["bookingRequest"].includes(e)&&(l(".js-validate-order-action").addClass("loading"),l.post(this._data.validationUrl,{contract:t}).then(()=>{l(".js-validate-order-action").removeClass("loading").addClass("success").html(this._translations["contractView.action.requestValidated"])}))});const t=this._root.find(".js-characteristicsBlockTrigger"),e=this._root.find(".js-characteristicsBlock");l(t).off("click").on("click",t=>{t.stopPropagation();const e=t.currentTarget.getAttribute("data-target"),a=this._root.find("."+e);l(t.currentTarget).add(a).toggleClass("open")}),l(e).off("click").on("click",t=>{t.stopPropagation()}),l(document).keydown(t=>{27===t.which&&l(".open").removeClass("open")}).on("click",()=>{l(t).add(l(e)).removeClass("open")}),l(this._root).find('[data-toggle="tooltip"]').tooltip()}async _getMainDocument(t){const e=await(0,s.gW)(this.apiClient),a=await this.apiClient.getFirstObjectBy("contract/contractDocument",{filter:{$and:[{contract:{id:t}},{document:{extranetDiffusion:!!e||{$ne:"no"}}}]},order:["document.createdAt","desc"],join:["document.attachment"]});return!!a&&(a?.document?.attachment&&(a.document.attachments=[a.document.attachment.pathWeb],delete a.document.attachment),a)}}n.set(window,["blg","Extranet","ContractView"],d);const m=d},90634(t,e,a){function n(t,e,a){const n=Number.isInteger(a.itemId)||!a.itemId.match(/^[0-9]+$/)?a.itemId:parseInt(a.itemId),o=t.makeWellKnownObject(a.action,a.namespace,a.objectName,n),i=t.makeShortWellKnown(o),c=a.extranetUrl||e.apiUrl.split("/api")[0],r=new 
1URL(c);return r.pathname=i,a.token&&r.searchParams.set("token",a.token),r.href}function o(t){switch(t){case"invoice":return["invoice","invoice"];case"contract":return["contract","contract"];case"sale":return["sale","quote"];default:return console.warn(`Location for ${t} is not defined!`),[]}}a.d(e,{Z:()=>n,a:()=>o})},14848(t,e,a){a.d(e,{XX:()=>r,cM:()=>i});var n=a(40508),o=a(90634);async function i(t,e){try{const{documentType:a,objectType:n,templateName:o,type:i,data:r,extranetUrl:s,options:l={}}=e,d=Array.isArray(i)?i:[i];return Object.assign(r,function(t,e,a,n){return{extranetRaw:n,extranetUrl:n,extranetHome:n,extranetUrlWithWk:c(t,e,a,n),token:t.token}}(t,n||a,r.id,s),{extranetCall:!0}),function(t){let e={};if(1===t.length){const{styleSheet:a,htmlContent:n,data:o}=t[0];e={css:a,html:n,data:o}}else for(const a of t){const t=Object.keys(a);t.includes("styleSheet")?e.css=a.styleSheet:t.includes("htmlContent")?e.html=a.htmlContent:t.includes("id")&&(e.data=a)}return e}(await Promise.all(d.map(e=>t.htmlPdfDocumentGenerator.generateAny(a,o,e,r,{needXBlgApiUrlHeader:!1,...l}))))}catch(t){return console.error(t),null}}function c(t,e,a,i){const[c,r]=(0,o.a)(e);let s;try{s=(0,o.Z)(n,{},{action:"view",namespace:c,objectName:r,itemId:a,extranetUrl:i,token:t.token})}catch(t){console.warn(t),s=i}return s}function r(t,e){const{html:a,css:n}=t;n&&function(t){const e=document.createElement("style");e.innerText=t,document.querySelector("head").append(e)}(n),function(t,e){e.html(t)}(a,e)}},978(t,e,a){a.d(e,{rm:()=>c,z0:()=>i});var n=a(54266);async function o(t,e,a,n){(function(t,e,a){const n=new URL(window.location.href),o=function(t,e,a){const n=JSON.parse(localStorage.getItem("blg_document_access"))||{},o=n[e]?.find(e=>e.type===t&&e.id===a);if(o){const i=o.time<Date.now()-3e5;return i&&function(t,e,a,n){const o=t[a]?.findIndex(t=>t.type===e&&t.id===n);t[a].splice(o,1),localStorage.setItem("blg_document_access",JSON.stringify(t))}(n,t,e,a),i}return!0}(t,e,a),i=n.host.includes("localhost")||n.host.includes("10.10."),c="true"===localStorage.getItem("blg_debug");return o&&!i&&!c})(e,a,n)&&(await t.putObject("document/documentAccess",{[a]:{"@id":n},type:e}),function(t,e,a){const n=JSON.parse(localStorage.getItem("blg_document_access"))||{};n[e]||(n[e]=[]),n[e].push({id:a,type:t,time:Date.now()}),localStorage.setItem("blg_document_access",JSON.stringify(n))}(e,a,n))}async function i(t,e,a){setTimeout(async()=>{await o(t,"onlineView",e,a)},1500)}async function c(t,e,a,i){const c=n(t.currentTarget).attr("href");t.preventDefault(),await async function(t,e,a){await o(t,"download",e,a)}(e,a,i);const r=window.open();null!==r?r.location=c:window.location=c}}}]);
2//# sourceMappingURL=Extranet-ContractView-js-ContractView-js.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.