Initialise le service avec les données nécessaires
function __construct($id_type, $id_obje) {
$this->DIR = __DIR__;
$this->typeDevis = $id_type;
$this->idDevis = $id_obje;
// Vérifie si une commande existe déjà
$this->verifierCommandeExistante();
// Si pas de commande existante, charge les données du devis
if (!$this->commandeExistante) {
$this->chargerDonneesDevis();
} else {
//$this->Notifaction("Commande déjà existante", "warning");
}
}
function creerCommande() {
if ($this->commandeExistante) {
return false; // Si la commande existe on retourne false
}
try {
// Création de l'en-tête de la commande
$idClient = fwc7_data_att_getraw('', MapperCommande::TYPE_OPPORTUNITE($this->typeDevis), $this->devis['att1'], "att2");
$donneesCommande = [
'att4' => 'TEMPNUM',
'att1' => $this->devis['att17'],
'att90' => $this->devis['att13'],
'att3' => $this->devis['att90'],
// ... (truncated)
↩️ Returns
(int|false) L'ID de la commande créée ou false si échec
🔧 creerLignesCommande
Crée les lignes de la commande
function creerLignesCommande() {
foreach ($this->lignes as $ligne) {
$donneesLigne = [
'lig3' => $ligne['lig3'], // Quantité
'lig2' => $ligne['lig2'], // Prix unitaire
'lig1' => $ligne['lig1'], // Produit (non spé)
'lig4' => $ligne['lig4'], // Total HT
'lig5' => $ligne['lig5'], // Taux TVA
'lig6' => $ligne['lig15'], // Total TTC Remisé
'lig7' => $ligne['lig6'], // Total TVA
'lig8' => $ligne['lig7'], // Total TTC
'lig90' => $ligne['lig90'], // Description
'lig9' => $ligne['lig10'], // Produit (spé)
'lig10' => $ligne['lig9'], // Type remise
'lig11' => $ligne['lig14'], // Remise TTC ou Euros
];
// il y a t-il des unités dans les ligne de devis ? alors on les reprends dans les lignes de commande
$uniteDevis = fwp7_param_template_lig_get_number('',$this->typeDevis, fwp7_param_objet_setting_get('',$this->typeDevis,'devis','id_lig'),'unite');
$uniteCommande = fwp7_param_template_lig_get_number('','168',fwp7_param_objet_setting_get('','168','commande','tlig'),'unite');
if (!empty($uniteDevis) && !empty($uniteCommande)) {
$donneesLigne[$uniteCommande] = $ligne[$uniteDevis];
}
// ... (truncated)
⚠️ Throws
Exception: Si erreur pendant la création des lignes