0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
administrer
/
[
Home
]
File: proforma.php
<?php $menu=1; include("../configuration.inc.php"); necessite_identification(); necessite_priv("admin"); //ini_set('display_errors',1); $DOC_TITLE = "création d'une facture proforma"; include("modeles/haut.php"); switch (vb($_REQUEST['mode'])) { case "insere" : $comid = insere_proforma($_POST); $act = 'update'; $p=1; if (isset($_POST['insprod'])) affiche_form_proforma($comid, $act, $p); else affiche_liste_proforma(); break; case "update" : update_proforma($_POST); $act = 'update'; $p=1; if (isset($_POST['insprod'])) affiche_form_proforma($_POST['commandeid'], $act, $p); else affiche_liste_proforma(); break; case "ajout" : affiche_form_proforma($id = 0, $_GET['action']); break; case "modif" : affiche_form_proforma(intval($_GET['id']), $_GET['action']); break; case "suppr" : efface_proforma(intval($_GET['id'])); affiche_liste_proforma(); break; case "suppr_line" : efface_line_proforma(intval($_GET['produit_id']), intval($_GET['comid'])); $act = 'update'; $p=1; affiche_form_proforma($_GET['comid'], $act, $p); break; case "mail" : mail_proforma(intval($_GET['id'])); affiche_liste_proforma(); break; case "voir" : affiche_proforma_detail($_GET['commandeid']); break; default : affiche_liste_proforma(); break; } include("modeles/bas.php"); function affiche_form_proforma(&$id, &$action, $p=0) { global $wwwroot; if (!empty($id)) { $result = mysql_query_override(" SELECT * FROM gaia_commandes WHERE id = '$id' "); if ($result) { if (mysql_num_rows_override($result) > 0) { $frm = mysql_fetch_array_override($result); } } } if (!empty($_GET['id_utilisateur']) || !empty($frm['id_utilisateur'])) { if (!empty($_GET['id_utilisateur'])) $iduser = $_GET['id_utilisateur']; if (!empty($frm['id_utilisateur'])) $iduser = $frm['id_utilisateur']; $result_client = mysql_query_override("SELECT * FROM gaia_utilisateurs WHERE id_utilisateur = '".intval($iduser)."' "); if ($result_client) { if (mysql_num_rows_override($result_client) > 0) { $frm_client = mysql_fetch_array_override($result_client); } } } if ($p==1) echo '<script type="text/javascript">scrolldown();</script>'; ?> <form method="post" action="<?=$wwwroot?>/administrer/proforma.php" name="focusform" id="focusform" autocomplete="off"> <input type="hidden" name="mode" value="<?=$action?>"> <input type="hidden" name="commandeid" value="<?=$id?>"> <input type="hidden" name="priv" value="<?=$frm_client['priv']?>"> <input type="hidden" name="id_utilisateur" value="<?=((isset($_GET['id_utilisateur']))?$_GET['id_utilisateur']:'0')?>"> <table class="tablespace" border="0" width="100%"> <tr> <th class="entete" colspan="2">Créer ou modifier une facture proforma</th> </tr> <? if (isset($_GET['id_utilisateur'])) { ?> <tr> <td colspan="2" class="menu">Adresse de facturation</td> </tr> <tr> <td class="normal">Profil :</td> <td class="normal"> <? $recprofil = mysql_query_override("select * from gaia_profil where priv = '".$frm_client['priv']."'"); $profil = mysql_fetch_array_override($recprofil); echo $profil['name']; ?> <input name="profil" id="profil" type="hidden" value="<?=vb($frm_client['priv'])?>"></td> </tr> <tr> <td class="normal">Société :</td> <td><?=vb($frm_client['societe'])?><input name="societe1" value="<?=vb($frm_client['societe'])?>" type="hidden"></td> </tr> <tr> <td class="normal">Prénom Nom </td> <td><?=vb($frm_client['prenom'])." ".vb($frm_client['nom_famille'])?> <input type="hidden" name="nom1" value="<?=vb($frm_client['nom_famille'])?>"> <input type="hidden" name="prenom1" value="<?=vb($frm_client['prenom'])?>"> </td> </tr> <tr> <td class="normal">Email :</td> <td><?=vb($frm_client['email'])?><input type="hidden" name="email1" value="<?=vb($frm_client['email'])?>"></td> </tr> <tr> <td class="normal">Téléphone :</td> <td><?=vb($frm_client['telephone'])?><input type="hidden" name="telephone1" value="<?=vb($frm_client['telephone'])?>"></td> </tr> <tr> <td class="normal">Adresse :</td> <td><?=vb($frm_client['adresse'])?><input type="hidden" name="adresse1" value="<?=vb($frm_client['adresse'])?>"></td> </tr> <tr> <td class="normal">Code postal Ville:</td> <td><?=vb($frm_client['code_postal']). " ".vb($frm_client['ville'])?> <input type="hidden" name="cp1" value="<?=vb($frm_client['code_postal'])?>"> <input type="hidden" name="ville1" value="<?=vb($frm_client['ville'])?>"> </td> </tr> <tr> <td class="normal">Pays :</td> <td> <?php $res = mysql_query_override("SELECT pays_".$_SESSION['langue']." as pays FROM gaia_pays WHERE id = '".intval($frm_client['pays'])."'"); $obj = mysql_fetch_object_override($res); $pays = $obj->pays; echo stripslashes($pays); ?> <input type="hidden" name="pays1" value="<?php echo stripslashes($pays); ?>"> </td> </tr> <? } else { ?> <tr> <td colspan="2" class="menu">Adresse de facturation</td> </tr> <tr> <td class="normal">Profil :</td> <td><select class="formulaire1" name="profil" id="profil"> <?php $sql_pays = "SELECT * FROM gaia_profil WHERE id <> '2' and id <> '4' ORDER BY name"; $res_pays = mysql_query_override($sql_pays); if ($res_pays) { if (mysql_num_rows_override($res_pays)) { while ($tab_pays = mysql_fetch_array_override($res_pays)) { echo "<option value=\"".$tab_pays['priv']."\""; if (vb($frm_client['priv']) == $tab_pays['priv']) echo "selected"; echo ">".stripslashes($tab_pays['name'])."</option>"; } } } ?> </select> </td> </tr> <tr> <td class="normal">Société :</td> <td><input class="formulaire1" name="societe1" value="<?=stripslashes(vb($frm['societe_bill']))?>"></td> </tr> <tr> <td class="normal">Nom :</td> <td><input class="formulaire1" name="nom1" value="<?=stripslashes(vb($frm['nom_bill']))?>"></td> </tr> <tr> <td class="normal">Prénom :</td> <td><input class="formulaire1" name="prenom1" value="<?=stripslashes(vb($frm['prenom_bill']))?>"></td> </tr> <tr> <td class="normal">Email :</td> <td><input class="formulaire1" name="email1" value="<?=stripslashes(vb($frm['email_bill']))?>"></td> </tr> <tr> <td class="normal">Téléphone :</td> <td><input class="formulaire1" name="telephone1" value="<?=stripslashes(vb($frm['telephone_bill']))?>"></td> </tr> <tr> <td class="normal">Adresse :</td> <td><input class="formulaire1" name="adresse1" value="<?=stripslashes(vb($frm['adresse_bill']))?>"></td> </tr> <tr> <td class="normal">Code postal :</td> <td><input class="formulaire1" name="cp1" value="<?=stripslashes(vb($frm['zip_bill']))?>"></td> </tr> <tr> <td class="normal">Ville :</td> <td><input class="formulaire1" name="ville1" value="<?=stripslashes(vb($frm['ville_bill']))?>"></td> </tr> <tr> <td class="normal">Pays :</td> <td><select class="formulaire1" name="pays1"> <option value="">--</option> <?php $sql_pays = "SELECT id, pays_".$_SESSION['langue']." FROM gaia_pays WHERE etat = '1' ORDER BY pays_".$_SESSION['langue'].""; $res_pays = mysql_query_override($sql_pays); if ($res_pays) { if (mysql_num_rows_override($res_pays)) { while ($tab_pays = mysql_fetch_array_override($res_pays)) { echo "<option value=\"".$tab_pays['pays_'.$_SESSION['langue'].'']."\""; if (vb($frm['pays_bill']) == $tab_pays['pays_'.$_SESSION['langue'].'']) echo "selected"; echo ">".stripslashes($tab_pays['pays_'.$_SESSION['langue'].''])."</option>"; } } } ?> </select> </td> </tr> <? } ?> <tr> <td colspan="2" class="menu">Adresse de livraison<br />(si différente de l'adresse de facturation)</td> </tr> <tr> <td class="normal">Société :</td> <td><input class="formulaire1" name="societe2" value="<?=stripslashes(vb($frm['societe_ship']))?>"></td> </tr> <tr> <td class="normal">Nom :</td> <td><input class="formulaire1" name="nom2" value="<?=stripslashes(vb($frm['nom_ship']))?>"></td> </tr> <tr> <td class="normal">Prénom :</td> <td><input class="formulaire1" name="prenom2" value="<?=stripslashes(vb($frm['prenom_ship']))?>"></td> </tr> <tr> <td class="normal">Email :</td> <td><input class="formulaire1" name="email2" value="<?=stripslashes(vb($frm['email_ship']))?>"></td> </tr> <tr> <td class="normal">Téléphone :</td> <td><input class="formulaire1" name="telephone2" value="<?=stripslashes(vb($frm['telephone_ship']))?>"></td> </tr> <tr> <td class="normal">Adresse :</td> <td><input class="formulaire1" name="adresse2" value="<?=stripslashes(vb($frm['adresse_ship']))?>"></td> </tr> <tr> <td class="normal">Code postal :</td> <td><input class="formulaire1" name="cp2" value="<?=stripslashes(vb($frm['zip_ship']))?>"></td> </tr> <tr> <td class="normal">Ville :</td> <td><input class="formulaire1" name="ville2" value="<?=stripslashes(vb($frm['ville_ship']))?>"></td> </tr> <tr> <td class="normal">Pays :</td> <td> <select class="formulaire1" name="pays2"> <option value="">--</option> <?php $sql_pays = "SELECT id, pays_".$_SESSION['langue']." FROM gaia_pays WHERE etat = '1' ORDER BY pays_".$_SESSION['langue'].""; $res_pays = mysql_query_override($sql_pays); if ($res_pays) { if (mysql_num_rows_override($res_pays)) { while ($tab_pays = mysql_fetch_array_override($res_pays)) { echo "<option value=\"".$tab_pays['pays_'.$_SESSION['langue'].'']."\""; if (vb($frm['pays_ship']) == $tab_pays['pays_'.$_SESSION['langue'].'']) echo "selected"; echo ">".stripslashes($tab_pays['pays_'.$_SESSION['langue'].''])."</option>"; } } } ?> </select> </td> </tr> <tr> <td colspan="2" class="menu">Information sur la commande</td> </tr> <tr> <td class="normal">TVA</td> <td class="normal"><select class="formulaire1" name="tva" style="width:100px"> <?php $sql = "SELECT id, tva FROM gaia_tva ORDER BY tva DESC"; $result = mysql_query_override($sql); if (mysql_num_rows_override($result)) { if (mysql_num_rows_override($result) > 0) { while ($arr = mysql_fetch_array_override($result)) { echo "<option value=\"".$arr['id']."\" ".(($frm['zone_tva']==$arr['id'])?'selected':'').">".$arr['tva']."</option>"; } } } ?> </select></td> </tr> <tr> <td class="normal">Type de paiement</td> <td class="normal"> <?php $sql_paiement = "SELECT id, nom_".$_SESSION['langue']." FROM gaia_paiement ORDER BY position"; $res_paiement = mysql_query_override($sql_paiement); if ($res_paiement) { if (mysql_num_rows_override($res_paiement) > 0) { $cpt=0; while ($tab_paiement = mysql_fetch_array_override($res_paiement)) { echo "<label style=\"width:130px; float:left;\"><input type=\"radio\" name=\"paiement\" ".(($cpt==0)?'checked':'')." value=\"".$tab_paiement['nom_'.$_SESSION['langue'].'']."\""; if (propre(vb($frm['paiement'])) == propre(utf8_decode(html_entity_decode($tab_paiement['nom_'.$_SESSION['langue'].''])))) echo "checked"; echo ">".stripslashes($tab_paiement['nom_'.$_SESSION['langue'].''])."</label> "; $cpt++; } } } ?> </td> </tr> <!-- <tr> <td class="normal">Conditions de paiement</td> <td class="normal"> <select name="conditions"> <option value="3" <?=(($frm['conditions']==3)?'selected':((isset($frm_client['conditions']) && $frm_client['conditions']==3)?'selected':''))?>>Précommande</option> <option value="0" <?=(($frm['conditions']==0)?'selected':((isset($frm_client['conditions']) && $frm_client['conditions']==0)?'selected':''))?>>Paiement Comptant</option> <option value="4" <?=(($frm['conditions']==4)?'selected':((isset($frm_client['conditions']) && $frm_client['conditions']==4)?'selected':''))?>>Paiement 3 jours</option> <option value="1" <?=(($frm['conditions']==1)?'selected':((isset($frm_client['conditions']) && $frm_client['conditions']==1)?'selected':''))?>>Paiement 30 jours</option> <option value="2" <?=(($frm['conditions']==2)?'selected':((isset($frm_client['conditions']) && $frm_client['conditions']==2)?'selected':''))?>>Paiement 60 jours</option> </select> </td> </tr> --> <tr> <td class="normal">Type de transport</td> <td class="normal"> <select class="formulaire1" name="transport"> <?php $sql_type = "SELECT nom_".$_SESSION['langue'].", IF(id=12, 0,position) as position FROM gaia_types ORDER BY position"; echo $sql_type; $res_type = mysql_query_override($sql_type) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR());; if ($res_type) { if (mysql_num_rows_override($res_type)) { while ($tab_type = mysql_fetch_array_override($res_type)) { echo "<option value=\"".$tab_type['nom_'.$_SESSION['langue'].'']."\""; if (vb($frm['transport']) == $tab_type['nom_'.$_SESSION['langue'].'']) echo "selected"; echo ">".stripslashes($tab_type['nom_'.$_SESSION['langue'].''])."</option>"; } } } ?> </select> </td> </tr> <tr> <td class="normal">Cout du transport (en € TTC)</td> <td class="normal"><input type="text" name="cout_transport" value="<? $tr = $frm['cout_transport']; echo vn($tr)?>" class="formulaire1"> </td> </tr> <!-- <tr> <td class="normal">Transport manuel</td> <td class="normal"><input type="checkbox" name="transport_manuel" value="1" <?=frmvalide($frm['transport_manuel'])?> <?php if(pv($frm['transport_manuel'])=="1") echo "checked" ?> class="formulaire1"> </td> </tr> --> <!-- <tr> <td colspan="2" class="label">Commentaires : <br /> <textarea class="formulaire1" name="commentaires" rows="5"><?=trim(stripslashes(vb($frm['commentaires'])))?> </textarea></td> </tr> --> <input type="hidden" name="commentaires" value="" /> <tr> <td colspan="2" class="menu">Remise commerciale</td> </tr> <tr> <td class="normal">Type de remise</td> <td class="normal"> <select name="remise_proforma_type"> <option value="0" <?=(($frm['remise_proforma_type']==0)?'selected':'')?>>--</option> <option value="1" <?=(($frm['remise_proforma_type']==1)?'selected':'')?>>€</option> <option value="2" <?=(($frm['remise_proforma_type']==2)?'selected':'')?>>%</option> <option value="3" <?=(($frm['remise_proforma_type']==3)?'selected':'')?>>Frais de port offert</option> </select> </td> </tr> <tr> <td class="normal">Valeur remise (si € et %, si € renseigner le TTC)</td> <td class="normal"><input type="text" name="remise_proforma_val" value="<? $tr = $frm['remise_proforma_val']; echo number_format($tr,2,'.','')?>" class="formulaire1"> </td> </tr> <tr> <td colspan="2" style="padding-left:0"> <? //########################################################## ?> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td style="width:380px" class="menu">Libellé du produit</td> <? $rectail = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectail)){ echo '<td style="text-align:center" class="menu">'.stripslashes($pt['nom_fr']).'</td>'; } ?> <td style="width:50px" class="menu">Qté</td> <td style="width:50px" class="menu">PU HT</td> <td style="width:50px" class="menu">TOT</td> <!--<td style="width:70px" class="menu">Taux TVA</td>--> <td width="50" class="menu"></td> </tr> <?php $resutat_requete = mysql_query_override(" SELECT oi.nom_produit AS nom ,oi.prix AS purchase_prix ,oi.prix_ht AS purchase_prix_ht ,oi.quantite ,oi.taille ,oi.produit_id ,oi.tva ,oi.id FROM gaia_commandes_articles oi, gaia_produits p WHERE commande_id = '$id' AND p.id = oi.produit_id GROUP BY produit_id order by nom_produit "); $k=1; $tabok = array(); if (mysql_num_rows_override($resutat_requete) > 11111111111110) { while ($tab = mysql_fetch_array_override($resutat_requete)) { $tabok[] = $tab['produit_id']; ?> <tr> <td style="padding:3px"> <? $recprod = mysql_query_override("select * from gaia_produits where id = '".$tab['produit_id']."'"); $prod = mysql_fetch_array_override($recprod); echo '<input type="hidden" class="formulaire1" name="l'.$k.'" id="l'.$k.'" style="width:200px" value="'.$tab['produit_id'].'">'; //echo '<input type="text" readonly class="formulaire1" name="nomnprod'.$k.'" id="nomnprod'.$k.'" style="width:200px" value="'.stripslashes($prod['nom_fr']).'">'; echo ''.stripslashes($prod['nom_fr']).''; ?></td> <? $qtetotal = 0; $rectail = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectail)){ echo '<td width="70" style="padding-left:3px"><div id="tail'.$k.'_'.$pt['id'].'">'; $table = 'gaia_stocks'; if($frm_client['priv']=='clico') $table = 'gaia_stocks'; $rectailaaa = mysql_query_override("select t.*, s.stock from ".$table." s, gaia_tailles t where s.taille_id = t.id and t.id = '".$pt['id']."' and s.produit_id = '".$tab['produit_id']."' "); if(mysql_num_rows_override($rectailaaa)>0) { $pr = mysql_fetch_array_override($rectailaaa); $qtetail = 0; $recqte = mysql_query_override("select * from gaia_commandes_articles where commande_id = '".$id."' and produit_id = '".$tab['produit_id']."' and taille = '".addslashes($pr['nom_fr'])."'"); if(mysql_num_rows_override($recqte)>0) { $qtetail = mysql_result_override($recqte,0,'quantite'); $qtetotal += $qtetail; } echo '<input type="text" name="tail'.$k.'_'.$pt['id'].'" value="'.$qtetail.'" style="width:25px" onkeyup="xajax_change_prix(xajax.getFormValues(\'focusform\'), \''.$k.'\');if(this.value>'.($pr['stock']+$qtetail).') this.value='.($pr['stock']+$qtetail).'">'; } echo '</div></td>'; } ?> <td width="70" style="padding:3px"><input type="text" id="q<?=$k?>" name="q<?=$k?>" value="<?=$qtetotal?>" readonly="readonly" style="width:30px"></td> <td width="70" style="padding:3px"><input class="formulaire1" name="p<?=$k?>" id="p<?=$k?>" style="width:50px" value="<?=$tab['purchase_prix_ht']?>" onblur="xajax_change_prix(xajax.getFormValues('focusform'), '<?=$k?>')"></td> <td width="70" style="padding:3px"><input class="formulaire1" name="p9<?=$k?>" id="p9<?=$k?>" readonly="readonly" style="width:50px" value="<?=$qtetotal*$tab['purchase_prix_ht']?>"></td> <!-- <td width="70"><select class="formulaire1" name="t<?=$k?>" style="width:100px"> <?php $sql = "SELECT tva FROM gaia_tva ORDER BY tva DESC"; $result = mysql_query_override($sql); if (mysql_num_rows_override($result)) { if (mysql_num_rows_override($result) > 0) { while ($arr = mysql_fetch_array_override($result)) { echo "<option value=\"".$arr['tva']."\" ".(($tab['tva']==$arr['tva'])?'selected':'').">".$arr['tva']."</option>"; } } } ?> </select></td> --> <td width="50" style="padding:3px"> <a href="<?=$_SERVER['PHP_SELF']?>?mode=suppr_line&comid=<?=$id?>&produit_id=<?=$tab['produit_id']?>"><i class=" icon-large icon-remove"></i></a> </td> </tr> <? $k++; } } $table = 'gaia_stocks'; if($frm_client['priv']=='clico') $table = 'gaia_stocks'; $prodpanier = array(); $prodqte = array(); $recprod = mysql_query_override("select distinct(produit_id), sum(quantite) as qte, prix_ht from gaia_commandes_articles where commande_id = '".intval($id)."'"); while($prodp = mysql_fetch_array_override($recprod)) { $prodpanier[] = $prodp['produit_id']; $prodqte[$prodp['produit_id']] = $prodp['qte']; $prodprix[$prodp['produit_id']] = $prodp['prix_ht']; } $k=0; $cpt=0; $recprod = mysql_query_override("select * from gaia_produits p left join gaia_produits_couleurs pc on pc.produit_id = p.id order by nom_fr"); if(mysql_num_rows_override($recprod)>0) { while($prod = mysql_fetch_array_override($recprod)){ //if(!in_array($prod['id'], $tabok)) { $reccolor = mysql_query_override("select * from gaia_couleurs where id = '".$prod['couleur_id']."'"); $color = mysql_result_override($reccolor,0,'nom_fr'); $verifstockpro = mysql_query_override("select sum(stock) as totstock from ".$table." where couleur_id = '".$prod['couleur_id']."' and produit_id = '".$prod['id']."'"); $totalstock = mysql_result_override($verifstockpro,0,'totstock'); if($totalstock>0 || in_array($prod['id'],$prodpanier)) { $cpt++; $k++; if($prodqte[$prod['id']]>0) $newprix = $prodprix[$prod['id']]; else { $newprix = $prod['prix'] / (1+$prod['tva']/100); if ($frm_client['priv']=='reve') $newprix = $prod['prix_revendeur'] / (1+$prod['tva']/100); elseif ($frm_client['priv']=='distri') $newprix = $prod['prix_distributeur'] / (1+$prod['tva']/100); } ?> <tr <?php echo (($cpt%2==0)?'style="background:#fff"':''); ?>> <td style="padding:3px"> <input type="hidden" class="formulaire1" name="l<?=$k?>" id="l<?=$k?>" value="<?php echo $prod['id']; ?>" /> <input type="hidden" class="formulaire1" name="c<?=$k?>" id="c<?=$k?>" value="<?php echo intval($prod['couleur_id']); ?>" /> <? echo '<b>'.stripslashes($prod['nom_fr']).'</b> : '.$totalstock.'<br /><i> '.$color.'</i>'; ?> </td> <? $qtetotal = 0; $recqte = mysql_query_override("select * from gaia_commandes_articles where commande_id = '".intval($id)."' and produit_id = '".$prod['id']."' and taille = '' and couleur = '".addslashes($color)."'"); if(mysql_num_rows_override($recqte)>0) { $qtetail = mysql_result_override($recqte,0,'quantite'); $qtetotal += $qtetail; } $rectaila = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectaila)){ $val = ''; $rectail = mysql_query_override("select t.*, s.stock from ".$table." s, gaia_tailles t where s.taille_id = t.id and t.id = '".$pt['id']."' and s.couleur_id = '".$prod['couleur_id']."' and s.produit_id = '".$prod['id']."' "); //$rectail = mysql_query_override("select * from ".$table." where taille_id = '".$pt['id']."' and produit_id = '".$prod['id']."'"); // and s.stock > 0 "); $nbtail = mysql_num_rows_override($rectail); if($nbtail>0) { $pr = mysql_fetch_array_override($rectail); $qtetail = 0; $recqte = mysql_query_override("select * from gaia_commandes_articles where commande_id = '".intval($id)."' and produit_id = '".$prod['id']."' and taille = '".addslashes($pr['nom_fr'])."' and couleur = '".addslashes($color)."'"); if(mysql_num_rows_override($recqte)>0) { $qtetail = mysql_result_override($recqte,0,'quantite'); $qtetotal += $qtetail; } $val = '<input type="text" name="tail'.$k.'_'.$pt['id'].'" value="'.$qtetail.'" style="width:25px" onkeyup="xajax_change_prix(xajax.getFormValues(\'focusform\'), \''.$k.'\');if(this.value>'.($pr['stock']+$qtetail).') this.value='.($pr['stock']+$qtetail).'"><br />'.$pr['stock']; } echo '<td width="70" style="padding-left:3px; text-align:center;"><div id="tail'.$k.'_'.$pt['id'].'">'.$val.'</div></td>'; } ?> <td width="70" style="padding:3px"><input type="text" id="q<?=$k?>" name="q<?=$k?>" value="<?=$qtetotal?>" <?php echo (($nbtail>0)?'readonly="readonly"':'onkeyup="xajax_change_prix(xajax.getFormValues(\'focusform\'), \''.$k.'\', true);if(this.value>'.($totalstock+$prodqte[$prod['id']]).') this.value='.($totalstock+$prodqte[$prod['id']]).'"'); ?> style="width:30px"></td> <td width="70" style="padding:3px"><input class="formulaire1" name="p<?=$k?>" id="p<?=$k?>" onblur="xajax_change_prix(xajax.getFormValues('focusform'), '<?=$k?>')" style="width:50px" value="<?php echo number_format($newprix,2,'.',''); ?>"> <td width="70" style="padding:3px"><input class="formulaire1" name="p9<?=$k?>" id="p9<?=$k?>" value="<?=number_format($qtetotal*$newprix,2,'.','')?>" readonly="readonly" style="width:50px" value=""></td> <!-- <td width="70"><select class="formulaire1" name="t<?=$k?>" style="width:100px"> <?php $sql = "SELECT tva FROM gaia_tva ORDER BY tva DESC"; $result = mysql_query_override($sql); if (mysql_num_rows_override($result)) { if (mysql_num_rows_override($result) > 0) { while ($arr = mysql_fetch_array_override($result)) { echo "<option value=\"".$arr['tva']."\">".$arr['tva']."</option>"; } } } ?> </select></td> --> <td width="50" style="padding:3px"> <button class="bouton" name="insprod" value="1" style="border:0; background:0; margin:0; padding:0" type="submit"><i class=" icon-large icon-plus-sign"></i></button> </td> </tr> <?php }}} //} ?> </table> <input type="hidden" name="cptinput" value="<?=$k?>" /> <? //########################################################## ?> </td> </tr> <tr> <td class="normal" colspan="2" align="center"> <input type="submit" value="créer une facture proforma" class="bouton"> </td> </tr> </table> </form> <?php } function insere_proforma($frm) { global $dpd_france, $dpd_europe, $dpd_suisse; // Création des variables $email = ""; $paiement = ""; $conditions = ""; $montant = 0; $transport = ""; $cout_transport = 0; $cout_transport_ht = 0; $transport_manuel = intval($frm['transport_manuel']); $remise_proforma_type = $frm['remise_proforma_type']; $remise_proforma_val = $frm['remise_proforma_val']; $societe1 = addslashes($frm['societe1']); $prenom1 = addslashes($frm['prenom1']); $nom1 = addslashes($frm['nom1']); $adresse1 = addslashes($frm['adresse1']); $ville1 = addslashes($frm['ville1']); $cp1 = $frm['cp1']; $pays1 = addslashes($frm['pays1']); $email1 = $frm['email1']; $telephone1 = $frm['telephone1']; !empty($frm['societe2']) ? $societe2 = addslashes($frm['societe2']) : $societe2 = addslashes($frm['societe1']); !empty($frm['prenom2']) ? $prenom2 = addslashes($frm['prenom2']) : $prenom2 = addslashes($frm['prenom1']); !empty($frm['nom2']) ? $nom2 = addslashes($frm['nom2']) : $nom2 = addslashes($frm['nom1']); !empty($frm['adresse2']) ? $adresse2 = addslashes($frm['adresse2']) : $adresse2 = addslashes($frm['adresse1']); !empty($frm['cp2']) ? $cp2 = addslashes($frm['cp2']) : $cp2 = addslashes($frm['cp1']); !empty($frm['ville2']) ? $ville2 = addslashes($frm['ville2']) : $ville2 = addslashes($frm['ville1']); !empty($frm['pays2']) ? $pays2 = addslashes($frm['pays2']) : $pays2 = addslashes($frm['pays1']); !empty($frm['email2']) ? $email2 = addslashes($frm['email2']) : $email2 = addslashes($frm['email1']); !empty($frm['telephone2']) ? $telephone2 = addslashes($frm['telephone2']) : $telephone2 = addslashes($frm['telephone1']); $paiment = vb($frm['paiement']); $conditions = vb($frm['conditions']); $statut = 0; /* if($conditions==0) $statut = 10; if($conditions==1) $statut = 11; if($conditions==2) $statut = 11; if($conditions==3) $statut = 2; if($conditions==4) $statut = 11; $date_paiement = 0; if($conditions==1) $date_paiement = mktime(date('H'),date('i'),date('s'),date('m'),date('d')+30,date('Y')); if($conditions==2) $date_paiement = mktime(date('H'),date('i'),date('s'),date('m'),date('d')+60,date('Y')); if($conditions==4) $date_paiement = mktime(date('H'),date('i'),date('s'),date('m'),date('d')+3,date('Y')); if($conditions==0) $date_paiement = mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y')); */ $date_paiement = mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y')); $transport = vb($frm['transport']); //if($transport == "Retrait au showroom - 13821 La penne sur Huveaune") $statut = 12; $cout_transport = vn($frm['cout_transport']); $commentaires = addslashes($frm['commentaires']); $email = $frm['email1']; $id_utilisateur = intval($frm['id_utilisateur']); if ($id_utilisateur == 0) { $sql = "SELECT id_utilisateur, email FROM gaia_utilisateurs WHERE email = '".$email1."'"; $result = mysql_query_override($sql); if (mysql_num_rows_override($result) == 0) { $mot_passe = MDP(); $qid = mysql_query_override(" INSERT INTO gaia_utilisateurs ( email , mot_passe , prenom , nom_famille , priv , societe , telephone , adresse , code_postal , ville , pays , newsletter , commercial ) VALUES ( '$email' ,'".md5($mot_passe)."' ,'$prenom1' ,'$nom1' ,'$profil' ,'$societe1' ,'$telephone1' ,'$adresse1' ,'$cp1' ,'$ville1' ,'$pays1' ,'1' ,'1' )"); $email = $email1; $id_utilisateur = mysql_insert_id_override(); } else { $u = mysql_fetch_object_override($result); $email = $u->email; $id_utilisateur = $u->id_utilisateur; } } $montant_ht = 0; for($i=1;$i<($frm['cptinput']+1);$i++) { $montant_ht += $frm["p".$i] * $frm["q".$i]; } //$montant = $montant + $cout_transport; $rec = mysql_query_override("select * from gaia_tva where id = '".$frm['tva']."'"); $ttva = mysql_result_override($rec,0,'tva'); $taux_tva = 1+$ttva/100; $cout_transport_ht = $cout_transport/1.2; //$taux_tva; if($ttva==0) $cout_transport = $cout_transport_ht; $montant_ht = $montant_ht; $montant = $montant_ht*$taux_tva; // + $cout_transport; $total_produit_avant_promo = $total_produit = $montant; //########################################################## //gestion du calcul remise proforma $remise_proforma_calcul = $remise_proforma_calcul_ht = 0; //euros if($remise_proforma_type==1) { $remise_proforma_calcul = $remise_proforma_val; $remise_proforma_calcul_ht = $remise_proforma_val/$taux_tva; if($ttva==0) $remise_proforma_calcul = $remise_proforma_calcul_ht; } //pourcentage if($remise_proforma_type==2) { $remise_proforma_calcul = $montant*$remise_proforma_val/100; $remise_proforma_calcul_ht = $montant_ht*$remise_proforma_val/100; } //frais de port offert if($remise_proforma_type==3) { $remise_proforma_calcul = $cout_transport; $remise_proforma_calcul_ht = $cout_transport_ht; } $montant_ht = $montant_ht - $remise_proforma_calcul_ht; $montant = $montant - $remise_proforma_calcul; //########################################################## $total_produit_avant_promo_ht = $total_produit_avant_promo/$taux_tva; $montant = $montant + $cout_transport; $montant_ht = $montant_ht + $cout_transport_ht; $total_tva = $montant - $montant_ht; $client_info1 = $societe1."\n" .$prenom1." ".$nom1."\n" .$adresse1."\n" .$cp1." ".$ville1."\n".$pays1."\n" ."email : ".$email1."\n" ."tel : ".$telephone1."\n"; $client_info2 = $societe2."\n" .$prenom2." ".$nom2."\n" .$adresse2."\n" .$cp2." ".$ville2."\n".$pays2."\n" ."email : ".$email2."\n" ."tel : ".$telephone2."\n"; $reca = mysql_query_override("select numero from gaia_commandes where a_timestamp like '".date('Y')."-%' order by numero desc "); $num = 0; // mysql_result_override($reca,0,'numero')+1; /* Sauvegarde les infos de la facture proforma */ $requete = " INSERT INTO gaia_commandes ( email , numero , id_utilisateur , o_timestamp , a_timestamp , date_paiement , conditions , statut , statut_details , client_info1 , client_info2 , societe_bill , nom_bill , prenom_bill , adresse_bill , zip_bill , ville_bill , pays_bill , email_bill , telephone_bill , societe_ship , nom_ship , prenom_ship , adresse_ship , zip_ship , ville_ship , pays_ship , email_ship , telephone_ship , commentaires , montant , montant_ht , total_produit_avant_promo , total_produit_avant_promo_ht , total_produit , total_tva , zone_tva , paiement , proforma , transport , cout_transport , cout_transport_ht , transport_manuel , remise_proforma_type , remise_proforma_val , remise_proforma_calcul , remise_proforma_calcul_ht , lang ) VALUES ( '".$email."' , '".$num ."' , '".$id_utilisateur."' , now() , now() , '".$date_paiement."' , '".$conditions."' , '".$statut."' , 'commande enregistrée' , '".$client_info1."' , '".$client_info2."' , '".$societe1."' , '".$nom1."' , '".$prenom1."' , '".$adresse1."' , '".$cp1."' , '".$ville1."' , '".$pays1."' , '".$email1."' , '".$telephone1."' , '".$societe2."' , '".$nom2."' , '".$prenom2."' , '".$adresse2."' , '".$cp2."' , '".$ville2."' , '".$pays2."' , '".$email2."' , '".$telephone2."' , '".$commentaires."' , '".$montant."' , '".$montant_ht."' , '".$total_produit_avant_promo."' , '".$total_produit_avant_promo_ht."' , '".$total_produit."' , '".$total_tva."' , '".$frm['tva']."' , '".$paiment."' , '1' , '".$transport."' , '".$cout_transport."' , '".$cout_transport_ht."' , '".$transport_manuel."' , '".$remise_proforma_type."' , '".$remise_proforma_val."' , '".$remise_proforma_calcul."' , '".$remise_proforma_calcul_ht."' , '".$_SESSION['langue']."' )"; /* echo $requete; die; */ $qid = mysql_query_override($requete); $commandeid = mysql_insert_id_override(); for($i=1;$i<($frm['cptinput']+1);$i++) { $prix_revient = $frm["p".$i]; $recprod = mysql_query_override("select * from gaia_produits where id = '".$frm["l".$i]."'"); // Récupère les variables dans le formulaire $nom = mysql_result_override($recprod,0,'nom_fr'); $prodid = $frm["l".$i]; $poidstot = 0; $nbcolis = 0; $istaille=0; $rectailaaa = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectailaaa)){ //echo 'i '.$i.' id '.$pt['id'].' val '. $frm["tail".$i."_".$pt['id']]; if(isset($frm["tail".$i."_".$pt['id']]) && intval($frm["tail".$i."_".$pt['id']]) > 0) { $istaille++; // Récupère les variables dans le formulaire $rectail = mysql_query_override("select * from gaia_tailles where id = '".$pt['id']."'"); $taille = mysql_result_override($rectail,0,'nom_fr'); $couleur = ''; $reccol = mysql_query_override("select * from gaia_couleurs where id = '".$frm["c".$i]."'"); if(mysql_num_rows_override($reccol)>0) $couleur = mysql_result_override($reccol,0,'nom_fr'); $quantite = $frm["tail".$i."_".$pt['id']]; $prix = $frm["p".$i] * (1+$ttva/100); //(1+$frm["t".$i]/100); $prix_ht = $frm["p".$i]; $tva = $ttva; //$frm["t".$i]; $total_prix = $prix * $quantite; $total_revient = $prix_revient * $quantite; $total_prix_ht = $prix_ht * $quantite; $marge = $total_prix_ht - $total_revient; // Lie la commande au produit $requete = "INSERT INTO gaia_commandes_articles ( commande_id, produit_id, nom_produit, taille, couleur, marge, prix, prix_cat, prix_ht, prix_cat_ht, total_prix, total_prix_ht, quantite, tva ) VALUES ( '".$commandeid."' ,'".$prodid."' ,'".$nom."' ,'".$taille."' ,'".$couleur."' ,'".$marge."' ,'".$prix."' ,'".$prix."' ,'".$prix_ht."' ,'".$prix_ht."' ,'".$total_prix."' ,'".$total_prix_ht."' ,'".$quantite."' ,'".$tva."')"; $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); $poidstot += $prod['poids']*$quantite; if (!empty($quantite) && !empty($prodid)) { mysql_query_override($requete); if ($prod['on_stock'] == 1) { $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_fr = '".$taille."'")); $table = 'gaia_stocks'; if($frm['priv']=='clico') $table = 'gaia_stocks'; $s = mysql_fetch_array_override(mysql_query_override("SELECT stock FROM ".$table." WHERE produit_id = '".$prod['id']."' AND taille_id = '".vn($t['id'])."'")); $stock = $s['stock'] - $quantite; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) { $stock_to_order = $quantite - $s['stock'] ; mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); } else $stock_to_order = 0; mysql_query_override("UPDATE ".$table." SET stock = ".$stock_restant." WHERE produit_id = '".$prod['id']."' AND taille_id = '".vn($t['id'])."'"); } } }} if($istaille==0) { $quantite = $frm["q".$i]; $taille = $couleur = ''; $reccol = mysql_query_override("select * from gaia_couleurs where id = '".$frm["c".$i]."'"); if(mysql_num_rows_override($reccol)>0) $couleur = mysql_result_override($reccol,0,'nom_fr'); $prix = $frm["p".$i] * (1+$ttva/100); //(1+$frm["t".$i]/100); $prix_ht = $frm["p".$i]; $tva = $ttva; //$frm["t".$i]; $total_prix = $prix * $quantite; $total_revient = $prix_revient * $quantite; $total_prix_ht = $prix_ht * $quantite; $marge = $total_prix_ht - $total_revient; // Lie la commande au produit $requete = "INSERT INTO gaia_commandes_articles ( commande_id, produit_id, nom_produit, taille, couleur, marge, prix, prix_cat, prix_ht, prix_cat_ht, total_prix, total_prix_ht, quantite, tva ) VALUES ( '".$commandeid."' ,'".$prodid."' ,'".$nom."' ,'".$taille."' ,'".$couleur."' ,'".$marge."' ,'".$prix."' ,'".$prix."' ,'".$prix_ht."' ,'".$prix_ht."' ,'".$total_prix."' ,'".$total_prix_ht."' ,'".$quantite."' ,'".$tva."')"; $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); $poidstot += $prod['poids']*$quantite; if (!empty($quantite) && !empty($prodid)) { mysql_query_override($requete); $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); if ($prod['on_stock'] == 1) { $table = 'gaia_stocks'; $s = mysql_fetch_array_override(mysql_query_override("SELECT stock FROM ".$table." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."' ")); $stock = $s['stock'] - $quantite; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) { $stock_to_order = $quantite - $s['stock'] ; mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); } else { $stock_to_order = 0; } mysql_query_override("UPDATE ".$table." SET stock = ".$stock_restant." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."'"); } } } } if($transport_manuel==0) { $poidstot = $poidstot/1000; $nbcolis = ceil($poidstot/30); $montant = $montant - $cout_transport; $montant_ht = $montant_ht - $cout_transport_ht; if($pays2=='France') $cout_transport_ht = $nbcolis*$dpd_france; elseif($pays2=='Suisse') $cout_transport_ht = $nbcolis*$dpd_suisse; else $cout_transport_ht = $nbcolis*$dpd_europe; $cout_transport = $cout_transport_ht*1.2; if($ttva==0) $cout_transport = $cout_transport_ht; $montant = $montant + $cout_transport; $montant_ht = $montant_ht + $cout_transport_ht; $total_tva = $montant - $montant_ht; mysql_query_override("UPDATE gaia_commandes SET montant = '".$montant."', montant_ht = '".$montant_ht."', total_tva = '".$total_tva."', cout_transport = '".$cout_transport."', cout_transport_ht = '".$cout_transport_ht."', nbcolis = '".$nbcolis."' WHERE id = '".$commandeid."'"); } return $commandeid; } function affiche_liste_proforma() { global $wwwroot; /* Charge la liste des commandes et les affiche. */ $result = mysql_query_override("SELECT * FROM gaia_commandes WHERE proforma = '1' ORDER BY o_timestamp DESC"); if ($result) { print "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\" class=\"tablespace\">"; print "<tr><th class=\"entete\" colspan=\"9\">Liste des factures proforma</th></tr>"; print "<tr><td class=\"action\" colspan=\"7\"> <a class=\"normal\" href=\"".$_SERVER['PHP_SELF']."?mode=ajout&action=insere\">[Créer une facture proforma]</a> <a class=\"normal\" href=\"utilisateurs.php\">[Créer une facture proforma à partir de la liste des utilisateurs]</a> </td></tr>"; if (mysql_num_rows_override($result) > 0) { ?> <table border="0" class="tablespace" width="100%" cellpadding="0" cellspacing="0"> <tr bgcolor="#9999cc"> <td class='menu' align='center'>action</td> <td class='menu' align='center'>Proforma nº</td> <td class='menu' align='center'>Facture nº</td> <td class='menu' align='center'>client</td> <td class='menu' align='center'>date</td> <td class='menu' align='center'>montant</td> <td class='menu' align='center'>paiement</td> </tr> <? while ($c = mysql_fetch_array_override($result)) { ?> <tr> <td><a href="#myModal<?=$c['id']?>" role="button" data-toggle="modal" title="Supprimer" rel="tooltip" ><i class="ti-close"></i></a> <a title="Modifier" rel="tooltip" href="<?=$_SERVER['PHP_SELF']?>?mode=modif&id=<?=$c['id'] ?>&action=update"><i class="ti-pencil"></i></a> <a title="Voir" rel="tooltip" href="<?=$_SERVER['PHP_SELF']?>?mode=voir&commandeid=<?=$c['id'] ?>"><i class="ti-eye"></i></a> <a title="Envoyer" rel="tooltip" href="<?=$_SERVER['PHP_SELF']?>?mode=mail&id=<?=$c['id'] ?>"><i class="ti-email"></i></a> </td> <td class='petit' align='center'><?echo $c['id'];?></td> <td class='petit' align='center'><?echo $c['numero'];?></td> <td class='petit' align='center'><?echo $c['societe_bill'];?></td> <td class='petit' align='center'><?echo return_date_fr($c['o_timestamp']);?></td> <td class='petit' align='center'><?echo fprix($c['montant']);?></td> <td class='petit' align='center'><?echo $c['paiement'];?></td> </tr> <div id="myModal<?=$c['id']?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Supprimer</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <p>Êtes-vous sur de vouloir supprimer cette proforma ?<br /><strong>ATTENTION : Le stock sera recrédité</strong>.</p> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Annuler</button> <a class="btn btn-primary" href="<?=$_SERVER['PHP_SELF']?>?mode=suppr&id=<?=$c['id'] ?>">Supprimer</a> </div> </div> </div> </div> <? } } else { print "<tr><td colspan=\"7\" class=\"normal\">Aucune facture proforma n'est actuellement enregistrée dans la base.</td></tr>"; } } print "</table>"; } function efface_line_proforma($id, $comid) { /* Efface la commande dont le n° est $id */ $reccom = mysql_query_override("select * from gaia_commandes where id = '".$comid."'"); $com = mysql_fetch_array_override($reccom); $recclient = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur = '".$com['id_utilisateur']."'"); $client = mysql_fetch_array_override($recclient); $recart = mysql_query_override ("select * from gaia_commandes_articles WHERE produit_id = '$id' and commande_id = '".$comid."'"); while ($art = mysql_fetch_array_override($recart)) { $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_fr = '".$art['taille']."'")); $table = 'gaia_stocks'; if($client['priv']=='clico') $table = 'gaia_stocks'; mysql_query_override("UPDATE ".$table." SET stock = (stock + ".$art['quantite'].") WHERE produit_id = '".$art['produit_id']."' AND taille_id = '".vn($t['id'])."'"); } mysql_query_override("DELETE FROM gaia_commandes_articles WHERE produit_id = '$id' and commande_id = '".$comid."'"); } function efface_proforma($id) { /* Efface la commande dont le n° est $id */ $reccom = mysql_query_override("select * from gaia_commandes where id = '".$id."'"); $com = mysql_fetch_array_override($reccom); $recclient = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur = '".$com['id_utilisateur']."'"); $client = mysql_fetch_array_override($recclient); mysql_query_override("DELETE FROM gaia_commandes WHERE id = '$id'"); $recart = mysql_query_override ("select * from gaia_commandes_articles WHERE commande_id = '$id'"); while ($art = mysql_fetch_array_override($recart)) { $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_fr = '".$art['taille']."'")); $table = 'gaia_stocks'; if($client['priv']=='clico') $table = 'gaia_stocks'; mysql_query_override("UPDATE ".$table." SET stock = (stock + ".$art['quantite'].") WHERE produit_id = '".$art['produit_id']."' AND taille_id = '".vn($t['id'])."'"); } mysql_query_override("DELETE FROM gaia_commandes_articles WHERE commande_id = '$id'"); echo "<div class='alert alert-error'>La facture proforma $id a été effacée.</div>"; } function update_proforma($frm) { global $dpd_france, $dpd_europe, $dpd_suisse; /* Met à jour le produit $id avec de nouvelles valeurs. Les champs sont dans $frm */ $commandeid = $frm['commandeid']; $email = addslashes($frm['email1']); $paiement = ""; $conditions = ""; $montant = 0; $transport = ""; $cout_transport = 0; $cout_transport_ht = 0; $transport_manuel = intval($frm['transport_manuel']); $remise_proforma_type = $frm['remise_proforma_type']; $remise_proforma_val = $frm['remise_proforma_val']; //$transport_manuel = valide($frm['transport_manuel']); $societe1 = addslashes($frm['societe1']); $prenom1 = addslashes($frm['prenom1']); $nom1 = addslashes($frm['nom1']); $adresse1 = addslashes($frm['adresse1']); $ville1 = addslashes($frm['ville1']); $cp1 = $frm['cp1']; $pays1 = addslashes($frm['pays1']); $email1 = $frm['email1']; $telephone1 = $frm['telephone1']; !empty($frm['societe2']) ? $societe2 = addslashes($frm['societe2']) : $societe2 = addslashes($frm['societe1']); !empty($frm['prenom2']) ? $prenom2 = addslashes($frm['prenom2']) : $prenom2 = addslashes($frm['prenom1']); !empty($frm['nom2']) ? $nom2 = addslashes($frm['nom2']) : $nom2 = addslashes($frm['nom1']); !empty($frm['adresse2']) ? $adresse2 = addslashes($frm['adresse2']) : $adresse2 = addslashes($frm['adresse1']); !empty($frm['cp2']) ? $cp2 = addslashes($frm['cp2']) : $cp2 = addslashes($frm['cp1']); !empty($frm['ville2']) ? $ville2 = addslashes($frm['ville2']) : $ville2 = addslashes($frm['ville1']); !empty($frm['pays2']) ? $pays2 = addslashes($frm['pays2']) : $pays2 = addslashes($frm['pays1']); !empty($frm['email2']) ? $email2 = addslashes($frm['email2']) : $email2 = addslashes($frm['email1']); !empty($frm['telephone2']) ? $telephone2 = addslashes($frm['telephone2']) : $telephone2 = addslashes($frm['telephone1']); $paiment = vb($frm['paiement']); $conditions = vb($frm['conditions']); $transport = vb($frm['transport']); $verif = mysql_query_override("select * from gaia_commandes WHERE id = '$commandeid'"); $oldstatut = mysql_result_override($verif,0,'statut'); $olddate_com = strtotime(mysql_result_override($verif,0,'o_timestamp')); $statut = $oldstatut; $date_paiement = $olddate_com; /* if($oldstatut==2 || $oldstatut==10 || $oldstatut==11) { if($conditions==0) $statut = 10; if($conditions==1) $statut = 11; if($conditions==2) $statut = 11; if($conditions==3) $statut = 2; if($conditions==4) $statut = 11; //if($transport == "Retrait au showroom - 13821 La penne sur Huveaune") $statut = 12; } if($conditions==0) $date_paiement = 0; if($conditions==1) $date_paiement = mktime(date('H',$olddate_com),date('i',$olddate_com),date('s',$olddate_com),date('m',$olddate_com),date('d',$olddate_com)+30,date('Y',$olddate_com)); if($conditions==2) $date_paiement = mktime(date('H',$olddate_com),date('i',$olddate_com),date('s',$olddate_com),date('m',$olddate_com),date('d',$olddate_com)+60,date('Y',$olddate_com)); if($conditions==4) $date_paiement = mktime(date('H',$olddate_com),date('i',$olddate_com),date('s',$olddate_com),date('m',$olddate_com),date('d',$olddate_com)+3,date('Y',$olddate_com)); if($conditions==0) $date_paiement = mktime(date('H',$olddate_com),date('i',$olddate_com),date('s',$olddate_com),date('m',$olddate_com),date('d',$olddate_com),date('Y',$olddate_com)); */ mktime(date('H',$olddate_com),date('i',$olddate_com),date('s',$olddate_com),date('m',$olddate_com),date('d',$olddate_com),date('Y',$olddate_com)); $cout_transport = vn($frm['cout_transport']); $commentaires = addslashes($frm['commentaires']); $max=$frm['cptinput']; $montant_ht = 0; for ($i = 1; $i <= $max; $i++) { $montant_ht += $frm["p".$i] * $frm["q".$i]; } $rec = mysql_query_override("select * from gaia_tva where id = '".$frm['tva']."'"); $ttva = mysql_result_override($rec,0,'tva'); $taux_tva = 1+$ttva/100; $cout_transport_ht = $cout_transport/1.2; ///$taux_tva; if($ttva==0) $cout_transport = $cout_transport_ht; $montant_ht = $montant_ht; $montant = $montant_ht*$taux_tva; // + $cout_transport; $total_produit_avant_promo = $total_produit = $montant; //########################################################## //gestion du calcul remise proforma $remise_proforma_calcul = $remise_proforma_calcul_ht = 0; //euros if($remise_proforma_type==1) { $remise_proforma_calcul = $remise_proforma_val; $remise_proforma_calcul_ht = $remise_proforma_val/$taux_tva; if($ttva==0) $remise_proforma_calcul = $remise_proforma_calcul_ht; } //pourcentage if($remise_proforma_type==2) { $remise_proforma_calcul = $montant*$remise_proforma_val/100; $remise_proforma_calcul_ht = $montant_ht*$remise_proforma_val/100; } //frais de port offert if($remise_proforma_type==3) { $remise_proforma_calcul = $cout_transport; $remise_proforma_calcul_ht = $cout_transport_ht; } $montant_ht = $montant_ht - $remise_proforma_calcul_ht; $montant = $montant - $remise_proforma_calcul; //########################################################## $total_produit_avant_promo_ht = $total_produit_avant_promo/$taux_tva; $montant = $montant + $cout_transport; $montant_ht = $montant_ht + $cout_transport_ht; $total_tva = $montant - $montant_ht; $client_info1 = $societe1."\n" .$prenom1." ".$nom1."\n" .$adresse1."\n" .$cp1.' '.$ville1."\n".$pays1."\n" ."email : ".$email1."\n" ."tel : ".$telephone1."\n"; $client_info2 = $societe2."\n" .$prenom2." ".$nom2."\n" .$adresse2."\n" .$cp2.' '.$ville2."\n".$pays2."\n" ."email : ".$email2."\n" ."tel : ".$telephone2."\n"; /* Met à jour la table produits */ $sql = " UPDATE gaia_commandes SET client_info1 = '$client_info1' ,client_info2 = '$client_info2' ,email = '$email' ,societe_bill = '$societe1' ,nom_bill = '$nom1' ,prenom_bill = '$prenom1' ,adresse_bill = '$adresse1' ,zip_bill = '$cp1' ,ville_bill = '$ville1' ,pays_bill = '$pays1' ,email_bill = '$email1' ,telephone_bill = '$telephone1' ,societe_ship = '$societe2' ,nom_ship = '$nom2' ,prenom_ship = '$prenom2' ,adresse_ship = '$adresse2' ,zip_ship = '$cp2' ,ville_ship = '$ville2' ,pays_ship = '$pays2' ,email_ship = '$email2' ,telephone_ship = '$telephone2' ,paiement = '$paiment' ,conditions = '$conditions' ,date_paiement = '$date_paiement' ,statut = '$statut' ,commentaires = '$commentaires' ,montant = '$montant' ,montant_ht = '$montant_ht' ,total_produit_avant_promo = '$total_produit_avant_promo' ,total_produit_avant_promo_ht = '$total_produit_avant_promo_ht' ,total_produit = '$total_produit' ,total_tva = '$total_tva' ,zone_tva = '".$frm['tva']."' ,transport = '$transport' ,cout_transport = '$cout_transport' ,cout_transport_ht = '$cout_transport_ht' ,transport_manuel = '$transport_manuel' ,remise_proforma_type = '$remise_proforma_type' ,remise_proforma_val = '$remise_proforma_val' ,remise_proforma_calcul = '$remise_proforma_calcul' ,remise_proforma_calcul_ht = '$remise_proforma_calcul_ht' ,lang = '".$_SESSION['langue']."' WHERE id = '$commandeid ' "; $qid = mysql_query_override($sql); $recart = mysql_query_override ("select * from gaia_commandes_articles WHERE commande_id = '$commandeid'"); while ($art = mysql_fetch_array_override($recart)) { $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_fr = '".$art['taille']."'")); $table = 'gaia_stocks'; if($frm['priv']=='clico') $table = 'gaia_stocks'; mysql_query_override("UPDATE ".$table." SET stock = (stock + ".$art['quantite'].") WHERE produit_id = '".$art['produit_id']."' AND taille_id = '".vn($t['id'])."'"); } $poidstot = 0; $nbcolis = 0; mysql_query_override("DELETE FROM gaia_commandes_articles WHERE commande_id = '$commandeid'"); for ($i = 1; $i <= $max; $i++) { $recprod = mysql_query_override("select * from gaia_produits where id = '".$frm["l".$i]."'"); // Récupère les variables dans le formulaire $prix_revient = $frm["p".$i]; if (mysql_num_rows_override($recprod)>0) { $nom = mysql_result_override($recprod,0,'nom_fr'); } $prodid = $frm["l".$i]; $istaille = 0; $rectailaaa = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectailaaa)){ if(isset($frm["tail".$i."_".$pt['id']]) && $frm["tail".$i."_".$pt['id']] > 0) { $istaille++; // Récupère les variables dans le formulaire $rectail = mysql_query_override("select * from gaia_tailles where id = '".$pt['id']."'"); $taille = mysql_result_override($rectail,0,'nom_fr'); $quantite = $frm["tail".$i."_".$pt['id']]; $couleur = ''; $reccol = mysql_query_override("select * from gaia_couleurs where id = '".$frm["c".$i]."'"); if(mysql_num_rows_override($reccol)>0) $couleur = mysql_result_override($reccol,0,'nom_fr'); $prix = $frm["p".$i] * (1+$ttva/100); //(1+$frm["t".$i]/100); $prix_ht = $frm["p".$i]; $tva = $ttva; //$frm["t".$i]; $total_prix = $prix * $quantite; $total_revient = $prix_revient * $quantite; $total_prix_ht = $prix_ht * $quantite; $marge = $total_prix_ht - $total_revient; // Lie la commande au produit $requete = "INSERT INTO gaia_commandes_articles ( commande_id, produit_id, nom_produit, taille, couleur, marge, prix, prix_cat, prix_ht, prix_cat_ht, total_prix, total_prix_ht, quantite, tva ) VALUES ( '".$commandeid."' ,'".$prodid."' ,'".$nom."' ,'".$taille."' ,'".$couleur."' ,'".$marge."' ,'".$prix."' ,'".$prix."' ,'".$prix_ht."' ,'".$prix_ht."' ,'".$total_prix."' ,'".$total_prix_ht."' ,'".$quantite."' ,'".$tva."')"; $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); $poidstot += $prod['poids']*$quantite; if (!empty($quantite) && !empty($prodid)) { mysql_query_override($requete); $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); if ($prod['on_stock'] == 1) { $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_fr = '".$taille."'")); $table = 'gaia_stocks'; if($frm['priv']=='clico') $table = 'gaia_stocks'; $s = mysql_fetch_array_override(mysql_query_override("SELECT stock FROM ".$table." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."' AND taille_id = '".vn($t['id'])."'")); $stock = $s['stock'] - $quantite; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) { $stock_to_order = $quantite - $s['stock'] ; mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); } else { $stock_to_order = 0; } mysql_query_override("UPDATE ".$table." SET stock = ".$stock_restant." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."' AND taille_id = '".vn($t['id'])."'"); } } }} if($istaille==0) { $quantite = $frm["q".$i]; $taille = $couleur = ''; $reccol = mysql_query_override("select * from gaia_couleurs where id = '".$frm["c".$i]."'"); if(mysql_num_rows_override($reccol)>0) $couleur = mysql_result_override($reccol,0,'nom_fr'); $prix = $frm["p".$i] * (1+$ttva/100); //(1+$frm["t".$i]/100); $prix_ht = $frm["p".$i]; $tva = $ttva; //$frm["t".$i]; $total_prix = $prix * $quantite; $total_revient = $prix_revient * $quantite; $total_prix_ht = $prix_ht * $quantite; $marge = $total_prix_ht - $total_revient; // Lie la commande au produit $requete = "INSERT INTO gaia_commandes_articles ( commande_id, produit_id, nom_produit, taille, couleur, marge, prix, prix_cat, prix_ht, prix_cat_ht, total_prix, total_prix_ht, quantite, tva ) VALUES ( '".$commandeid."' ,'".$prodid."' ,'".$nom."' ,'".$taille."' ,'".$couleur."' ,'".$marge."' ,'".$prix."' ,'".$prix."' ,'".$prix_ht."' ,'".$prix_ht."' ,'".$total_prix."' ,'".$total_prix_ht."' ,'".$quantite."' ,'".$tva."')"; $recprod = mysql_query_override ("select * from gaia_produits where id = '".$frm['l'.$i]."'"); $prod = mysql_fetch_array_override($recprod); $poidstot += $prod['poids']*$quantite; if (!empty($quantite) && !empty($prodid)) { mysql_query_override($requete); if ($prod['on_stock'] == 1) { $table = 'gaia_stocks'; $s = mysql_fetch_array_override(mysql_query_override("SELECT stock FROM ".$table." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."' ")); $stock = $s['stock'] - $quantite; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) { $stock_to_order = $quantite - $s['stock'] ; mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); } else { $stock_to_order = 0; } mysql_query_override("UPDATE ".$table." SET stock = ".$stock_restant." WHERE produit_id = '".$prod['id']."' AND couleur_id = '".$frm['c'.$i]."'"); } } } } if ($cout_transport>0 && $transport_manuel == 0) { $poidstot = $poidstot/1000; $nbcolis = ceil($poidstot/30); $montant = $montant - $cout_transport; $montant_ht = $montant_ht - $cout_transport_ht; if($pays2=='France') $cout_transport_ht = $nbcolis*$dpd_france; elseif($pays2=='Suisse') $cout_transport_ht = $nbcolis*$dpd_suisse; else $cout_transport_ht = $nbcolis*$dpd_europe; $cout_transport = $cout_transport_ht*1.2; if($ttva==0) $cout_transport = $cout_transport_ht; $montant = $montant + $cout_transport; $montant_ht = $montant_ht + $cout_transport_ht; $total_tva = $montant - $montant_ht; mysql_query_override("UPDATE gaia_commandes SET montant = '".$montant."', montant_ht = '".$montant_ht."', total_tva = '".$total_tva."', cout_transport = '".($cout_transport)."', cout_transport_ht = '".$cout_transport_ht."', nbcolis = '".$nbcolis."' WHERE id = '".$commandeid."'"); } } function affiche_proforma_detail(&$commandeid) { global $wwwroot; /* Charge la liste des commandes et les affiche. */ $qid_commande = mysql_query_override("SELECT * FROM gaia_commandes WHERE id = '" . $commandeid . "'"); $qid_items = mysql_query_override(" SELECT oi.nom_produit AS nom ,oi.prix AS purchase_prix ,oi.prix_ht AS purchase_prix_ht ,oi.quantite ,oi.taille ,oi.produit_id ,oi.prix * oi.quantite AS total ,oi.tva FROM gaia_commandes_articles oi WHERE commande_id = '" . $commandeid . "' Group by produit_id order by nom_produit"); $c = mysql_fetch_array_override($qid_commande); $total_ht = $c['montant_ht']; $total_ttc = $c['montant']; $recclient = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur = '".$c['id_utilisateur']."'"); $client = mysql_fetch_array_override($recclient); if($client['priv']=='reve' || $client['priv']=='distri' || $client['priv']=='stop') $sup = 'prof'; else $sup = 'html'; $sup = 'html'; ?> <table border="0" class="tablespace" cellpadding="0" cellspacing="5" width="100%"> <tr> <td class="menu">DETAIL DE LA PROFORMA N° <?echo $c['id'];?> DU <?echo return_date_fr($c['o_timestamp']);?></td> <td class="menu"><a style="font-size:14px" href=<?=$_SERVER['PHP_SELF']?>?mode=modif&id=<?=$c['id'];?>&action=update><strong>éditer / modifier</strong></a></td></tr> <!-- <tr> <td class='petit'>Lien bon de livraison</td> <td ><a class="petit" href='<?=$wwwroot?>/factures/facture_<?=$sup?>.php?id=<?=$c['id'];?>×tamp=<?=urlencode($c['o_timestamp'])?>&mode=livraison' target="_blank">cliquez ici</a></td> </tr> --> <tr> <td class='petit'>Lien proforma</td> <td ><a class="petit" href='<?=$wwwroot?>/factures/facture_<?=$sup?>.php?id=<?=$c['id'];?>×tamp=<?=urlencode($c['o_timestamp'])?>&mode=proforma' target="_blank">cliquez ici</a></td> </tr> <tr> <td class='petit'>Lien facture</td> <td><a class="petit" href='<?=$wwwroot?>/factures/facture_<?=$sup?>.php?id=<?=$c['id'];?>×tamp=<?=urlencode($c['o_timestamp'])?>&mode=facture' target="_blank">cliquez ici</a></td> </tr> <tr> <td class='petit' >N° Facture proforma</td> <td class='petit' ><?echo $c['id'];?></td> </tr> <tr> <td class='petit' >Identifiant client</td> <td class='petit' ><?echo $c['email'];?></td> </tr> <tr><td colspan="2" class="menu">Adresse de facturation</td></tr> <tr> <td class='petit' >Société</td> <td class='petit' ><?echo $c['societe_bill'];?></td> </tr> <tr> <td class='petit' >Contact</td> <td class='petit' ><?echo $c['prenom_bill']." ".$c['nom_bill'];?></td> </tr> <tr> <td class='petit' >Adresse</td> <td class='petit' ><?echo $c['adresse_bill'];?></td> </tr> <tr> <td class='petit' >Ville</td> <td class='petit' ><?echo $c['zip_bill']." ".$c['ville_bill'];?></td> </tr> <tr> <td class='petit' >Pays</td> <td class='petit' ><?echo $c['pays_bill'];?></td> </tr> <tr> <td class='petit' >Téléphone</td> <td class='petit' ><?echo $c['telephone_bill'];?></td> </tr> <tr> <td class='petit' >Email</td> <td class='petit' ><?echo $c['email_bill'];?></td> </tr> <tr><td colspan="2" class="menu">Adresse de livraison</td></tr> <tr> <td class='petit' >Société</td> <td class='petit' ><?echo $c['societe_ship'];?></td> </tr> <tr> <td class='petit' >Contact</td> <td class='petit' ><?echo $c['prenom_ship']." ".$c['nom_bill'];?></td> </tr> <tr> <td class='petit' >Adresse</td> <td class='petit' ><?echo $c['adresse_ship'];?></td> </tr> <tr> <td class='petit' >Ville</td> <td class='petit' ><?echo $c['zip_ship']." ".$c['ville_ship'];?></td> </tr> <tr> <td class='petit' >Pays</td> <td class='petit' ><?echo $c['pays_ship'];?></td> </tr> <tr> <td class='petit' >Téléphone</td> <td class='petit' ><?echo $c['telephone_ship'];?></td> </tr> <tr> <td class='petit' >Email</td> <td class='petit' ><?echo $c['email_ship'];?></td> </tr> <tr><td colspan="2" class="menu">Informations sur la commande</td></tr> <tr> <td class='petit' >TVA</td> <td class='petit' > <? $rec = mysql_query_override("select * from gaia_tva where id = '".$c['zone_tva']."'"); echo $ttva = mysql_result_override($rec,0,'tva').'%'; ?> </td> </tr> <tr> <td class='petit' >Paiement</td> <td class='petit' ><?echo $c['paiement'];?></td> </tr> <!-- <tr> <td class='petit' >Conditions</td> <td class='petit' > <?=(($c['conditions']==3)?'Pr�commande':'')?> <?=(($c['conditions']==0)?'Paiement comptant':'')?> <?=(($c['conditions']==4)?'Paiement 3 jours':'')?> <?=(($c['conditions']==1)?'Paiement 30 jours':'')?> <?=(($c['conditions']==2)?'Paiement 60 jours':'')?> </td> </tr> --> <tr> <td class='petit' >Type de transport</td> <td class='petit' ><?echo $c['transport'];?></td> </tr> <tr> <td class='petit' >Coût de transport TTC</td> <td class='petit' ><?echo $c['cout_transport'];?></td> </tr> <tr> <td class='petit' >Commentaires</td> <td class='petit' ><?echo !empty($c['commentaires']) ? nl2br(stripslashes($c['commentaires'])) : "aucun";?></td> </tr> <tr> <th class='entete' colspan='2'>Liste des produits commandés :</th> </tr> <tr> <td class='petit' colspan='2'> <table border='0' cellpadding='0' cellspacing='0' width='100%'> <tr > <td class="menu" >produit</td> <? $rectail = mysql_query_override("select * from gaia_tailles order by position"); while($pt = mysql_fetch_array_override($rectail)){ echo '<td class="menu" align="center">'.stripslashes($pt['nom_fr']).'</td>'; } ?> <td class="menu" align='center'>quantité</td> <td class="menu" align='center'>prix unitaire HT</td> <td class="menu" align='right'>prix total HT</td> </tr> <? $qte_total = 0; while ($prod = mysql_fetch_array_override($qid_items)) { ?> <tr> <td class='petit' ><?echo stripslashes($prod['nom']);?></td> <? $qtetotal = 0; $rectail = mysql_query_override("select * from gaia_tailles order by position"); if(mysql_num_rows_override($rectail)>0) { while ($pt = mysql_fetch_array_override($rectail)) { echo '<td class="petit" align="center" style="width:25px">'; $table = 'gaia_stocks'; if ($client['priv'] == 'clico') $table = 'gaia_stocks'; $rectailaaa = mysql_query_override("select t.*, s.stock from " . $table . " s left join gaia_tailles t on s.taille_id = t.id where t.id = '" . $pt['id'] . "' and s.produit_id = '" . $prod['produit_id'] . "' "); if (mysql_num_rows_override($rectailaaa) > 0) { $pr = mysql_fetch_array_override($rectailaaa); $recqte = mysql_query_override("select * from gaia_commandes_articles where commande_id = '" . $commandeid . "' and produit_id = '" . $prod['produit_id'] . "' and taille = '" . addslashes($pr['nom_fr']) . "'"); $qtetail = mysql_result_override($recqte, 0, 'quantite'); $qtetotal += $qtetail; echo $qtetail; //'<input type="text" value="'.$qtetail.'" style="width:25px" />'; } else { echo $prod['quantite']; $qtetotal += $prod['quantite']; } echo "</td>"; } } else { $qtetotal = $prod['quantite']; } ?> <td class='petit' align='center'><?echo $qtetotal; $qte_total += $qtetotal; ?></td> <td class='petit' align='center'><?echo $prod['purchase_prix_ht'];?></td> <td class='petit' align='right'><?echo $qtetotal*$prod['purchase_prix_ht'];?></td> </tr> <? } ?> <tr> <? $rectail = mysql_query_override("select * from gaia_tailles order by position"); $nbt = mysql_num_rows_override($rectail); ?> <td colspan="<?=($nbt+1)?>"></td> <td class='petit' align='center'><?=$qte_total?></td> <td colspan="2"></td> </tr> <tr> <td colspan="5"><hr size='1' color='#99cccc'></td> </tr> <tr> <td colspan="25" class='petit' align='right'><b>TOTAL HT :</b> <span class='total' align='right'><font color='red'><?echo fprix($total_ht);?> € H.T</font></span></td> </tr> <? if($ttva>0) { ?> <tr> <td colspan="25" class='petit' align='right'> <b>TOTAL TTC :</b> <span class='total'><font color='red'><?echo fprix($total_ttc);?> € T.T.C</font></span></td> </tr> <? } ?> </table> </td></tr> </table> <? } function mail_proforma(&$id) { global $support; global $site; global $wwwroot; global $lg; $sql = "SELECT u.priv, c.* FROM gaia_commandes c, gaia_utilisateurs u WHERE c.id_utilisateur = u.id_utilisateur and id = '".$id."'"; $resultat = mysql_query_override($sql); $c = mysql_fetch_array_override($resultat); $commandeid = $c['id']; $urlproforma = "$wwwroot/factures/facture_prof.php?timestamp=".urlencode($c['o_timestamp'])."&mode=proforma&id=".$c['id']; $urlproforma = "$wwwroot/factures/facture_html.php?timestamp=".urlencode($c['o_timestamp'])."&mode=facture&id=".$c['id']; $mailHeaders = "From: ".$site." <".$support.">\n"; $mailHeaders .= "Content-Type: text/html;\n"; $mailHeaders .= "Date: ".date("D, j M Y H:i:s"). " +0100\n"; if($c['priv']=='util' || $c['priv']=='clico') $link = 'http://www.colissimo.fr/particuliers/home.jsp'; else $link = 'http://www.dpd.fr/trace'; /* destinataire */ $destinataire = $c['email']; /* sujet */ $mail = get_static(430); $mailSubject = $mail['nom_'.$c['lang']]; $mailObjet = mail_transform(4,$mail['description_'.$c['lang']], intval($id), 0 ); mail_confirm($c['email'],$mailSubject,$mailObjet,$mailHeaders); /* $objet = "[$site FACTURE N° $id]"; $message = "Bonjour ".$c['prenom_bill'].",<br /><br />"; $message .= "Merci pour ta confiance.<br />Ta commande vient d'�tre exp�di�e, elle porte le num�ro de traking :<br />"; $message .= "".$c['colis']."<br /><br />"; $message .= "Tu peux suivre l'�volution de ton / tes colis sur le site en rentrant ce num�ro sur la droite dans l'espace suivi de colis <a href=\"".$link."?lang=fr\">sur ce site</a>.<br /><br />"; $message .= "Tu peux �diter ta facture en <a href=\"".$urlproforma."&lg=fr\">cliquant ici</a>.<br /><br />"; $message .= "Je reste � ton enti�re disposition pour tous renseignements compl�mentaires.<br /><br />"; $message .= "L'�quipe de Hyraw Clothing"; $message .= "<br /><br />--------------------------------------------------------------------------<br /><br />"; $message .= "Good morning ".$c['prenom_bill'].",<br /><br />"; $message .= "Thanks for you order.<br />You order has been shipped, you can follow your boxes thanks to the tracking number :<br />"; $message .= "".$c['colis']."<br /><br />"; $message .= "You can follow the progress of your delivery with this tracking number <a href=\"".$link."?lang=en\">on this website</a>.<br /><br />"; $message .= "You could see and print your invoice by <a href=\"".$urlproforma."&lg=en\">clicking here</a>. <br /><br />"; $message .= "We stay at your full disposal for any help or any question.<br /><br />"; $message .= "Hyraw Team"; mail($c['email'],$objet,$message,$mailHeaders); */ echo '<div class= "alert alert-success">Le mail pour la proforma '.$id.' a été envoyé au destinataire '.$destinataire.'</div>'; } ?>