Add field frstrecur to be managed by withdrawal module.
This commit is contained in:
parent
3678a12767
commit
d2843ceabb
@ -84,6 +84,9 @@ WithdrawalFile=Withdrawal file
|
||||
SetToStatusSent=Set to status "File Sent"
|
||||
ThisWillAlsoAddPaymentOnInvoice=This will also apply payments to invoices and will classify them as "Paid"
|
||||
StatisticsByLineStatus=Statistics by status of lines
|
||||
RUM=RUM
|
||||
RUMWillBeGenerated=RUM number will be generated once bank account information are saved
|
||||
WithdrawMode=Withdraw mode (FRST or RECUR)
|
||||
|
||||
### Notifications
|
||||
InfoCreditSubject=Payment of standing order %s by the bank
|
||||
|
||||
@ -48,6 +48,7 @@ class CompanyBankAccount extends Account
|
||||
var $proprio;
|
||||
var $owner_address;
|
||||
var $default_rib;
|
||||
var $frstrecur;
|
||||
|
||||
var $datec;
|
||||
var $datem;
|
||||
@ -117,44 +118,34 @@ class CompanyBankAccount extends Account
|
||||
*/
|
||||
function update($user='')
|
||||
{
|
||||
// $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
// $sql .= " WHERE rowid = ".$this->id;
|
||||
//
|
||||
// $result = $this->db->query($sql);
|
||||
// if ($result)
|
||||
// {
|
||||
// if ($this->db->num_rows($result) == 0)
|
||||
// {
|
||||
// $this->create();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dol_print_error($this->db);
|
||||
// return 0;
|
||||
// }
|
||||
global $conf;
|
||||
|
||||
if (! $this->id) {
|
||||
if (! $this->id)
|
||||
{
|
||||
$this->create();
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET ";
|
||||
$sql .= " bank = '" .$this->db->escape($this->bank)."'";
|
||||
$sql .= ",code_banque='".$this->code_banque."'";
|
||||
$sql .= ",code_guichet='".$this->code_guichet."'";
|
||||
$sql .= ",number='".$this->number."'";
|
||||
$sql .= ",cle_rib='".$this->cle_rib."'";
|
||||
$sql .= ",bic='".$this->bic."'";
|
||||
$sql .= ",iban_prefix = '".$this->iban."'";
|
||||
$sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
|
||||
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
|
||||
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
|
||||
$sql .= ",default_rib = ".$this->default_rib;
|
||||
if (trim($this->label) != '')
|
||||
$sql .= ",label = '".$this->db->escape($this->label)."'";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
|
||||
$sql.= " bank = '" .$this->db->escape($this->bank)."'";
|
||||
$sql.= ",code_banque='".$this->code_banque."'";
|
||||
$sql.= ",code_guichet='".$this->code_guichet."'";
|
||||
$sql.= ",number='".$this->number."'";
|
||||
$sql.= ",cle_rib='".$this->cle_rib."'";
|
||||
$sql.= ",bic='".$this->bic."'";
|
||||
$sql.= ",iban_prefix = '".$this->iban."'";
|
||||
$sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
|
||||
$sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
|
||||
$sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
|
||||
$sql.= ",default_rib = ".$this->default_rib;
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
$sql.= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
|
||||
}
|
||||
if (trim($this->label) != '')
|
||||
$sql.= ",label = '".$this->db->escape($this->label)."'";
|
||||
else
|
||||
$sql .= ",label = NULL";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
$sql.= ",label = NULL";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -179,7 +170,8 @@ class CompanyBankAccount extends Account
|
||||
{
|
||||
if (empty($id) && empty($socid)) return -1;
|
||||
|
||||
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, owner_address, default_rib, label, datec, tms as datem";
|
||||
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
||||
$sql.= " owner_address, default_rib, label, datec, tms as datem, frstrecur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
if ($id) $sql.= " WHERE rowid = ".$id;
|
||||
if ($socid) $sql.= " WHERE fk_soc = ".$socid." AND default_rib = 1";
|
||||
@ -207,6 +199,7 @@ class CompanyBankAccount extends Account
|
||||
$this->default_rib = $obj->default_rib;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->datem);
|
||||
$this->frstrecur = $obj->frstrecur;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
|
||||
@ -77,6 +77,7 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->owner_address = $_POST["owner_address"];
|
||||
$account->frstrecur = GETPOST('frstrecur');
|
||||
|
||||
$result = $account->update($user);
|
||||
if (! $result)
|
||||
@ -135,11 +136,12 @@ if ($action == 'add' && ! $_POST["cancel"])
|
||||
$account->domiciliation = $_POST["domiciliation"];
|
||||
$account->proprio = $_POST["proprio"];
|
||||
$account->owner_address = $_POST["owner_address"];
|
||||
|
||||
$account->frstrecur = GETPOST('frstrecur');
|
||||
|
||||
$result = $account->update($user); // TODO Use create and include update into create method
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessage($account->error, 'errors');
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$_GET["action"]='create'; // Force chargement page création
|
||||
}
|
||||
else
|
||||
@ -155,7 +157,8 @@ if ($action == 'setasdefault')
|
||||
{
|
||||
$account = new CompanyBankAccount($db);
|
||||
$res = $account->setAsDefault(GETPOST('ribid','int'));
|
||||
if ($res) {
|
||||
if ($res)
|
||||
{
|
||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id;
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
@ -199,7 +202,6 @@ llxHeader();
|
||||
|
||||
$head=societe_prepare_head2($soc);
|
||||
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
$account = new CompanyBankAccount($db);
|
||||
if (! $id)
|
||||
@ -209,16 +211,27 @@ else
|
||||
if (empty($account->socid)) $account->socid=$soc->id;
|
||||
|
||||
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
}
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Visu et edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
// View
|
||||
if ($socid && $action != 'edit' && $action != "create")
|
||||
{
|
||||
// Confirm delete third party
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
// Confirm delete third party
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$soc->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1);
|
||||
@ -228,10 +241,10 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("LabelRIB").'</td>';
|
||||
print '<tr><td width="35%">'.$langs->trans("LabelRIB").'</td>';
|
||||
print '<td colspan="4">'.$account->label.'</td></tr>';
|
||||
|
||||
print '<tr><td valign="top" width="35%">'.$langs->trans("BankName").'</td>';
|
||||
print '<tr><td valign="top">'.$langs->trans("BankName").'</td>';
|
||||
print '<td colspan="4">'.$account->bank.'</td></tr>';
|
||||
|
||||
// Show fields of bank account
|
||||
@ -361,6 +374,7 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
if (! empty($conf->prelevement->enabled))
|
||||
{
|
||||
print '<td>RUM</td>';
|
||||
print '<td>'.$langs->trans("WithdrawMode").'</td>';
|
||||
}
|
||||
print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"');
|
||||
print '<td width="40"></td>';
|
||||
@ -383,6 +397,8 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
if (! empty($conf->prelevement->enabled))
|
||||
{
|
||||
print '<td>'.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).'</td>';
|
||||
|
||||
print '<td>'.$rib->frstrecur.'</td>';
|
||||
}
|
||||
|
||||
// Default
|
||||
@ -410,16 +426,14 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
print img_picto($langs->trans("Delete"),'delete');
|
||||
print '</a>';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$var = !$var;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
if (count($rib_list) == 0)
|
||||
{
|
||||
$colspan=7;
|
||||
if (! empty($conf->prelevement->enabled)) $colspan++;
|
||||
if (! empty($conf->prelevement->enabled)) $colspan+=2;
|
||||
print '<tr '.$bc[0].'><td colspan="'.$colspan.'" align="center">'.$langs->trans("NoBANRecord").'</td></tr>';
|
||||
}
|
||||
|
||||
@ -427,22 +441,16 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Edition */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
// Edit
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td valign="top" width="35%" class="fieldrequired">'.$langs->trans("LabelRIB").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
|
||||
@ -533,30 +541,39 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
print $account->owner_address;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '</table><br>';
|
||||
print '</table>';
|
||||
|
||||
print '<div align="center">';
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="35%">'.$langs->trans("RUM").'</td>';
|
||||
print '<td colspan="4">'.$account->rum.'</td></tr>';
|
||||
|
||||
print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur).'"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div align="center">';
|
||||
print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' ';
|
||||
print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Création */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
// Create
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" width="100%">';
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
|
||||
print '<tr><td valign="top" width="35%" class="fieldrequired">'.$langs->trans("LabelRIB").'</td>';
|
||||
@ -615,19 +632,41 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
print GETPOST('owner_address');
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '</table><br>';
|
||||
print '</table>';
|
||||
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<div align="center">';
|
||||
print '<tr><td width="35%">'.$langs->trans("RUM").'</td>';
|
||||
print '<td colspan="4">'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
|
||||
|
||||
print '<tr><td width="35%">'.$langs->trans("WithdrawMode").'</td>';
|
||||
print '<td colspan="4"><input size="30" type="text" name="frstrecur" value="'.(isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST').'"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div align="center">';
|
||||
print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
|
||||
print ' ';
|
||||
print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
print '</form>';
|
||||
}
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
if ($socid && $action != 'edit' && $action != 'create')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user