DevisManager

🔧 __construct

function __construct($id_type, $id_objet,$contexte="") { global $user; $this->id_type = $id_type; $this->id_objet = $id_objet; $this->initialiserDevis($contexte); $this ->identification = get_UserIdentification($user->id,$this->devis[fwp7_param_template_att_get_number('',$this->id_type,'id_user')]); $this ->devis_module_codes = (new ModuleCode($id_type,$id_objet))->setModuleCode($this->id_type, '162'); }

🔧 __construct

Constructeur
function __construct($id_type, $id_objet,$contexte="") { global $user; $this->id_type = $id_type; $this->id_objet = $id_objet; $this->initialiserDevis($contexte); $this ->identification = get_UserIdentification($user->id,$this->devis[fwp7_param_template_att_get_number('',$this->id_type,'id_user')]); $this ->devis_module_codes = (new ModuleCode($id_type,$id_objet))->setModuleCode($this->id_type, '162'); }

⚙️ Parameters


🔧 initialiserDevis

Initialise les données du devis
function initialiserDevis($contexte) { $this->devis = fwc7_data_objet_att('', $this->id_type, $this->id_objet); $opportunite_clientID = fwc7_data_att_getraw('', '148', $this->devis['att1'], "att2"); // Si Pas d'opportunité (dans le cas d'une création de Devis d'un Franchiseur par exemple)/ // Récupération des informations depuis le client directement. if($opportunite_clientID === null || $opportunite_clientID === "") { $this->client = fwc7_data_objet_att('', '80', $this->devis["att2"]); } else { $this->client = fwc7_data_objet_att('', '80', $opportunite_clientID); $this->opportunite = fwc7_data_objet_att('', '148', $this->devis['att1']); } // le contexte ici est soit "FACTURATION" soit "INTERVENTION" if(isset($contexte)){ // ... (truncated)

🔧 getLignesDevis

function getLignesDevis($htmlVue=true){ $wc= array(); $this->lignesDeProduit = fwc7_data_objet_ligs("",$this->id_type,$this->id_objet,MapperDevis::TLIG_DEVIS($this->id_type),"","1",$wc); if($htmlVue && count($this->lignesDeProduit)>1){ $html = '<style> table { width: 100%; border-collapse: collapse; margin: 20px 0; font-family: Arial, sans-serif; } tr{ page-break-inside: avoid !important; break-inside: avoid !important; margin-bottom: 15px !important; } th, td { padding: 12px; border: 1px solid #ddd; } * { -webkit-print-color-adjust: exact !important; color-adjust: exact !important; } p, tr { orphans: 3; widows: 3; } th { background-color: #f5f5f5; color: black; font-weight: bold; } .total-row { font-weight: bold; background-color: #f9f9f9; } .col-product { width: 63%; text-align: left; padding-bottom: 25px !important; } .col-qty { width: 5%; } .col-unit-price { width: 10%; } .col-total-ht { width: 11%; } .each-line{ padding-bottom: 35px; } .col-total-ttc { width: 11%; } .header-center { text-align: center; } .cell-right { text-align: center !important; } .page-break { page-break-before: always; } .no-break { page-break-inside: avoid; } @page { size: A4; margin: 2cm 1.5cm; @top-center { content: "Devis N° DEV-SML-35"; } @bottom-right { content: "Page " counter(page) " sur " counter(pages); } } </style>'; $html.= '<table>'; $html.=' <thead> <tr> <th class="col-product">Produit</th> <th class="col-qty header-center">Qte</th> <th class="col-unit-price header-center">Prix U HT</th> <th class="col-total-ht header-center">Total HT</th> <th class="col-total-ttc header-center">Total TTC</th> </tr> </thead><tbody>'; function cleanTcpdfValue($tcpdfValue) { $replacements = [ '</p><p>'.PHP_EOL => '', // ... (truncated)

↩️ Returns

(string|void)

🔧 getAllContacts

function getAllContacts(){ // chercher sur la table client, tous les Contacts destinataire. $wc =array(); $wc[]=" att8 ='".$this->client["id_obje"]."' "; $all_contacts = fwc7_data_objet_atts('',MapperDevis::TYPE_CONTACT($this->id_type),"1",$wc); return array_column(array_values($all_contacts), 'att6'); }

↩️ Returns

(mixed)

🔧 getIdendite_Interlocuteur_Franchise

function getIdendite_Interlocuteur_Franchise(){ $franchise = $this->getEntite(); $wc = []; $wc ["lig1"]=$this->devis['att11']; $current_interlocuteur = fwc7_data_objet_lig('', '152',$franchise['id_obje'], '180', '', $wc); $user = fwc7_user_detail('',$current_interlocuteur['lig1']); return [ 'franchise'=> $franchise, 'banner_url' => $current_interlocuteur['lig2'], 'email'=>$franchise['att10'], // ... (truncated)

↩️ Returns

(array)

🔧 getAddressData

Récupère l'adresse d'intervention ou l'adresse de facturation depuis le devis et la formatte
function getAddressData() { $addressFields = ($this->addressType == 'FACTURATION') ? ['31', '32', '33', '34', '35'] // att des champs de facturation : ['38', '39', '40', '41', '42']; // att des champs d'intervention return [ 'adresseLigne1' => $this->devis["att" . $addressFields[0]], 'adresseLigne2' => $this->devis["att" . $addressFields[1]], 'cp' => $this->devis["att" . $addressFields[2]], 'ville' => $this->devis["att" . $addressFields[3]], 'pays' => $this->devis["att" . $addressFields[4]] ]; // ... (truncated)

↩️ Returns

(array)

🔧 getAddressDataIntervention

Récupère l'adresse d'intervention depuis le devis et la formatte
function getAddressDataIntervention() { $addressFields = ['38', '39', '40', '41', '42']; // att des champs d'intervention return [ 'adresseLigne1' => $this->devis["att" . $addressFields[0]], 'adresseLigne2' => $this->devis["att" . $addressFields[1]], 'cp' => $this->devis["att" . $addressFields[2]], 'ville' => $this->devis["att" . $addressFields[3]], 'pays' => $this->devis["att" . $addressFields[4]] ]; }

↩️ Returns

(array)

🔧 handleAdresseIntervention

Créer l'adresse d'intervention dans le devis $id_att="att19" de lieu d'intervention
function handleAdresseIntervention() { $datas = []; //TODO: on assume de prendre la première adresse qui vient... if($this->opportunite !== null) { // on est dans le cas d'une création de devis avec opportunité. $obj_client_adresse_ligne_ID = $this->opportunite['att8']; $this->adresseIntervention = fwc7_data_objet_lig('1', '80', $this->opportunite['att2'], '147', $obj_client_adresse_ligne_ID, '1'); } else { $this->adresseIntervention = fwc7_data_objet_lig('1', $this->client['id_type'], $this->client['id_obje'], '147', '', '1'); } // Recopie des adresses d'intervention $datas['att38'] = $this->adresseIntervention["lig2"]; // Adresse $datas['att39'] = $this->adresseIntervention["lig3"]; // Code Postal $datas['att40'] = $this->adresseIntervention["lig4"]; // Code Postal $datas['att41'] = $this->adresseIntervention["lig5"]; // Ville $datas['att42'] = $this->adresseIntervention["lig6"]; // Pays $datas['att19'] = implode(" ", [ $this->adresseIntervention["lig1"], // ... (truncated)

↩️ Returns

(array)

🔧 handleAdresseFacturation

Créer l'adresse de facturation dans le devis
function handleAdresseFacturation($datas = []) { // Recopie adresse de facturation $datas['att31'] = $this->client["att14"]; // Adresse $datas['att32'] = $this->client["att15"]; // complement $datas['att33'] = $this->adresseIntervention["att7"]; // Code Postal $datas['att34'] = $this->adresseIntervention["att17"]; // Ville $datas['att35'] = $this->adresseIntervention["att18"]; // Pays // Constitution de l'adresse de facturation $adresse_facturation = !empty($this->client["att9"]) ? $this->client["att9"]."\r\n " : ''; $adresse_facturation .= implode(" ", [ $this->client["att13"], $this->client["att15"], $this->client["att14"], $this->client["att7"], $this->client["att17"] ]); // ... (truncated)

⚙️ Parameters

↩️ Returns

(array)

🔧 handlePrescripteur

Gère les informations du prescripteur
function handlePrescripteur($datas) { if (!empty($this->opportunite['att12'])) { $datas['att44'] = $this->opportunite['att12']; } return $datas; }

⚙️ Parameters

↩️ Returns

(array)

🔧 handleEmail

function handleEmail($datas){ if(!empty($this->client)){ $datas["att23"] = $this->client["att12"]; } return $datas; }

↩️ Returns

(mixed)

🔧 handleEntiteInfo

Gère les informations de l'entité (franchisé)
function handleEntiteInfo($datas) { $id_user = $this->devis["att11"]; $this->entite = array_values(fwk7_TS_NOOA_get_Entiteinfos_byUserID($id_user))[0]; // Adresse vendeur $adresse_vendeur = $this->generateAdresseVendeur(); $datas['att18'] = $adresse_vendeur; // Pied de page $pied_de_page = $this->generatePiedDePage(); $datas['att22'] = $pied_de_page; return $datas; }

⚙️ Parameters

↩️ Returns

(array)

🔧 generateAdresseVendeur

Crée l'adresse du vendeur au moment de la création du devis
function generateAdresseVendeur(): string { return "<span style='line-height: 15px'> <p><strong>Rainea {$this->entite["att2"]}

↩️ Returns

(string)

🔧 generatePiedDePage

Génère le pied de page
function generatePiedDePage() { return "<p>Rainea {$this->entite["att2"]}

↩️ Returns

(string)

🔧 creerDevis

Méthode principale pour créer le devis
function creerDevis() { $datas = $this->handleAdresseIntervention(); $datas = $this->handleAdresseFacturation($datas); $datas = $this->handlePrescripteur($datas); $datas = $this->handleEntiteInfo($datas); $datas = $this->handleEmail($datas); fwc7_modify_att_edit('', $this->id_type, $this->id_objet, $datas); }

↩️ Returns

(void)

🔧 generateFormattedAddress

Méthode principale pour générer les adresse formattés
function generateFormattedAddress(): string { $addressData = $this->getAddressData(); $html = '<div style="font-size: 10px;">'; $html .= $this->formatClientHeader(); $html .= $this->formatSecondaryContact(); $html .= $this->formatAddress($addressData); $html .= $this->formatPhone(); $html .= $this->formatVatNumber(); $html .= '</div>'; return $html; // ... (truncated)

↩️ Returns

(string)

🔧 generateTauxTVA

function generateTauxTVA(): string { $ligneDevis = fwc7_data_objet_ligs('', $this->id_type, $this->id_objet, MapperDevis::TLIG_DEVIS($this->id_type), 'all', 1, ''); $groupedArray = []; foreach ($ligneDevis as $key => $item) { $lig5Value = $item[MapperDevis::TAUX_TVA_DEVIS($this->id_type)] ?? 'undefined'; // undefined si pas de TVA renseigné $groupedArray[$lig5Value][] = $item; } $resultString = ""; foreach ($groupedArray as $lig5 => $group) { $totalLig4 = 0; // Addition du total HT pour le calcul de la TVA foreach ($group as $item) { // ... (truncated)

↩️ Returns

(string)

🔧 generateFormattedAddressIntervention

Méthode pour générer l'adresse d'intervention formatée
function generateFormattedAddressIntervention(): string { $addressData = $this->getAddressDataIntervention(); $devisOBJ = $this->getDevisInfos(); $html = '<div style="font-size: 10px;">'; $html .= '<p style="line-height: 1em; font-weight: bold; font-size: 9px;">Adresse du chantier </p>'; $html .= $this->formatAddress($addressData); //$html .= $this->formatPhone(); $html .= '</div>'; $html .= '<div>'; if (isset($devisOBJ["att45"]) && !empty($devisOBJ["att45"])) { $html .= '<p style="line-height: 1em;"><strong>Conditions de paiement : </strong></p>'; // ... (truncated)

↩️ Returns

(string)

🔧 generateInfosDevis

Méthode pour générer les infos du devis formatté
function generateInfosDevis(): string { $infoDevis = $this->getDevisInfos(); return '<div style="margin-top: 1rem">'. '<p style="font-size: 2em; font-weight: bold; line-height: 1em; color: '.MapperDevis::COULEUR_TEXT($this->id_type).';">Devis</p>'. '<p style="line-height: 1em; font-size: 10px;">N° '.$infoDevis["att4"]. '</p>'. (!empty($infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'date_devis')])?'<p style="line-height: 1em; font-size: 10px;">En date du : '.date('d/m/Y', strtotime($infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'date_devis')])). '</p>':' '). (!empty($infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'date_expiration')])?'<p style="line-height: 1em; font-size: 10px;">Valable jusqu\'au : '.date('d/m/Y', strtotime($infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'date_expiration')])).'</p>':' '). (!empty($infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'duree_estimee')])?'<p style="line-height: 1em; font-size: 10px;">Durée estimée à : '.$infoDevis[fwp7_param_template_att_get_number('',$this->id_type,'duree_estimee')].'</p>':' '). '</div>'; }

↩️ Returns

(string)

🔧 generateTotalDevis

Méthode pour générer les infos du devis formatté
function generateTotalDevis(): string { $infoDevis = $this->getDevisInfos(); $html = '<div style="display: flex; justify-content: space-between; line-height: 0; width: 100%;">'; $html .= '<p style="text-align: left;"><strong>Total HT : </strong></p>'; $html .= '<p style="text-align: right;"><strong>' . number_format($infoDevis['att7'], 2, '.', '') . ' €</strong></p>'; $html .= '</div>'; $html .= $this->generateTauxTVA(); /* $html .= '<div style="display: flex; justify-content: space-between; line-height: 1em; width: 100%;">'; $html .= '<p style="text-align: left;">Total TVA</p>'; $html .= '<p style="text-align: right;">' . number_format($infoDevis['att8'], 2, '.', '') . ' €</p>'; $html .= '</div>'; */ if ($infoDevis['att27'] != "" && $infoDevis['att27'] != 0) { $html .= '<div style="display: flex; justify-content: space-between; line-height: 0; width: 100%;">'; // ... (truncated)

↩️ Returns

(string)

🔧 getCGVByTypeUser

Fonction permettant de récupérer dynamiquement le fichier CVG
function getCGVByTypeUser($cooperative_id = null): array{ if (!empty(array_intersect_key($this->identification, array_flip(["isCommercial", "isSuperAdmin", "isFranchise", "isFranchiseur"])))) { $cgv = $this->getCGV($this->identification, $cooperative_id); }else{ $cgv = [ 'response'=> false, 'message'=> 'Objet appartenant ni à une franchise ni à un franchiseur', 'document'=>null ]; } // ... (truncated)

↩️ Returns

(array) [response, message, document]

🔧 getCGV

Fonction permettant de retourner le fichier CGV correspondant à la franchise de l'objet ou au franchiseur si pas de cgv franchisé Dépendance: - setting objet devis (code : franchise, key : id & code: configuration, key id_type) - fiche configuration réseau Lors de la création d'un projet créer une fiche configuration réseau et ajouter le document CGV du franchiseur Paramétrer le setting (dans l'objet devis) code : configuration, key : id_type avec l'id_type de l'objet configuration réseau Paramétrer le setting (dans l'objet devis) code : franchise, key id : avec l'id_type de l'objet franchise Paramétrer le typage Document pour la franchise et la configuration réseau avec 'cgv'
function getCGV($userIdentification, $cooperative_id = null) : array { $wcFile= array(); $wcFile[]="specif = 'cgv'"; $id_obje = $userIdentification['obje']['franchise_obje']['id_obje']; $id_type = MapperDevis::FRANCHISE_ID_TYPE($this->id_type); if($cooperative_id){ $id_obje = $cooperative_id; $id_type = "175"; } $fileCGV = array_values(fwc7_data_files('', $id_type, $id_obje, '1',$wcFile)); // ... (truncated)

↩️ Returns

(array) (response-> document trouvé ou non, message-> appartenance du fichier cgv ou message d'erreur,document-> [chemin de fichier, id fichier, nom fichier, pdf?] )