From 5485dc883024472b5363d9d942b428a31de1a82e Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 7 Nov 2003 09:46:55 +0000 Subject: [PATCH] Modif creation --- htdocs/commande/fiche.php | 772 ++++++++++++++------------------------ 1 file changed, 276 insertions(+), 496 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 0b5c41a7818..d62c9197f97 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -25,7 +25,6 @@ $user->getrights('commande'); if (!$user->rights->commande->lire) accessforbidden(); -require("../commande.class.php"); require("../project.class.php"); require("../propal.class.php"); @@ -45,7 +44,7 @@ if ($user->societe_id > 0) if ($HTTP_POST_VARS["action"] == 'classin') { $commande = new Commande($db); - $commande->fetch($facid); + $commande->fetch($_GET["id"]); $commande->classin($HTTP_POST_VARS["projetid"]); } /* @@ -53,74 +52,25 @@ if ($HTTP_POST_VARS["action"] == 'classin') */ if ($HTTP_POST_VARS["action"] == 'add') { - $datecommande = mktime(12, 0 , 0, $remonth, $reday, $reyear); + $datecommande = mktime(12, 0 , 0, $HTTP_POST_VARS["remonth"], $HTTP_POST_VARS["reday"], $HTTP_POST_VARS["reyear"]); - $commande = new Commande($db, $socid); + $commande = new Commande($db); - $commande->number = $HTTP_POST_VARS["facnumber"]; - $commande->date = $datecommande; + $commande->soc_id = $HTTP_POST_VARS["soc_id"]; + $commande->date_commande = $datecommande; $commande->note = $HTTP_POST_VARS["note"]; - if ($HTTP_POST_VARS["fac_rec"] > 0) - { - /* - * Commande récurrente - */ - $commande->fac_rec = $HTTP_POST_VARS["fac_rec"]; - $facid = $commande->create($user); - } - else - { - $commande->projetid = $HTTP_POST_VARS["projetid"]; - $commande->cond_reglement = $HTTP_POST_VARS["condid"]; - $commande->amount = $HTTP_POST_VARS["amount"]; - $commande->remise = $HTTP_POST_VARS["remise"]; - $commande->remise_percent = $HTTP_POST_VARS["remise_percent"]; + $commande->projetid = $HTTP_POST_VARS["projetid"]; + $commande->remise_percent = $HTTP_POST_VARS["remise_percent"]; - if (!$HTTP_POST_VARS["propalid"]) - { - $commande->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]); - $commande->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]); - $commande->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]); - $commande->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]); - - $facid = $commande->create($user); - } - else - { - $commande->propalid = $HTTP_POST_VARS["propalid"]; - - $facid = $commande->create($user); - - if ($facid) - { - $prop = New Propal($db); - if ( $prop->fetch($HTTP_POST_VARS["propalid"]) ) - { - for ($i = 0 ; $i < sizeof($prop->lignes) ; $i++) - { - $result = $commande->addline($facid, - addslashes($prop->lignes[$i]->libelle), - $prop->lignes[$i]->subprice, - $prop->lignes[$i]->qty, - $prop->lignes[$i]->tva_tx, - $prop->lignes[$i]->product_id, - $prop->lignes[$i]->remise_percent); - } - } - else - { - print "Erreur"; - } - } - else - { - print "

Erreur : la commande n'a pas été créée, vérifier le numéro !"; - print "

Retour à la propal"; - print $db->error(); - } - } - } + $commande->add_product($HTTP_POST_VARS["idprod1"],$HTTP_POST_VARS["qty1"],$HTTP_POST_VARS["remise_percent1"]); + $commande->add_product($HTTP_POST_VARS["idprod2"],$HTTP_POST_VARS["qty2"],$HTTP_POST_VARS["remise_percent2"]); + $commande->add_product($HTTP_POST_VARS["idprod3"],$HTTP_POST_VARS["qty3"],$HTTP_POST_VARS["remise_percent3"]); + $commande->add_product($HTTP_POST_VARS["idprod4"],$HTTP_POST_VARS["qty4"],$HTTP_POST_VARS["remise_percent4"]); + + $commande_id = $commande->create($user); + + $id = $commande->id; $action = ''; } @@ -129,142 +79,78 @@ if ($HTTP_POST_VARS["action"] == 'add') * */ -if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] == yes && $user->rights->commande->valider) -{ - $fac = new Commande($db); - $fac->fetch($facid); - $soc = new Societe($db); - $soc->fetch($fac->socidp); - $result = $fac->set_valid($facid, $user, $soc); - if ($result) - { - commande_pdf_create($db, $facid); - } -} - -if ($action == 'payed' && $user->rights->commande->paiement) -{ - $fac = new Commande($db); - $result = $fac->set_payed($facid); -} if ($HTTP_POST_VARS["action"] == 'setremise' && $user->rights->commande->creer) { - $fac = new Commande($db); - $fac->fetch($facid); + $commande = new Commande($db); + $commande->fetch($id); - $fac->set_remise($user, $HTTP_POST_VARS["remise"]); + $commande->set_remise($user, $HTTP_POST_VARS["remise"]); } - -if ($action == 'addligne' && $user->rights->commande->creer) +if ($HTTP_POST_VARS["action"] == 'addligne' && $user->rights->commande->creer) { - $fac = new Commande($db); - $fac->fetch($facid); - $result = $fac->addline($facid, - $HTTP_POST_VARS["desc"], - $HTTP_POST_VARS["pu"], - $HTTP_POST_VARS["qty"], - $HTTP_POST_VARS["tva_tx"], - 0, - $HTTP_POST_VARS["remise_percent"]); + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + + if ($HTTP_POST_VARS["p_idprod"] > 0) + { + $result = $commande->addline("DESC", + $HTTP_POST_VARS["pu"], + $HTTP_POST_VARS["pqty"], + $HTTP_POST_VARS["tva_tx"], + $HTTP_POST_VARS["p_idprod"], + $HTTP_POST_VARS["premise"]); + } + else + { + $result = $commande->addline($HTTP_POST_VARS["desc"], + $HTTP_POST_VARS["pu"], + $HTTP_POST_VARS["qty"], + $HTTP_POST_VARS["tva_tx"], + 0, + $HTTP_POST_VARS["remise_percent"]); + } } if ($action == 'updateligne' && $user->rights->commande->creer) { - $fac = new Commande($db,"",$facid); - $fac->fetch($facid); - $result = $fac->updateline($rowid, - $HTTP_POST_VARS["desc"], - $HTTP_POST_VARS["price"], - $HTTP_POST_VARS["qty"], - $HTTP_POST_VARS["remise_percent"]); + $fac = new Commande($db,"",$id); + $commande->fetch($id); + $result = $commande->updateline(rowid, + $HTTP_POST_VARS["desc"], + $HTTP_POST_VARS["price"], + $HTTP_POST_VARS["qty"], + $HTTP_POST_VARS["remise_percent"]); } if ($action == 'deleteline' && $user->rights->commande->creer) { - $fac = new Commande($db,"",$facid); - $fac->fetch($facid); - $result = $fac->deleteline($rowid); + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + $result = $commande->delete_line($_GET["lineid"]); +} + +if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] == yes && $user->rights->commande->valider) +{ + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + $soc = new Societe($db); + $soc->fetch($commande->soc_id); + $result = $commande->valid($user); } if ($HTTP_POST_VARS["action"] == 'confirm_delete' && $HTTP_POST_VARS["confirm"] == yes) { if ($user->rights->commande->supprimer ) { - $fac = new Commande($db); - $fac->delete($facid); - $facid = 0 ; + $commande = new Commande($db); + $commande->id = $_GET["id"]; + $commande->delete(); + $id = 0 ; } } -/* - * - */ -if ($action == 'send') -{ - $fac = new Commande($db,"",$facid); - $fac->fetch($facid); - - $soc = new Societe($db, $fac->socidp); - - $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; - - if (file_exists($file)) - { - - $sendto = $soc->contact_get_email($HTTP_POST_VARS["destinataire"]); - $sendtoid = $HTTP_POST_VARS["destinataire"]; - - if (strlen($sendto)) - { - - $subject = "Commande $fac->ref"; - $message = "Veuillez trouver ci-joint la commande $fac->ref\n\nCordialement\n\n"; - $filename = "$fac->ref.pdf"; - - $replyto = $HTTP_POST_VARS["replytoname"] . " <".$HTTP_POST_VARS["replytomail"] .">"; - - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$file, "application/pdf", $filename); - - if ( $mailfile->sendfile() ) - { - - $sendto = htmlentities($sendto); - - $sql = "INSERT INTO llx_actioncomm (datea,fk_action,fk_soc,note,fk_commande, fk_contact,fk_user_author, label, percent) VALUES (now(), 9 ,$fac->socidp ,'Envoyée à $sendto',$fac->id, $sendtoid, $user->id, 'Envoi Commande par mail',100);"; - - if (! $db->query($sql) ) - { - print $db->error(); - print "

$sql

"; - } - } - else - { - print "!! erreur d'envoi
$sendto
$replyto
$filename"; - } - } - else - { - print "Can't get email $sendto"; - } - } -} -/* - * - */ -if ($HTTP_POST_VARS["action"] == 'relance') -{ - $fac = new Commande($db,"",$facid); - $fac->fetch($facid); - - $fac->send_relance($HTTP_POST_VARS["destinataire"], - $HTTP_POST_VARS["replytoname"], - $HTTP_POST_VARS["replytomail"], - $user); -} - /* * */ @@ -274,7 +160,7 @@ if ($action == 'pdf') * Generation de la commande * définit dans /includes/modules/commande/modules_commande.php */ - commande_pdf_create($db, $facid); + commande_pdf_create($db, $_GET["id"]); } $html = new Form($db); @@ -288,7 +174,7 @@ $html = new Form($db); ************************************************************************/ if ($action == 'create') { - print_titre("Emettre une commande"); + print_titre("Créer une commande"); if ($propalid) { @@ -316,7 +202,7 @@ if ($action == 'create') print '
'; print ''; - print '' ."\n"; + print '' ."\n"; print ''; print ''; @@ -326,7 +212,7 @@ if ($action == 'create') print ""; - print ''; print ""; print ""; print ''; - print ""; + print ""; if ($propalid > 0) @@ -420,38 +288,7 @@ if ($action == 'create') print '
Auteur :".$user->fullname."'; + print ''; print '
Date :"; @@ -336,29 +222,11 @@ if ($action == 'create') print "
Numéro :Provisoire
Conditions de réglement :"; - $sql = "SELECT rowid, libelle FROM llx_cond_reglement ORDER BY sortorder"; - $result = $db->query($sql); - $conds=array(); - if ($result) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($i); - $conds[$objp->rowid]=$objp->libelle; - $i++; - } - $db->free(); - } - - $html->select_array("condid",$conds); - print "
Projet :"; $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($socidp)); + $html->select_array("projetid",$proj->liste_array($socidp),0,1); print "
'; print ''; } - /* - * Commandes récurrentes - * - */ - if ($propalid == 0) - { - $sql = "SELECT r.rowid, r.titre, r.amount FROM llx_commande_rec as r"; - $sql .= " WHERE r.fk_soc = $socidp"; - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - $i = 0; - - if ($num > 0) - { - print 'Commandes récurrentes : '; - } - $db->free(); - } - else - { - print "$sql"; - } - } + /* * */ @@ -521,30 +358,28 @@ if ($action == 'create') } else { - print $db->error(); + print $db->error() . "
$sql";; } } else /* *************************************************************************** */ /* */ -/* */ +/* Mode vue et edition */ /* */ /* *************************************************************************** */ -{ - - if ($facid > 0) +{ + if ($id > 0) { - - $fac = New Commande($db); - if ( $fac->fetch($facid, $user->societe_id) > 0) + $commande = New Commande($db); + if ( $commande->fetch($id) > 0) { - $soc = new Societe($db, $fac->socidp); - $soc->fetch($fac->socidp); + $soc = new Societe($db); + $soc->fetch($commande->soc_id); $author = new User($db); - $author->id = $fac->user_author; + $author->id = $commande->user_author_id; $author->fetch(); - print_titre("Commande : ".$fac->ref); + print_titre("Commande : ".$commande->ref); /* * Confirmation de la suppression de la commande @@ -552,7 +387,7 @@ else */ if ($action == 'delete') { - $html->form_confirm("$PHP_SELF?facid=$facid","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete"); + $html->form_confirm("$PHP_SELF?id=$id","Supprimer la commande","Etes-vous sûr de vouloir supprimer cette commande ?","confirm_delete"); } /* @@ -561,220 +396,161 @@ else */ if ($action == 'valid') { - $numfa = commande_get_num($soc); - $html->form_confirm("$PHP_SELF?facid=$facid","Valider la commande","Etes-vous sûr de vouloir valider cette commande avec le numéro $numfa ?","confirm_valid"); + //$numfa = commande_get_num($soc); + $html->form_confirm("$PHP_SELF?id=$id","Valider la commande","Etes-vous sûr de vouloir valider cette commande ?","confirm_valid"); } /* * Commande */ + if ($commande->brouillon == 1 && $user->rights->commande->creer) + { + print ''; + print ''; + } + print ''; print ""; print "'; + print ''.$soc->nom.''; - print ""; + print ""; print ""; - print "\n"; - print ""; + print "\n"; - print '"; + print " "; print ""; - if ($fac->remise_percent > 0) + print ''; + print ''; + print ''; + + print '"; - - print ''; - print ''; - print ''; - - if ($fac->remise_percent > 0) - { - print ''; - print ''; - print ''; - } - - print ''; - print ''; - print ''; - print ''; - if ($fac->note) - { - print '"; - } - - print "
Client"; - print ''.$soc->nom.'Conditions de réglement : " . $fac->cond_reglement ."
Source : " . $commande->sources[0] ."
Date".strftime("%A %d %B %Y",$fac->date)."Date limite de réglement : " . strftime("%d %B %Y",$fac->date_lim_reglement) ."
".strftime("%A %d %B %Y",$commande->date)."
Projet'; - if ($fac->projetid > 0) + print 'Projet : '; + if ($commande->projet_id > 0) { $projet = New Project($db); - $projet->fetch($fac->projetid); - print ''.$projet->title.''; + $projet->fetch($commande->projet_id); + print ''.$projet->title.''; } else { - print 'Classer la commande'; + print 'Classer la commande'; } - print " Paiements
Auteur$author->fullname
Montant'.price($commande->total_ht).''.MAIN_MONNAIE.' HT
Remise'; + + if ($commande->brouillon == 1 && $user->rights->commande->creer) { - print ''; + print '%'; + print ''; } else { - print ''; + print $commande->remise_percent.' % '; } - - /* - * Paiements - */ - $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid"; - $sql .= " FROM llx_paiement as p, c_paiement as c WHERE p.fk_commande = $facid AND p.fk_paiement = c.id"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - $i = 0; $total = 0; - echo ''; - print ''; - print ""; - if (! $fac->paye) - { - print ""; - } - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print '\n"; - if (! $fac->paye && $user->rights->commande->paiement) - { - print '"; - $total = $total + $objp->amount; - $i++; - } + print ''; - if ($fac->paye == 0) - { - print "\n"; - print "\n"; - - $resteapayer = price($fac->total_ttc - $total); - - print ""; - print "\n"; - } - print "
DateTypeMontant  
".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount)."$_MONNAIEDel'; - } - print "
Total :".price($total)."$_MONNAIE
Facturé :".price($fac->total_ttc)."$_MONNAIE
Reste à payer :".price($fac->total_ttc - $total)."$_MONNAIE
"; - $db->free(); - } else { - print $db->error(); - } - - print "
Montant'.price($fac->total_ht).''.MAIN_MONNAIE.' HT
Remise'.$fac->remise_percent.'%
TVA'.price($fac->total_tva).''.MAIN_MONNAIE.'
Total'.price($fac->total_ttc).''.MAIN_MONNAIE.' TTC
Note : '.nl2br($fac->note)."

"; - - if ($fac->brouillon == 1 && $user->rights->commande->creer) - { - print ''; - print ''; - print '
Remise'; - print '%'; - print ''; - print '
'; - } - - /* - * Lignes de commandes - * - */ - - $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice"; - $sql .= " FROM llx_commandedet as l WHERE l.fk_commande = $facid ORDER BY l.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - $i = 0; $total = 0; - - echo ''; - if ($num) - { - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } - print ''; - print ''; - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - print '\n"; - if ($fac->statut == 0 && $user->rights->commande->creer) - { - print ''; - print ''; - } - else - { - print ''; - } - print ""; + print ''; + print ''; + print ''; + print ''; + if ($commande->note) + { + print '"; + } - if ($action == 'editline' && $rowid == $objp->rowid) - { - print ""; - print ''; - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - print "\n"; - } - - $total = $total + ($objp->qty * $objp->price); - $i++; - } - - $db->free(); - // print "
DescriptionTvaQuantitéRemiseP.U.  
'.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_taux.' %'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice)."deledit  
TVA'.price($commande->total_tva).''.MAIN_MONNAIE.'
Total'.price($commande->total_ttc).''.MAIN_MONNAIE.' TTC
Note : '.nl2br($commande->note)."
 %
"; - } + print "
"; + + if ($commande->brouillon == 1 && $user->rights->commande->creer) + { + print ''; + } + + /* + * Lignes de commandes + * + */ + echo ''; + + $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice"; + $sql .= " FROM llx_commandedet as l WHERE l.fk_commande = $id ORDER BY l.rowid"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + print ""; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + print ''; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + if ($commande->statut == 0 && $user->rights->commande->creer) + { + print ''; + print ''; + } + else + { + print ''; + } + print ""; + + if ($action == 'editline' && $rowid == $objp->rowid) + { + print ""; + print ''; + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print '' . "\n"; + print "\n"; + } + + $total = $total + ($objp->qty * $objp->price); + $i++; + $var=!$var; + } + + $db->free(); + // print "
DescriptionTvaQuantitéRemiseP.U.  
'.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.' %'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice)."deledit  
 %
"; + } else { print $db->error(); @@ -784,21 +560,41 @@ else * Ajouter une ligne * */ - if ($fac->statut == 0 && $user->rights->commande->creer) + if ($commande->statut == 0 && $user->rights->commande->creer) { - print "
"; - // echo ''; - print ""; + $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM llx_product as p "; + $sql .= " WHERE envente = 1"; + $sql .= " ORDER BY p.nbvente DESC LIMIT 20"; + if ( $db->query($sql) ) + { + $opt = ""; + if ($result) + { + $num = $db->num_rows(); $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $opt .= "\n"; + $i++; + } + } + $db->free(); + } + else + { + print $db->error(); + } + + print ""; + print ""; print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; - print "\n"; + print ''."\n"; print ''; - print ''; + print "".''; print ''; @@ -808,6 +604,14 @@ else print ''; + $var=!$var; + print ""; + print ''; + print ''; + print ''; + print ''; + print "\n"; + print ""; } print "
DescriptionTvaQuantitéRemiseP.U.  
  
'; print $html->select_tva("tva_tx"); print '
% 
"; @@ -819,64 +623,43 @@ else { print '

'; - if ($fac->statut == 0 && $user->rights->commande->supprimer) + if ($commande->statut == 0 && $user->rights->commande->supprimer) { - print ""; + print ""; } - elseif ($fac->statut == 1 && abs($resteapayer) > 0 && $user->rights->commande->envoyer) + elseif ($commande->statut == 1 && abs($resteapayer) > 0 && $user->rights->commande->envoyer) { - print ""; + print ""; } else { print ""; } - if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->commande->paiement) - { - print ""; - } - else - { - print ""; - } + + print ""; + - if ($fac->statut == 1 && abs($resteapayer) == 0 && $fac->paye == 0) - { - if ($user->rights->commande->paiement) - { - print ""; - } - else - { - print ''; - } - } - elseif ($fac->statut == 1 && $resteapayer > 0 && $user->rights->commande->envoyer) - { - print ""; - } - else - { - print ''; - } + + print ''; + - if ($fac->statut == 0 && $fac->total_ht > 0) + if ($commande->statut == 0) { if ($user->rights->commande->valider) { - print ""; + print ""; } else { print ''; } } - elseif ($fac->statut == 1 && $fac->paye == 0) + elseif ($commande->statut == 1 && $commande->paye == 0) { if ($user->rights->commande->creer) { - print ""; + print ""; } else { @@ -888,16 +671,9 @@ else print ''; } - if ($fac->statut > 0) - { - //print ''; - print ''; - } - else - { - print ''; - } + print ''; + print "
[Supprimer][Supprimer][Envoyer][Envoyer]-[Emettre un paiement]--[Classer 'Payée']-[Envoyer une relance]--[Valider][Valider]-Générer la commandeGénérer la commande--Récurrente--
"; } @@ -907,7 +683,7 @@ else * Documents générés * */ - $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + $file = FAC_OUTPUTDIR . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; if (file_exists($file)) { @@ -916,7 +692,7 @@ else print ''; print ""; - print ''; + print ''; print ''; print ''; print ''; @@ -929,7 +705,7 @@ else * */ $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note"; - $sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_commande = $facid"; + $sql .= " FROM llx_actioncomm as a WHERE a.fk_soc = $commande->socidp AND a.fk_action in (9,10) AND a.fk_commande = $id"; $result = $db->query($sql); if ($result) @@ -972,13 +748,13 @@ else */ if ($action == 'classer') { - print "

\n"; + print "

\n"; print ''; print '

Commande PDFref."/".$fac->ref.'.pdf">'.$fac->ref.'.pdfref."/".$commande->ref.'.pdf">'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
'; print '"; print '
Projet'; $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($socidp)); + $html->select_array("projetid",$proj->liste_array($commande->soc_id)); print "

'; @@ -995,7 +771,7 @@ else $replytomail = $user->email; $from_mail = $replytomail; - print "
\n"; + print "\n"; print ''; print ''; @@ -1006,7 +782,7 @@ else $form = new Form($db); $form->select_array("destinataire",$soc->contact_email_array()); - print "email\">"; + print "email\">"; print "Expéditeur$from_name$from_mail"; print "Reply-to$replytoname"; print "$replytomail"; @@ -1022,7 +798,7 @@ else $replytomail = $user->email; $from_mail = $replytomail; - print "\n"; + print "\n"; print ''; print ''; print ''; @@ -1034,7 +810,7 @@ else $form = new Form($db); $form->select_array("destinataire",$soc->contact_email_array()); - print "email\">"; + print "email\">"; print "Expéditeur$from_name$from_mail"; print "Reply-to$replytoname"; print "$replytomail"; @@ -1044,10 +820,10 @@ else /* * Propales - */ + * $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; - $sql .= " FROM llx_propal as p, llx_fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_commande = $facid"; + $sql .= " FROM llx_propal as p, llx_fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_commande = $id"; $result = $db->query($sql); if ($result) @@ -1091,7 +867,11 @@ else } } else { print $db->error(); - } + } + + * + * + */ } else {