Merge branch 'develop' into fix-warnings-contrat-and-contratligne

This commit is contained in:
Laurent Destailleur 2023-10-02 18:19:53 +02:00 committed by GitHub
commit 59fc407e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 37 deletions

View file

@ -1080,7 +1080,7 @@ if ($resql) {
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
// When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
if ($action == 'reconcile') {
$arrayfields['b.num_releve']['checked'] = 1;
@ -1089,8 +1089,14 @@ if ($resql) {
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">';
// Actions and select
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre valignmiddle center">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
}
if (!empty($arrayfields['b.rowid']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
@ -1168,14 +1174,20 @@ if ($resql) {
}
// Actions and select
print '<td class="liste_titre" align="middle">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre valignmiddle center">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
}
print "</tr>\n";
// Fields title
print '<tr class="liste_titre">';
// Actions and select
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
}
if (!empty($arrayfields['b.rowid']['checked'])) {
print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder);
}
@ -1186,10 +1198,10 @@ if ($resql) {
print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center ");
}
if (!empty($arrayfields['b.datev']['checked'])) {
print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['type']['checked'])) {
print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['b.num_chq']['checked'])) {
print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center ");
@ -1229,7 +1241,9 @@ if ($resql) {
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Actions and select
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ');
}
print "</tr>\n";
$balance = 0; // For balance
@ -1317,6 +1331,10 @@ if ($resql) {
}
print '<tr class="oddeven trforbreak">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td></td>';
}
if ($tmpnbfieldbeforebalance) {
print '<td colspan="'.$tmpnbfieldbeforebalance.'">';
print '&nbsp;';
@ -1347,9 +1365,13 @@ if ($resql) {
</script>';
print '</td>';
}
print '<td colspan="'.($tmpnbfieldafterbalance + 1).'">';
print '<td colspan="'.($tmpnbfieldafterbalance).'">';
print '&nbsp;';
print '</td>';
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td></td>';
}
print '</tr>';
}
}
@ -1388,6 +1410,21 @@ if ($resql) {
print '<tr class="oddeven" '.$backgroundcolor.'>';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Ref
if (!empty($arrayfields['b.rowid']['checked'])) {
print '<td class="nowrap left">';
@ -1780,16 +1817,18 @@ if ($resql) {
}
// Action column
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n";

View file

@ -2175,10 +2175,11 @@ class AccountLine extends CommonObjectLine
/**
* Delete bank transaction record
*
* @param User|null $user User object that delete
* @return int <0 if KO, >0 if OK
* @param User|null $user User object that delete
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
public function delete(User $user = null)
public function delete(User $user = null, $notrigger = 0)
{
global $conf;
@ -2192,6 +2193,16 @@ class AccountLine extends CommonObjectLine
$this->db->begin();
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('BANKACCOUNTLINE_DELETE', $user);
if ($result < 0) {
$this->db->rollback();
return -1;
}
// End call triggers
}
// Protection to avoid any delete of accounted lines. Protection on by default
if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) {
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".((int) $this->id);

View file

@ -57,7 +57,7 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') {
if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) && $action == 'dvnext') {
// Increase date
$al = new AccountLine($db);
$al->datev_next(GETPOST('rowid', 'int'));
@ -68,7 +68,7 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') {
if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) && $action == 'dvprev') {
// Decrease date
$al = new AccountLine($db);
$al->datev_previous(GETPOST('rowid', 'int'));
@ -79,18 +79,18 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') {
if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) && $action == 'donext') {
// Increase date
$al = new AccountLine($db);
$al->dateo_next(GETPOST('rowid', 'int'));
$al->fetch(GETPOST('rowid', 'int'));
var_dump($al);
print '<span class="spanforajaxedit" id="dateoperation_'.$al->id.'">'.dol_print_date($al->dateo, "day").'</span>';
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') {
if (($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) && $action == 'doprev') {
// Decrease date
$al = new AccountLine($db);
$al->dateo_previous(GETPOST('rowid', 'int'));

View file

@ -9965,11 +9965,11 @@ class Form
{
$out = '<div class="nowraponall">';
if ($pos == 'left') {
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
} else {
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
$out .= '<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
$out .= '<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
}
$out .= '</div>';

View file

@ -754,15 +754,14 @@ class Notify
continue;
}
$sendto = $val;
$threshold = (float) $reg[1];
if (!empty($object->total_ht) && $object->total_ht <= $threshold) {
dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
continue;
}
$param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
$sendto = $conf->global->$param;
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
if ($notifcodedefid <= 0) {
dol_print_error($this->db, 'Failed to get id from code');
@ -973,7 +972,7 @@ class Notify
if ($mailfile->sendfile()) {
$sql = "INSERT INTO ".$this->db->prefix()."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", null, 'email', 'tofixedemail', '".$this->db->escape($object_type)."', ".((int) $object->id).", '".$this->db->escape($conf->global->$param)."')";
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".((int) $notifcodedefid).", ".($object->socid > 0 ? ((int) $object->socid) : 'null').", null, 'email', 'tofixedemail', '".$this->db->escape($object_type)."', ".((int) $object->id).", '".$this->db->escape($sendto)."')";
if (!$this->db->query($sql)) {
dol_print_error($this->db);
}

View file

@ -9999,6 +9999,11 @@ function printCommonFooter($zone = 'private')
// Add 'field required' class on closest td for all input elements : input, textarea and select
print 'jQuery(":input[name=\'' . $paramkey . '\']").closest("tr").find("td:first").addClass("fieldrequired");' . "\n";
}
// If we submit the cancel button we remove the required attributes
print 'jQuery("input[name=\'cancel\']").click(function() {
console.log("We click on cancel button so removed all required attribute");
jQuery("input, textarea, select").each(function(){this.removeAttribute(\'required\');});
});'."\n";
}
}
}

View file

@ -195,7 +195,8 @@ function dolDecrypt($chain, $key = '')
$ciphering = $reg[1];
if (function_exists('openssl_decrypt')) {
if (empty($key)) {
return 'Error dolDecrypt decrypt key is empty';
dol_syslog("Error dolDecrypt decrypt key is empty", LOG_ERR);
return $chain;
}
$tmpexplode = explode(':', $reg[2]);
if (!empty($tmpexplode[1]) && is_string($tmpexplode[0])) {
@ -204,7 +205,8 @@ function dolDecrypt($chain, $key = '')
$newchain = openssl_decrypt($tmpexplode[0], $ciphering, $key, 0, null);
}
} else {
$newchain = 'Error dolDecrypt function openssl_decrypt() not available';
dol_syslog("Error dolDecrypt openssl_decrypt is not available", LOG_ERR);
return $chain;
}
return $newchain;
} else {