Fix creation/edit rum number
This commit is contained in:
parent
918738ce46
commit
8674867db2
@ -70,7 +70,7 @@ class CompanyBankAccount extends Account
|
|||||||
function create(User $user = null, $notrigger=0)
|
function create(User $user = null, $notrigger=0)
|
||||||
{
|
{
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
// Correct default_rib to be sure to have always one default
|
// 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";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -90,28 +90,26 @@ class CompanyBankAccount extends Account
|
|||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
|
$result=$this->call_trigger('COMPANY_RIB_CREATE',$user);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
if(! $error )
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -133,13 +131,9 @@ class CompanyBankAccount extends Account
|
|||||||
global $conf;
|
global $conf;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
if (! $this->id) return -1;
|
||||||
|
|
||||||
if (! $this->id)
|
if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
|
||||||
{
|
|
||||||
$this->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
|
|
||||||
if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
||||||
|
|||||||
@ -207,6 +207,8 @@ if (empty($reshook))
|
|||||||
$account->rum = GETPOST('rum','alpha');
|
$account->rum = GETPOST('rum','alpha');
|
||||||
$account->datec = dol_now();
|
$account->datec = dol_now();
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
// This test can be done only once properties were set
|
// This test can be done only once properties were set
|
||||||
if ($account->needIBAN() == 1)
|
if ($account->needIBAN() == 1)
|
||||||
{
|
{
|
||||||
@ -226,26 +228,44 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if (empty($account->rum))
|
$result = $account->create($user);
|
||||||
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id);
|
$error++;
|
||||||
$account->date_rum = dol_now();
|
setEventMessages($account->error, $account->errors, 'errors');
|
||||||
|
$action='create'; // Force chargement page création
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($account->rum))
|
||||||
|
{
|
||||||
|
$account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id);
|
||||||
|
$account->date_rum = dol_now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$result = $account->update($user); // This will set the UMR number.
|
$result = $account->update($user); // This will set the UMR number.
|
||||||
// TODO Use create and include update into create method
|
if ($result < 0)
|
||||||
if (! $result)
|
{
|
||||||
{
|
$error++;
|
||||||
setEventMessages($account->error, $account->errors, 'errors');
|
setEventMessages($account->error, $account->errors, 'errors');
|
||||||
$_GET["action"]='create'; // Force chargement page création
|
$action='create';
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
|
||||||
header('Location: '.$url);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
|
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
||||||
|
header('Location: '.$url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,11 +341,14 @@ $formfile = new FormFile($db);
|
|||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$head=societe_prepare_head($object);
|
$head=societe_prepare_head($object);
|
||||||
|
|
||||||
if (! $id)
|
if (! $id)
|
||||||
$account->fetch(0,$object->id);
|
{
|
||||||
|
$account->fetch(0,$object->id);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$account->fetch($id);
|
$account->fetch($id);
|
||||||
|
}
|
||||||
if (empty($account->socid)) $account->socid=$object->id;
|
if (empty($account->socid)) $account->socid=$object->id;
|
||||||
|
|
||||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||||
@ -775,7 +798,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
|
|
||||||
// RUM
|
// RUM
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
|
print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
|
||||||
print '<td><input size="30" type="text" name="rum" value="'.dol_escape_htmltag($account->rum).'"></td></tr>';
|
print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($account->rum).'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
||||||
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
||||||
@ -872,7 +895,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
|||||||
|
|
||||||
// RUM
|
// RUM
|
||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
|
||||||
print '<td colspan="4"><input size="30" type="text" name="rum" value="'.dol_escape_htmltag($account->rum).'"><br>'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
|
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"><br>'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
||||||
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user