From 4b987150a70af7f8493e342b1da67ef1927279e4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Dec 2010 17:14:26 +0000 Subject: [PATCH] Works on best mutualized code Works on MVC --- htdocs/compta/facture.php | 152 +----------------- .../core/class/actions_commonobject.class.php | 3 + 2 files changed, 6 insertions(+), 149 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 280b0ddb882..6bdba55e562 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1385,7 +1385,7 @@ if ($_GET['action'] == 'create') { $projectid=GETPOST('originid'); } - else if (in_array($element,array('order','commande','propal','contrat','contract'))) + else { // For compatibility if ($element == 'commande') { $subelement = 'customerorder'; } @@ -1398,7 +1398,7 @@ if ($_GET['action'] == 'create') $objectsrc->fetch(GETPOST('originid')); if (empty($objectsrc->object->lines) && method_exists($objectsrc->object,'fetch_lines')) $objectsrc->object->fetch_lines(); $objectsrc->object->fetch_thirdparty(); - + $projectid = (!empty($objectsrc->object->fk_project)?$object->fk_project:''); $ref_client = (!empty($objectsrc->object->ref_client)?$object->ref_client:''); @@ -1776,10 +1776,8 @@ if ($_GET['action'] == 'create') print "\n"; - // Try to read line from origin - $sql=''; - // TODO deplacer dans la classe + // View origin lines if (is_object($objectsrc)) { $title=$langs->trans('ProductsAndServices'); @@ -1792,150 +1790,6 @@ if ($_GET['action'] == 'create') $objectsrc->printOriginLinesList($object); print ''; - /* - $title=$langs->trans('ProductsAndServices'); - - $sql = 'SELECT pt.rowid, pt.description, pt.fk_remise_except,'; - $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,'; - $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 = '.$objectsrc->object->id; - $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; - } - // TODO deplacer dans la classe - if ($_GET['origin'] == 'commande') - { - $title=$langs->trans('Products'); - - $sql = 'SELECT pt.rowid, pt.description, pt.fk_remise_except,'; - $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,'; - $sql.= ' pt.date_start as date_debut_prevue, pt.date_end as date_fin_prevue,'; - $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; - $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 = '.$objectsrc->object->id; - $sql.= ' ORDER BY pt.rowid ASC'; - } - // TODO deplacer dans la classe - if ($_GET['origin'] == 'contrat') - { - $title=$langs->trans('Services'); - - $sql = 'SELECT pt.rowid, pt.description,'; - $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, 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.fk_product_type, p.rowid as prodid'; - $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 = '.$objectsrc->object->id; - $sql.= ' ORDER BY pt.rowid ASC'; - } - - if ($sql) - { - print '
'; - print_titre($title); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Lignes - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - - $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 '\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - dol_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) == 2) - { - print ''; - print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); - print ''; - } - else if ($objp->prodid) - { - print ''; - print ($objp->fk_product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product')); - print ' '.$objp->ref.''; - print $objp->product?' - '.$objp->product:''; - // Dates - if ($date_start || $date_end) - { - print_date_range($date_start,$date_end); - } - } - else - { - print ($objp->product_type == -1 ? ' ' : ($objp->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product'))); - // Dates - if ($date_start || $date_end) - { - print_date_range($date_start,$date_end); - } - } - print "'; - if ($objp->description) - { - if ($objp->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($db); - $discount->fetch($objp->fk_remise_except); - print $langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - elseif ($obj->description == '(DEPOSIT)') - { - $discount=new DiscountAbsolute($db); - $discount->fetch($objp->fk_remise_except); - print $langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); - } - else - { - print dol_trunc($objp->description,60); - } - } - else - { - print ' '; - } - print ''.vatrate($objp->tva_tx).'%'.price($objp->subprice).''; - print (($objp->info_bits & 2) != 2) ? $objp->qty : ' '; - print ''; - print (($objp->info_bits & 2) != 2) ? $objp->remise_percent.'%' : ' '; - print '
';*/ } } diff --git a/htdocs/core/class/actions_commonobject.class.php b/htdocs/core/class/actions_commonobject.class.php index 16f57077c73..d509cd7afd4 100644 --- a/htdocs/core/class/actions_commonobject.class.php +++ b/htdocs/core/class/actions_commonobject.class.php @@ -96,6 +96,8 @@ class ActionsCommonObject { global $langs,$bc; + //var_dump($line); + $var=!$var; $date_start=$line->date_debut_prevue; @@ -125,6 +127,7 @@ class ActionsCommonObject else { print ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product'))); + print ($line->label ? ' '.$line->label : ''); // Dates if ($date_start || $date_end) {