From f9c1769c1c595f5b1be2206fa008976256a5737e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Aug 2005 02:47:45 +0000 Subject: [PATCH] Uniformisation lignes de commande, propal, facture --- htdocs/comm/fiche.php | 21 +-- htdocs/comm/propal.php | 40 ++--- htdocs/commande/fiche.php | 360 ++++++++++++++++++++------------------ 3 files changed, 210 insertions(+), 211 deletions(-) diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 370d9dbf4d8..e09dd44eba0 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -335,15 +335,15 @@ if ($_socid > 0) print ''; $var=!$var; } - $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; + $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); print ""; print "propalid\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."\n"; - if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) + if ( ($objp->dp < time() - $conf->propal->cloture->warning_delay) && $objp->statutid == 1 ) { - print " > 15 jours"; + print " ".img_warning(); } print ''.dolibarr_print_date($objp->dp)."\n"; print ''.price($objp->price).''; @@ -385,7 +385,7 @@ if ($_socid > 0) print '
'.$langs->trans("LastOrders",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')
'; print ''; } - $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; + $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); @@ -432,7 +432,7 @@ if ($_socid > 0) print ''.$langs->trans("AllContracts").' ('.$num.')'; print ''; } - $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; + $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); @@ -478,7 +478,7 @@ if ($_socid > 0) print ''; $var=!$var; } - $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; + $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); @@ -857,15 +857,6 @@ if ($_socid > 0) } print ""; - // Notes sur la societe - /* - if ($objsoc->note) - { - print ''; - print ""; - print "
".nl2br($objsoc->note)."
"; - } - */ } } else { dolibarr_print_error($db); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 2840815609f..137ee743bbf 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -65,6 +65,8 @@ $NBLINES=4; $form=new Form($db); + + /******************************************************************************/ /* Actions */ /******************************************************************************/ @@ -179,20 +181,7 @@ if ($_POST['action'] == 'send') } $actionmsg2='Envoi Propal par mail'; } - /* - if ($_POST["action"] == 'relance') - { - $subject = "Relance facture $propal->ref"; - $actiontypeid=10; - $actionmsg="Mail envoyé par $from à $sendto.
"; - if ($message) - { - $actionmsg.="Texte utilisé dans le corps du message:
"; - $actionmsg.=$message; - } - $actionmsg2="Relance Facture par mail"; - } - */ + $filepath[0] = $file; $filename[0] = $propal->ref.'.pdf'; $mimetype[0] = 'application/pdf'; @@ -279,7 +268,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer) * Ajout d'une ligne produit dans la propale */ $propal = new Propal($db); - $propal->fetch($_POST['propalid']); + $ret=$propal->fetch($_POST['propalid']); if (isset($_POST['np_tva_tx'])) { @@ -611,18 +600,20 @@ if ($_GET['propalid']) * Lignes de propale * */ - $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; - $sql .= ' WHERE pt.fk_propal = '.$propal->id; - $sql .= ' ORDER BY pt.rowid ASC'; + $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,"; + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; + $sql.= ' WHERE pt.fk_propal = '.$propal->id; + $sql.= ' ORDER BY pt.rowid ASC'; $resql = $db->query($sql); if ($resql) { - $num_lignes = $db->num_rows($resql); + $num = $db->num_rows($resql); $i = 0; $total = 0; print ''; - if ($num_lignes) + if ($num) { print ''; print ''; @@ -635,7 +626,7 @@ if ($_GET['propalid']) print "\n"; } $var=true; - while ($i < $num_lignes) + while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; @@ -662,7 +653,7 @@ if ($_GET['propalid']) { print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')'; } - print $objp->description?'
'.$objp->description:''; + print ($objp->description && $objp->description!=$obj->product)?'
'.$objp->description:''; print ''; } else @@ -724,7 +715,8 @@ if ($_GET['propalid']) print ''; print ''; print ''; - print ''; + print ''; + print ''; } $total = $total + ($objp->qty * $objp->price); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 8df3da018b8..2aa0c0249c6 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -45,16 +45,16 @@ require_once(DOL_DOCUMENT_ROOT."/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); -/* - * Sécurité accés client - */ +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } + + /* - * + * Actions */ if ($_POST["action"] == 'classin' && $user->rights->commande->creer) { @@ -94,7 +94,6 @@ if ($_POST["action"] == 'add' && $user->rights->commande->creer) * */ - if ($_POST["action"] == 'setremise' && $user->rights->commande->creer) { $commande = new Commande($db); @@ -112,27 +111,33 @@ if ($_POST["action"] == 'setnote' && $user->rights->commande->creer) if ($_POST["action"] == 'addligne' && $user->rights->commande->creer) { - $commande = new Commande($db); - $commande->fetch($_GET["id"]); + /* + * Ajout d'une ligne produit dans la commande + */ + $commande = new Commande($db); + $ret=$commande->fetch($_POST["id"]); + + if (isset($_POST["p_idprod"])) + { + $result = $commande->addline( + $_POST["np_desc"], + $_POST["pu"], + $_POST["pqty"], + $_POST["tva_tx"], + $_POST["p_idprod"], + $_POST["premise"]); + } + else + { + $result = $commande->addline( + $_POST["desc"], + $_POST["pu"], + $_POST["qty"], + $_POST["tva_tx"], + 0, + $_POST["remise_percent"]); + } - if ($_POST["p_idprod"] > 0) - { - $result = $commande->addline("DESC", - $_POST["pu"], - $_POST["pqty"], - $_POST["tva_tx"], - $_POST["p_idprod"], - $_POST["premise"]); - } - else - { - $result = $commande->addline($_POST["desc"], - $_POST["pu"], - $_POST["qty"], - $_POST["tva_tx"], - 0, - $_POST["remise_percent"]); - } } if ($_POST["action"] == 'updateligne' && $user->rights->commande->creer) @@ -566,7 +571,7 @@ else } else { - print $commande->remise_percent.' %'; @@ -575,8 +580,7 @@ else print ''; print ''; - print "
'.$langs->trans('Description').'
%
 '; + print $commande->remise_percent.'% '; } print '
'.$langs->trans("TotalTTC").''.price($commande->total_ttc).''.$langs->trans("Currency".$conf->monnaie).'
"; - + print '
'; if ($commande->brouillon == 1 && $user->rights->commande->creer) { print ''; @@ -586,162 +590,174 @@ else * 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 ".MAIN_DB_PREFIX."commandedet as l"; - $sql .= " WHERE l.fk_commande = ".$commande->id; - $sql .= " ORDER BY l.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - $var=true; - while ($i < $num) + $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; + $sql.= " WHERE l.fk_commande = ".$commande->id; + $sql.= " ORDER BY l.rowid"; + + $resql = $db->query($sql); + if ($resql) { - $objp = $db->fetch_object($result); + $num = $db->num_rows($resql); + $i = 0; $total = 0; - $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 ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') - { - print ''; - print ''; - } - else + print '
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Discount").''.$langs->trans("PriceU").'  
'; - print ''.img_object($langs->trans("ShowProduct"),"product").' '.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.'%'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice)."'; - print img_edit(); - print ''; - print img_delete(); - print '
'; + if ($num) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; + print "\n"; } - print ""; - - if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) + $var=true; + while ($i < $num) { - print ""; - print ''; - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - print "\n"; + $objp = $db->fetch_object($resql); + $var=!$var; + + // Update ligne de propale + if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) + { + print ''; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print '\n"; + } + print ''; + + print '\n"; + + print ''; + + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + + // Icone d'edition et suppression + if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') + { + print ''; + print ''; + } + else + { + print ''; + } + print ''; + } + + // Update ligne de commande + if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) + { + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + $total = $total + ($objp->qty * $objp->price); + $i++; } - $i++; - } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } - /* - * Ajouter une ligne - * - */ - if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') - { - $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM ".MAIN_DB_PREFIX."product as p "; - $sql .= " WHERE envente = 1"; - $sql .= " ORDER BY p.nbvente DESC"; - $sql .= " LIMIT 20"; - if ( $db->query($sql) ) - { - $opt = ""; - if ($result) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object(); - $opt .= "\n"; - $i++; - } - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } + /* + * Ajouter une ligne + */ + if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] == '') + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + // Ajout produit produits/services personalisés + print ""; + print ''; + print ''; + + $var=true; + print '\n"; + print ' '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; - print ""; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''."\n"; - print ''; - print "".''; - print ''; - print ''; - print ''; - print ''; + // Ajout de produits/services prédéfinis + print ""; + print ''; + print ''; - print ''; + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + } + - $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print '
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').''.$langs->trans('AmountHT').'  
%
'; + if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$objp->ref.' - '.stripslashes(nl2br($objp->product)); + print ($objp->description && $objp->description!=$objp->product)?'
'.$objp->description:''; + print '
'.stripslashes(nl2br($objp->description)); + print "'.$objp->tva_tx.'%'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent."% '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; + print img_edit(); + print ''; + print img_delete(); + print '  
%
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('Discount').'   
'; + print $html->select_tva("tva_tx",$conf->defaulttx); + print '%
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Discount").''.$langs->trans("PriceU").'  
'; - print $html->select_tva("tva_tx",$conf->defaulttx); - print '%
'; + $html->select_produits('','p_idprod','',20); + print '
'; + print ''; + print '
 %
% 
'; - print ""; - } - print ""; - - /* - * Fin Ajout ligne - * - */ print '';