';
dol_print_object_info($object);
diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php
index 8ca880de25f..6a9fdcbffff 100644
--- a/htdocs/accountancy/bookkeeping/card.php
+++ b/htdocs/accountancy/bookkeeping/card.php
@@ -351,7 +351,7 @@ if ($action == 'create')
print ''."\n";
print ''."\n";
- dol_fiche_head();
+ print dol_get_fiche_head();
print '';
@@ -415,7 +415,7 @@ if ($action == 'create')
$head[$h][2] = 'transaction';
$h++;
- dol_fiche_head($head, 'transaction', '', -1);
+ print dol_get_fiche_head($head, 'transaction', '', -1);
//dol_banner_tab($object, '', $backlink);
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
index 321ef282dff..9e21a712e7e 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
@@ -135,7 +135,7 @@ $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
-dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company');
+print dol_get_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company');
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
index 144c2595d25..a0f930e50d7 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
@@ -134,7 +134,7 @@ $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
-dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company');
+print dol_get_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company');
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php
index ed8f347a177..4343946a85e 100644
--- a/htdocs/accountancy/customer/card.php
+++ b/htdocs/accountancy/customer/card.php
@@ -119,7 +119,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_accountancy');
- dol_fiche_head();
+ print dol_get_fiche_head();
print '';
diff --git a/htdocs/accountancy/expensereport/card.php b/htdocs/accountancy/expensereport/card.php
index ab02592f6b8..153717d05e4 100644
--- a/htdocs/accountancy/expensereport/card.php
+++ b/htdocs/accountancy/expensereport/card.php
@@ -121,7 +121,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_accountancy');
- dol_fiche_head();
+ print dol_get_fiche_head();
print '';
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index 4a4747cfaf4..bee34f291f5 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -121,7 +121,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_accountancy');
- dol_fiche_head();
+ print dol_get_fiche_head();
print '';
diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php
index a7e7a6f3634..c0b5998f035 100644
--- a/htdocs/adherents/agenda.php
+++ b/htdocs/adherents/agenda.php
@@ -118,7 +118,7 @@ if ($object->id > 0) {
if (!empty($conf->notification->enabled)) $langs->load("mails");
$head = member_prepare_head($object);
- dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
+ print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index cd432aa12d6..128b915ef0f 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -4,7 +4,7 @@
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005-2018 Regis Houssin
* Copyright (C) 2012 Marcos García
- * Copyright (C) 2012-2018 Philippe Grand
+ * Copyright (C) 2012-2020 Philippe Grand
* Copyright (C) 2015-2018 Alexandre Spangaro
* Copyright (C) 2018 Frédéric France
*
@@ -833,7 +833,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '';
if ($backtopage) print '';
- dol_fiche_head('');
+ print dol_get_fiche_head('');
print '';
print '';
@@ -1058,7 +1058,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '';
if ($backtopage) print '';
- dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
+ print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
print '';
@@ -1268,7 +1268,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
*/
$head = member_prepare_head($object);
- dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
+ print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
// Confirm create user
if ($action == 'create_user') {
diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 32630b9e478..0f6e6250796 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -100,7 +100,7 @@ if ($id > 0) {
$head = member_prepare_head($object);
- dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
+ print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
$linkback = ''.$langs->trans("BackToList").'';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index a09844da014..78c5a263ce1 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1634,6 +1634,7 @@ class Propal extends CommonObject
$sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
$sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").",";
$sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").",";
+ $sql .= " fk_input_reason=".(isset($this->demand_reason_id) ? $this->demand_reason_id : "null").",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").",";
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 0ab4974ce7f..85ad01ab7a6 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -981,6 +981,45 @@ class Invoices extends DolibarrApi
return $this->_cleanObjectDatas($this->invoice);
}
+ /**
+ * Get discount from invoice
+ *
+ * @param int $id Id of invoice
+ *
+ * @url GET {id}/discount
+ *
+ * @return mixed
+ */
+ public function getDiscount($id)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
+
+ if (!DolibarrApiAccess::$user->rights->facture->lire) {
+ throw new RestException(401);
+ }
+
+ $result = $this->invoice->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'Invoice not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ $discountcheck = new DiscountAbsolute($this->db);
+ $result = $discountcheck->fetch(0, $this->invoice->id);
+
+ if ($result == 0){
+ throw new RestException(404, 'Discount not found');
+ }
+ if ($result < 0){
+ throw new RestException(500, $discountcheck->error);
+ }
+
+ return parent::_cleanObjectDatas($discountcheck);
+ }
+
/**
* Create a discount (credit available) for a credit note or a deposit.
*
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 4f795274ad2..ba902c4b773 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -206,10 +206,10 @@ $arrayfields = array(
'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200),
'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>210),
'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>220), // Not enabled by default because slow
- 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled)?0:1)),
- 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled)?0:1)),
- 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || empty($conf->global->DISPLAY_MARGIN_RATES)?0:1)),
- 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || empty($conf->global->DISPLAY_MARK_RATES)?0:1)),
+ 'total_pa' => array('label' => ($conf->global->MARGIN_TYPE == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous?0:1)),
+ 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous?0:1)),
+ 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES)?0:1)),
+ 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES)?0:1)),
'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
'f.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))),
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 249d2dd9b8c..76c6833c07b 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -81,7 +81,7 @@ if ($id > 0 || !empty($ref))
$totalpaye = $object->getSommePaiement();
- dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
+ print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
// Invoice content
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 0591d75d5a3..cdf5a0e62c4 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -8,6 +8,7 @@
* Copyright (C) 2016 Marcos García
* Copyright (C) 2019 Nicolas ZABOURI
* Copyright (C) 2020 Tobias Sekan
+ * Copyright (C) 2020 Josep Lluís Amador
*
* 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
@@ -143,8 +144,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql .= ", s.nom as name";
$sql .= ", s.rowid as socid, s.email";
$sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
+ $sql .= ", cc.rowid as country_id, cc.code as country_code";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
+ $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = ".Facture::STATUS_DRAFT;
$sql .= " AND f.entity IN (".getEntity('invoice').")";
@@ -161,6 +163,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
$sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
+ $sql .= ", cc.rowid as country_id, cc.code as country_code";
// Add Group from hooks
$parameters = array();
@@ -207,6 +210,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$companystatic->id = $obj->socid;
$companystatic->name = $obj->name;
$companystatic->email = $obj->email;
+ $companystatic->country_id = $obj->country_id;
+ $companystatic->country_code = $obj->country_code;
$companystatic->client = 1;
$companystatic->code_client = $obj->code_client;
$companystatic->code_fournisseur = $obj->code_fournisseur;
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index de672af203b..72c5bf3e825 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -5,7 +5,7 @@
* Copyright (C) 2011-2016 Juanjo Menent
* Copyright (C) 2013 Philippe Grand
* Copyright (C) 2015-2016 Alexandre Spangaro
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2020 Frédéric France
*
* 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
@@ -385,7 +385,7 @@ if ($action == 'new')
$sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, ";
$sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,";
- $sql .= " p.rowid as paymentid";
+ $sql .= " p.rowid as paymentid, p.ref as paymentref";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
@@ -411,6 +411,7 @@ if ($action == 'new')
$lines[$obj->bid][$i]["banque"] = $obj->banque;
$lines[$obj->bid][$i]["id"] = $obj->transactionid;
$lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
+ $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
$i++;
}
@@ -482,7 +483,7 @@ if ($action == 'new')
// Link to payment
print '| ';
$paymentstatic->id = $value["paymentid"];
- $paymentstatic->ref = $value["paymentid"];
+ $paymentstatic->ref = $value["paymentref"];
if ($paymentstatic->id)
{
print $paymentstatic->getNomUrl(1);
@@ -616,7 +617,7 @@ if ($action == 'new')
// List of bank checks
$sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,";
$sql .= " b.dateo as date, b.datec as datec, b.banque,";
- $sql .= " p.rowid as pid, ba.rowid as bid, p.statut";
+ $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
@@ -662,9 +663,8 @@ if ($action == 'new')
// Link to payment
print ' | ';
$paymentstatic->id = $objp->pid;
- $paymentstatic->ref = $objp->pid;
- if ($paymentstatic->id)
- {
+ $paymentstatic->ref = $objp->pref;
+ if ($paymentstatic->id) {
print $paymentstatic->getNomUrl(1);
} else {
print ' ';
@@ -673,8 +673,7 @@ if ($action == 'new')
// Link to bank transaction
print ' | ';
$accountlinestatic->rowid = $objp->rowid;
- if ($accountlinestatic->rowid)
- {
+ if ($accountlinestatic->rowid) {
print $accountlinestatic->getNomUrl(1);
} else {
print ' ';
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 1710b4dda6a..45fd513d1a3 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville
* Copyright (C) 2004-2011 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2020 Frédéric France
*
* 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
@@ -66,9 +66,9 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact-
if ($file_OK)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
if (GETPOST('deletephoto'))
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$fileimg = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/'.$object->photo;
$dirthumbs = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos/thumbs';
dol_delete_file($fileimg);
@@ -134,7 +134,7 @@ if ($action == 'edit')
* Fiche en mode edition
*/
- print ' | |