. */ /* */ /*************************************************************************************/ require_once("pre.php"); require_once("auth.php"); require_once("../fonctions/divers.php"); ?> charger_id($type_paiement); $client = new Client(); $client->charger_ref($id_client); $nbart = $_SESSION["commande"]->nbart; $sessionventeprod = $_SESSION["commande"]->venteprod; $commande = new Commande(); $commande->client = $client->id; $commande->transport = $type_livraison; $commande->paiement = $type_paiement; $commande->statut=Commande::NONPAYE; $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; $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; if($client->pourcentage>0) $commande->remise = $total * $client->pourcentage / 100; if($remise != "") $commande->remise+=$remise; $commande->transaction = genid($commande->id, 6); $commande->port = $fraisport; $commande->maj(); ActionsModules::instance()->appel_module("aprescommande", $commande); // Appeler la fonction mail() du module try { $module = ActionsModules::instance()->instancier($modules->nom); $module->mail($commande); } catch (Exception $e) { } redirige("commande_details.php?ref=".$commande->ref); } $_SESSION["commande"] = ""; $_SESSION["commande"]->nbart = 0; $_SESSION["commande"]->venteprod = array(); //$_SESSION["commande"]->commande = new Commande(); ?>