diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f072a066ec0ce3b09f13a74a519472a0aad755e9..d8f65c0830237d0d1db11c15cdb3b6284bd19ed2 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -258,6 +258,10 @@ class Account extends CommonObject $string .= $this->code_guichet.' '; } elseif ($val == 'BankAccountNumberKey') { $string .= $this->cle_rib.' '; + }elseif ($val == 'BIC') { + $string .= $this->bic.' '; + }elseif ($val == 'IBAN') { + $string .= $this->iban.' '; } } @@ -1151,9 +1155,9 @@ class Account extends CommonObject if ($user->societe_id) { return 0; } - + $nb=0; - + $sql = "SELECT COUNT(ba.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; @@ -1169,7 +1173,7 @@ class Account extends CommonObject return $nb; } - + /** * Return clicable name (with picto eventually) * @@ -1204,7 +1208,7 @@ class Account extends CommonObject $link = '<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$this->id.$linkclose; $linkend='</a>'; } - + if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' '); $result.=$link.$this->label.$linkend; return $result; @@ -1324,12 +1328,16 @@ class Account extends CommonObject if ($detailedBBAN == 0) { return array( - 'BankAccountNumber' + 'IBAN', + 'BIC', + 'BankAccountNumber' ); } elseif ($detailedBBAN == 2) { return array( - 'BankCode', - 'BankAccountNumber' + 'IBAN', + 'BIC', + 'BankCode', + 'BankAccountNumber' ); } @@ -1352,16 +1360,20 @@ class Account extends CommonObject global $conf; $fieldlists = array( - 'BankCode', - 'DeskCode', - 'BankAccountNumber', - 'BankAccountNumberKey' + 'IBAN', + 'BIC', + 'BankCode', + 'DeskCode', + 'BankAccountNumber', + 'BankAccountNumberKey' ); if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) { if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) { if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') { $fieldlists = array( + 'IBAN', + 'BIC', 'BankCode', 'DeskCode', 'BankAccountNumberKey', diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 45e9ff1df5d4eb808ca2d13a67848a56f93990e3..d299d11798aa0d26fc717f1b90a06c2781db6e1e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -292,7 +292,7 @@ function pdf_getHeightForLogo($logo, $url = false) /** * Function to try to calculate height of a HTML Content - * + * * @param TCPDF $pdf PDF initialized object * @param string $htmlcontent HTML Contect * @see getStringHeight @@ -315,7 +315,7 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) if ($end_page == $start_page) { $height = $end_y - $start_y; } - else + else { for ($page=$start_page; $page <= $end_page; ++$page) { $pdf->setPage($page); @@ -331,7 +331,7 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) } } // restore previous object - $pdf = $pdf->rollbackTransaction(); + $pdf = $pdf->rollbackTransaction(); return $height; } @@ -404,9 +404,9 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target { $withCountry = 0; if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; - + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; - + if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) { // Phone @@ -419,13 +419,13 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); } } - + if ($mode == 'target' || preg_match('/targetwithdetails/',$mode)) { if ($usecontact) { $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs,1)); - + if (!empty($targetcontact->address)) { $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcontact))."\n"; }else { @@ -438,7 +438,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; } - + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) { // Phone @@ -471,7 +471,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany))."\n"; // Country if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code))."\n"; - + if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) { // Phone @@ -499,13 +499,13 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target } } } - + // Intra VAT if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) { if ($targetcompany->tva_intra) $stringaddress.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); } - + // Professionnal Ids if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) { @@ -543,7 +543,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; $stringaddress.="\n".$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); } - + // Public note if (! empty($conf->global->MAIN_PUBLIC_NOTE_IN_ADDRESS)) { @@ -558,7 +558,7 @@ function pdf_build_address($outputlangs,$sourcecompany,$targetcompany='',$target } } } - + return $stringaddress; } @@ -641,7 +641,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default global $mysoc, $conf; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; - + $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); $diffsizecontent=(empty($conf->global->PDF_DIFFSIZE_CONTENT)?4:$conf->global->PDF_DIFFSIZE_CONTENT); $pdf->SetXY($curx, $cury); @@ -683,7 +683,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default // number = account number // key = check control key used only when $usedetailedbban = 1 if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); - + foreach ($account->getFieldsToShow() as $val) { @@ -706,8 +706,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default // Key $tmplength = 13; $content = $account->cle_rib; + }elseif ($val == 'IBAN' || $val == 'BIC') { + // Key + $tmplength = 0; + $content = ''; } else { - dol_print_error($this->db, 'Unexpected value for getFieldsToShow: '.$val); + dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val); break; } @@ -720,7 +724,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $pdf->line($curx, $cury + 1, $curx, $cury + 7); } } - + $curx=$savcurx; $cury+=8; } @@ -1054,7 +1058,7 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al { $reftoshow .= ' / '.$linkedobject["date_value"]; } - + $posy+=3; $pdf->SetXY($posx,$posy); $pdf->SetFont('','', $default_font_size - 2); @@ -1095,7 +1099,7 @@ function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hide $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); $action=''; $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1415,7 +1419,7 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1451,12 +1455,12 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) { - if (empty($hidedetails) || $hidedetails > 1) + if (empty($hidedetails) || $hidedetails > 1) { $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); $result.=price($sign * $subprice, 0, $outputlangs); @@ -1488,7 +1492,7 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1521,7 +1525,7 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; } if (empty($reshook)) @@ -1555,7 +1559,7 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1589,7 +1593,7 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1623,7 +1627,7 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1647,7 +1651,7 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = false) { global $langs; - + $reshook=0; $result=''; //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1665,7 +1669,7 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag ); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1702,7 +1706,7 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1735,7 +1739,7 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); $action = ''; $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; } if (empty($reshook)) @@ -1772,7 +1776,7 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1813,7 +1817,7 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); $action=''; $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - + if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; } if (empty($reshook)) @@ -1889,7 +1893,7 @@ function pdf_getLinkedObjects($object,$outputlangs) $linkedobjects=array(); $object->fetchObjectLinked(); - + foreach($object->linkedObjects as $objecttype => $objects) { if ($objecttype == 'facture') @@ -1949,7 +1953,7 @@ function pdf_getLinkedObjects($object,$outputlangs) if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); - //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; + //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); } else diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 9fa62dea587bf2acabf49a39bb6d60d978f55e6b..61629e63838b1824088b2d77a09ea8ebc1495a93 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -233,7 +233,7 @@ class CompanyBankAccount extends Account { $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) { if ($this->label && $displayriblabel) { $rib = $this->label." : "; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 69262715b31f4a83ae3156f341c35263dea387d7..4fca804638ebddd048ad9d35aff82add84fe3e7d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -357,7 +357,7 @@ class Societe extends CommonObject // Multicurrency var $fk_multicurrency; var $multicurrency_code; - + /** * To contains a clone of this when we need to save old properties of object * @var Societe @@ -406,14 +406,14 @@ class Societe extends CommonObject if (empty($this->client)) $this->client=0; if (empty($this->fournisseur)) $this->fournisseur=0; $this->import_key = trim($this->import_key); - + if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { $this->multicurrency_code = ''; $this->fk_multicurrency = 0; } - + dol_syslog(get_class($this)."::create ".$this->name); // Check parameters @@ -845,7 +845,7 @@ class Societe extends CommonObject $sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null"); $sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null"); $sql .= ",fk_shipping_method = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null"); - + $sql .= ",client = " . (! empty($this->client)?$this->client:0); $sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0); $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); @@ -1055,7 +1055,7 @@ class Societe extends CommonObject else if ($idprof4) $sql .= " WHERE s.idprof4 = '".$this->db->escape($idprof4)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof5) $sql .= " WHERE s.idprof5 = '".$this->db->escape($idprof5)."' AND s.entity IN (".getEntity($this->element, 1).")"; else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")"; - + $resql=$this->db->query($sql); dol_syslog(get_class($this)."::fetch ".$sql); if ($resql) @@ -1900,10 +1900,10 @@ class Societe extends CommonObject $link.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'"'; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label=$langs->trans("ShowCompany"); - $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $link.= ' title="'.dol_escape_htmltag($label, 1).'"'; $link.=' class="classfortooltip"'; @@ -2195,6 +2195,7 @@ class Societe extends CommonObject function display_rib($mode='label') { require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + $bac = new CompanyBankAccount($this->db); $bac->fetch(0,$this->id); @@ -2206,6 +2207,7 @@ class Societe extends CommonObject { if (empty($bac->rum)) { + require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php'; $prelevement = new BonPrelevement($this->db); $bac->fetch_thirdparty(); $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); @@ -3126,7 +3128,7 @@ class Societe extends CommonObject } else return false; } - + /** * Check if we must use revenue stamps feature or not according to country (country of $mysocin most cases). * @@ -3355,7 +3357,7 @@ class Societe extends CommonObject } - + /** * Create a document onto disk according to template module. * @@ -3390,8 +3392,8 @@ class Societe extends CommonObject return $result; } - - + + /** * Sets object to supplied categories. * diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 0d8cdcc1264612070f2ff107dbbf9cadd91705f0..d820058d83b2bad9c0994c246022202640407483 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -59,43 +59,70 @@ if ($action == 'update' && ! $_POST["cancel"]) // Modification $account = new CompanyBankAccount($db); - $account->fetch($id); - $account->socid = $object->id; - - $account->bank = $_POST["bank"]; - $account->label = $_POST["label"]; - $account->courant = $_POST["courant"]; - $account->clos = $_POST["clos"]; - $account->code_banque = $_POST["code_banque"]; - $account->code_guichet = $_POST["code_guichet"]; - $account->number = $_POST["number"]; - $account->cle_rib = $_POST["cle_rib"]; - $account->bic = $_POST["bic"]; - $account->iban = $_POST["iban"]; - $account->domiciliation = $_POST["domiciliation"]; - $account->proprio = $_POST["proprio"]; - $account->owner_address = $_POST["owner_address"]; - $account->frstrecur = GETPOST('frstrecur'); - - $result = $account->update($user); - if (! $result) + if (! GETPOST('label')) { - setEventMessages($account->error, $account->errors, 'errors'); - $_GET["action"]='edit'; // Force chargement page edition + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + $action='update'; + $error++; } - else + if (! GETPOST('bank')) { - // If this account is the default bank account, we disable others - if ($account->default_rib) + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='update'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='update'; + $error++; + } + + $account->fetch($id); + if (! $error) + { + $account->socid = $object->id; + + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); + $account->frstrecur = GETPOST('frstrecur','alpha'); + + $result = $account->update($user); + if (! $result) { - $account->setAsDefault($id); // This will make sure there is only one default rib + setEventMessages($account->error, $account->errors, 'errors'); } + else + { + // If this account is the default bank account, we disable others + if ($account->default_rib) + { + $account->setAsDefault($id); // This will make sure there is only one default rib + } - $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; - header('Location: '.$url); - exit; - } + $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; + header('Location: '.$url); + exit; + } + } } if ($action == 'add' && ! $_POST["cancel"]) @@ -114,6 +141,18 @@ if ($action == 'add' && ! $_POST["cancel"]) $action='create'; $error++; } + if (! GETPOST('iban')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); + $action='create'; + $error++; + } + if (! GETPOST('bic')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); + $action='create'; + $error++; + } if (! $error) { @@ -122,19 +161,19 @@ if ($action == 'add' && ! $_POST["cancel"]) $account->socid = $object->id; - $account->bank = $_POST["bank"]; - $account->label = $_POST["label"]; - $account->courant = $_POST["courant"]; - $account->clos = $_POST["clos"]; - $account->code_banque = $_POST["code_banque"]; - $account->code_guichet = $_POST["code_guichet"]; - $account->number = $_POST["number"]; - $account->cle_rib = $_POST["cle_rib"]; - $account->bic = $_POST["bic"]; - $account->iban = $_POST["iban"]; - $account->domiciliation = $_POST["domiciliation"]; - $account->proprio = $_POST["proprio"]; - $account->owner_address = $_POST["owner_address"]; + $account->bank = GETPOST('bank','alpha'); + $account->label = GETPOST('label','alpha'); + $account->courant = GETPOST('courant','alpha'); + $account->clos = GETPOST('clos','alpha'); + $account->code_banque = GETPOST('code_banque','alpha'); + $account->code_guichet = GETPOST('code_guichet','alpha'); + $account->number = GETPOST('number','alpha'); + $account->cle_rib = GETPOST('cle_rib','alpha'); + $account->bic = GETPOST('bic','alpha'); + $account->iban = GETPOST('iban','alpha'); + $account->domiciliation = GETPOST('domiciliation','alpha'); + $account->proprio = GETPOST('proprio','alpha'); + $account->owner_address = GETPOST('owner_address','alpha'); $account->frstrecur = GETPOST('frstrecur'); $result = $account->update($user); // TODO Use create and include update into create method @@ -161,8 +200,8 @@ if ($action == 'setasdefault') $url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id; header('Location: '.$url); exit; - } - else + } + else { setEventMessages($db->lasterror, null, 'errors'); } @@ -239,9 +278,9 @@ if ($socid && $action != 'edit' && $action != "create") } dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + print '<div class="fichecenter">'; - + print load_fiche_titre($langs->trans("DefaultRIB"), '', ''); print '<div class="underbanner clearboth"></div>'; @@ -265,35 +304,31 @@ if ($socid && $action != 'edit' && $action != "create") $content = $account->number; } elseif ($val == 'BankAccountNumberKey') { $content = $account->cle_rib; + }elseif ($val == 'IBAN') { + $content = $account->iban; + if (! empty($account->iban)) { + if (! checkIbanForAccount($account)) { + $content.= img_picto($langs->trans("IbanNotValid"),'warning'); + } else { + $content.= img_picto($langs->trans("IbanValid"),'info'); + } + } + }elseif ($val == 'BIC') { + $content = $account->bic; + if (! empty($account->bic)) { + if (! checkSwiftForAccount($account)) { + $content.= img_picto($langs->trans("SwiftNotValid"),'warning'); + } else { + $content.= img_picto($langs->trans("SwiftValid"),'info'); + } + } } print '<tr><td>'.$langs->trans($val).'</td>'; - print '<td colspan="3">'.$content.'</td>'; + print '<td colspan="4">'.$content.'</td>'; print '</tr>'; } - print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>'; - print '<td colspan="4">'.$account->iban . ' '; - if (! empty($account->iban)) { - if (! checkIbanForAccount($account)) { - print img_picto($langs->trans("IbanNotValid"),'warning'); - } else { - print img_picto($langs->trans("IbanValid"),'info'); - } - } - print '</td></tr>'; - - print '<tr><td valign="top">'.$langs->trans("BIC").'</td>'; - print '<td colspan="4">'.$account->bic.' '; - if (! empty($account->bic)) { - if (! checkSwiftForAccount($account)) { - print img_picto($langs->trans("SwiftNotValid"),'warning'); - } else { - print img_picto($langs->trans("SwiftValid"),'info'); - } - } - print '</td></tr>'; - print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">'; print $account->domiciliation; print "</td></tr>\n"; @@ -315,7 +350,7 @@ if ($socid && $action != 'edit' && $action != "create") } print "</div>"; - + dol_fiche_end(); @@ -418,9 +453,9 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + print '<div class="fichecenter">'; - + print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; @@ -432,6 +467,8 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Show fields of bank account foreach ($account->getFieldsToShow() as $val) { + + $require=false; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -448,20 +485,23 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) $name = 'cle_rib'; $size = 3; $content = $account->cle_rib; + } elseif ($val == 'IBAN') { + $name = 'iban'; + $size = 30; + $content = $account->iban; + $require=true; + } elseif ($val == 'BIC') { + $name = 'bic'; + $size = 12; + $content = $account->bic; + $require=true; } - print '<tr><td>'.$langs->trans($val).'</td>'; + print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>'; print '</tr>'; } - // IBAN - print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>'; - print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>'; - - print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BIC").'</td>'; - print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>'; - print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">'; print '<textarea name="domiciliation" rows="4" cols="40">'; print $account->domiciliation; @@ -498,7 +538,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) } print '</div>'; - + dol_fiche_end(); print '<div align="center">'; @@ -515,9 +555,9 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + print '<div class="fichecenter">'; - + print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; @@ -527,6 +567,13 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>'; print '<td><input size="30" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>'; + // IBAN + print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>'; + print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>'; + + print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BIC").'</td>'; + print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>'; + // BBAN if ($account->useDetailedBBAN() == 1) { @@ -556,13 +603,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) print '</tr>'; } - // IBAN - print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>'; - print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>'; - - print '<tr><td valign="top">'.$langs->trans("BIC").'</td>'; - print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>'; - print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">'; print '<textarea name="domiciliation" rows="4" cols="40">'; print GETPOST('domiciliation'); @@ -597,7 +637,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) } print '</div>'; - + dol_fiche_end(); print '<div align="center">'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index fb758c52f2970973ccd2dff0bcf0fd20f97793cc..ed42b16cee2d164c10a6f789b4b5eafb5bd3ded8 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -106,7 +106,7 @@ if (empty($reshook)) { header("Location: ".$backtopage); exit; - } + } } if ($action == 'confirm_merge' && $confirm == 'yes') @@ -200,8 +200,8 @@ if (empty($reshook)) { setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs'); $db->commit(); - } - else + } + else { $langs->load("errors"); setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors'); @@ -262,8 +262,8 @@ if (empty($reshook)) $error++; $action='create'; } - - + + if ($action == 'update') { $ret=$object->fetch($socid); @@ -340,13 +340,13 @@ if (empty($reshook)) $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); } - + // Multicurrency if (!empty($conf->multicurrency->enabled)) { $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); } - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) @@ -1494,7 +1494,7 @@ else print $object->ref; print '</td></tr>'; } - + // Name print '<tr><td class="titlefield">'.fieldLabel('ThirdPartyName','name',1).'</td>'; print '<td colspan="3"><input type="text" size="60" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus"></td></tr>'; @@ -1922,13 +1922,13 @@ else dol_htmloutput_errors($error,$errors); $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; - + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - - + + print '<div class="fichecenter">'; print '<div class="fichehalfleft">'; - + print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; @@ -1936,12 +1936,12 @@ else print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>'; print $object->getLibCustProspStatut(); print '</td></tr>'; - + // Prospect/Customer print '<tr><td>'.$langs->trans('Supplier').'</td><td>'; print yn($object->fournisseur); print '</td></tr>'; - + // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { @@ -2019,7 +2019,7 @@ else print yn($object->tva_assuj); print '</td>'; print '</tr>'; - + // VAT Code print '<tr>'; print '<td class="nowrap">'.$langs->trans('VATIntra').'</td><td>'; @@ -2163,13 +2163,13 @@ else print '<tr><td>'.$langs->trans("Staff").'</td><td>'.$object->effectif.'</td></tr>'; print '</table>'; - + print '</div>'; print '<div class="fichehalfright"><div class="ficheaddleft">'; - + print '<div class="underbanner clearboth"></div>'; print '<table class="border tableforfield" width="100%">'; - + // Legal print '<tr><td width="25%">'.$langs->trans('JuridicalStatus').'</td><td>'.$object->forme_juridique.'</td></tr>'; @@ -2244,7 +2244,7 @@ else print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : ''; print '</td></tr>'; } - + // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -2325,10 +2325,10 @@ else print '</table>'; print '</div>'; - + print '</div></div>'; print '<div style="clear:both"></div>'; - + dol_fiche_end(); @@ -2345,13 +2345,13 @@ else $TContact = $object->contact_array_objects(); foreach ($TContact as &$contact) { - if (!empty($contact->email)) + if (!empty($contact->email)) { $at_least_one_email_contact = true; break; } } - + if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); @@ -2408,7 +2408,7 @@ else print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(); - + // Define output language $outputlangs = $langs; $newlang = '';