Skip to content

Commit

Permalink
Merge branch '18.0' of [email protected]:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 4, 2023
2 parents 73bdb71 + 78db102 commit 40f1058
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 42 deletions.
24 changes: 17 additions & 7 deletions htdocs/compta/bank/class/paymentvarious.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ class PaymentVarious extends CommonObject
);
// END MODULEBUILDER PROPERTIES

/**
* Draft status
*/
const STATUS_DRAFT = 0;


/**
* Constructor
*
Expand Down Expand Up @@ -622,15 +628,19 @@ public function getLibStatut($mode = 0)
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;
Expand Down
30 changes: 20 additions & 10 deletions htdocs/compta/bank/various_payment/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@

$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) {
Expand Down Expand Up @@ -586,7 +586,7 @@ function setPaymentType()
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);
Expand Down Expand Up @@ -638,15 +638,25 @@ function setPaymentType()
// Account of Chart of account
$editvalue = '';
if (isModEnabled('accounting')) {
$editvalue = $formaccounting->select_account($object->accountancy_code, 'accountancy_code', 1, null, 1, 1);
}
print '<tr><td class="nowrap">';
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
print '</td><td>';
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 '</td></tr>';
print '<tr><td class="nowrap">';
print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
print '</td><td>';
print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'asis', $editvalue, 0, null, '', 1, 'lengthAccountg');
print '</td></tr>';
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">';
Expand Down
10 changes: 7 additions & 3 deletions htdocs/compta/bank/various_payment/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,13 @@

// Accounting account
if (!empty($arrayfields['account']['checked'])) {
$accountingaccount->fetch('', $obj->accountancy_code, 1);

print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->accountancy_code.' '.$accountingaccount->label).'">'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).'</td>';
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']++;
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5008,10 +5008,10 @@ public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateS
//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
}
}
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/customreports.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion htdocs/core/lib/security.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";
Expand Down
45 changes: 29 additions & 16 deletions htdocs/core/lib/signature.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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 = '';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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;
Expand Down

0 comments on commit 40f1058

Please sign in to comment.