From d208a018b556a7cf88ea2f75afdea0e2b72dd7ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Aug 2006 21:46:21 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Le=20bit=20des=20remises=20cr=E9e=20sur?= =?UTF-8?q?=20propales,=20commandes,=20contrat=20n'=E9tait=20pas=20propag?= =?UTF-8?q?=E9=20qd=20on=20cr=E9e=20une=20facture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/facture.php | 222 ++++++++++++-------------------------- 1 file changed, 71 insertions(+), 151 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f725d90734b..ceda4f7eacc 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -338,7 +338,11 @@ if ($_POST['action'] == 'add') $prop->lignes[$i]->qty, $prop->lignes[$i]->tva_tx, $prop->lignes[$i]->fk_product, - $prop->lignes[$i]->remise_percent); + $prop->lignes[$i]->remise_percent, + '', + '', + 0, + $prop->lignes[$i]->info_bits); } } else @@ -1217,184 +1221,86 @@ if ($_GET['action'] == 'create') // Si creation depuis un propal if ($_GET['propalid']) { - print '
'; - print_titre($langs->trans('ProductsAndServices')); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Lignes de propal - $sql = 'SELECT p.label as product, p.ref, p.rowid as prodid,'; - $sql.= ' pt.rowid, pt.tva_tx, pt.price, pt.qty, pt.remise_percent, pt.description, pt.info_bits'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; + $title=$langs->trans('ProductsAndServices'); + + $sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.fk_remise_except,'; + $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,'; + $sql.= ' p.description as product_desc'; + $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 = '.$_GET['propalid']; - $sql.= ' ORDER BY pt.rowid ASC'; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print '\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - dolibarr_print_error($db); - } - print '
'.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; - if ($objp->info_bits == 2) - { - print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount"); - } - else if ($objp->prodid) - { - print ''.img_object($langs->trans(''),'product').' '.$objp->ref.''; - print $objp->product?' - '.$objp->product:''; - } - else - { - print ' '; - } - print "'; - print nl2br(dolibarr_trunc($objp->description,60)); - print ''.$objp->tva_tx.'%'.price($objp->price).''.$objp->qty.''; - print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' '; - print '
'; + $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; } - - // Si creation depuis une commande if ($_GET['commandeid']) { - print '
'; - print_titre($langs->trans('Products')); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + $title=$langs->trans('Products'); $sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description, pt.info_bits,'; $sql.= ' p.label as product, p.ref, p.rowid as prodid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; $sql.= ' WHERE pt.fk_commande = '.$commande->id; $sql.= ' ORDER BY pt.rowid ASC'; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print '\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - dolibarr_print_error($db); - } - print '
'.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; - if ($objp->info_bits == 2) - { - print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount"); - } - else if ($objp->prodid) - { - print ''.img_object($langs->trans(''),'product').' '.$objp->ref.''; - print $objp->product?' - '.$objp->product:''; - } - else - { - print ' '; - } - print "'; - print nl2br(dolibarr_trunc($objp->description,60)); - print ''.$objp->tva_tx.'%'.price($objp->subprice).''.$objp->qty.''; - print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' '; - print '
'; } - - // Si creation depuis un contrat if ($_GET['contratid']) { - print '
'; - print_titre($langs->trans('Services')); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Lignes de contrat produits prédéfinis + $title=$langs->trans('Services'); + $sql = 'SELECT pt.rowid, pt.subprice, pt.tva_tx, pt.qty, pt.remise_percent, pt.description, pt.info_bits,'; $sql.= ' pt.date_ouverture_prevue as date_debut_prevue, pt.date_ouverture as date_debut_reel,'; $sql.= ' pt.date_fin_validite as date_fin_prevue, pt.date_cloture as date_fin_reel,'; $sql.= ' p.label as product, p.ref, p.rowid as prodid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'contratdet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'contratdet as pt'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; $sql.= ' WHERE pt.fk_contrat = '.$contrat->id; $sql.= ' ORDER BY pt.rowid ASC'; + } + if ($_GET['propalid'] || $_GET['commandeid'] || $_GET['contratid']) + { + print '
'; + print_titre($title); - $result = $db->query($sql); - if ($result) + print '
'.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Lignes + $resql = $db->query($sql); + if ($resql) { - $num = $db->num_rows($result); + $num = $db->num_rows($resql); $i = 0; $var=True; while ($i < $num) { - $objp = $db->fetch_object($result); + $objp = $db->fetch_object($resql); $var=!$var; print ''; print ''; print ''; - print ''; print ''; + print ''; print ''; $i++; @@ -1508,9 +1416,21 @@ else if ($_GET['action'] == 'payed' && $resteapayer > 0) { // Crée un tableau formulaire + // \todo Restreindre les choix en fonction d'une option globale + $helpescompte_avoir=$langs->trans("ConfirmClassifyPayedPartiallyAvoir").'

'.$langs->trans("Note").': '.$langs->trans("HelpEscompte"); + $helpescompte_novat=$langs->trans("ConfirmClassifyPayedPartiallyNoVat").'

'.$langs->trans("Note").': '.$langs->trans("HelpEscompte"); + $helpescompte_vat =$langs->trans("ConfirmClassifyPayedPartiallyVat"). '

'.$langs->trans("Note").': '.$langs->trans("HelpEscompte"); + $reason_avoir=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonDiscountAvoir",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$helpescompte_avoir,1); + $reason_novat=$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonDiscountNoVat",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$helpescompte_novat,1); + $reason_vat =$html->textwithhelp($langs->transnoentities("ConfirmClassifyPayedPartiallyReasonDiscountVat",$resteapayer,$langs->trans("Currency".$conf->monnaie)),$helpescompte_vat,1); + $reason_other=$langs->trans("ConfirmClassifyPayedPartiallyReasonOther"); + $arrayreasons['discount_avoir']=$reason_avoir; + $arrayreasons['discount_novat']=$reason_novat; + $arrayreasons['discount_vat'] =$reason_vat; + $arrayreasons['discount_other']=$reason_other; $formquestion=array( 'text' => $langs->trans("ConfirmClassifyPayedPartiallyQuestion"), - array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => array('escompte' => $langs->trans("ConfirmClassifyPayedPartiallyReasonEscompte",$resteapayer,$langs->trans("Currency".$conf->monnaie)), 'other' => $langs->trans("ConfirmClassifyPayedPartiallyReasonOther"))), + array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'size' => '70') ); // Paiement incomplet. On demande si motif = escompte ou autre @@ -1640,7 +1560,7 @@ else if ($fac->close_code == 'escompte') { print ''; } print '';
'.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; - if ($objp->info_bits == 2) + if (($objp->info_bits & 2) == 2) { - print img_object($langs->trans(''),'reduc').' '.$langs->trans("Discount"); + print ''; + print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); + print ''; } else if ($objp->prodid) { print ''.img_object($langs->trans(''),'service').' '.$objp->ref.''; print $objp->product?' - '.$objp->product:''; - // Plage de dates - $date_start=$objp->date_debut_prevue; - if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel; - $date_end=$objp->date_fin_prevue; - if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel; - print_date_range($date_start,$date_end); + // Plage de dates si contrat + if ($_GET['contratid']) + { + $date_start=$objp->date_debut_prevue; + if ($objp->date_debut_reel) $date_start=$objp->date_debut_reel; + $date_end=$objp->date_fin_prevue; + if ($objp->date_fin_reel) $date_end=$objp->date_fin_reel; + print_date_range($date_start,$date_end); + } } else { @@ -1406,9 +1312,11 @@ if ($_GET['action'] == 'create') print ''.$objp->tva_tx.'%'.price($objp->subprice).''.$objp->qty.''; - print $objp->info_bits != 2 ? $objp->remise_percent.'%' : ' '; + print (($objp->info_bits & 2) != 2) ? $objp->qty : ' '; + print ''; + print (($objp->info_bits & 2) != 2) ? $objp->remise_percent.'%' : ' '; print '
'; - $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1); + print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1); print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('RemainderToPay').' :