From 9f03074127264712dca11808130c1efe04471e18 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Mon, 10 Jun 2013 16:05:41 +0200 Subject: [PATCH] - New: [ task #926 ] Add extrafield feature on order lines - New: [ task #927 ] Add extrafield feature on Proposal lines - New: [ task #928 ] Add extrafield feature on invoice lines --- ChangeLog | 3 + htdocs/admin/orderdet_extrafields.php | 160 +++++++++++++++++ htdocs/comm/admin/propaldet_extrafields.php | 161 ++++++++++++++++++ htdocs/comm/propal.php | 34 +++- htdocs/comm/propal/class/propal.class.php | 55 +++++- htdocs/commande/class/commande.class.php | 52 +++++- htdocs/commande/fiche.php | 45 ++++- htdocs/compta/facture.php | 45 ++++- .../admin/facturedet_cust_extrafields.php | 159 +++++++++++++++++ htdocs/compta/facture/class/facture.class.php | 41 ++++- htdocs/core/class/commoninvoice.class.php | 4 + htdocs/core/class/commonobject.class.php | 48 +++++- htdocs/core/class/commonorder.class.php | 9 + htdocs/core/lib/invoice.lib.php | 5 + htdocs/core/lib/order.lib.php | 5 + htdocs/core/lib/propal.lib.php | 9 +- .../core/tpl/freeproductline_create.tpl.php | 33 +++- htdocs/core/tpl/objectline_edit.tpl.php | 28 ++- htdocs/core/tpl/objectline_view.tpl.php | 46 ++--- .../tpl/predefinedproductline_create.tpl.php | 33 +++- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/fr_FR/admin.lang | 1 + 22 files changed, 919 insertions(+), 58 deletions(-) create mode 100644 htdocs/admin/orderdet_extrafields.php create mode 100644 htdocs/comm/admin/propaldet_extrafields.php create mode 100644 htdocs/compta/facture/admin/facturedet_cust_extrafields.php diff --git a/ChangeLog b/ChangeLog index 1fee8521e36..8724f49e5b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,9 @@ For users: - New: Add object_hour as substitution tag for opendocument generation. - New: Add option MEMBER_PAYONLINE_SENDEMAIL to send email when paypal or paybox payment is done. - New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error). +- New: [ task #926 ] Add extrafield feature on order lines +- New: [ task #927 ] Add extrafield feature on Proposal lines +- New: [ task #928 ] Add extrafield feature on invoice lines For translators: - Normalized sort order of all languages files with english ref file. diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php new file mode 100644 index 00000000000..64eeb2f4b52 --- /dev/null +++ b/htdocs/admin/orderdet_extrafields.php @@ -0,0 +1,160 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * 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 . + */ + +/** + * \file htdocs/admin/orderdet_extrafields.php + * \ingroup order + * \brief Page to setup extra fields of order + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("orders"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='commandedet'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Orders"); + +llxHeader('',$langs->trans("OrdersSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup'); +print "
\n"; + +$head = order_admin_prepare_head(null); + +dol_fiche_head($head, 'attributeslines', $langs->trans("ModuleSetup"), 0, 'order'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php new file mode 100644 index 00000000000..79509cc6593 --- /dev/null +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -0,0 +1,161 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Philippe Grand + * 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 . + */ + +/** + * \file htdocs/comm/admin/propaldet_extrafields.php + * \ingroup order + * \brief Page to setup extra fields of order + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("orders"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); + +$elementtype='propaldet'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Proposals"); + +llxHeader('',$langs->trans("PropalSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup'); +print "
\n"; + +$head = propal_admin_prepare_head(null); + +dol_fiche_head($head, 'attributeslines', $langs->trans("ModuleSetup"), 0, 'order'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5fbb94a5517..33588045ee9 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -640,6 +640,20 @@ else if ($action == "addline" && $user->rights->propal->creer) $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); $predef=((! empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); + //Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_".$key]); + } + } + if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); @@ -809,7 +823,8 @@ else if ($action == "addline" && $user->rights->propal->creer) $buyingprice, $label, $date_start, - $date_end + $date_end, + $array_option ); if ($result > 0) @@ -877,6 +892,20 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + //Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_".$key]); + } + } + // Define special_code for special lines $special_code=0; if (! GETPOST('qty')) $special_code=3; @@ -935,7 +964,8 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $label, $type, $date_start, - $date_end + $date_end, + $array_option ); if ($result >= 0) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index db8dd255b6c..3d325e4c540 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -309,11 +309,12 @@ class Propal extends CommonObject * @param string $label ??? * @param timestamp $date_start Start date of the line * @param timestamp $date_end End date of the line + * @param array $array_option extrafields array * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='') + function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0) { global $conf; @@ -420,6 +421,10 @@ class Propal extends CommonObject $this->line->price=$price; $this->line->remise=$remise; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->insert(); if ($result > 0) { @@ -473,9 +478,10 @@ class Propal extends CommonObject * @param int $type 0/1=Product/service * @param timestamp $date_start Start date of the line * @param timestamp $date_end End date of the line + * @param array $array_option extrafields array * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='') + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_option=0) { global $conf,$user,$langs; @@ -561,6 +567,10 @@ class Propal extends CommonObject $this->line->price=$price; $this->line->remise=$remise; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->update(); if ($result > 0) { @@ -2565,7 +2575,7 @@ class Propal extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->lines[$i] = new stdClass(); + $this->lines[$i] = new PropaleLigne($this->db); $this->lines[$i]->id = $obj->rowid; // for backward compatibility $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; @@ -2617,11 +2627,14 @@ class Propal extends CommonObject * \class PropaleLigne * \brief Class to manage commercial proposal lines */ -class PropaleLigne +class PropaleLigne extends CommonObject { var $db; var $error; + public $element='propaldet'; + public $table_element='propaldet'; + var $oldline; // From llx_propaldet @@ -2837,6 +2850,17 @@ class PropaleLigne if ($resql) { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + if (! $notrigger) { // Appel des triggers @@ -2877,6 +2901,19 @@ class PropaleLigne dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG); if ($this->db->query($sql) ) { + + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -2970,6 +3007,16 @@ class PropaleLigne $resql=$this->db->query($sql); if ($resql) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + if (! $notrigger) { // Appel des triggers diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index edfbb35f5cd..d630a993331 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1024,6 +1024,7 @@ class Commande extends CommonOrder * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) * @param string $label Label + * @param array $array_option extrafields array * @return int >0 if OK, <0 if KO * * @see add_product @@ -1033,7 +1034,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='') + function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0) { dol_syslog(get_class($this)."::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG); @@ -1140,6 +1141,10 @@ class Commande extends CommonOrder $this->line->price=$price; $this->line->remise=$remise; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->insert(); if ($result > 0) { @@ -2239,9 +2244,10 @@ class Commande extends CommonOrder * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label * @param int $special_code Special code (also used by externals modules!) + * @param array $array_option extrafields array * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0) { global $conf; @@ -2335,6 +2341,10 @@ class Commande extends CommonOrder $this->line->price=$price; $this->line->remise=$remise; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->update(); if ($result > 0) { @@ -2900,6 +2910,7 @@ class Commande extends CommonOrder { $obj = $this->db->fetch_object($resql); + $this->lines[$i] = new OrderLine($this->db); $this->lines[$i]->id = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; $this->lines[$i]->description = $obj->description; @@ -2952,11 +2963,14 @@ class Commande extends CommonOrder * \class OrderLine * \brief Classe de gestion des lignes de commande */ -class OrderLine +class OrderLine extends CommonOrderLine { var $db; var $error; + public $element='commandedet'; + public $table_element='commandedet'; + var $oldline; // From llx_commandedet @@ -3102,6 +3116,18 @@ class OrderLine $resql=$this->db->query($sql); if ($resql) { + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -3200,6 +3226,16 @@ class OrderLine { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + if (! $notrigger) { // Appel des triggers @@ -3294,6 +3330,16 @@ class OrderLine $resql=$this->db->query($sql); if ($resql) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + if (! $notrigger) { // Appel des triggers diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index ee2bdcc083b..97bcc12b504 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -80,7 +80,6 @@ $result=restrictedArea($user,'commande',$id); $object = new Commande($db); $extrafields = new ExtraFields($db); - // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); @@ -315,6 +314,13 @@ else if ($action == 'add' && $user->rights->commande->creer) $fk_parent_line = 0; } + //Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_option=$lines[$i]->array_options; + } + $result = $object->addline( $object_id, $desc, @@ -337,7 +343,8 @@ else if ($action == 'add' && $user->rights->commande->creer) $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $label + $label, + $array_option ); if ($result < 0) @@ -558,6 +565,20 @@ else if ($action == 'addline' && $user->rights->commande->creer) $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); + //Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_".$key]); + } + } + if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && (GETPOST('qty') < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); @@ -739,7 +760,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) GETPOST('fk_parent_line'), $fournprice, $buyingprice, - $label + $label, + $array_option ); if ($result > 0) @@ -813,6 +835,19 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + //Extrafields Lines + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield POST Data + if (is_array($extralabelsline)) + { + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_".$key]); + } + } + // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) @@ -866,7 +901,9 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' 0, $fournprice, $buyingprice, - $label + $label, + 0, + $array_option ); if ($result >= 0) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3663e71ffde..fce7398f9b5 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1006,6 +1006,13 @@ else if ($action == 'add' && $user->rights->facture->creer) $fk_parent_line = 0; } + //Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_option=$lines[$i]->array_options; + } + $result = $object->addline( $id, $desc, @@ -1031,7 +1038,8 @@ else if ($action == 'add' && $user->rights->facture->creer) $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - $label + $label, + $array_option ); if ($result > 0) @@ -1117,6 +1125,19 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); $price_ht = GETPOST('price_ht'); $tva_tx=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + + //Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_".$key]); + } + } if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && (GETPOST('qty') < 0)) { @@ -1312,7 +1333,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- GETPOST('fk_parent_line'), $fournprice, $buyingprice, - $label + $label, + $array_option ); if ($result > 0) @@ -1387,6 +1409,21 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + //Extrafields + $extrafieldsline = new ExtraFields($db); + $extralabelsline =$extrafieldsline->fetch_name_optionals_label($object->table_element_line); + $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + //Unset extrafield + if (is_array($extralabelsline)) + { + // Get extra fields + foreach ($extralabelsline as $key => $value) + { + unset($_POST["options_".$key]); + } + } + + // Check minimum price $productid = GETPOST('productid', 'int'); if (! empty($productid)) @@ -1441,7 +1478,9 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa 0, $fournprice, $buyingprice, - $label + $label, + 0, + $array_option ); if ($result >= 0) diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php new file mode 100644 index 00000000000..6ec01f0ed6d --- /dev/null +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -0,0 +1,159 @@ + +* Copyright (C) 2003 Jean-Louis Bergamo +* Copyright (C) 2004-2011 Laurent Destailleur +* Copyright (C) 2012 Regis Houssin +* Copyright (C) 2013 Jean-Francois FERRY +* 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 . +*/ + +/** +* \file htdocs/compta/facture/admin/facture_cust_extrafields.php +* \ingroup invoice +* \brief Page to setup extra fields of customer invoice +*/ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load("bills"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='facturedet'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* +* Actions +*/ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* +* View +*/ + +$textobject=strtolower($langs->transnoentitiesnoconv("BillsCustomers")); + + +llxHeader('',$langs->trans("BillsSetup")); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup'); +print '
'; + +$head = invoice_admin_prepare_head(null); + +dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Position").''.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index bd0bbaf121e..ddb1f85b9fd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -437,6 +437,7 @@ class Facture extends CommonInvoice if (! $error) { + $result=$this->update_price(1); if ($result > 0) { @@ -1972,9 +1973,10 @@ class Facture extends CommonInvoice * @param int $fk_fournprice To calculate margin * @param int $pa_ht Buying price of line * @param string $label Label of the line + * @param array $array_option extrafields array * @return int <0 if KO, Id of line if OK */ - function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='') + function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0) { dol_syslog(get_class($this)."::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2076,6 +2078,10 @@ class Facture extends CommonInvoice $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->insert(); if ($result > 0) { @@ -2129,9 +2135,10 @@ class Facture extends CommonInvoice * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label Label of the line * @param int $special_code Special code (also used by externals modules!) + * @param array $array_option extrafields array * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2225,6 +2232,10 @@ class Facture extends CommonInvoice //$this->line->price=$price; //$this->line->remise=$remise; + if (is_array($array_option) && count($array_option)>0) { + $this->line->array_options=$array_option; + } + $result=$this->line->update(); if ($result > 0) { @@ -3214,6 +3225,7 @@ class Facture extends CommonInvoice { $obj = $this->db->fetch_object($resql); + $this->lines[$i] = new FactureLigne($this->db); $this->lines[$i]->id = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; $this->lines[$i]->description = $obj->description; @@ -3266,11 +3278,14 @@ class Facture extends CommonInvoice * \brief Classe permettant la gestion des lignes de factures * Gere des lignes de la table llx_facturedet */ -class FactureLigne +class FactureLigne extends CommonInvoiceLine { var $db; var $error; + public $element='facturedet'; + public $table_element='facturedet'; + var $oldline; //! From llx_facturedet @@ -3498,6 +3513,16 @@ class FactureLigne { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + // Si fk_remise_except defini, on lie la remise a la facture // ce qui la flague comme "consommee". if ($this->fk_remise_except) @@ -3645,6 +3670,16 @@ class FactureLigne $resql=$this->db->query($sql); if ($resql) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + if (! $notrigger) { // Appel des triggers diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 0359d9dde25..e7dc17d62d1 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -289,4 +289,8 @@ abstract class CommonInvoice extends CommonObject } } +abstract class CommonInvoiceLine extends CommonObject +{ +} + ?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 419174a31dc..8d0e20d42d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2189,10 +2189,11 @@ abstract class CommonObject * * @param object $extrafields extrafield Object * @param string $mode Show output (view) or input (edit) for extrafield + * @param array $params optionnal parameters * * @return string */ - function showOptionals($extrafields,$mode='view') + function showOptionals($extrafields,$mode='view',$params=0) { global $_POST; @@ -2207,7 +2208,13 @@ abstract class CommonObject $e = 0; foreach($extrafields->attribute_label as $key=>$label) { - $colspan='3'; + if (is_array($params) && count($params)>0) { + if (array_key_exists('colspan',$params)) { + $colspan=$params['colspan']; + } + }else { + $colspan='3'; + } $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); if ($extrafields->attribute_type[$key] == 'separate') { @@ -2215,14 +2222,20 @@ abstract class CommonObject } else { + $csstyle=''; + if (is_array($params) && count($params)>0) { + if (array_key_exists('style',$params)) { + $csstyle=$params['style']; + } + } if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { - $out .= ''; + $out .= ''; $colspan='0'; } else { - $out .= ''; + $out .= ''; } // Convert date into timestamp format if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) @@ -2623,6 +2636,10 @@ abstract class CommonObject { global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; + //Line extrafield + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline = new ExtraFields($this->db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); // Use global variables + $dateSelector + $seller and $buyer include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); @@ -2644,6 +2661,11 @@ abstract class CommonObject global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; + //Line extrafield + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline = new ExtraFields($this->db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); + // Use global variables + $dateSelector + $seller and $buyer include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); } @@ -2664,6 +2686,11 @@ abstract class CommonObject global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; + //Line extrafield + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline = new ExtraFields($this->db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); + // 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')); @@ -2750,8 +2777,16 @@ abstract class CommonObject $var = true; $i = 0; + //Line extrafield + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafieldsline = new ExtraFields($this->db); + $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); + foreach ($this->lines as $line) { + //Line extrafield + $line->fetch_optionals($line->id,$extralabelslines); + $var=!$var; if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) @@ -2764,7 +2799,7 @@ abstract class CommonObject } else { - $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$hookmanager); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline); } $i++; @@ -2784,9 +2819,10 @@ abstract class CommonObject * @param string $seller Object of seller third party * @param string $buyer Object of buyer third party * @param string $selected Object line selected + * @param object $extrafieldline Object of extrafield line attribute * @return void */ - function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) { global $conf,$langs,$user,$hookmanager; global $form,$bc,$bcdd; diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 54ce4230e55..302894009e5 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -32,4 +32,13 @@ abstract class CommonOrder extends CommonObject } +/** + * \class CommonOrderLine + * \brief Superclass for orders classes + */ +abstract class CommonOrderLine extends CommonObject +{ + +} + ?> diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index b0d564c88d5..75b1bc95d00 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin + * 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 @@ -127,6 +128,10 @@ function invoice_admin_prepare_head($object) $head[$h][2] = 'attributes'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_cust_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines'; + $h++; complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice_admin','remove'); diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 16aae46f9fc..b7de009663e 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -133,6 +133,11 @@ function order_admin_prepare_head($object) $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines'; + $h++; complete_head_from_modules($conf,$langs,$object,$head,$h,'order_admin','remove'); diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 5d65032e421..db011bf3fad 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -131,12 +131,15 @@ function propal_admin_prepare_head($object) $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; - - + + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines'; + $h++; complete_head_from_modules($conf,$langs,$object,$head,$h,'propal_admin','remove'); - return $head; + return $head; } diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 1ee1a63ea78..e0dec028baa 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2013 Laurent Destailleur * Copyright (C) 2012 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 @@ -68,6 +69,13 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob > + global->MAIN_VIEW_LINE_NUMBER)) { + $coldisplay=2; } + else { + $coldisplay=0; } + ?> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> margin->enabled) && ! empty($object->element) && in_array($ob value=""> global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + 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)); + } + } + ?> * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 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 @@ -35,7 +36,13 @@ - +global->MAIN_VIEW_LINE_NUMBER)) { + $coldisplay=2; +} else { + $coldisplay=0; +} + ?> > global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
@@ -97,14 +104,14 @@ ?> - load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> + load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> - + global->MAIN_FEATURES_LEVEL > 1) { ?> - + - + info_bits & 2) != 2) { // 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 @@ -117,7 +124,7 @@ - + info_bits & 2) != 2) { ?> % @@ -126,7 +133,7 @@ margin->enabled)) { ?> - + @@ -136,6 +143,13 @@ ">
"> + + showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay)); + } + ?> service->enabled) && $line->product_type == 1 && $dateSelector) { ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index b2e777660f7..3e6f4dc9a49 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2011 Laurent Destailleur * Copyright (C) 2012 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 @@ -20,13 +21,13 @@ * $type, $text, $description, $line */ ?> - + > global->MAIN_VIEW_LINE_NUMBER)) { ?> - + -
+
info_bits & 2) == 2) { ?> - tva_tx,'%',$line->info_bits); ?> + tva_tx,'%',$line->info_bits); ?> - subprice); ?> + subprice); ?> global->MAIN_FEATURES_LEVEL > 1) { ?> -   +   - + 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 @@ -114,30 +115,30 @@ remise_percent) && $line->special_code != 3) { ?> - remise_percent,$langs); ?> + remise_percent,$langs); ?> -   +   margin->enabled) && empty($user->societe_id)) { ?> - pa_ht); ?> + pa_ht); ?> global->DISPLAY_MARGIN_RATES)) {?> - pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> + pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> global->DISPLAY_MARK_RATES)) {?> - marque_tx).'%'; ?> + marque_tx).'%'; ?> special_code == 3) { ?> - trans('Option'); ?> + trans('Option'); ?> - total_ht); ?> + total_ht); ?> statut == 0 && $user->rights->$element->creer) { ?> - + info_bits & 2) == 2) { ?> id.'#'.$line->id; ?>"> @@ -146,14 +147,14 @@ - + id; ?>"> 1 && empty($conf->browser->phone)) { ?> - + 0) { ?> id; ?>"> @@ -166,11 +167,18 @@ - browser->phone)?' class="tdlineupdown"':''); ?>> + browser->phone)?' class="tdlineupdown"':''); ?>> - + +showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); +} +?> + diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 32d3366f8ad..1d6dac70120 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 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 @@ -80,6 +81,12 @@ if (! empty($usemargins)) > +global->MAIN_VIEW_LINE_NUMBER)) { + $coldisplay=4; } +else { + $coldisplay=3; } +?> global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>> global->DISPLAY_MARGIN_RATES)) $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + $colspan++; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + $colspan++; + $coldisplay++; + } ?> @@ -125,6 +138,22 @@ if (! empty($usemargins)) " name="addline"> + 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)); + } + } + ?>