Merge pull request #7276 from atm-john/new_develop_extrafields_facture_rec
NEW extrafield on facture_rec
This commit is contained in:
commit
b3f77ed9f7
121
htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
Normal file
121
htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?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) 2017 John BOTELLA <contact@atm-consulting.fr>
|
||||
*
|
||||
* 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=ExtraFields::$type2label;
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$attrname=GETPOST('attrname', 'alpha');
|
||||
$elementtype='facture_rec'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/actions_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 load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup');
|
||||
|
||||
$head = invoice_admin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'attributesrec', $langs->trans("Invoices"), -1, 'invoice');
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||
|
||||
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 of an optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition of an optional field */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
if ($action == 'edit' && ! empty($attrname))
|
||||
{
|
||||
$langs->load("members");
|
||||
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
119
htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
Normal file
119
htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?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=ExtraFields::$type2label;
|
||||
$type2label=array('');
|
||||
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||
|
||||
$action=GETPOST('action', 'alpha');
|
||||
$attrname=GETPOST('attrname', 'alpha');
|
||||
$elementtype='facturedet_rec'; //Must be the $table_element of the class that manage extrafield
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/actions_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 load_fiche_titre($langs->trans("BillsSetup"),$linkback,'title_setup');
|
||||
|
||||
$head = invoice_admin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'attributeslinesrec', $langs->trans("Invoices"), -1, 'invoice');
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||
|
||||
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 load_fiche_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 load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -326,6 +326,14 @@ class FactureRec extends CommonInvoice
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
|
||||
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||
$this->fetch_optionals($this->id,$extralabels);
|
||||
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
@ -396,7 +404,7 @@ class FactureRec extends CommonInvoice
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$line = new FactureLigne($this->db);
|
||||
$line = new FactureLigneRec($this->db);
|
||||
|
||||
$line->id = $objp->rowid;
|
||||
$line->rowid = $objp->rowid;
|
||||
@ -436,6 +444,15 @@ class FactureRec extends CommonInvoice
|
||||
$line->price = $objp->price;
|
||||
$line->remise = $objp->remise;
|
||||
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafieldsline=new ExtraFields($line->db);
|
||||
$extrafieldsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
|
||||
$extralabelsline = $line->fetch_optionals($line->id,$extrafieldsline);
|
||||
|
||||
|
||||
$this->lines[$i] = $line;
|
||||
|
||||
$i++;
|
||||
@ -647,9 +664,10 @@ class FactureRec extends CommonInvoice
|
||||
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec");
|
||||
$this->id=$facid;
|
||||
$this->update_price();
|
||||
return 1;
|
||||
return $lineId;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1241,7 +1259,10 @@ class FactureRec extends CommonInvoice
|
||||
*/
|
||||
class FactureLigneRec extends CommonInvoiceLine
|
||||
{
|
||||
|
||||
|
||||
public $element='facturedetrec';
|
||||
public $table_element='facturedet_rec';
|
||||
|
||||
/**
|
||||
* Delete line in database
|
||||
*
|
||||
@ -1255,20 +1276,20 @@ class FactureLigneRec extends CommonInvoiceLine
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Call trigger
|
||||
/*$result=$this->call_trigger('LINEBILLREC_DELETE',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}*/
|
||||
// End call triggers
|
||||
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id);
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".($this->rowid > 0 ? $this->rowid : $this->id);
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEBILLREC_DELETE',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
@ -1280,4 +1301,159 @@ class FactureLigneRec extends CommonInvoiceLine
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Recupere les lignes de factures predefinies dans this->lines
|
||||
* @param int $rowid
|
||||
* @return int 1 if OK, < 0 if KO
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' l.rang, l.special_code,';
|
||||
$sql.= ' l.fk_unit, l.fk_contract_line,';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= ' WHERE l.rowid = '.$rowid;
|
||||
$sql.= ' ORDER BY l.rang';
|
||||
|
||||
dol_syslog('FactureRec::fetch_lines', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $objp->rowid;
|
||||
$this->label = $objp->custom_label; // Label line
|
||||
$this->desc = $objp->description; // Description line
|
||||
$this->description = $objp->description; // Description line
|
||||
$this->product_type = $objp->product_type; // Type of line
|
||||
$this->ref = $objp->product_ref; // Ref product
|
||||
$this->product_ref = $objp->product_ref; // Ref product
|
||||
$this->libelle = $objp->product_label; // deprecated
|
||||
$this->product_label = $objp->product_label; // Label product
|
||||
$this->product_desc = $objp->product_desc; // Description product
|
||||
$this->fk_product_type = $objp->fk_product_type; // Type of product
|
||||
$this->qty = $objp->qty;
|
||||
$this->price = $objp->price;
|
||||
$this->subprice = $objp->subprice;
|
||||
$this->fk_facture = $objp->fk_facture;
|
||||
$this->vat_src_code = $objp->vat_src_code;
|
||||
$this->tva_tx = $objp->tva_tx;
|
||||
$this->localtax1_tx = $objp->localtax1_tx;
|
||||
$this->localtax2_tx = $objp->localtax2_tx;
|
||||
$this->localtax1_type = $objp->localtax1_type;
|
||||
$this->localtax2_type = $objp->localtax2_type;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
$this->fk_product = $objp->fk_product;
|
||||
$this->info_bits = $objp->info_bits;
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->code_ventilation = $objp->fk_code_ventilation;
|
||||
$this->rang = $objp->rang;
|
||||
$this->special_code = $objp->special_code;
|
||||
$this->fk_unit = $objp->fk_unit;
|
||||
$this->fk_contract_line = $objp->fk_contract_line;
|
||||
|
||||
|
||||
$this->db->free($result);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a line to invoice_rec
|
||||
* @return int <0 if KO, Id of line if OK
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
if ($fk_product)
|
||||
{
|
||||
$product=new Product($this->db);
|
||||
$result=$product->fetch($fk_product);
|
||||
$product_type=$product->type;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET ";
|
||||
$sql.= " fk_facture = '".$this->fk_facture."'";
|
||||
$sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
|
||||
$sql.= ", description='".$this->db->escape($this->desc)."'";
|
||||
$sql.= ", price=".price2num($this->price);
|
||||
$sql.= ", qty=".price2num($this->qty);
|
||||
$sql.= ", tva_tx=".price2num($this->tva_tx);
|
||||
$sql.= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'";
|
||||
$sql.= ", localtax1_tx=".price2num($this->localtax1_tx);
|
||||
$sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'";
|
||||
$sql.= ", localtax2_tx=".price2num($this->localtax2_tx);
|
||||
$sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
|
||||
$sql.= ", fk_product=".(! empty($this->fk_product)?"'".$this->fk_product."'":"null");
|
||||
$sql.= ", product_type=".$this->product_type;
|
||||
$sql.= ", remise_percent='".price2num($this->remise_percent)."'";
|
||||
$sql.= ", subprice='".price2num($this->subprice)."'";
|
||||
$sql.= ", total_ht='".price2num($this->total_ht)."'";
|
||||
$sql.= ", total_tva='".price2num($this->total_tva)."'";
|
||||
$sql.= ", total_localtax1='".price2num($this->total_localtax1)."'";
|
||||
$sql.= ", total_localtax2='".price2num($this->total_localtax2)."'";
|
||||
$sql.= ", total_ttc='".price2num($this->total_ttc)."'";
|
||||
$sql.= ", rang=".$this->rang;
|
||||
$sql.= ", special_code=".$this->special_code;
|
||||
$sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit )."'":"null");
|
||||
$sql.= ", fk_contract_line=".($this->fk_contract_line?$this->fk_contract_line:"null");
|
||||
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('LINEBILL_REC_UPDATE',$user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -315,6 +315,8 @@ class Facture extends CommonInvoice
|
||||
$this->note_private=trim($this->note_private);
|
||||
$this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref));
|
||||
|
||||
$this->array_options=$_facrec->array_options;
|
||||
|
||||
//if (! $this->remise) $this->remise = 0;
|
||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||
$this->brouillon = 1;
|
||||
@ -634,7 +636,7 @@ class Facture extends CommonInvoice
|
||||
if (empty($tva_tx)) $tva_npr=0;
|
||||
$localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr);
|
||||
$localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr);
|
||||
|
||||
|
||||
$result_insert = $this->addline(
|
||||
$_facrec->lines[$i]->desc,
|
||||
$_facrec->lines[$i]->subprice,
|
||||
@ -654,7 +656,7 @@ class Facture extends CommonInvoice
|
||||
null,
|
||||
0,
|
||||
$_facrec->lines[$i]->label,
|
||||
null,
|
||||
empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options,
|
||||
$_facrec->lines[$i]->situation_percent,
|
||||
'',
|
||||
$_facrec->lines[$i]->fk_unit
|
||||
|
||||
@ -40,6 +40,7 @@ if (! empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('compta');
|
||||
@ -103,7 +104,7 @@ $hookmanager->initHooks(array('invoicereccard','globalcard'));
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('facture');
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
|
||||
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||
|
||||
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||
@ -394,6 +395,28 @@ if (empty($reshook))
|
||||
setEventMessages($line->error, $line->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from update form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
|
||||
if ($ret < 0)
|
||||
$error ++;
|
||||
|
||||
if (! $error) {
|
||||
|
||||
$result = $object->insertExtraFields();
|
||||
if ($result < 0) {
|
||||
$error ++;
|
||||
}
|
||||
} else if ($reshook < 0)
|
||||
$error ++;
|
||||
|
||||
if ($error) {
|
||||
$action = 'edit_extras';
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Add a new line
|
||||
if ($action == 'addline' && $user->rights->facture->creer)
|
||||
@ -737,6 +760,18 @@ if (empty($reshook))
|
||||
$extrafieldsline = new ExtraFields($db);
|
||||
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
|
||||
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
|
||||
|
||||
$objectline = new FactureLigneRec($db);
|
||||
if ($objectline->fetch(GETPOST('lineid')))
|
||||
{
|
||||
$objectline->array_options=$array_options;
|
||||
$result=$objectline->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($langs->trans('Error').$result, null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Unset extrafield
|
||||
if (is_array($extralabelsline))
|
||||
{
|
||||
@ -1326,6 +1361,11 @@ else
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Other attributes
|
||||
$cols = 2;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
@ -1278,6 +1278,15 @@ class Contrat extends CommonObject
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
|
||||
*
|
||||
* 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
|
||||
@ -151,6 +152,16 @@ function invoice_admin_prepare_head()
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$head[$h][2] = 'attributeslines';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_rec_cust_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoicesRec");
|
||||
$head[$h][2] = 'attributesrec';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facturedet_rec_cust_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLinesRec");
|
||||
$head[$h][2] = 'attributeslinesrec';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove');
|
||||
|
||||
|
||||
@ -77,6 +77,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
|
||||
if ($object->element=='shipping') $permok=$user->rights->expedition->creer;
|
||||
if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer;
|
||||
if ($object->element=='productlot') $permok=$user->rights->stock->creer;
|
||||
if ($object->element=='facturerec') $permok=$user->rights->facture->creer;
|
||||
|
||||
if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key]))
|
||||
&& $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key)
|
||||
|
||||
@ -372,6 +372,9 @@ else {
|
||||
elseif ($this->table_element_line=='facture_fourn_det') {
|
||||
$newline = new SupplierInvoiceLine($this->db);
|
||||
}
|
||||
elseif ($this->table_element_line=='facturedet_rec') {
|
||||
$newline = new FactureLigneRec($this->db);
|
||||
}
|
||||
if (is_object($newline)) {
|
||||
print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8));
|
||||
}
|
||||
|
||||
@ -585,3 +585,23 @@ ALTER TABLE llx_mailing_cibles MODIFY COLUMN source_url varchar(255);
|
||||
|
||||
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'IGST-CGST', 8, 8, '1', 0, '0', 0, 'IGST-CGST', 1);
|
||||
insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'SGST', 0, 0, '0', 16, '1', 0, 'SGST', 1);
|
||||
|
||||
CREATE TABLE llx_facture_rec_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14)
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object);
|
||||
|
||||
CREATE TABLE llx_facturedet_rec_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_facturedet_rec_extrafields ADD INDEX idx_facturedet_rec_extrafields (fk_object);
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
|
||||
--
|
||||
-- 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/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object);
|
||||
26
htdocs/install/mysql/tables/llx_facture_rec_extrafields.sql
Normal file
26
htdocs/install/mysql/tables/llx_facture_rec_extrafields.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
|
||||
--
|
||||
-- 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/>.
|
||||
--
|
||||
-- ========================================================================
|
||||
|
||||
create table llx_facture_rec_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL,
|
||||
import_key varchar(14) -- import key
|
||||
) ENGINE=innodb;
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
-- ===================================================================
|
||||
-- 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/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
|
||||
ALTER TABLE llx_facturedet_rec_extrafields ADD INDEX idx_facturedet_rec_extrafields (fk_object);
|
||||
@ -0,0 +1,25 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2017 ATM-CONSULTING <contact@atm-consulting.fr>
|
||||
--
|
||||
-- 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/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
create table llx_facturedet_rec_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
tms timestamp,
|
||||
fk_object integer NOT NULL, -- object id
|
||||
import_key varchar(14) -- import key
|
||||
)ENGINE=innodb;
|
||||
@ -1095,6 +1095,7 @@ 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)
|
||||
ExtraFieldsLinesRec=Complementary attributes (templates invoices lines)
|
||||
ExtraFieldsSupplierOrdersLines=Complementary attributes (order lines)
|
||||
ExtraFieldsSupplierInvoicesLines=Complementary attributes (invoice lines)
|
||||
ExtraFieldsThirdParties=Complementary attributes (thirdparty)
|
||||
@ -1102,6 +1103,7 @@ ExtraFieldsContacts=Complementary attributes (contact/address)
|
||||
ExtraFieldsMember=Complementary attributes (member)
|
||||
ExtraFieldsMemberType=Complementary attributes (member type)
|
||||
ExtraFieldsCustomerInvoices=Complementary attributes (invoices)
|
||||
ExtraFieldsCustomerInvoicesRec=Complementary attributes (templates invoices)
|
||||
ExtraFieldsSupplierOrders=Complementary attributes (orders)
|
||||
ExtraFieldsSupplierInvoices=Complementary attributes (invoices)
|
||||
ExtraFieldsProject=Complementary attributes (projects)
|
||||
|
||||
@ -1080,6 +1080,7 @@ 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)
|
||||
ExtraFieldsLinesRec=Attributs supplémentaires (lignes factures modèles)
|
||||
ExtraFieldsSupplierOrdersLines=Attributs supplémentaires (lignes de commandes)
|
||||
ExtraFieldsSupplierInvoicesLines=Attributs supplémentaires (lignes de factures)
|
||||
ExtraFieldsThirdParties=Attributs supplémentaires (tiers)
|
||||
@ -1087,6 +1088,7 @@ ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses)
|
||||
ExtraFieldsMember=Attributs supplémentaires (adhérents)
|
||||
ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents)
|
||||
ExtraFieldsCustomerInvoices=Attributs supplémentaires (factures)
|
||||
ExtraFieldsCustomerInvoicesRec=Attributs supplémentaires (factures modèles)
|
||||
ExtraFieldsSupplierOrders=Attributs supplémentaires (commandes)
|
||||
ExtraFieldsSupplierInvoices=Attributs supplémentaires (factures)
|
||||
ExtraFieldsProject=Attributs supplémentaires (projets)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user