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

This commit is contained in:
Laurent Destailleur
2023-10-04 13:04:31 +02:00
7 changed files with 82 additions and 42 deletions

View File

@@ -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
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');
if (empty($status)) {
$status = 0;
}
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
$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;

View File

@@ -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 .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$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 '</td></tr>';
print '<tr><td class="nowrap">';
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
print '</td><td>';
print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'asis', $editvalue, 0, null, '', 1, 'lengthAccountg');
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 $accountingaccount->getNomUrl(0, 1, 1, '', 1);
}
print '</td></tr>';
} else {
print '<tr><td class="nowrap">';
print $langs->trans("AccountAccounting");
print '</td><td>';
print $object->accountancy_code;
print '</td></tr>';
}
// Subledger account
print '<tr><td class="nowrap">';

View File

@@ -824,9 +824,13 @@ while ($i < $imaxinloop) {
// Accounting account
if (!empty($arrayfields['account']['checked'])) {
$accountingaccount->fetch('', $obj->accountancy_code, 1);
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$result = $accountingaccount->fetch('', $obj->accountancy_code, 1);
if ($result > 0) {
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->accountancy_code.' '.$accountingaccount->label).'">'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
} else {
print '<td></td>';
}
if (!$i) {
$totalarray['nbfield']++;
}

View File

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

View File

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

View File

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

View File

@@ -22,9 +22,10 @@
*
* @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').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'</span><br>';
$url = getOnlineSignatureUrl(0, $type, $ref);
$url = getOnlineSignatureUrl(0, $type, $ref, $obj);
$out .= '<div class="urllink">';
if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
$out .= $url;
@@ -55,11 +56,23 @@ function showOnlineSignatureUrl($type, $ref)
* @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;