From 07a10d398455ae53030d2960622b6a52d6644b11 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 27 Aug 2012 17:18:46 +0200 Subject: [PATCH 1/2] Fix: add compatibility with old static combobox --- htdocs/core/class/commonobject.class.php | 42 ++++++++ htdocs/core/tpl/objectline_add.tpl.php | 39 +++++++- htdocs/product/ajax/products.php | 121 ++++++++++++++++------- 3 files changed, 166 insertions(+), 36 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ba8f32e0bd1..0f536a7c746 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2444,6 +2444,48 @@ abstract class CommonObject /* This is to show add lines */ + /** + * Show add predefined products/services form + * TODO Edit templates to use global variables and include them directly in controller call + * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * + * @param int $dateSelector 1=Show also date range input fields + * @param Societe $seller Object thirdparty who sell + * @param Societe $buyer Object thirdparty who buy + * @param HookManager $hookmanager Hook manager instance + * @return void + * @deprecated + */ + function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) + { + global $conf,$langs,$object; + global $form,$bcnd,$var; + + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); + } + + /** + * Show add free products/services form + * TODO Edit templates to use global variables and include them directly in controller call + * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. + * + * @param int $dateSelector 1=Show also date range input fields + * @param Societe $seller Object thirdparty who sell + * @param Societe $buyer Object thirdparty who buy + * @param HookManager $hookmanager Hook manager instance + * @return void + * @deprecated + */ + function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) + { + global $conf,$langs,$object; + global $form,$bcnd,$var; + + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); + } + /** * Show add free and predefined products/services form diff --git a/htdocs/core/tpl/objectline_add.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php index 1f5643b8d78..3d80df83ba5 100644 --- a/htdocs/core/tpl/objectline_add.tpl.php +++ b/htdocs/core/tpl/objectline_add.tpl.php @@ -218,7 +218,7 @@ $(document).ready(function() { $('#service_duration_area').hide(); $('#idprod').change(function() { - if ($(this).val().length > 0) { + if ($(this).val() > 0) { if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') { // We use CKEditor CKEDITOR.instances['product_desc'].focus(); @@ -226,9 +226,46 @@ $(document).ready(function() { // We use a simple textarea $('#product_desc').focus(); } + // For compatibility with combobox + global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?> + $.post('/product/ajax/products.php', { + 'action': 'fetch', + 'id': $(this).val(), + 'price_level': price_level; ?> + }, + function(data) { + if (typeof data != 'undefined') { + $('#select_type').val(data.type).attr('disabled','disabled'); + $('#product_ref').val(data.ref); + $('#product_label').val(data.label).attr('disabled','disabled'); + $('#origin_label_cache').val(data.label); + $('#origin_desc_cache').val(data.desc); + $('#price_base_type').val(data.pricebasetype); + $('#price_ht').val(data.price_ht).attr('disabled','disabled'); + $('#origin_price_ht_cache').val(data.price_ht); + $('#update_label_area').show().trigger('show'); + $('#update_desc_area').show().trigger('show'); + $('#update_price_area').show().trigger('show'); + } + }, 'json'); + } else { $('#update_desc_checkbox').removeAttr('checked').trigger('change'); $('#update_price_checkbox').removeAttr('checked').trigger('change'); + // For compatibility with combobox + global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?> + $('#select_type').val('').removeAttr('disabled'); + $('#product_ref').val(''); + $('#product_label').val('').removeAttr('disabled'); + $('#origin_label_cache').val(''); + $('#origin_desc_cache').val(''); + $('#price_base_type').val(''); + $('#price_ht').val('').removeAttr('disabled'); + $('#origin_price_ht_cache').val(''); + $('#update_label_area').hide().trigger('hide'); + $('#update_desc_area').hide().trigger('hide'); + $('#update_price_area').hide().trigger('hide'); + } }); diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 9a8f3b87f3d..5f7c8f7506f 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -31,10 +31,6 @@ if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - -$langs->load("products"); -$langs->load("main"); $htmlname=GETPOST('htmlname','alpha'); $socid=GETPOST('socid','int'); @@ -43,50 +39,105 @@ $mode=GETPOST('mode','int'); $status=((GETPOST('status','int') >= 0) ? GETPOST('status','int') : -1); $outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0); $pricelevel=GETPOST('price_level','int'); +$action=GETPOST('action', 'alpha'); +$id=GETPOST('id', 'int'); /* * View */ -// Ajout directives pour resoudre bug IE -//header('Cache-Control: Public, must-revalidate'); -//header('Pragma: public'); - -//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. -top_httphead(); - //print ''."\n"; -//print ''."\n"; - dol_syslog(join(',',$_GET)); //print_r($_GET); -if (empty($htmlname)) return; - -$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); -sort($match); -$idprod = (! empty($match[0]) ? $match[0] : ''); - -if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; - -// When used from jQuery, the search term is added as GET param "term". -$searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); - -$form = new Form($db); -if (empty($mode) || $mode == 1) +if (! empty($action) && $action == 'fetch' && ! empty($id)) { - $arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson); + require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + + $outjson=array(); + + $object = new Product($db); + $ret=$object->fetch($id); + if ($ret > 0) + { + $outref=$object->ref; + $outlabel=$object->label; + $outdesc=$object->description; + $outtype=$object->type; + + $found=false; + + // Multiprice + if ($price_level >= 1) // If we need a particular price level (from 1 to 6) + { + $sql= "SELECT price, price_ttc, price_base_type "; + $sql.= "FROM ".MAIN_DB_PREFIX."product_price "; + $sql.= "WHERE fk_product='".$id."'"; + $sql.= " AND price_level=".$price_level; + $sql.= " ORDER BY date_price"; + $sql.= " DESC LIMIT 1"; + + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); + if ($objp) + { + $found=true; + $outprice_ht=price($objp->price); + $outprice_ttc=price($objp->price_ttc); + $outpricebasetype=$objp->price_base_type; + } + } + } + + if (! $found) + { + $outprice_ht=price($object->price); + $outprice_ttc=price($object->price_ttc); + $outpricebasetype=$object->price_base_type; + } + + $outjson = array('ref'=>$outref, 'label'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype); + } + + echo json_encode($outjson); + } -elseif ($mode == 2) +else { - $arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + $langs->load("products"); + $langs->load("main"); + + top_httphead(); + + if (empty($htmlname)) return; + + $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); + sort($match); + $idprod = (! empty($match[0]) ? $match[0] : ''); + + if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; + + // When used from jQuery, the search term is added as GET param "term". + $searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); + + $form = new Form($db); + if (empty($mode) || $mode == 1) + { + $arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson); + } + elseif ($mode == 2) + { + $arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); + } + + $db->close(); + + if ($outjson) print json_encode($arrayresult); } -$db->close(); - -if ($outjson) print json_encode($arrayresult); - -//print ""; -//print ""; ?> \ No newline at end of file From 7ca0aa8a784a9141662f1aa131088bc8768aa5f7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 27 Aug 2012 17:23:35 +0200 Subject: [PATCH 2/2] Fix: restore deprecated files --- .../core/tpl/freeproductline_create.tpl.php | 127 +++++++++++++ htdocs/core/tpl/freeproductline_edit.tpl.php | 101 ++++++++++ htdocs/core/tpl/freeproductline_view.tpl.php | 142 ++++++++++++++ .../tpl/predefinedproductline_create.tpl.php | 173 ++++++++++++++++++ .../tpl/predefinedproductline_edit.tpl.php | 164 +++++++++++++++++ .../tpl/predefinedproductline_view.tpl.php | 111 +++++++++++ 6 files changed, 818 insertions(+) create mode 100644 htdocs/core/tpl/freeproductline_create.tpl.php create mode 100644 htdocs/core/tpl/freeproductline_edit.tpl.php create mode 100644 htdocs/core/tpl/freeproductline_view.tpl.php create mode 100644 htdocs/core/tpl/predefinedproductline_create.tpl.php create mode 100644 htdocs/core/tpl/predefinedproductline_edit.tpl.php create mode 100644 htdocs/core/tpl/predefinedproductline_view.tpl.php diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php new file mode 100644 index 00000000000..dd2014df079 --- /dev/null +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -0,0 +1,127 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 + */ +?> + + + + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
trans('AddNewLine').' - '.$langs->trans("FreeZone"); ?> + trans('VAT'); ?> + trans('PriceUHT'); ?> + trans('Qty'); ?> + trans('ReductionShort'); ?> +margin->enabled)) { +?> + trans('BuyingPrice'); ?> +global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> +   + + +
" /> + + + +> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1); + if (($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '
'; + + if (is_object($hookmanager)) + { + $parameters=array(); + $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + ?> + + + + tva_assuj == "0") echo '0'; + else echo $form->load_tva('np_tva_tx', (isset($_POST["np_tva_tx"])?$_POST["np_tva_tx"]:-1), $seller, $buyer); + ?> + + "> + "> + % +margin->enabled)) { +?> + "> +global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> + + + + +service->enabled && $dateSelector) { +if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + $colspan = 10; +else + $colspan = 9; +if (! empty($conf->margin->enabled)) { + if($conf->global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> +> + + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); + ?> + + + + + + diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php new file mode 100644 index 00000000000..6a5e6e7ef30 --- /dev/null +++ b/htdocs/core/tpl/freeproductline_edit.tpl.php @@ -0,0 +1,101 @@ + + * Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 + */ +?> + + +
id; ?>" method="POST"> + + + + + + +> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> +
+ + $line,'fk_parent_line'=>$line->fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); + $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); + } + + // editeur wysiwyg + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + ?> + + + load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> + + + + + info_bits & 2) != 2) { ?> + + +   + + + + + info_bits & 2) != 2) { ?> + % + +   + + + +margin->enabled)) { +?> + + + "> +
"> + + +service->enabled && $dateSelector && $line->product_type == 1) { ?> +> + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne"); + ?> + + + + + + diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/freeproductline_view.tpl.php new file mode 100644 index 00000000000..e5746c52d58 --- /dev/null +++ b/htdocs/core/tpl/freeproductline_view.tpl.php @@ -0,0 +1,142 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 . + * + */ +?> + + +> + global->MAIN_VIEW_LINE_NUMBER)) { ?> + + +
+ info_bits & 2) == 2) { ?> + + trans("ShowReduc"),'reduc').' '; + if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); + //else $txt=$langs->trans("Discount"); + print $txt; + ?> + + description) + { + if ($line->description == '(CREDIT_NOTE)') + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($line->description == '(DEPOSIT)') + { + $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).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); + } + } + } + else + { + if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + echo $text.' '.dol_htmlentitiesbr($line->description); + // Show range + print_date_range($line->date_start,$line->date_end); + } + ?> + + + tva_tx,'%',$line->info_bits); ?> + + subprice); ?> + + + info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; + else echo ' '; ?> + + + remise_percent) && $line->special_code != 3) { ?> + remise_percent,$langs); ?> + +   + margin->enabled)) { + ?> + pa_ht); ?> + global->DISPLAY_MARGIN_RATES) {?> + pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> + global->DISPLAY_MARK_RATES) {?> + marque_tx).'%'; ?> + + + special_code == 3) { ?> + trans('Option'); ?> + + total_ht); ?> + + + statut == 0 && $user->rights->$element->creer) { ?> + + info_bits & 2) == 2) { ?> + + id.'#'.$line->id; ?>"> + + + + + + + id; ?>"> + + + + + 1) { ?> + + 0) { ?> + id; ?>"> + + + + + id; ?>"> + + + + + +   + + +   + + + + diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php new file mode 100644 index 00000000000..35ca0e16cf3 --- /dev/null +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -0,0 +1,173 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 + */ +?> + + + + + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>> + trans("AddNewLine").' - '; + if ($conf->service->enabled) + echo $langs->trans('RecordedProductsAndServices'); + else + echo $langs->trans('RecordedProducts'); + ?> + + trans('Qty'); ?> + trans('ReductionShort'); ?> +margin->enabled)) { +?> + trans('BuyingPrice'); ?> +global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> +   + + +
" /> + + + + + +> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>> + select_produits('','idprod','',$conf->product->limit_size,$buyer->price_level); + + if (is_object($hookmanager)) + { + $parameters=array('fk_parent_line'=>$_POST["fk_parent_line"]); + $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('np_desc',$_POST["np_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + ?> + + + % +margin->enabled)) { +?> + + + "> + +global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> + " name="addline"> + + +service->enabled) && $dateSelector) { +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) + $colspan = 10; +else + $colspan = 9; +if (! empty($conf->margin->enabled)) { + if($conf->global->DISPLAY_MARGIN_RATES) + $colspan++; + if($conf->global->DISPLAY_MARK_RATES) + $colspan++; +} +?> +> + + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $form->select_date('','date_start_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date('','date_end_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct"); + ?> + + + + + +margin->enabled)) { +?> + + + diff --git a/htdocs/core/tpl/predefinedproductline_edit.tpl.php b/htdocs/core/tpl/predefinedproductline_edit.tpl.php new file mode 100644 index 00000000000..4c9cd208eee --- /dev/null +++ b/htdocs/core/tpl/predefinedproductline_edit.tpl.php @@ -0,0 +1,164 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 + */ +?> + + +
id; ?>" method="POST"> + + + + + +> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> +
+ + + product_type==1) echo img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + echo ' '.$line->ref; + ?> + + product_label); + echo '
'; + + if (is_object($hookmanager)) + { + $fk_parent_line = ($_POST["fk_parent_line"] ? $_POST["fk_parent_line"] : $line->fk_parent_line); + $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); + $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); + } + + // editeur wysiwyg + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + ?> + + + load_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?> + + + + + + + info_bits & 2) != 2) { ?> + +   + + + + info_bits & 2) != 2) { ?> + % + +   + + +margin->enabled)) { +?> + + + + + + + + ">
+ "> + + + +service->enabled && $dateSelector && $line->product_type == 1) { ?> +> + trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne"); + ?> + + + +margin->enabled)) { +?> + + + diff --git a/htdocs/core/tpl/predefinedproductline_view.tpl.php b/htdocs/core/tpl/predefinedproductline_view.tpl.php new file mode 100644 index 00000000000..5aef6995f74 --- /dev/null +++ b/htdocs/core/tpl/predefinedproductline_view.tpl.php @@ -0,0 +1,111 @@ + + * Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 2012 Christophe Battarel + * + * 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 2 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 . + * + */ +?> + + +> + global->MAIN_VIEW_LINE_NUMBER)) { ?> + + +
+ textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + + // Show range + print_date_range($line->date_start, $line->date_end); + + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; + } + ?> + + + tva_tx,'%',$line->info_bits); ?> + + subprice); ?> + + + info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; + else echo ' '; ?> + + + remise_percent) && $line->special_code != 3) { ?> + remise_percent,$langs); ?> + +   + margin->enabled)) { + ?> + pa_ht); ?> + global->DISPLAY_MARGIN_RATES) {?> + pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> + global->DISPLAY_MARK_RATES) {?> + marque_tx).'%'; ?> + + + special_code == 3) { ?> + trans('Option'); ?> + + total_ht); ?> + + + statut == 0 && $user->rights->$element->creer) { ?> + + info_bits & 2) == 2) { ?> + + id.'#'.$line->id; ?>"> + + + + + + + id; ?>"> + + + + + 1) { ?> + + 0) { ?> + id; ?>"> + + + + + id; ?>"> + + + + + +   + + +   + + + +