From 7d2cedfdcf3da53d5c7b1bfd8dcd4d25c7503c8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Jun 2019 19:29:49 +0200 Subject: [PATCH] Debug bom module --- htdocs/bom/class/bom.class.php | 12 +- htdocs/bom/tpl/objectline_create.tpl.php | 1 - htdocs/bom/tpl/objectline_view.tpl.php | 149 +---------------------- htdocs/core/class/commonobject.class.php | 112 ++++------------- htdocs/core/tpl/objectline_title.tpl.php | 131 ++++++++++++++++++++ htdocs/fichinter/card.php | 4 +- 6 files changed, 170 insertions(+), 239 deletions(-) create mode 100644 htdocs/core/tpl/objectline_title.tpl.php diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 56f790052e7..f4fd4ab93b9 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -106,7 +106,7 @@ class BOM extends CommonObject 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'fk_user_valid' => array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>512, 'notnull'=>0,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Enabled', 9=>'Disabled')), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'notnull'=>1, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Enabled', 9=>'Disabled')), ); public $rowid; public $ref; @@ -753,23 +753,23 @@ class BOM extends CommonObject } elseif ($mode == 2) { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 3) { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 4) { - return img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; } elseif ($mode == 5) { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); } elseif ($mode == 6) { - return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.$status, '', false, 0, 0, '', 'valignmiddle'); + return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle'); } } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index da9942fce44..0101024df40 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -107,7 +107,6 @@ if ($nolinesbefore) { { if ($forceall >= 0 && $freelines) echo '
'; echo ''; - $filtertype=''; if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 46c25e3674c..82c5efbb71b 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -58,6 +58,8 @@ $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; +// Lines for extrafield +$objectline = new BOMLine($this->db); ?> @@ -68,146 +70,18 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
info_bits & 2) == 2) { - ?> - - trans("ShowReduc"), 'reduc').' '; - if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - elseif ($line->description == '(EXCESS RECEIVED)') $txt=$langs->trans("ExcessReceived"); - elseif ($line->description == '(EXCESS PAID)') $txt=$langs->trans("ExcessPaid"); - //else $txt=$langs->trans("Discount"); - print $txt; - ?> - - description) - { - if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); - } - elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); - // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) - echo ' ('.dol_print_date($discount->datec).')'; - } - elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } - elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); - } - else - { - echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); - } - } - } - else - { - $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE?'dayhour':'day'; - - if ($line->fk_product > 0) - { - echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); - } - else - { - if ($type==1) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - echo $form->textwithtooltip($text, dol_htmlentitiesbr($line->description), 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); - } else { - if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); - echo $text.' '.dol_htmlentitiesbr($line->description); - } - } - - // Show date range - if ($line->element == 'facturedetrec') { - if ($line->date_start_fill || $line->date_end_fill) echo '
'; - if ($line->date_start_fill) echo $langs->trans('AutoFillDateFromShort').': '.yn($line->date_start_fill); - if ($line->date_start_fill && $line->date_end_fill) echo ' - '; - if ($line->date_end_fill) echo $langs->trans('AutoFillDateToShort').': '.yn($line->date_end_fill); - if ($line->date_start_fill || $line->date_end_fill) echo '
'; - } - else { - if ($line->date_start || $line->date_end) echo '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; - //echo get_date_range($line->date_start, $line->date_end, $format); - } - + echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); // Add description in form - if ($line->fk_product > 0 && ! empty($conf->global->PRODUIT_DESC_IN_FORM)) + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; } } - - if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) - { - $accountingaccount=new AccountingAccount($this->db); - $accountingaccount->fetch($line->fk_accounting_account); - echo '

' . $langs->trans('AccountingAffectation') . ' : ' . $accountingaccount->getNomUrl(0, 1, 1); - } - ?> - element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines - { - ?> - ref_fourn?$line->ref_fourn:$line->ref_supplier); - ?> - - tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->total_localtax1)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->total_localtax2)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($line->vat_src_code?' ('.$line->vat_src_code.')':''), '%', $line->info_bits); - //echo vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); - ?> - - subprice); ?> - - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> - multicurrency_subprice); ?> - - - - pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?> - - info_bits & 2) != 2) && $line->special_code != 3) { - // I comment this because it shows info even when not required - // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated - // must also not be output for most entities (proposal, intervention, ...) - //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price - } else echo ' '; + echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price ?> @@ -237,9 +111,6 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; ?> - special_code == 3) { ?> - trans('Option'); ?> - global->MAIN_OPTIMIZEFORTEXTBROWSER)) @@ -257,16 +128,8 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; { print '
'; } - ?> + ?> - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> - multicurrency_total_ht); ?> - - - - total_ttc); ?> - - statut == 0 && ($object_rights->creer) && $action != 'selectlines' ) { ?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5a09ea17127..02c7a9ca6dd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3911,12 +3911,13 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param int $selected Object line selected * @param int $dateSelector 1=Show also date range input fields + * @param string $defaulttpldir Directory where to find the template * @return void */ - public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) + public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/core/tpl') { - global $conf, $hookmanager, $langs, $user; - // TODO We should not use global var for this ! + global $conf, $hookmanager, $langs, $user, $object; + // TODO We should not use global var for this global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax; // Define usemargins @@ -3934,90 +3935,26 @@ abstract class CommonObject $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - // Title line - print "\n"; - - print ''; - - // Adds a line numbering column - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; - - // Description - print ''.$langs->trans('Description').''; - - if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' || $this->element == 'invoice_supplier') + // Output template part (modules that overwrite templates must declare this into descriptor) + // Use global variables + $dateSelector + $seller and $buyer + $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); + foreach($dirtpls as $module => $reldir) { - print ''.$langs->trans("SupplierRef").''; - } - - // VAT - print ''.$langs->trans('VAT').''; - - // Price HT - print ''.$langs->trans('PriceUHT').''; - - // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; - - if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; - - // Qty - print ''.$langs->trans('Qty').''; - - if($conf->global->PRODUCT_USE_UNITS) - { - print ''.$langs->trans('Unit').''; - } - - // Reduction short - print ''.$langs->trans('ReductionShort').''; - - // Fields for situation invoice - if ($this->situation_cycle_ref) { - print '' . $langs->trans('Progress') . ''; - print '' . $langs->trans('TotalHT100Short') . ''; - } - - if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) - { - if (!empty($user->rights->margins->creer)) + if (!empty($module)) { - if ($conf->global->MARGIN_TYPE == "1") - print ''.$langs->trans('BuyingPrice').''; - else - print ''.$langs->trans('CostPrice').''; + $tpl = dol_buildpath($reldir.'/objectline_title.tpl.php'); } - - if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarginRate').''; - if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarkRate').''; + else + { + $tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php'; + } + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } - - // Total HT - print ''.$langs->trans('TotalHTShort').''; - - // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; - - if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; - - print ''; // No width to allow autodim - - print ''; - - print ''; - - if($action == 'selectlines') - { - print ''; - print ''; - print ''; - print ''; - } - - print "\n"; - print "\n"; } $var = true; @@ -4045,7 +3982,7 @@ abstract class CommonObject } if (empty($reshook)) { - $this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafieldsline); + $this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafieldsline, $defaulttpldir); } $i++; @@ -4067,9 +4004,10 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param int $selected Object line selected * @param int $extrafieldsline Object of extrafield line attribute + * @param string $defaulttpldir Directory where to find the template * @return void */ - public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) + public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0, $defaulttpldir = '/core/tpl') { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; @@ -4157,7 +4095,7 @@ abstract class CommonObject } } - // Ligne en mode update + // Line in update mode if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) { $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); @@ -4167,7 +4105,7 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + $dirtpls=array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach($dirtpls as $module => $reldir) { if (!empty($module)) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php new file mode 100644 index 00000000000..fd848764721 --- /dev/null +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -0,0 +1,131 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2017 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Need to have following variables defined: + * $object (invoice, order, ...) + * $conf + * $langs + * $element (used to test $user->rights->$element->creer) + * $permtoedit (used to replace test $user->rights->$element->creer) + * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) + * $outputalsopricetotalwithtax + * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) + * + * $type, $text, $description, $line + */ + +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} +?> + +\n"; + +print ''; + +// Adds a line numbering column +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; + +// Description +print ''.$langs->trans('Description').''; + +if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier' || $this->element == 'invoice_supplier') +{ + print ''.$langs->trans("SupplierRef").''; +} + +// VAT +print ''.$langs->trans('VAT').''; + +// Price HT +print ''.$langs->trans('PriceUHT').''; + +// Multicurrency +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + +if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; + +// Qty +print ''.$langs->trans('Qty').''; + +if($conf->global->PRODUCT_USE_UNITS) +{ + print ''.$langs->trans('Unit').''; +} + +// Reduction short +print ''.$langs->trans('ReductionShort').''; + +// Fields for situation invoice +if ($this->situation_cycle_ref) { + print '' . $langs->trans('Progress') . ''; + print '' . $langs->trans('TotalHT100Short') . ''; +} + +if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) +{ + if (!empty($user->rights->margins->creer)) + { + if ($conf->global->MARGIN_TYPE == "1") + print ''.$langs->trans('BuyingPrice').''; + else + print ''.$langs->trans('CostPrice').''; + } + + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) + print ''.$langs->trans('MarginRate').''; + if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) + print ''.$langs->trans('MarkRate').''; +} + +// Total HT +print ''.$langs->trans('TotalHTShort').''; + +// Multicurrency +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + +if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; + +print ''; // No width to allow autodim + +print ''; + +print ''; + +if($action == 'selectlines') +{ + print ''; + print ''; + print ''; + print ''; +} + +print "\n"; +print "\n"; +?> + + \ No newline at end of file diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 31db9d0c2b4..f38b8fb10e0 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1647,11 +1647,11 @@ elseif ($id > 0 || ! empty($ref)) } // create intervention model - if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { + if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; }