diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 0b4307f8a98c8a3afd03763494d70ee34cc226b0..c84e7f474826fb93f31ab7ae5b022b3db0325ce9 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $langs->load("banks"); +$langs->load("bills"); $langs->load("categories"); $langs->load("companies"); $langs->load("compta"); @@ -70,7 +71,7 @@ if ($_POST["action"] == 'add') $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; $account->url = $_POST["url"]; - + $account->bank = trim($_POST["bank"]); $account->code_banque = trim($_POST["code_banque"]); $account->code_guichet = trim($_POST["code_guichet"]); @@ -94,8 +95,8 @@ if ($_POST["action"] == 'add') $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; - $account->min_allowed = $_POST["account_min_allowed"]; - $account->min_desired = $_POST["account_min_desired"]; + $account->min_allowed = GETPOST("account_min_allowed",'int'); + $account->min_desired = GETPOST("account_min_desired",'int'); $account->comment = trim($_POST["account_comment"]); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) @@ -169,8 +170,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; - $account->min_allowed = $_POST["account_min_allowed"]; - $account->min_desired = $_POST["account_min_desired"]; + $account->min_allowed = GETPOST("account_min_allowed",'int'); + $account->min_desired = GETPOST("account_min_desired",'int'); $account->comment = trim($_POST["account_comment"]); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) @@ -251,9 +252,6 @@ if ($action == 'create') document.formsoc.action.value="create"; document.formsoc.submit(); }); - })'."\n"; - - print 'jQuery(document).ready(function () { jQuery("#selectaccount_country_id").change(function() { document.formsoc.action.value="create"; document.formsoc.submit(); @@ -275,7 +273,7 @@ if ($action == 'create') // Label print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>'; - print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.$_POST["label"].'"></td></tr>'; + print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.GETPOST("label").'"></td></tr>'; // Type print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountType").'</td>'; @@ -299,15 +297,17 @@ if ($action == 'create') print $form->selectarray("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print '</td></tr>'; - // Country - print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>'; - print '<td colspan="3">'; + // Country $selectedcode=''; if (isset($_POST["account_country_id"])) { $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$account->country_code; } else if (empty($selectedcode)) $selectedcode=$mysoc->country_code; + $account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + + print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>'; + print '<td colspan="3">'; print $form->select_country($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '</td></tr>'; @@ -333,10 +333,10 @@ if ($action == 'create') print '<td colspan="3">'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment',$account->comment,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70); + $doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70); $doleditor->Create(); print '</td></tr>'; - + // Other attributes $parameters=array('colspan' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$account,$action); // Note that $action and $object may have been modified by hook @@ -353,7 +353,7 @@ if ($action == 'create') // Sold print '<tr><td valign="top" width="25%">'.$langs->trans("InitialBankBalance").'</td>'; - print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.($_POST["solde"]?$_POST["solde"]:price2num($account->solde)).'"></td></tr>'; + print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($account->solde)).'"></td></tr>'; print '<tr><td valign="top">'.$langs->trans("Date").'</td>'; print '<td colspan="3">'; @@ -445,10 +445,10 @@ if ($action == 'create') if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; // IBAN - print '<tr><td valign="top">'.$langs->trans($ibankey).'</td>'; + print '<tr><td>'.$langs->trans($ibankey).'</td>'; print '<td colspan="3"><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.$account->iban.'"></td></tr>'; - print '<tr><td valign="top">'.$langs->trans($bickey).'</td>'; + print '<tr><td>'.$langs->trans($bickey).'</td>'; print '<td colspan="3"><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>'; print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">'; @@ -468,25 +468,25 @@ if ($action == 'create') print '</table>'; print '<br>'; } - + print '<table class="border" width="100%">'; // Accountancy code if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) { print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("AccountancyCode").'</td>'; - print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>'; + print '<td colspan="3"><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number'):$account->account_number).'"></td></tr>'; } else { print '<tr><td valign="top" width="25%">'.$langs->trans("AccountancyCode").'</td>'; - print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>'; + print '<td colspan="3"><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number'):$account->account_number).'"></td></tr>'; } // Accountancy journal if (! empty($conf->accounting->enabled)) { print '<tr><td valign="top">'.$langs->trans("AccountancyJournal").'</td>'; - print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.$account->accountancy_journal.'"></td></tr>'; + print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.(GETPOST("accountancy_journal")?GETPOST('accountancy_journal'):$account->accountancy_journal).'"></td></tr>'; } print '</table>'; @@ -599,7 +599,7 @@ else print "</td></tr>\n"; print '<tr><td valign="top">'.$langs->trans("Comment").'</td>'; - print '<td colspan="3">'.$account->comment.'</td></tr>'; + print '<td colspan="3">'.dol_htmlentitiesbr($account->comment).'</td></tr>'; // Other attributes $parameters=array('colspan' => 3); @@ -612,11 +612,11 @@ else print '</table>'; print '<br>'; - + if ($account->type == 0 || $account->type == 1) { print '<table class="border" width="100%">'; - + print '<tr><td valign="top" width="25%">'.$langs->trans("BankName").'</td>'; print '<td colspan="3">'.$account->bank.'</td></tr>'; @@ -783,7 +783,7 @@ else document.formsoc.submit(); }); })'."\n"; - + print 'jQuery(document).ready(function () { jQuery("#selectaccount_country_id").change(function() { document.formsoc.action.value="edit"; @@ -834,11 +834,13 @@ else // Country $account->country_id=$account->country_id?$account->country_id:$mysoc->country_id; - print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Country").'</td>'; - print '<td colspan="3">'; $selectedcode=$account->country_code; if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; else if (empty($selectedcode)) $selectedcode=$mysoc->country_code; + $account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + + print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Country").'</td>'; + print '<td colspan="3">'; print $form->select_country($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '</td></tr>'; @@ -881,7 +883,7 @@ else print '<td colspan="3">'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('account_comment',(isset($_POST["account_comment"])?$_POST["account_comment"]:$account->comment),'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,70); + $doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$account->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,4,70); $doleditor->Create(); print '</td></tr>'; @@ -898,7 +900,7 @@ else if ($_POST["type"] == 0 || $_POST["type"] == 1) { print '<table class="border" width="100%">'; - + // If bank account print '<tr><td valign="top" width="25%">'.$langs->trans("BankName").'</td>'; print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td>'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 98ef24e177d496296c5e47bf39f7e7f1c1d00a2c..cfbda320fb76f7ea3da4476a86574b577625e2e7 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -468,7 +468,7 @@ class Account extends CommonObject $this->error=$this->db->lasterror(); return -3; } - + // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); $parameters=array('id'=>$this->id); @@ -513,8 +513,6 @@ class Account extends CommonObject global $langs,$conf, $hookmanager; // Clean parameters - if (! $this->min_allowed) $this->min_allowed=0; - if (! $this->min_desired) $this->min_desired=0; $this->state_id = ($this->state_id?$this->state_id:$this->state_id); $this->country_id = ($this->country_id?$this->country_id:$this->country_id); @@ -544,7 +542,7 @@ class Account extends CommonObject $sql.= ",url = ".($this->url?"'".$this->url."'":"null"); $sql.= ",account_number = '".$this->account_number."'"; $sql.= ",accountancy_journal = '".$this->accountancy_journal."'"; - + $sql.= ",bank = '".$this->db->escape($this->bank)."'"; $sql.= ",code_banque='".$this->code_banque."'"; $sql.= ",code_guichet='".$this->code_guichet."'"; @@ -558,8 +556,8 @@ class Account extends CommonObject $sql.= ",currency_code = '".$this->currency_code."'"; - $sql.= ",min_allowed = '".price2num($this->min_allowed)."'"; - $sql.= ",min_desired = '".price2num($this->min_desired)."'"; + $sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); + $sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); $sql.= ",comment = '".$this->db->escape($this->comment)."'"; $sql.= ",state_id = ".($this->state_id>0?"'".$this->state_id."'":"null"); @@ -572,7 +570,7 @@ class Account extends CommonObject $result = $this->db->query($sql); if ($result) { - + // Actions on extra fields (by external module or standard code) $hookmanager->initHooks(array('bankdao')); $parameters=array('id'=>$this->id); @@ -589,8 +587,8 @@ class Account extends CommonObject } } else if ($reshook < 0) return -1; - - + + return 1; } else @@ -736,15 +734,15 @@ class Account extends CommonObject $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; - + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); $this->fetch_optionals($this->id,$extralabels); - - + + return 1; } else @@ -776,7 +774,7 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - + // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { @@ -787,7 +785,7 @@ class Account extends CommonObject dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } - + return 1; } else { @@ -1076,7 +1074,7 @@ class Account extends CommonObject * * @return int 0=No bank code need + Account number is enough * 1=Need 2 fields for bank code: Bank, Desk (France, Spain, ...) + Account number and key - * 2=Neek 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number + * 2=Need 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number */ function useDetailedBBAN() {