public function defalquer_stock($retourenstock = false) { try { $modules = new Modules(); if ($modules->charger_id($this->paiement)) { $modpaiement = ActionsModules::instance()->instancier($modules->nom); if ($retourenstock) { $defalquer = $modpaiement->defalqcmd != 0 || $modpaiement->defalqcmd == 0 && $this->statut != self::NONPAYE; } else { $defalquer = $modpaiement->defalqcmd == 0; } if ($defalquer) { $delta = $retourenstock ? 1 : -1; $venteprod = new Venteprod(); $query = "select * from {$venteprod->table} where commande='" . $this->id . "'"; $resul = $venteprod->query($query); while ($resul && ($row = $venteprod->fetch_object($resul))) { // Mise à jour du stock général $produit = new Produit($row->ref); $produit->stock += $delta * $row->quantite; $produit->maj(); $vdec = new Ventedeclidisp(); $query2 = "select * from {$vdec->table} where venteprod='" . $row->id . "'"; $resul2 = $vdec->query($query2); while ($resul2 && ($row2 = $vdec->fetch_object($resul2))) { $stock = new Stock(); // Mise à jour du stock des declinaisons if ($stock->charger($row2->declidisp, $produit->id)) { $stock->valeur += $delta * $row->quantite; $stock->maj(); } } } } } } catch (Exception $ex) { // Rien } }
function liste_parent($parent, $niveau, $commande, $grandParent, $debutLie = 0) { global $deco, $listePassee; $venteprod = new Venteprod(); $query = "select * from {$venteprod->table} where commande='{$commande->id}' AND parent='{$parent}'"; $resul = $venteprod->query($query); $memFin = ""; while ($resul && ($row = $venteprod->fetch_object($resul))) { $venteprod->charger($row->id); $baseIndentation = 25; $paddingIndentation = 5; //base $largeurDesignation = 399; $indentation = ""; if ($debutLie) { $indentation = "╓"; } elseif ($grandParent != 0 && $grandParent == $venteprod->id) { $indentation = "╙"; } elseif ($niveau > 0) { /*for($niv=0;$niv<$niveau;$niv++) { $indentation .= " "; }*/ $paddingIndentation += $baseIndentation * $niveau; $indentation .= "↳"; } $largeurDesignation -= $paddingIndentation; $produit = new Produit(); $produitdesc = new Produitdesc(); $produit->charger($venteprod->ref); $produitdesc->charger($produit->id); $rubrique = new Rubrique(); $rubrique->charger($produit->rubrique); $rubriquedesc = new Rubriquedesc(); $rubriquedesc->charger($rubrique->id); if ($rubriquedesc->titre != "") { $titrerub = $rubriquedesc->titre; } else { $titrerub = "//"; } if (!($deco % 2)) { $fond = "ligne_fonce_BlocDescription"; } else { $fond = "ligne_claire_BlocDescription"; } $listePassee[] = $venteprod->id; if ($grandParent != 0 && $grandParent == $venteprod->id) { $memFin = "<ul class=\"__COULEUR_FOND__\">\n\t\t\t\t<li style=\"width:" . $largeurDesignation . "px;padding-left:" . $paddingIndentation . "px\">{$indentation} {$venteprod->ref} - {$titrerub} - " . str_replace("\n", "<br />", $venteprod->titre) . "</li>\n\t\t\t\t<li style=\"width:73px;\">" . round($venteprod->prixu, 2) . "</li>\n\t\t\t\t<li style=\"width:23px;\">" . $venteprod->quantite . "</li>\n\t\t\t\t<li style=\"width:20px;\">" . round($venteprod->quantite * $venteprod->prixu, 2) . "</li>\n\t\t\t\t</ul>"; } else { $deco++; ?> <ul class="<?php echo $fond; ?> "> <li style="width:<?php echo $largeurDesignation; ?> px; padding-left:<?php echo $paddingIndentation; ?> px;"><?php echo $indentation . " " . $venteprod->ref . " - " . $titrerub; ?> - <?php echo str_replace("\n", "<br />", $venteprod->titre); ?> </li> <li style="width:73px;"><?php echo round($venteprod->prixu, 2); ?> </li> <li style="width:23px;"><?php echo $venteprod->quantite; ?> </li> <li style="width:20px;"><?php echo round($venteprod->quantite * $venteprod->prixu, 2); ?> </li> </ul> <?php } if ($grandParent != $venteprod->id) { liste_parent($venteprod->id, $niveau + 1, $commande, $parent); } } if ($memFin != "") { if (!($deco % 2)) { $fond = "ligne_fonce_BlocDescription"; } else { $fond = "ligne_claire_BlocDescription"; } $deco++; echo str_replace("__COULEUR_FOND__", $fond, $memFin); } }
public function createOrder($facturation_raison, $facturation_entreprise, $facturation_nom, $facturation_prenom, $facturation_adresse1, $facturation_adresse2, $facturation_adresse3, $facturation_cpostal, $facturation_ville, $facturation_tel, $facturation_pays, $livraison_raison, $livraison_entreprise, $livraison_nom, $livraison_prenom, $livraison_adresse1, $livraison_adresse2, $livraison_adresse3, $livraison_cpostal, $livraison_ville, $livraison_tel, $livraison_pays, $type_paiement, $type_transport, $fraisport, $remise, $client_selected, $ref_client, $email, \Panier $panier, $applyClientDiscount, $callMail, $callPayment) { $client = new Client(); if ($client_selected == 1) { $clientOK = $client->charger_ref($ref_client); } else { if ($email != '' && $client->charger_mail($email)) { $existeDeja = 1; } elseif ($email != '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) { $badFormat = 1; } else { $client->email = $email; $client->raison = $facturation_raison; $client->entreprise = $facturation_entreprise; $client->prenom = $facturation_prenom; $client->nom = $facturation_nom; $client->adresse1 = $facturation_adresse1; $client->adresse2 = $facturation_adresse2; $client->adresse3 = $facturation_adresse3; $client->cpostal = $facturation_cpostal; $client->ville = $facturation_ville; $client->tel = $facturation_tel; $client->pays = $facturation_pays; $pass = genpass(8); $client->motdepasse = $pass; } } $facturationAddress = new Venteadr(); $facturationAddress->raison = $facturation_raison; $facturationAddress->entreprise = $facturation_entreprise; $facturationAddress->prenom = $facturation_prenom; $facturationAddress->nom = $facturation_nom; $facturationAddress->adresse1 = $facturation_adresse1; $facturationAddress->adresse2 = $facturation_adresse2; $facturationAddress->adresse3 = $facturation_adresse3; $facturationAddress->cpostal = $facturation_cpostal; $facturationAddress->ville = $facturation_ville; $facturationAddress->tel = $facturation_tel; $facturationAddress->pays = $facturation_pays; $livraisonAddress = new Venteadr(); $livraisonAddress->raison = $livraison_raison; $livraisonAddress->entreprise = $livraison_entreprise; $livraisonAddress->prenom = $livraison_prenom; $livraisonAddress->nom = $livraison_nom; $livraisonAddress->adresse1 = $livraison_adresse1; $livraisonAddress->adresse2 = $livraison_adresse2; $livraisonAddress->adresse3 = $livraison_adresse3; $livraisonAddress->cpostal = $livraison_cpostal; $livraisonAddress->ville = $livraison_ville; $livraisonAddress->tel = $livraison_tel; $livraisonAddress->pays = $livraison_pays; $order = new Commande(); $order->date = date("Y-m-d H:i:s"); $order->livraison = "L" . date("ymdHis") . strtoupper(ereg_caracspec(substr($client->prenom, 0, 3))); $order->transport = $type_transport; $order->paiement = $type_paiement; $order->statut = Commande::NONPAYE; $order->transaction = genid($order->id, 6); $module_paiement = new Modules(); $module_paiement->charger_id($type_paiement); if ($facturationAddress->raison != "" && $facturationAddress->prenom != "" && $facturationAddress->nom != "" && $facturationAddress->adresse1 != "" && $facturationAddress->cpostal != "" && $facturationAddress->ville != "" && $facturationAddress->pays != "" && $livraisonAddress->raison != "" && $livraisonAddress->prenom != "" && $livraisonAddress->nom != "" && $livraisonAddress->adresse1 != "" && $livraisonAddress->cpostal != "" && $livraisonAddress->ville != "" && $livraisonAddress->pays != "" && $order->transport != "" && is_numeric($fraisport) && $fraisport >= 0 && is_numeric($remise) && $remise >= 0 && $module_paiement->actif && $order->paiement != "" && $panier->nbart > 0 && ($clientOK || $client_selected != 1 && !$existeDeja && !$badFormat) && $email != '') { $facturationAddress->id = $facturationAddress->add(); $livraisonAddress->id = $livraisonAddress->add(); if (!$client->id) { $client->crypter(); $client->id = $client->add(); $client->ref = date("ymdHi") . genid($client->id, 6); $client->maj(); ClientAdmin::getInstance()->sendMailCreation($client, $pass); } $devise = ActionsDevises::instance()->get_devise_courante(); $order->adrfact = $facturationAddress->id; $order->adrlivr = $livraisonAddress->id; $order->client = $client->id; $order->devise = $devise->id; $order->taux = $devise->taux; $order->lang = ActionsLang::instance()->get_id_langue_courante(); $order->id = $order->add(); $order->ref = "C" . date("ymdHi") . genid($order->id, 6); $order->maj(); $total = 0; foreach ($panier->tabarticle as $pos => $article) { $venteprod = new Venteprod(); $dectexte = "\n"; $stock = new Stock(); foreach ($article->perso as $perso) { $declinaison = new Declinaison(); $declinaisondesc = new Declinaisondesc(); if (is_numeric($perso->valeur) && ActionsModules::instance()->instancier($module_paiement->nom)->defalqcmd) { // diminution des stocks de déclinaison si on est sur un module de paiement qui défalque de suite $stock->charger($perso->valeur, $article->produit->id); $stock->valeur -= $article->quantite; $stock->maj(); } $declinaison->charger($perso->declinaison); $declinaisondesc->charger($declinaison->id); // recup valeur declidisp ou string if ($declinaison->isDeclidisp($perso->declinaison)) { $declidisp = new Declidisp(); $declidispdesc = new Declidispdesc(); $declidisp->charger($perso->valeur); $declidispdesc->charger_declidisp($declidisp->id); $dectexte .= "- " . $declinaisondesc->titre . " : " . $declidispdesc->titre . "\n"; } else { $dectexte .= "- " . $declinaisondesc->titre . " : " . $perso->valeur . "\n"; } } // diminution des stocks classiques si on est sur un module de paiement qui défalque de suite $produit = new Produit($article->produit->ref); if (ActionsModules::instance()->instancier($module_paiement->nom)->defalqcmd) { $produit->stock -= $article->quantite; $produit->maj(); } $venteprod->quantite = $article->quantite; $venteprod->prixu = $article->produit->prix; $venteprod->ref = $article->produit->ref; $venteprod->titre = $article->produitdesc->titre . " " . $dectexte; $venteprod->chapo = $article->produitdesc->chapo; $venteprod->description = $article->produitdesc->description; $venteprod->tva = $article->produit->tva; $venteprod->commande = $order->id; $venteprod->id = $venteprod->add(); $correspondanceParent[] = $venteprod->id; // ajout dans ventedeclisp des declidisp associées au venteprod foreach ($article->perso as $perso) { $declinaison = new Declinaison(); $declinaison->charger($perso->declinaison); // si declidisp (pas un champs libre) if ($declinaison->isDeclidisp($perso->declinaison)) { $vdec = new Ventedeclidisp(); $vdec->venteprod = $venteprod->id; $vdec->declidisp = $perso->valeur; $vdec->add(); } } ActionsModules::instance()->appel_module("apresVenteprodAdmin", $venteprod, $pos); $total += $venteprod->prixu * $venteprod->quantite; } foreach ($correspondanceParent as $id_panier => $id_venteprod) { if ($panier->tabarticle[$id_panier]->parent >= 0) { $venteprod->charger($id_venteprod); $venteprod->parent = $correspondanceParent[$panier->tabarticle[$id_panier]->parent]; $venteprod->maj(); } } if ($client->pourcentage > 0 && $applyClientDiscount) { $order->remise = $total * $client->pourcentage / 100; } $order->remise += $remise; if ($order->remise > $total) { $order->remise = $total; } $order->port = $fraisport; $order->maj(); ActionsModules::instance()->appel_module("aprescommandeadmin", $order); if ($callMail) { ActionsModules::instance()->instancier($module_paiement->nom)->mail($order); } if ($callPayment) { ActionsModules::instance()->instancier($module_paiement->nom)->paiement($order); } else { self::getInstance($order->id)->redirect(); } } else { if ($existeDeja) { throw new TheliaAdminException("error creating order", TheliaAdminException::EMAIL_ALREADY_EXISTS); } if ($badFormat) { throw new TheliaAdminException("error creating order", TheliaAdminException::EMAIL_FORMAT_ERROR); } else { throw new TheliaAdminException("error creating order", TheliaAdminException::ORDER_ADD_ERROR); } } }
$adr->ville = $client->ville; $adr->tel = $client->telfixe . " " . $client->telport; $adr->pays = $client->pays; $adrcli = $adr->add(); $commande->adrfact = $adrcli; $commande->adrlivr = $adrcli; $commande->facture = 0; $commande->lang = ActionsLang::instance()->get_id_langue_courante(); $devise = ActionsDevises::instance()->get_devise_courante(); $commande->devise = $devise->id; $commande->taux = $devise->taux; $idcmd = $commande->add(); $commande->charger($idcmd); for ($i = 0; $i < $nbart; $i++) { $produit = new Produit(); $venteprod = new Venteprod(); if ($produit->charger($sessionventeprod[$i]->ref)) { $produit->stock -= $sessionventeprod[$i]->quantite; $poids += $produit->poids; $produit->maj(); } $venteprod->ref = $sessionventeprod[$i]->ref; $venteprod->titre = $sessionventeprod[$i]->titre; $venteprod->quantite = $sessionventeprod[$i]->quantite; $venteprod->tva = $sessionventeprod[$i]->tva; $venteprod->prixu = $sessionventeprod[$i]->prixu; $venteprod->commande = $idcmd; $venteprod->add(); $total += $venteprod->prixu * $venteprod->quantite; } $commande->remise = 0;
public function substitmail($corps, $commande) { ActionsModules::instance()->appel_module("preSubstitmail", $corps, $commande); $nomsite = Variable::lire("nomsite"); $jour = substr($commande->date, 8, 2); $mois = substr($commande->date, 5, 2); $annee = substr($commande->date, 0, 4); $heure = substr($commande->date, 11, 2); $minute = substr($commande->date, 14, 2); $seconde = substr($commande->date, 17, 2); $client = new Client($commande->client); $paiement = new Modules($commande->paiement); $paiementdesc = new Modulesdesc($paiement->nom, $commande->lang); $transport = new Modules($commande->transport); $transportdesc = new Modulesdesc($transport->nom, $commande->lang); $total = $commande->total(); $totcmdport = $commande->port + $total; $adresse = new Venteadr($commande->adrlivr); $raisondesc = new Raisondesc(); $raisondesc->charger($adresse->raison, $commande->lang); $nom = $adresse->nom; $prenom = $adresse->prenom; $entreprise = $adresse->entreprise; $adresse1 = $adresse->adresse1; $adresse2 = $adresse->adresse2; $adresse3 = $adresse->adresse3; $cpostal = $adresse->cpostal; $ville = $adresse->ville; $pays = new Paysdesc($adresse->pays, $commande->lang); $corps = str_replace("__COMMANDE_REF__", $commande->ref, $corps); $corps = str_replace("__COMMANDE_DATE__", $jour . "/" . $mois . "/" . $annee, $corps); $corps = str_replace("__COMMANDE_HEURE__", $heure . ":" . $minute, $corps); $corps = str_replace("__COMMANDE_TRANSACTION__", $commande->transaction, $corps); $corps = str_replace("__COMMANDE_PAIEMENT__", $paiementdesc->titre, $corps); $corps = str_replace("__COMMANDE_TOTALPORT__", $totcmdport - $commande->remise, $corps); $corps = str_replace("__COMMANDE_TOTAL__", $total, $corps); $corps = str_replace("__COMMANDE_PORT__", $commande->port, $corps); $corps = str_replace("__COMMANDE_REMISE__", $commande->remise, $corps); $corps = str_replace("__COMMANDE_TRANSPORT__", $transportdesc->titre, $corps); $corps = str_replace("__COMMANDE_TRANSPORTCHAPO__", $transportdesc->chapo, $corps); $corps = str_replace("__COMMANDE_LIVRRAISON__", $raisondesc->court, $corps); $corps = str_replace("__COMMANDE_LIVRNOM__", $nom, $corps); $corps = str_replace("__COMMANDE_LIVRPRENOM__", $prenom, $corps); $corps = str_replace("__COMMANDE_LIVRENTREPRISE__", $entreprise, $corps); $corps = str_replace("__COMMANDE_LIVRADRESSE1__", $adresse1, $corps); $corps = str_replace("__COMMANDE_LIVRADRESSE2__", $adresse2, $corps); $corps = str_replace("__COMMANDE_LIVRADRESSE3__", $adresse3, $corps); $corps = str_replace("__COMMANDE_LIVRCPOSTAL__", $cpostal, $corps); $corps = str_replace("__COMMANDE_LIVRVILLE__", $ville, $corps); $corps = str_replace("__COMMANDE_LIVRPAYS__", $pays->titre, $corps); $corps = str_replace("__COMMANDE_LIVRTEL__", $adresse->tel, $corps); $corps = str_replace("__NOMSITE__", $nomsite, $corps); $corps = str_replace("__URLSITE__", urlfond(), $corps); $adresse = new Venteadr($commande->adrfact); $raisondesc = new Raisondesc(); $raisondesc->charger($adresse->raison); $pays = new Paysdesc(); $pays->charger($adresse->pays); $corps = str_replace("__CLIENT_REF__", $client->ref, $corps); $corps = str_replace("__CLIENT_RAISON__", $raisondesc->court, $corps); $corps = str_replace("__CLIENT_ENTREPRISE__", $client->entreprise, $corps); $corps = str_replace("__CLIENT_SIRET__", $client->siret, $corps); $corps = str_replace("__CLIENT_FACTNOM__", $adresse->nom, $corps); $corps = str_replace("__CLIENT_FACTPRENOM__", $adresse->prenom, $corps); $corps = str_replace("__CLIENT_ADRESSE1__", $adresse->adresse1, $corps); $corps = str_replace("__CLIENT_ADRESSE2__", $adresse->adresse2, $corps); $corps = str_replace("__CLIENT_ADRESSE3__", $adresse->adresse3, $corps); $corps = str_replace("__CLIENT_CPOSTAL__", $adresse->cpostal, $corps); $corps = str_replace("__CLIENT_VILLE__", $adresse->ville, $corps); $corps = str_replace("__CLIENT_PAYS__", $pays->titre, $corps); $corps = str_replace("__CLIENT_EMAIL__", $client->email, $corps); $corps = str_replace("__CLIENT_TELFIXE__", $client->telfixe, $corps); $corps = str_replace("__CLIENT_TELPORT__", $client->telport, $corps); $pattern = '{<VENTEPROD>((?:(?:(?!<VENTEPROD[^>]*>|</VENTEPROD>).)++|<VENTEPROD[^>]*>(?1)</VENTEPROD>)*)</VENTEPROD>}si'; if (preg_match($pattern, $corps, $cut)) { $corps = str_replace("<VENTEPROD>", "", $corps); $corps = str_replace("</VENTEPROD>", "", $corps); $res = ""; $venteprod = new Venteprod(); $query = "select * from {$venteprod->table} where commande=\"" . $commande->id . "\""; $resul = $venteprod->query($query); while ($resul && ($row = $venteprod->fetch_object($resul))) { $temp = str_replace("__VENTEPROD_TITRE__", $row->titre, $cut[1]); $temp = str_replace("__VENTEPROD_REF__", $row->ref, $temp); $temp = str_replace("__VENTEPROD_CHAPO__", $row->chapo, $temp); $temp = str_replace("__VENTEPROD_QUANTITE__", $row->quantite, $temp); $temp = str_replace("__VENTEPROD_PRIXU__", $row->prixu, $temp); $temp = str_replace("__VENTEPROD_TOTAL__", $row->prixu * $row->quantite, $temp); ActionsModules::instance()->appel_module("substitutionsventeprodmailcommande", $temp, $row); $res .= $temp; } $corps = str_replace($cut[1], $res, $corps); } // Substitutions mail "devise" $devise = new Devise($commande->devise); ActionsDevises::instance()->subsititutions_mail($devise, $corps); ActionsModules::instance()->appel_module("substitutionsmailcommande", $corps, $commande); return $corps; }
function paiement($type_paiement) { if (!$_SESSION['navig']->client->id || $_SESSION['navig']->panier->nbart < 1) { redirige(urlfond()); } $total = 0; $nbart = 0; $poids = 0; $unitetr = 0; ActionsModules::instance()->appel_module("avantcommande"); $modules = new Modules(); $modules->charger_id($type_paiement); if (!$modules->actif) { return 0; } try { $modpaiement = ActionsModules::instance()->instancier($modules->nom); $commande = new Commande(); $commande->transport = $_SESSION['navig']->commande->transport; $commande->client = $_SESSION['navig']->client->id; $commande->remise = 0; $devise = ActionsDevises::instance()->get_devise_courante(); $commande->devise = $devise->id; $commande->taux = $devise->taux; $client = new Client(); $client->charger_id($_SESSION['navig']->client->id); $adr = new Venteadr(); $adr->raison = $client->raison; $adr->entreprise = $client->entreprise; $adr->nom = $client->nom; $adr->prenom = $client->prenom; $adr->adresse1 = $client->adresse1; $adr->adresse2 = $client->adresse2; $adr->adresse3 = $client->adresse3; $adr->cpostal = $client->cpostal; $adr->ville = $client->ville; $adr->tel = $client->telfixe . " " . $client->telport; $adr->pays = $client->pays; $adrcli = $adr->add(); $commande->adrfact = $adrcli; $adr = new Venteadr(); $livraison = new Adresse(); if ($livraison->charger($_SESSION['navig']->adresse)) { $adr->raison = $livraison->raison; $adr->entreprise = $livraison->entreprise; $adr->nom = $livraison->nom; $adr->prenom = $livraison->prenom; $adr->adresse1 = $livraison->adresse1; $adr->adresse2 = $livraison->adresse2; $adr->adresse3 = $livraison->adresse3; $adr->cpostal = $livraison->cpostal; $adr->ville = $livraison->ville; $adr->tel = $livraison->tel; $adr->pays = $livraison->pays; } else { $adr->raison = $client->raison; $adr->entreprise = $client->entreprise; $adr->nom = $client->nom; $adr->prenom = $client->prenom; $adr->adresse1 = $client->adresse1; $adr->adresse2 = $client->adresse2; $adr->adresse3 = $client->adresse3; $adr->cpostal = $client->cpostal; $adr->ville = $client->ville; $adr->tel = $client->telfixe . " " . $client->telport; $adr->pays = $client->pays; } $adrlivr = $adr->add(); $commande->adrlivr = $adrlivr; $commande->facture = 0; $commande->statut = Commande::NONPAYE; $commande->paiement = $type_paiement; $commande->lang = ActionsLang::instance()->get_id_langue_courante(); $commande->id = $commande->add(); $pays = new Pays(); $pays->charger($adr->pays); $correspondanceParent = array(null); foreach ($_SESSION['navig']->panier->tabarticle as $pos => &$article) { $venteprod = new Venteprod(); $dectexte = "\n"; $produit = new Produit(); $stock = new Stock(); foreach ($article->perso as $perso) { $declinaison = new Declinaison(); $declinaisondesc = new Declinaisondesc(); if (is_numeric($perso->valeur) && $modpaiement->defalqcmd) { // diminution des stocks de déclinaison si on est sur un module de paiement qui défalque de suite $stock->charger($perso->valeur, $article->produit->id); $stock->valeur -= $article->quantite; $stock->maj(); } $declinaison->charger($perso->declinaison); $declinaisondesc->charger($declinaison->id); // recup valeur declidisp ou string if ($declinaison->isDeclidisp($perso->declinaison)) { $declidisp = new Declidisp(); $declidispdesc = new Declidispdesc(); $declidisp->charger($perso->valeur); $declidispdesc->charger_declidisp($declidisp->id); $dectexte .= "- " . $declinaisondesc->titre . " : " . $declidispdesc->titre . "\n"; } else { $dectexte .= "- " . $declinaisondesc->titre . " : " . $perso->valeur . "\n"; } } // diminution des stocks classiques si on est sur un module de paiement qui défalque de suite $produit = new Produit($article->produit->ref); if ($modpaiement->defalqcmd) { $produit->stock -= $article->quantite; $produit->maj(); } /* Gestion TVA */ $prix = $article->produit->prix; $prix2 = $article->produit->prix2; $tva = $article->produit->tva; if ($pays->tva != "" && (!$pays->tva || $pays->tva && $_SESSION['navig']->client->intracom != "" && !$pays->boutique)) { $prix = round($prix / (1 + $tva / 100), 2); $prix2 = round($prix2 / (1 + $tva / 100), 2); $tva = 0; } $venteprod->quantite = $article->quantite; if (!$article->produit->promo) { $venteprod->prixu = $prix; } else { $venteprod->prixu = $prix2; } $venteprod->ref = $article->produit->ref; $venteprod->titre = $article->produitdesc->titre . " " . $dectexte; $venteprod->chapo = $article->produitdesc->chapo; $venteprod->description = $article->produitdesc->description; $venteprod->tva = $tva; $venteprod->commande = $commande->id; $venteprod->id = $venteprod->add(); $correspondanceParent[] = $venteprod->id; // ajout dans ventedeclisp des declidisp associées au venteprod foreach ($article->perso as $perso) { $declinaison = new Declinaison(); $declinaison->charger($perso->declinaison); // si declidisp (pas un champs libre) if ($declinaison->isDeclidisp($perso->declinaison)) { $vdec = new Ventedeclidisp(); $vdec->venteprod = $venteprod->id; $vdec->declidisp = $perso->valeur; $vdec->add(); } } ActionsModules::instance()->appel_module("apresVenteprod", $venteprod, $pos); $total += $venteprod->prixu * $venteprod->quantite; $nbart++; $poids += $article->produit->poids; } foreach ($correspondanceParent as $id_panier => $id_venteprod) { if ($_SESSION['navig']->panier->tabarticle[$id_panier]->parent >= 0) { $venteprod->charger($id_venteprod); $venteprod->parent = $correspondanceParent[$_SESSION['navig']->panier->tabarticle[$id_panier]->parent]; $venteprod->maj(); } } $pays = new Pays($_SESSION['navig']->client->pays); if ($_SESSION['navig']->client->pourcentage > 0) { $commande->remise = $total * $_SESSION['navig']->client->pourcentage / 100; } $total -= $commande->remise; if ($_SESSION['navig']->promo->id != "") { $commande->remise += calc_remise($total); $_SESSION['navig']->promo->utilise = 1; if (!empty($commande->remise)) { $commande->remise = round($commande->remise, 2); } $commande->maj(); $temppromo = new Promo(); $temppromo->charger_id($_SESSION['navig']->promo->id); $temppromo->utilise++; $temppromo->maj(); $promoutil = new Promoutil(); $promoutil->commande = $commande->id; $promoutil->promo = $temppromo->id; $promoutil->code = $temppromo->code; $promoutil->type = $temppromo->type; $promoutil->valeur = $temppromo->valeur; $promoutil->add(); } if ($commande->remise > $total) { $commande->remise = $total; } $commande->port = port(); if (intval($commande->port) <= 0) { $commande->port = 0; } $_SESSION['navig']->promo = new Promo(); $_SESSION['navig']->commande = $commande; $commande->transaction = genid($commande->id, 6); $commande->maj(); $total = $_SESSION['navig']->panier->total(1, $_SESSION['navig']->commande->remise) + $_SESSION['navig']->commande->port; if ($total < $_SESSION['navig']->commande->port) { $total = $_SESSION['navig']->commande->port; } $_SESSION['navig']->commande->total = $total; ActionsModules::instance()->appel_module("aprescommande", $commande); // Appeler la méthode mail du plugin de paiement... $modpaiement->mail($commande); // ... et la méthode paiement $modpaiement->paiement($commande); } catch (Exception $e) { // FIXME: Echec de commande -> cas à traiter ? } }