diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7894351c01f..40aaf476f72 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -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 diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 3a57ce7a3d4..8904d2573ed 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -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); diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 5bb3710c7b5..d9b7df8153f 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -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 '
'; + print ''; + print ''; + print ''; +} +if ($socid && $action == 'create' && $user->rights->societe->creer) +{ + print ''; + print ''; + print ''; +} -/* ************************************************************************** */ -/* */ -/* 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 ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; // Show fields of bank account @@ -361,6 +374,7 @@ if ($socid && $action != 'edit' && $action != "create") if (! empty($conf->prelevement->enabled)) { print ''; + print ''; } print_liste_field_titre($langs->trans("DefaultRIB"), '', '', '', '', 'align="center"'); print ''; @@ -383,6 +397,8 @@ if ($socid && $action != 'edit' && $action != "create") if (! empty($conf->prelevement->enabled)) { print ''; + + print ''; } // Default @@ -410,16 +426,14 @@ if ($socid && $action != 'edit' && $action != "create") print img_picto($langs->trans("Delete"),'delete'); print ''; } - - print ''; - print ''; - $var = !$var; + print ''; + print ''; } - + if (count($rib_list) == 0) { $colspan=7; - if (! empty($conf->prelevement->enabled)) $colspan++; + if (! empty($conf->prelevement->enabled)) $colspan+=2; print ''; } @@ -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 ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("LabelRIB").''.$account->label.'
'.$langs->trans("BankName").'
'.$langs->trans("BankName").''.$account->bank.'
RUM'.$langs->trans("WithdrawMode").''.$prelevement->buildRumNumber($soc->code_client, $rib->datec, $rib->id).''.$rib->frstrecur.'
'.$langs->trans("NoBANRecord").'
'; + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); + + print '
'; print ''; print ''; @@ -533,30 +541,39 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) print $account->owner_address; print ""; - print '
'.$langs->trans("LabelRIB").'

'; + print ''; - print '
'; + if ($conf->prelevement->enabled) + { + print '
'; + + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print '
'.$langs->trans("RUM").''.$account->rum.'
'.$langs->trans("WithdrawMode").'
'; + } + + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; print '
'; - - print ''; } -/* ************************************************************************** */ -/* */ -/* Création */ -/* */ -/* ************************************************************************** */ - +// Create if ($socid && $action == 'create' && $user->rights->societe->creer) { - print '
'; - print ''; - print ''; - print ''; + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); + + print '
'; print ''; @@ -615,19 +632,41 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print GETPOST('owner_address'); print ""; - print '
'.$langs->trans("LabelRIB").'

'; + print ''; + + if ($conf->prelevement->enabled) + { + print '
'; + + print ''; - print '
'; + print '
'; + print ''; + + print ''; + print ''; + + print '
'.$langs->trans("RUM").''.$langs->trans("RUMWillBeGenerated").'
'.$langs->trans("WithdrawMode").'
'; + } + + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; print '
'; - - print '
'; } +if ($socid && $action == 'edit' && $user->rights->societe->creer) +{ + print ''; +} +if ($socid && $action == 'create' && $user->rights->societe->creer) +{ + print ''; +} -dol_fiche_end(); if ($socid && $action != 'edit' && $action != 'create')