diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index 3ae95881487..9a42dd11773 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -176,6 +176,12 @@ class PaymentVarious extends CommonObject
);
// END MODULEBUILDER PROPERTIES
+ /**
+ * Draft status
+ */
+ const STATUS_DRAFT = 0;
+
+
/**
* Constructor
*
@@ -622,15 +628,19 @@ class PaymentVarious extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
+ global $langs;
+
+ if (empty($status)) {
+ $status = 0;
+ }
+
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
- global $langs;
- //$langs->load("mymodule@mymodule");
- /*$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
- $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
- $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
+ $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
+ //$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
+ //$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
- $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
- $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');*/
+ //$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
+ //$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
}
$statusType = 'status'.$status;
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 35ebaa3b126..d166a3c2e82 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -223,7 +223,7 @@ if (empty($reshook)) {
$result = $object->fetch($id);
- $object->accountancy_code = GETPOST('accountancy_code', 'alpha');
+ $object->accountancy_code = GETPOST('accountancy_code', 'alphanohtml');
$res = $object->update($user);
if ($res > 0) {
@@ -586,7 +586,7 @@ if ($id) {
if ($action != 'classify') {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' ';
}
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (property_exists($object, 'socid') ? $object->socid : 0), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
@@ -638,15 +638,25 @@ if ($id) {
// Account of Chart of account
$editvalue = '';
if (isModEnabled('accounting')) {
- $editvalue = $formaccounting->select_account($object->accountancy_code, 'accountancy_code', 1, null, 1, 1);
- }
+ print '
| ';
+ print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
+ print ' | ';
+ if ($action == 'editaccountancy_code') {
+ print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
+ } else {
+ $accountingaccount = new AccountingAccount($db);
+ $accountingaccount->fetch('', $object->accountancy_code, 1);
- print ' |
';
- print '| ';
- print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
- print ' | ';
- print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'asis', $editvalue, 0, null, '', 1, 'lengthAccountg');
- print ' |
';
+ print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
+ }
+ print '';
+ } else {
+ print '| ';
+ print $langs->trans("AccountAccounting");
+ print ' | ';
+ print $object->accountancy_code;
+ print ' |
';
+ }
// Subledger account
print '| ';
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index 1c4e88558ff..f248414b30e 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -824,9 +824,13 @@ while ($i < $imaxinloop) {
// Accounting account
if (!empty($arrayfields['account']['checked'])) {
- $accountingaccount->fetch('', $obj->accountancy_code, 1);
-
- print ' | '.$accountingaccount->getNomUrl(0, 1, 1, '', 1).' | ';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+ $result = $accountingaccount->fetch('', $obj->accountancy_code, 1);
+ if ($result > 0) {
+ print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).' | ';
+ } else {
+ print ' | ';
+ }
if (!$i) {
$totalarray['nbfield']++;
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 16a85536a8a..9c9d880a96c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -5008,10 +5008,10 @@ abstract class CommonObject
//if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line)))
if (is_object($hookmanager)) { // Old code is commented on preceding line.
if (empty($line->fk_parent_line)) {
- $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element);
+ $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'defaulttpldir'=>$defaulttpldir);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
} else {
- $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
+ $parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line, 'defaulttpldir'=>$defaulttpldir);
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
}
diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php
index 5f933b435c4..f04dd7a991e 100644
--- a/htdocs/core/customreports.php
+++ b/htdocs/core/customreports.php
@@ -1079,7 +1079,7 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
}
}
// Add extrafields to Measures
- if (!empty($object->isextrafieldmanaged)) {
+ if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
$position = (!empty($val['position']) ? $val['position'] : 0);
@@ -1236,7 +1236,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
}
// Add extrafields to X-Axis
- if (!empty($object->isextrafieldmanaged)) {
+ if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
@@ -1398,7 +1398,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
}
// Add extrafields to Group by
- if (!empty($object->isextrafieldmanaged)) {
+ if (!empty($object->isextrafieldmanaged) && isset($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 824f36f9dba..f19046c0599 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -440,6 +440,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
$feature2 = 'commande';
}
}
+ if ($features == 'payment_sc') {
+ $tableandshare = 'paiementcharge';
+ $parentfortableentity = 'fk_charge@chargesociales';
+ }
//print $features.' - '.$tableandshare.' - '.$feature2.' - '.$dbt_select."\n";
@@ -914,7 +918,6 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
if ($dbt_select != 'rowid' && $dbt_select != 'id') {
$objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method.
}
-
// Check permission for objectid on entity only
if (in_array($feature, $check) && $objectid > 0) { // For $objectid = 0, no check
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php
index cd174655823..82f0b5be54d 100644
--- a/htdocs/core/lib/signature.lib.php
+++ b/htdocs/core/lib/signature.lib.php
@@ -20,11 +20,12 @@
/**
* Return string with full online Url to accept and sign a quote
*
- * @param string $type Type of URL ('proposal', ...)
- * @param string $ref Ref of object
- * @return string Url string
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @param Object $obj object (needed to make multicompany good links)
+ * @return string Url string
*/
-function showOnlineSignatureUrl($type, $ref)
+function showOnlineSignatureUrl($type, $ref, $obj = null)
{
global $conf, $langs;
@@ -34,7 +35,7 @@ function showOnlineSignatureUrl($type, $ref)
$servicename = 'Online';
$out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
';
- $url = getOnlineSignatureUrl(0, $type, $ref);
+ $url = getOnlineSignatureUrl(0, $type, $ref, $obj);
$out .= '';
if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
$out .= $url;
@@ -51,15 +52,27 @@ function showOnlineSignatureUrl($type, $ref)
/**
* Return string with full Url
*
- * @param int $mode 0=True url, 1=Url formated with colors
- * @param string $type Type of URL ('proposal', ...)
- * @param string $ref Ref of object
- * @param string $localorexternal 0=Url for browser, 1=Url for external access
- * @return string Url string
+ * @param int $mode 0=True url, 1=Url formated with colors
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @param string $localorexternal 0=Url for browser, 1=Url for external access
+ * @param Object $obj object (needed to make multicompany good links)
+ * @return string Url string
*/
-function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
+function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $obj = null)
{
- global $conf, $object, $dolibarr_main_url_root;
+ global $conf, $dolibarr_main_url_root;
+
+ if (empty($obj)) {
+ // For compatibility with 15.0 -> 19.0
+ global $object;
+ if (empty($object)) {
+ $obj = new stdClass();
+ } else {
+ dol_syslog(__METHOD__." using global object is deprecated, please give obj as argument", LOG_WARNING);
+ $obj = $object;
+ }
+ }
$ref = str_replace(' ', '', $ref);
$out = '';
@@ -90,7 +103,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : $obj->entity) : ''), '0');
}
/*
if ($mode == 1) {
@@ -129,7 +142,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + contract_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0');
}
} elseif ($type == 'fichinter') {
$securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN');
@@ -144,7 +157,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + fichinter_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (is_null($object) ? '' : $object->entity) : ''), '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0');
}
} else {
$securekeyseed = getDolGlobalString(dol_strtoupper($type).'ONLINE_SIGNATURE_SECURITY_TOKEN');
@@ -165,7 +178,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
// For multicompany
if (!empty($out) && isModEnabled('multicompany')) {
- $out .= "&entity=".(is_null($object) ? '' : $object->entity); // Check the entity because we may have the same reference in several entities
+ $out .= "&entity=".(empty($obj->entity) ? '' : (int) $obj->entity); // Check the entity because we may have the same reference in several entities
}
return $out;