- 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
This commit is contained in:
Florian Henry 2013-06-10 16:05:41 +02:00
parent 4f43ec0acf
commit 9f03074127
22 changed files with 919 additions and 58 deletions

View File

@ -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.

View File

@ -0,0 +1,160 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup');
print "<br>\n";
$head = order_admin_prepare_head(null);
dol_fiche_head($head, 'attributeslines', $langs->trans("ModuleSetup"), 0, 'order');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
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 "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();
?>

View File

@ -0,0 +1,161 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("PropalSetup"),$linkback,'setup');
print "<br>\n";
$head = propal_admin_prepare_head(null);
dol_fiche_head($head, 'attributeslines', $langs->trans("ModuleSetup"), 0, 'order');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
print '<br>';
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
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 "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();
?>

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,159 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
print '<br>';
$head = invoice_admin_prepare_head(null);
dol_fiche_head($head, 'attributeslines', $langs->trans("Invoices"), 0, 'invoice');
print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
// Load attribute_label
$extrafields->fetch_name_optionals_label($elementtype);
print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td align="center">'.$langs->trans("Position").'</td>';
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("AttributeCode").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Size").'</td>';
print '<td align="center">'.$langs->trans("Unique").'</td>';
print '<td align="center">'.$langs->trans("Required").'</td>';
print '<td width="80">&nbsp;</td>';
print "</tr>\n";
$var=True;
foreach($extrafields->attribute_type as $key => $value)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
print "<td>".$key."</td>\n";
print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_unique[$key])."</td>\n";
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=$key\">".img_delete()."</a></td>\n";
print "</tr>";
// $i++;
}
print "</table>";
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation d'un champ optionnel
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
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 "<br>";
print_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();
?>

View File

@ -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

View File

@ -289,4 +289,8 @@ abstract class CommonInvoice extends CommonObject
}
}
abstract class CommonInvoiceLine extends CommonObject
{
}
?>

View File

@ -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 .= '<tr>';
$out .= '<tr '.$csstyle.'>';
$colspan='0';
}
else
{
$out .= '<tr>';
$out .= '<tr '.$csstyle.'>';
}
// 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;

View File

@ -32,4 +32,13 @@ abstract class CommonOrder extends CommonObject
}
/**
* \class CommonOrderLine
* \brief Superclass for orders classes
*/
abstract class CommonOrderLine extends CommonObject
{
}
?>

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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');

View File

@ -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');

View File

@ -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;
}

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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
</tr>
<tr <?php echo $bcnd[$var]; ?>>
<?php
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=2; }
else {
$coldisplay=0; }
?>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<?php
@ -111,11 +119,32 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
</td>
<?php
if (! empty($conf->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++;
}
}
?>
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline"></td>
<?php
//Line extrafield
if (!empty($extrafieldsline)) {
if ($this->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));
}
}
?>
</tr>
<?php

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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 @@
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
<input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
<input type="hidden" id="product_id" name="productid" value="<?php echo (! empty($line->fk_product)?$line->fk_product:0); ?>" />
<?php
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=2;
} else {
$coldisplay=0;
}
?>
<tr <?php echo $bc[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<div id="<?php echo $line->id; ?>"></div>
@ -97,14 +104,14 @@
?>
</td>
<td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td>
<td align="right"><?php $coldisplay++; ?><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td>
<td align="right"><input type="text" class="flat" size="8" id="price_ht" name="price_ht" value="<?php echo price($line->subprice,0,'',0); ?>"></td>
<td align="right"><?php $coldisplay++; ?><input type="text" class="flat" size="8" id="price_ht" name="price_ht" value="<?php echo price($line->subprice,0,'',0); ?>"></td>
<?php if ($conf->global->MAIN_FEATURES_LEVEL > 1) { ?>
<td align="right"><input type="text" class="flat" size="8" id="price_ttc" name="price_ttc" value="<?php echo price($pu_ttc,0,'',0); ?>"></td>
<td align="right"><?php $coldisplay++; ?><input type="text" class="flat" size="8" id="price_ttc" name="price_ttc" value="<?php echo price($pu_ttc,0,'',0); ?>"></td>
<?php } ?>
<td align="right">
<td align="right"><?php $coldisplay++; ?>
<?php if (($line->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 @@
<?php } ?>
</td>
<td align="right" nowrap>
<td align="right" nowrap><?php $coldisplay++; ?>
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>">%
<?php } else { ?>
@ -126,7 +133,7 @@
</td>
<?php if (! empty($conf->margin->enabled)) { ?>
<td align="right">
<td align="right"><?php $coldisplay++; ?>
<select id="fournprice" name="fournprice" class="hideobject"></select>
<input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
</td>
@ -136,6 +143,13 @@
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
</td>
<?php
//Line extrafield
if (!empty($extrafieldsline)) {
print $line->showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay));
}
?>
</tr>
<?php if (! empty($conf->service->enabled) && $line->product_type == 1 && $dateSelector) { ?>

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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
*/
?>
<?php $coldisplay=0; ?>
<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
<tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>>
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td align="center"><?php echo ($i+1); ?></td>
<td align="center"><?php $coldisplay++; ?><?php echo ($i+1); ?></td>
<?php } ?>
<td><div id="<?php echo $line->rowid; ?>"></div>
<td><?php $coldisplay++; ?><div id="<?php echo $line->rowid; ?>"></div>
<?php if (($line->info_bits & 2) == 2) { ?>
<a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
<?php
@ -95,15 +96,15 @@
?>
</td>
<td align="right" class="nowrap"><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>
<td align="right" class="nowrap"><?php echo price($line->subprice); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->subprice); ?></td>
<?php if ($conf->global->MAIN_FEATURES_LEVEL > 1) { ?>
<td align="right" class="nowrap">&nbsp;</td>
<td align="right" class="nowrap"><?php $coldisplay++; ?>&nbsp;</td>
<?php } ?>
<td align="right" class="nowrap">
<td align="right" class="nowrap"><?php $coldisplay++; ?>
<?php if ((($line->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 @@
</td>
<?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
<td align="right"><?php echo dol_print_reduction($line->remise_percent,$langs); ?></td>
<td align="right"><?php $coldisplay++; ?><?php echo dol_print_reduction($line->remise_percent,$langs); ?></td>
<?php } else { ?>
<td>&nbsp;</td>
<td><?php $coldisplay++; ?>&nbsp;</td>
<?php }
if (! empty($conf->margin->enabled) && empty($user->societe_id)) {
?>
<td align="right" class="nowrap"><?php echo price($line->pa_ht); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {?>
<td align="right" class="nowrap"><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td>
<?php
}
if (! empty($conf->global->DISPLAY_MARK_RATES)) {?>
<td align="right" class="nowrap"><?php echo price($line->marque_tx).'%'; ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->marque_tx).'%'; ?></td>
<?php } } ?>
<?php if ($line->special_code == 3) { ?>
<td align="right" class="nowrap"><?php echo $langs->trans('Option'); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo $langs->trans('Option'); ?></td>
<?php } else { ?>
<td align="right" class="nowrap"><?php echo price($line->total_ht); ?></td>
<td align="right" class="nowrap"><?php $coldisplay++; ?><?php echo price($line->total_ht); ?></td>
<?php } ?>
<?php if ($this->statut == 0 && $user->rights->$element->creer) { ?>
<td align="center">
<td align="center"><?php $coldisplay++; ?>
<?php if (($line->info_bits & 2) == 2) { ?>
<?php } else { ?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#'.$line->id; ?>">
@ -146,14 +147,14 @@
<?php } ?>
</td>
<td align="center">
<td align="center"><?php $coldisplay++; ?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=ask_deleteline&amp;lineid='.$line->id; ?>">
<?php echo img_delete(); ?>
</a>
</td>
<?php if ($num > 1 && empty($conf->browser->phone)) { ?>
<td align="center" class="tdlineupdown">
<td align="center" class="tdlineupdown"><?php $coldisplay++; ?>
<?php if ($i > 0) { ?>
<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
<?php echo img_up(); ?>
@ -166,11 +167,18 @@
<?php } ?>
</td>
<?php } else { ?>
<td align="center"<?php echo (empty($conf->browser->phone)?' class="tdlineupdown"':''); ?>></td>
<td align="center"<?php echo (empty($conf->browser->phone)?' class="tdlineupdown"':''); ?>><?php $coldisplay++; ?></td>
<?php } ?>
<?php } else { ?>
<td colspan="3"></td>
<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
<?php } ?>
<?php
//Line extrafield
if (!empty($extrafieldsline)) {
print $line->showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay));
}
?>
</tr>
<!-- END PHP TEMPLATE objectline_view.tpl.php -->

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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))
</tr>
<tr <?php echo $bcnd[$var]; ?>>
<?php
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay=4; }
else {
$coldisplay=3; }
?>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>>
<?php
@ -112,8 +119,14 @@ if (! empty($usemargins))
$colspan = 4;
if (! empty($usemargins))
{
if (! empty($conf->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++;
}
?>
<td align="right">
<select id="fournprice" name="fournprice" class="flat" style="display: none;"></select>
@ -125,6 +138,22 @@ if (! empty($usemargins))
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
<input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline">
</td>
<?php
//Line extrafield
if (!empty($extrafieldsline)) {
if ($this->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));
}
}
?>
</tr>
<?php

View File

@ -954,6 +954,7 @@ MAIN_PROXY_USER=Login to use the proxy server
MAIN_PROXY_PASS=Password to use the proxy server
DefineHereComplementaryAttributes=Define here all attributes, not already available by default, and that you want to be supported for %s.
ExtraFields=Complementary attributes
ExtraFieldsLines=Complementary attributes (lines)
ExtraFieldsThirdParties=Complementary attributes (thirdparty)
ExtraFieldsContacts=Complementary attributes (contact/address)
ExtraFieldsMember=Complementary attributes (member)

View File

@ -955,6 +955,7 @@ MAIN_PROXY_USER=Identifiant pour passer le serveur proxy mandataire
MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire
DefineHereComplementaryAttributes=Définissez ici la liste des attributs supplémentaires, non disponibles en standard, et que vous voulez voir gérer sur les %s.
ExtraFields=Attributs supplémentaires
ExtraFieldsLines=Attributs supplémentaires (lignes)
ExtraFieldsThirdParties=Attributs supplémentaires (tiers)
ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses)
ExtraFieldsMember=Attributs supplémentaires (adhérents)