Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2017-08-26 19:58:01 +02:00
commit 254d92070f
19 changed files with 656 additions and 33 deletions

View 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();

View 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();

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
<?php
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2017 Olivier Geffroy <jeff@jeffinfo.com>
*
* 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
@ -62,6 +63,7 @@ if ($modecompta=="CREANCES-DETTES")
$nom=$langs->trans("SalesTurnover");
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
$period="$year_start - $year_end";
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCADue");
@ -70,10 +72,12 @@ if ($modecompta=="CREANCES-DETTES")
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
else {
else if ($modecompta=="RECETTES-DEPENSES")
{
$nom=$langs->trans("SalesTurnover");
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
$period="$year_start - $year_end";
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCAIn");
@ -81,6 +85,20 @@ else {
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
else if ($modecompta=="BOOKKEEPING")
{
$nom=$langs->trans("BookkeepingTurnover");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$period="$year_start - $year_end";
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesCABookkeeping");
$description.= $langs->trans("DepositsAreIncluded");
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
$moreparam=array();
if (! empty($modecompta)) $moreparam['modecompta']=$modecompta;
report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam,$calcmode);
@ -98,8 +116,10 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " WHERE f.fk_statut in (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)";
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
}
else
else if ($modecompta=="RECETTES-DEPENSES")
{
/*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
@ -111,9 +131,19 @@ else
$sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid";
}
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
}
else if ($modecompta=="BOOKKEEPING")
{
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql.= " WHERE b.numero_compte IN (SELECT a.account_number" ;
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_account as a";
$sql.= " WHERE a.fk_accounting_category = 1 ) " ; // todo sql with accounting category, but we need to define category in turnover
}
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
@ -481,7 +511,7 @@ print '</div>';
$i++;
}
print "<tr ".$bc[$var]."><td align=\"right\" colspan=\"5\"><i>Facture a encaisser : </i></td><td align=\"right\"><i>".price($total_ttc_Rac)."</i></td><td colspan=\"5\"><-- bug ici car n'exclut pas le deja r<EFBFBD>gl<EFBFBD> des factures partiellement r<>gl<67>es</td></tr>";
print "<tr ".$bc[$var]."><td align=\"right\" colspan=\"5\"><i>Facture a encaisser : </i></td><td align=\"right\"><i>".price($total_ttc_Rac)."</i></td><td colspan=\"5\"><-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es</td></tr>";
}
$db->free($resql);
}

View File

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

View File

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

View File

@ -562,15 +562,10 @@ class pdf_einstein extends ModelePDFCommandes
// Show square
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@ -587,18 +582,18 @@ class pdf_einstein extends ModelePDFCommandes
*/
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
$this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file,'F');
$pdf->Output($file, 'F');
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

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

View File

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

View File

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

View File

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

View 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;

View File

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

View File

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

View File

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

View File

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

View File

@ -130,6 +130,7 @@ AnnualByCompaniesDueDebtMode=Bilan des recettes et dépenses, détail par tiers
AnnualByCompaniesInputOutputMode=Bilan des recettes et dépenses, détail par tiers
SeeReportInInputOutputMode=Cliquer sur <b>%sRecettes-Dépenses%s</b> dit <b>comptabilité de caisse</b> pour un calcul sur les paiements effectivement réalisés
SeeReportInDueDebtMode=Cliquer sur <b>%sCréances-Dettes%s</b> dit <b>comptabilité d'engagement</b> pour un calcul sur les factures émises
SeeReportInBookkeepingMode=Cliquer sur <b>%sGrand Livre%s</b> dit <b>comptabilité avance</b> pour un calcul sur les factures dans le grand livre
RulesAmountWithTaxIncluded=- Les montants affichés sont les montants taxe incluse
RulesResultDue=- Il comprend les factures impayées, les dépenses, la TVA, les dons qu'elles soient payées ou non. Il comprend également les salaires versés. <br> - Il est basé sur la date de validation de factures et de la TVA et à la date prévue pour les dépenses. Pour les salaires définis avec le module de salaire, la date de paiement de la valeur est utilisée.
RulesResultInOut=- Il comprend les paiements réels effectués sur les factures, les dépenses, la TVA et les salaires. <br> - Il est basé sur les dates de paiement des factures, les dépenses, la TVA et les salaires. La date du don pour le don.