CommandeManager

🔧 __construct

Constructeur
function __construct($id_type, $id_obje, $contexte="") { $this->id_type = $id_type; $this->id_obje = $id_obje; $this->lignesDeProduit = fwc7_data_objet_ligs('',$this->id_type, $this->id_obje,Mapper_______________Commande::TLIG_COMMANDE_LIGNES($this->id_type),'','1',[]); $this->initialiserCommande($contexte); }

🔧 initialiserCommande

Initialise les données de la commande
function initialiserCommande($contexte) { $this->commande = fwc7_data_objet_att('',ConfigurationCommande::ID_TYPE_COMMANDE,$this->id_obje); $this->client = fwc7_data_objet_att('',ConfigurationCommande::ID_TYPE_CLIENT,$this->commande['att5']); if(isset($contexte)){ $this->adressType = $this->getAdressType($contexte); } $this->civilites = fwc7_data_liste_valeurs('','2','value',array('label')); $this->replicationTVA = fwp7_param_params_detail('','replication_taux_tva_ligne_de_produit'); }

🔧 getAddressData

Récupère l'adresse d'intervention ou l'adresse de facturation depuis le devis et la formatte
function getAddressData() { $adressFields = ($this->adressType=='FACTURATION') ?['25','26','27','28'] // att des champs de facturation :['17']; // att champ intervention return [ 'adresseLigne1'=> $this->commande['att'.$adressFields[0]], 'adresseLigne2'=> $this->commande['att'.$adressFields[1]], 'cp'=> $this->commande['att'.$adressFields[2]], 'ville'=> $this->commande['att'.$adressFields[3]], 'pays'=> $this->commande['att'.$adressFields[4]], ]; // ... (truncated)

↩️ Returns

(array)

🔧 handleAdresseFacturation

Créer l'adresse de facturation dans le devis
function handleAdresseFacturation($datas = []) { // Recopie adresse de facturation $datas['att25'] = $this->client["att14"]; // Adresse $datas['att26'] = $this->client["att15"]; // complement $datas['att27'] = $this->adresseIntervention["att7"]; // Code Postal $datas['att28'] = $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)

🔧 handleEmail

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

↩️ Returns

(mixed)

🔧 handleEntiteInfo

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

⚙️ Parameters

↩️ Returns

(array)

🔧 generateAdresseVendeur

Crée l'adresse du vendeur au moment de la création de la commande
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)

🔧 creerCommande

Méthode principale pour créer la commande
function creerCommande() { $datas = $this->handleAdresseFacturation(); $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>'; $html .= $this->formatClientHeader(); $html .= $this->formatAddress($addressData); $html .= '</div>'; $html .= $this->formatPhone(); $html .= $this->formatVatNumber(); return $html; }

↩️ Returns

(string)

🔧 verificationPresenceDocuments

Méthode pour la vérification de présence de documents Retourne true si les documents demandé sont présent autrement false Si mode attestation activé alors on demande obligatoirement le chargmeent de l'attestation sinon on demande juste le devis signé
function verificationPresenceDocuments($this_devis_obje): array { $att_attestation_fiscale = fwp7_param_template_att_get_number('', $this_devis_obje['id_type'], 'is_attestation_necessaire'); $is_att_fiscale = $this_devis_obje[$att_attestation_fiscale]; // Récupération des fichiers présent dans la commande $listFile = fwc7_data_files('', '168', $this->id_obje, '1', ''); // Checks files $documentTypes = []; foreach ($listFile as $file) { if (array_key_exists('specif', $file) && in_array($file['specif'], ['devis_signe', 'attestation_signe'])) { $documentTypes[] = $file['specif']; } } // ... (truncated)

↩️ Returns

(array)

🔧 submit_SECTION_Totals

Soumet et met à jour les totaux de SECTION Cette fonction gère les lignes de SECTION d'un document. Pour chaque SECTION, elle vérifie si une ligne existe déjà dans le document et la crée, met à jour ou supprime selon le cas. Le comportement est le suivant : - Si un taux de TVA a un montant > 0 dans les totaux : créer/restaurer et mettre à jour la ligne - Si un taux de TVA a un montant = 0 ou n'apparaît pas dans les totaux : supprimer la ligne
function submit_SECTION_Totals(): bool { // Environnement $environnement = fwp7_param_params_detail("",'franchiseur_nom'); // Recap SECTION tlig if ($environnement == 'Rainea') { $tlig_produit = fwp7_param_template_tlg_get_number('', $this->id_type, 'tlig_commande'); $att_is_section = fwp7_param_template_lig_get_number('', $this->id_type, $tlig_produit, 'ligne_section'); } else if ($environnement == 'Exteco') { $tlig_produit = fwp7_param_template_tlg_get_number('', $this->id_type, 'ligne_de_documents'); $att_is_section = fwp7_param_template_lig_get_number('', $this->id_type, $tlig_produit, 'ligne_section'); } $tlig_recap_section = fwp7_param_template_tlg_get_number('', $this->id_type, 'lignes_de_section'); // ... (truncated)

↩️ Returns

(bool) Retourne true en cas de succès, false en cas d'erreur

🔧 updateCodeComptable

Mise à jour du compte comptable PRODUIT et TVA sur les lignes du chantier/commande Mise à jour du montant TVA sur les lignes du chantier/commande Mise à jour du code client sur le chantier/commande
function updateCodeComptable(){ $attCodeClient = fwp7_param_template_att_get_number('', $this->id_type, 'code_comptable_client'); // Si le code client est vide on le rajoute if (empty($this->commande[$attCodeClient])) { $attCodeClientsurClient = fwp7_param_template_att_get_number('', $this->client['id_type'], 'compte_comptable_client'); if (!empty($this->client[$attCodeClientsurClient])) { $dataClient = [ $attCodeClient => $this->client[$attCodeClientsurClient] ]; fwc7_modify_att_edit('', $this->id_type, $this->id_obje, $dataClient); } // ... (truncated)

↩️ Returns

(void)