From 5fa05ee29d028d6271876f698406e4f57a75e2fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 May 2014 12:53:10 +0200 Subject: [PATCH] Start to clean code of templates to input lines --- htdocs/core/class/commonobject.class.php | 8 +- .../core/tpl/freeproductline_create.tpl.php | 335 ---------------- htdocs/core/tpl/objectline_create.tpl.php | 7 +- htdocs/core/tpl/objectline_edit.tpl.php | 241 ++--------- .../tpl/predefinedproductline_create.tpl.php | 375 ------------------ 5 files changed, 31 insertions(+), 935 deletions(-) delete mode 100644 htdocs/core/tpl/freeproductline_create.tpl.php delete mode 100644 htdocs/core/tpl/predefinedproductline_create.tpl.php diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c339a2c8ae1..f2c9ae0fc8a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2718,7 +2718,7 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs,$user,$hookmanager; + global $conf,$langs,$user,$object,$hookmanager; print ''; @@ -2757,11 +2757,11 @@ abstract class CommonObject // Total HT print ''.$langs->trans('TotalHTShort').''; - print ''; + print ''; // No width to allow autodim print ''; - print ''; // No width to allow autodim + print ''; print "\n"; @@ -2816,7 +2816,7 @@ abstract class CommonObject */ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) { - global $conf,$langs,$user,$hookmanager; + global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; $element=$this->element; diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php deleted file mode 100644 index a4c4b733fed..00000000000 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ /dev/null @@ -1,335 +0,0 @@ - - * Copyright (C) 2010-2013 Laurent Destailleur - * Copyright (C) 2012-2013 Christophe Battarel - * Copyright (C) 2013 Florian Henry - * - * 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: - * $conf - * $langs - * $dateSelector - * $this (invoice, order, ...) - * $line defined - */ - -$usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; - -?> - - - - - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> -
- trans('AddNewLine').' - ' ?>trans("FreeZone"); ?> - - trans('VAT'); ?> - trans('PriceUHT'); ?> - trans('Qty'); ?> - trans('ReductionShort'); ?> - - - global->MARGIN_TYPE == "1") - echo $langs->trans('BuyingPrice'); - else - echo $langs->trans('CostPrice'); - ?> - - rights->margins->creer) - { - if(! empty($conf->global->DISPLAY_MARGIN_RATES)) - { - echo ''.$langs->trans('MarginRate').''; - } - if(! empty($conf->global->DISPLAY_MARK_RATES)) - { - echo ''.$langs->trans('MarkRate').''; - } - } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; - } - } - ?> -   - - -> -global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay=2; } -else { - $coldisplay=0; } -?> - - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> - '; - echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1); - echo ''; - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); - } - - if ((! empty($conf->product->enabled) && ! empty($conf->service->enabled)) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '
'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70); - $doleditor->Create(); - ?> - - - tva_assuj == "0") echo '0'; - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); - ?> - - "> - "> - remise_client); ?>" name="remise_percent">% - - - "> - - rights->margins->creer) - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - echo '%'; - $colspan++; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - echo '%'; - $colspan++; - $coldisplay++; - } - } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $coldisplay++; - } - } - } - ?> - - - - table_element_line=='commandedet') { - $newline = new OrderLine($this->db); - } - elseif ($this->table_element_line=='propaldet') { - $newline = new PropaleLigne($this->db); - } - elseif ($this->table_element_line=='facturedet') { - $newline = new FactureLigne($this->db); - } - if (is_object($newline)) { - print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); - } - } - ?> - - -service->enabled) && $dateSelector) -{ - if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; - else $colspan = 9; - - if (! empty($usemargins)) - { - $colspan++; // For the buying price - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; - } -?> - -> - - element) && $object->element == 'contrat') - { - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start",$usehm,$usehm,1,"addline_sl"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end",$usehm,$usehm,1,"addline_sl"); - } - else - { - echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - echo $form->select_date('','date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date('','date_end',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct"); - } - ?> - - - - - -rights->margins->creer) -{ -?> - - - diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 9e61940e112..02480058498 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -41,9 +41,7 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; // Define colspan for button Add $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc -if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move -if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; -if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; +if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button ?> @@ -390,8 +388,7 @@ if (! empty($usemargins) && $user->rights->margins->creer) $dec=','; $thousand=' '; if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); - if ($thousand == 'None') $thousand=''; - print "var dec='".$dec."'; var thousand='".$thousand."';\n"; + print "var dec='".$dec."'; var thousand='".$thousand."';\n"; // Set var in javascript ?> var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN; ?>; diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 94ad11c991c..09517a5281c 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -17,14 +17,31 @@ * 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 * $dateSelector - * $this (invoice, order, ...) - * $line defined + * $forceall (0 by default, 1 for supplier invoices/orders) + * $senderissupplier (0 by default, 1 for supplier invoices/orders) + * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ + + +$usemargins=0; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; + +global $dateSelector, $forceall, $senderissupplier, $inputalsopricewithtax; +if (empty($dateSelector)) $dateSelector=0; +if (empty($forceall)) $forceall=0; +if (empty($senderissupplier)) $senderissupplier=0; +if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; + + +// Define colspan for button Add +$colspan = 3; // Col total ht + col edit + col delete +if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc +if (in_array($object->element,array('propal','facture','invoice','commande','order'))) $colspan++; // With this, there is a column move button ?> @@ -41,29 +58,7 @@ $coldisplay=-1; // We remove first td - global->MAIN_FEATURES_LEVEL > 1) - { - if ($line->fk_product > 0) - { - echo $text . ' - '; - } - else - { - echo $form->select_type_of_lines($line->product_type, 'type', 1, 1); - } - ?> - - fk_product) && empty($line->label)) ? ' disabled="disabled"' : ''); ?>> - - - textwithtooltip($langs->trans('UpdateOriginalProductLabel'), $langs->trans('HelpUpdateOriginalProductLabel'),1,0,'','',3); ?> - - - -
- - fk_product > 0) { ?> + fk_product > 0) { ?> - + ">
"> @@ -185,193 +180,6 @@ $coldisplay=-1; // We remove first td - - '; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat') $filtertype='1'; - $form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level, 1, 2, '', 3, array(),$buyer->id); - echo ''; - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); - } - - echo '
'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('np_desc',GETPOST('np_desc"'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,70); - $doleditor->Create(); - ?> - - - - % - - - - "> - - rights->margins->creer) - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - echo '%'; - $colspan++; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - echo '%'; - $colspan++; - $coldisplay++; - } - } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $coldisplay++; - } - } - } - ?> - - - - table_element_line=='commandedet') { - $newline = new OrderLine($this->db); - } - elseif ($this->table_element_line=='propaldet') { - $newline = new PropaleLigne($this->db); - } - elseif ($this->table_element_line=='facturedet') { - $newline = new FactureLigne($this->db); - } - if (is_object($newline)) { - print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var],'colspan'=>$coldisplay+5), '_predef'); - } - } - ?> - - -service->enabled) && $dateSelector) -{ - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; - else $colspan = 9; - if (! empty($usemargins)) - { - $colspan++; // For the buying price - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; - } -?> - -> - - element) && $object->element == 'contrat') - { - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start_predef",$usehm,$usehm,1,"addline"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end_predef",$usehm,$usehm,1,"addline"); - } - else - { - echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - echo $form->select_date('','date_start_predef',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addpredefinedproduct"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date('','date_end_predef',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addpredefinedproduct"); - } - ?> - - - - - -rights->margins->creer) -{ -?> - - -