Fix set of date of rum signature

This commit is contained in:
Laurent Destailleur 2021-08-02 18:13:35 +02:00
parent 8077fae42e
commit efda27000e
2 changed files with 12 additions and 11 deletions

View File

@ -83,7 +83,7 @@ class CompanyBankAccount extends Account
$now = dol_now();
$error = 0;
// Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".((int) $this->socid)." AND default_rib = 1 AND type = 'ban'";
$result = $this->db->query($sql);
if ($result) {
$numrows = $this->db->num_rows($result);
@ -96,7 +96,7 @@ class CompanyBankAccount extends Account
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$sql .= " VALUES (".((int) $this->socid).", 'ban', '".$this->db->idate($now)."')";
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->affected_rows($resql)) {
@ -135,6 +135,7 @@ class CompanyBankAccount extends Account
public function update(User $user = null, $notrigger = 0)
{
global $conf;
$error = 0;
if (!$this->id) {
@ -160,7 +161,7 @@ class CompanyBankAccount extends Account
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql .= ",default_rib = ".((int) $this->default_rib);
if ($conf->prelevement->enabled) {
if (!empty($conf->prelevement->enabled)) {
$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
$sql .= ",rum = '".$this->db->escape($this->rum)."'";
$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");

View File

@ -161,9 +161,6 @@ if (empty($reshook)) {
if (empty($companybankaccount->rum)) {
$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
}
if (empty($companybankaccount->date_rum)) {
$companybankaccount->date_rum = dol_now();
}
$result = $companybankaccount->update($user);
if (!$result) {
@ -268,9 +265,9 @@ if (empty($reshook)) {
$companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha');
$companybankaccount->proprio = GETPOST('proprio', 'alpha');
$companybankaccount->owner_address = GETPOST('owner_address', 'alpha');
$companybankaccount->frstrecur = GETPOST('frstrecur');
$companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha');
$companybankaccount->rum = GETPOST('rum', 'alpha');
$companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
$companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth', 'int'), GETPOST('date_rumday', 'int'), GETPOST('date_rumyear', 'int'));
$companybankaccount->datec = dol_now();
$companybankaccount->status = 1;
@ -300,7 +297,6 @@ if (empty($reshook)) {
if (empty($companybankaccount->rum)) {
$companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
$companybankaccount->date_rum = dol_now();
}
}
@ -1638,8 +1634,10 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) {
print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>';
$date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
print '<tr><td class="titlefield">'.$langs->trans("DateRUM").'</td>';
print '<td>'.$form->selectDate(GETPOST('date_rum') ?GETPOST('date_rum') : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'</td></tr>';
print '<td>'.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'</td></tr>';
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
@ -1800,8 +1798,10 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) {
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum', 'alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>';
$date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear'));
print '<tr><td class="titlefieldcreate">'.$langs->trans("DateRUM").'</td>';
print '<td colspan="4">'.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0, 0, 1, 'date_rum').'</td></tr>';
print '<td colspan="4">'.$form->selectDate($date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'</td></tr>';
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));