trigger_commande

🔧 calcul_ligne_de_commande

Trigger Commande Script This script handles triggers and automated actions for the Commande (order) object. It calculates order line prices, updates order totals, and synchronizes order data with external calendars to manage interventions. The script supports: - Calculating prices with taxes and discounts - Automatic updating of order totals when line items change - Calendar synchronization for intervention scheduling
function calcul_ligne_de_commande($lig): array{ /// valeurs modifiables par l'utilisateur :::: /// Quantité == Quantité lig3 /// Prix Unitaire HT == Prix Unitaire HT lig2 /// TVA lig5 /// Remise en [Euros TTC, Pourcentage] lig10 /// Remise TTC --> impact Total Rémisé TTC lig11 /// :::: /// lig8 = Total TTC sans remise // calcul du prix total HT $lig['lig4'] = (float)$lig['lig2'] * (float)$lig['lig3']; // eteko AOR : int => Float pour les décimales // calcul du prix total TTC $lig['lig8'] = $lig['lig4'] + ($lig['lig4'] * (float)$lig['lig5'] / 100); $type_remise = (string)$lig['lig10']; // calcul du Prix Remisé en fonction du type de Remise if($type_remise == "euro"){ $totalTTCRemise = !empty($lig['lig11']) ? $lig['lig8'] - $lig['lig11'] : $lig['lig8']; } elseif ($type_remise == "pourcentage"){ $totalTTCRemise = !empty($lig['lig11']) ? $lig['lig8'] * (1 - ((float)$lig['lig11'] / 100)) : $lig['lig8']; } else { $totalTTCRemise = "0"; // ... (truncated)

🔧 calcul_ligne_de_commande

function calcul_ligne_de_commande($lig): array{ /// valeurs modifiables par l'utilisateur :::: /// Quantité == Quantité lig3 /// Prix Unitaire HT == Prix Unitaire HT lig2 /// TVA lig5 /// Remise en [Euros TTC, Pourcentage] lig10 /// Remise TTC --> impact Total Rémisé TTC lig11 /// :::: /// lig8 = Total TTC sans remise // calcul du prix total HT $lig['lig4'] = (float)$lig['lig2'] * (float)$lig['lig3']; // eteko AOR : int => Float pour les décimales // calcul du prix total TTC $lig['lig8'] = $lig['lig4'] + ($lig['lig4'] * (float)$lig['lig5'] / 100); $type_remise = (string)$lig['lig10']; // calcul du Prix Remisé en fonction du type de Remise if($type_remise == "euro"){ $totalTTCRemise = !empty($lig['lig11']) ? $lig['lig8'] - $lig['lig11'] : $lig['lig8']; } elseif ($type_remise == "pourcentage"){ $totalTTCRemise = !empty($lig['lig11']) ? $lig['lig8'] * (1 - ((float)$lig['lig11'] / 100)) : $lig['lig8']; } else { $totalTTCRemise = "0"; // ... (truncated)

↩️ Returns

(array)

🔧 fwt_TS_NOOA_COMMANDE_trigger_att

Main trigger function for handling attribute changes in Commande objects This function is called when attributes of a commande object are modified. It recalculates totals and manages calendar synchronization.
function fwt_TS_NOOA_COMMANDE_trigger_att($id_type, $id_obje) { $type_id_devis = 165; $devis = fwc7_data_objet_att('',$type_id_devis,fwc7_data_objet_att('',$id_type,$id_obje)["att14"]); $CommandeManager = new CommandeManager_Nooa($id_type,$id_obje); global $global_modified_attX; $tlig_id = fwp7_param_objet_setting_get('',$id_type,'commande','tlig'); // Dans le cas d'une modification d'une ligne if($global_modified_attX[$id_obje]){ $ligs = $CommandeManager->getLignesDeProduits(); // Initialize result array to store calculated totals $result = [ "totalHT"=> 0, // ... (truncated)

⚙️ Parameters

↩️ Returns

(void)

🔧 handleCalendarCreation

Handles creation or update of calendar events for commande objects This function creates or updates a calendar event when specific commande attributes are modified (date_intervention, duration, nb_contributor, adresse).
function handleCalendarCreation($id_type, $id_obje) { global $global_message; global $user; // Input validation if (empty($id_type) || !is_numeric($id_type) || empty($id_obje) || !is_numeric($id_obje)) { error_log("Invalid parameters provided to handleCalendarCreation: id_type=$id_type, id_obje=$id_obje"); return; } if (!isset($user) || empty($user->id)) { error_log("Missing user information in handleCalendarCreation"); return; // ... (truncated)

⚙️ Parameters

↩️ Returns

(void)