';
- if ($possiblelink[label] == 'LinkToContract') {
+ if ($possiblelink['label'] == 'LinkToContract') {
$form = new Form($db);
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
}
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index 20ffa3f52b6..789a84df04d 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014 Florian Henry
- * Copyright (C) 2019 Eric Seigne
+/* Copyright (C) 2013-2014 Olivier Geffroy
+ * Copyright (C) 2013-2021 Alexandre Spangaro
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2019 Eric Seigne
*
* 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
@@ -257,8 +257,8 @@ function getDefaultDatesForTransfer()
$periodbydefaultontransfer = $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER;
isset($periodbydefaultontransfer) ? $periodbydefaultontransfer : 0;
if ($periodbydefaultontransfer == 2) {
- $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
- $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
+ $sql = "SELECT date_start, date_end FROM ".MAIN_DB_PREFIX."accounting_fiscalyear ";
+ $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1);
$res = $db->query($sql);
if ($res->num_rows > 0) {
@@ -268,6 +268,9 @@ function getDefaultDatesForTransfer()
} else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
+ if ($conf->global->SOCIETE_FISCAL_MONTH_START > dol_print_date(dol_now(), '%m')) {
+ $year_start = $year_start - 1;
+ }
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 057122ec648..c81e5440a5d 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -285,15 +285,15 @@ class modAccounting extends DolibarrModules
//'b.doc_type'=>'Doctype',
'b.doc_ref'=>'Piece',
'b.code_journal'=>'Codejournal',
- //'b.journal_label'=>'JournalLabel',
+ 'b.journal_label'=>'JournalLabel',
'b.numero_compte'=>'AccountAccounting',
- //'b.label_compte'=>'LabelAccount',
+ 'b.label_compte'=>'LabelAccount',
'b.subledger_account'=>'SubledgerAccount',
'b.subledger_label'=>'SubledgerAccountLabel',
'b.label_operation'=>'LabelOperation',
'b.debit'=>"Debit",
'b.credit'=>"Credit",
- 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit
+ 'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replaced into accountancyexport.class.php by a detection using ->debit and ->credit
);
$this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
@@ -303,9 +303,9 @@ class modAccounting extends DolibarrModules
//'b.doc_type'=>'import',
'b.doc_ref'=>'My document ABC',
'b.code_journal'=>"VTE",
- //'b.journal_label'=>"Sale journal",
+ 'b.journal_label'=>"Sale journal",
'b.numero_compte'=>"707",
- //'b.label_compte'=>'Product account 707',
+ 'b.label_compte'=>'Product account 707',
'b.subledger_account'=>'',
'b.subledger_label'=>'',
'b.label_operation'=>"Sale of ABC",
diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
index 7b6ec019683..bf1711970dc 100644
--- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
+++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
@@ -241,7 +241,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME))
{
- $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp;
+ $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp;
+ $newfiletmp = preg_replace('/__+/', '_', $newfiletmp); // Replace repeated _ into one _ (to avoid string with substitution syntax)
}
if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{
diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php
deleted file mode 100644
index 62ceb504dac..00000000000
--- a/htdocs/expensereport/ajax/ajaxprojet.php
+++ /dev/null
@@ -1,84 +0,0 @@
-
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2007-2010 Laurent Destailleur
- * Copyright (C) 2010 Cyrille de Lambert
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/expensereport/ajax/ajaxprojet.php
- * \ingroup expensereport
- * \brief File to return Ajax response on third parties request
- */
-
-if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
-if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
-if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
-if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
-
-$res = 0;
-require '../../main.inc.php';
-
-
-/*
- * View
- */
-
-// Ajout directives pour resoudre bug IE
-//header('Cache-Control: Public, must-revalidate');
-//header('Pragma: public');
-
-//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
-top_httphead();
-
-//print ''."\n";
-
-dol_syslog(join(',', $_GET));
-
-
-// Generation liste des projets
-if (GETPOST('fk_projet') != '')
-{
- $return_arr = array();
-
- $sql = "SELECT p.rowid, p.ref, p.title, s.nom";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
- if (!empty($_GET["fk_projet"])) $sql .= " WHERE p.ref LIKE '%".$db->escape($_GET["fk_projet"])."%' OR p.title LIKE '%".$db->escape($_GET["fk_projet"])."%' OR s.nom LIKE '%".$db->escape($_GET["fk_projet"])."%'"; // Add other filters
- $sql .= " ORDER BY p.ref ASC";
-
- $resql = $db->query($sql);
- if ($resql)
- {
- while ($row = $db->fetch_array($resql))
- {
- $label = $row['ref'].' - '.$row['title'];
- $row_array['label'] = $label;
- $row_array['value'] = $label;
- $row_array['key'] = $row['rowid'];
-
- array_push($return_arr, $row_array);
- }
-
- echo json_encode($return_arr);
- } else {
- echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error'));
- }
-} else {
- echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter'));
-}
diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php
index 254e577f2f2..fe74a763eba 100644
--- a/htdocs/fourn/class/api_supplier_orders.class.php
+++ b/htdocs/fourn/class/api_supplier_orders.class.php
@@ -72,7 +72,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(404, 'Supplier order not found');
}
- if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
+ if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -239,7 +239,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(404, 'Supplier order not found');
}
- if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
+ if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -270,7 +270,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(404, 'Supplier order not found');
}
- if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
+ if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -315,7 +315,7 @@ class SupplierOrders extends DolibarrApi
throw new RestException(404, 'Order not found');
}
- if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) {
+ if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php
index 1bf8984a6ee..f61d1795cba 100644
--- a/htdocs/fourn/paiement/list.php
+++ b/htdocs/fourn/paiement/list.php
@@ -11,6 +11,7 @@
* Copyright (C) 2017 Alexandre Spangaro
* Copyright (C) 2018 Frédéric France
* Copyright (C) 2020 Tobias Sekan
+ * Copyright (C) 2021 Ferran Marcet
*
* 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
@@ -171,7 +172,7 @@ if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_payment_type != '') $sql .= " AND c.code='".$db->escape($search_payment_type)."'";
if ($search_cheque_num != '') $sql .= natural_search('p.num_paiement', $search_cheque_num);
if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1);
-if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.$search_bank_account."'";
+if ($search_bank_account > 0) $sql .= ' AND b.fk_account='.((int) $search_bank_account);
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php
index 3bac7265606..66aa1b300b8 100644
--- a/htdocs/reception/card.php
+++ b/htdocs/reception/card.php
@@ -237,8 +237,6 @@ if (empty($reshook))
$objectsrc = new $classname($db);
$objectsrc->fetch($object->origin_id);
-
-
$object->socid = $objectsrc->socid;
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
$object->model_pdf = GETPOST('model');
@@ -280,10 +278,8 @@ if (empty($reshook))
$stockLocation = "ent1".$i."_0";
$qty = "qtyl".$i;
-
-
- //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit;
- //reception line for product with no batch management and no multiple stock location
+ //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit;
+ //reception line for product with no batch management and no multiple stock location
if (GETPOST($qty, 'int') > 0)
$totalqty += GETPOST($qty, 'int');
@@ -318,9 +314,15 @@ if (empty($reshook))
$entrepot_id = is_numeric(GETPOST($ent, 'int')) ? GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int');
+ if (!empty($lineToTest)) {
+ $fk_product = $lineToTest->fk_product;
+ } else {
+ $fk_product = $linesrc->fk_product;
+ }
+
if ($entrepot_id < 0)
$entrepot_id = '';
- if (!($linesrc->fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ if (!($fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES))
$entrepot_id = 0;
$eatby = GETPOST($eatby, 'alpha');
$sellby = GETPOST($sellby, 'alpha');