diff --git a/htdocs/companybankaccount.class.php b/htdocs/companybankaccount.class.php index 7a587a30a59..a4280ed8476 100644 --- a/htdocs/companybankaccount.class.php +++ b/htdocs/companybankaccount.class.php @@ -14,16 +14,21 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ +/* + * \version $Id$ + */ + +/** + * \brief Class + * + */ class CompanyBankAccount { var $rowid; var $socid; - + var $bank; var $courant; var $clos; @@ -32,209 +37,194 @@ class CompanyBankAccount var $number; var $cle_rib; var $bic; - var $iban_prefix; + var $iban; + var $iban_prefix; // deprecated var $proprio; var $adresse_proprio; + + /** + * Constructor + */ + function CompanyBankAccount($DB) + { + $this->db = $DB; + + $this->socid = 0; + $this->clos = 0; + $this->solde = 0; + $this->error_number = 0; + return 1; + } + + + /* + * Creation du compte bancaire + * + */ + function create() + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, ".$this->db->idate(mktime()).")"; + if ($this->db->query($sql)) + { + if ($this->db->affected_rows()) + { + return 1; + } + } + else + { + print $this->db->error(); + return 0; + } + } + + /* + * + * + */ + function update($user='') + { + + $sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql .= " WHERE fk_soc = ".$this->socid; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows() == 0) + { + $this->create(); + } + } + else + { + print $this->db->error(); + return 0; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET "; + + $sql .= " bank = '" .addslashes($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_prefix."'"; + $sql .= ",domiciliation='".addslashes($this->domiciliation)."'"; + $sql .= ",proprio = '".addslashes($this->proprio)."'"; + $sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'"; + + $sql .= " WHERE fk_soc = ".$this->socid; + + $result = $this->db->query($sql); + + if ($result) + { + return 1; + } + else + { + dolibarr_print_error($this->db); + return 0; + } + } + + /* + * + * + */ + function fetch() + { + + $sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql.= " WHERE fk_soc = ".$this->socid; + + $result = $this->db->query($sql); + + if ($result) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object($result); + + $this->bank = $obj->bank; + $this->courant = $obj->courant; + $this->clos = $obj->clos; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->iban_prefix = $obj->iban; // deprecated + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->adresse_proprio = $obj->adresse_proprio; + } + $this->db->free(); + } + else + { + dolibarr_print_error($this->db); + } + } + + /* + * + * + */ + function error() + { + return $this->error; + } + - function CompanyBankAccount($DB, $socid) + /** + * + * + */ + function verif() { - global $config; - - $this->db = $DB; - $this->socid = $socid; + require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php'; - $this->clos = 0; - $this->solde = 0; - $this->error_number = 0; - return 1; - } + // Call function to check BAN + if (! verif_rib($this)) + { + $this->error_number = 12; + $this->error_message = 'RIBControlError'; + } - - /* - * Creation du compte bancaire - * - */ - function create() - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, datec) values ($this->socid, ".$this->db->idate(mktime()).")"; - if ($this->db->query($sql)) - { - if ($this->db->affected_rows()) - { - return 1; - } + if ($this->error_number == 0) + { + return 1; + } + else + { + return 0; + } } - else + + /** + * \brief Return account country code + * \return String country code + */ + function getCountryCode() { - print $this->db->error(); - return 0; + if (! empty($this->iban)) + { + // If IBAN defined, we can know country of account from it + if (eregi("^([a-zA-Z][a-zA-Z])",$this->iban,$reg)) return $reg[1]; + } + + // We return country code + $company=new Societe($this->db); + $result=$company->fetch($this->socid); + if (! empty($company->pays_code)) return $company->pays_code; - } - } - /* - * - * - */ - function update($user='') - { - - $sql = "SELECT fk_soc FROM ".MAIN_DB_PREFIX."societe_rib "; - $sql .= " WHERE fk_soc = ".$this->socid; - - $result = $this->db->query($sql); - - if ($result) - { - if ($this->db->num_rows() == 0) - { - $this->create(); - } - } - else - { - print $this->db->error(); - return 0; - } - - if (strlen(trim($this->iban_prefix)) == 0) - { - // Indispensable de la positionner pour vérifier le RIB - $this->iban_prefix = 'FR'; - } - - - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET "; - - $sql .= " bank = '" .addslashes($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_prefix."'"; - $sql .= ",domiciliation='".addslashes($this->domiciliation)."'"; - $sql .= ",proprio = '".addslashes($this->proprio)."'"; - $sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'"; - - $sql .= " WHERE fk_soc = ".$this->socid; - - $result = $this->db->query($sql); - - if ($result) - { - return 1; - } - else - { - dolibarr_print_error($this->db); - return 0; - } - } - - /* - * - * - */ - function fetch() - { - - $sql = "SELECT rowid, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix, domiciliation, proprio, adresse_proprio FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql .= " WHERE fk_soc = ".$this->socid; - - $result = $this->db->query($sql); - - if ($result) - { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object($result); - - $this->bank = $obj->bank; - $this->courant = $obj->courant; - $this->clos = $obj->clos; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban_prefix = $obj->iban_prefix; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->adresse_proprio = $obj->adresse_proprio; - } - $this->db->free(); - } - else - { - dolibarr_print_error($this->db); - } - } - - /* - * - * - */ - function error() - { - return $this->error; - } - - /* - * - * - */ - function verif() - { - require_once DOL_DOCUMENT_ROOT . '/lib/bank.lib.php'; - - - if (strlen(trim($this->code_banque)) == 0) - { - $this->error_number = 32; - $this->error_message = "Le code banque n'est pas renseigné"; - } - - if (strlen(trim($this->code_guichet)) == 0) - { - $this->error_number = 33; - $this->error_message = "Le code guichet n'est pas renseigné"; - } - - - if (strlen(trim($this->number)) == 0) - { - $this->error_number = 34; - $this->error_message = "Le numéro de compte n'est pas renseigné"; - } - - if (strlen(trim($this->cle_rib)) == 0) - { - $this->error_number = 35; - $this->error_message = "La clé n'est pas renseignée"; - } - - if (strlen(trim($this->iban_prefix)) == 0) - { - $this->error_number = 36; - $this->error_message = "La cle IBAN n'est pas renseignée"; - } - - - if (! verif_rib($this->code_banque, $this->code_guichet, $this->number, $this->cle_rib, $this->iban_prefix)) - { - $this->error_number = 12; - $this->error_message = "Le RIB n'est pas valide"; - } - - if ($this->error_number == 0) - { - return 1; - } - else - { - return 0; - } - } + return ''; + } } ?> diff --git a/htdocs/compta/bank/account.class.php b/htdocs/compta/bank/account.class.php index 59bf7074a0a..10f1bcc8ad6 100644 --- a/htdocs/compta/bank/account.class.php +++ b/htdocs/compta/bank/account.class.php @@ -48,17 +48,17 @@ class Account extends CommonObject var $clos; var $rappro; var $url; - //! Code banque dans le RIB + //! BBAN field for French Code banque var $code_banque; - //! Code guichet dans le RIB + //! BBAN field for French Code guichet var $code_guichet; - //! Numero du compte dans le RIB + //! BBAN main account number var $number; - //! Cle de controle du RIB + //! BBAN field for French Cle de controle var $cle_rib; - //! Numero BIC/SWIFT du compte + //! BIC/SWIFT number var $bic; - //! Prefix IBAN a utiliser pour creer la cle IBAN International Bank Account Number + //! IBAN number (International Bank Account Number) var $iban_prefix; var $proprio; var $adresse_proprio; @@ -277,9 +277,10 @@ class Account extends CommonObject // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php'; - if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) { - $this->error="Le controle de la cle indique que les informations de votre compte bancaire sont incorrectes."; - return 0; + if (! verif_rib($this)) + { + $this->error='RIBControlError'; + return -1; } if (! $this->ref) @@ -345,6 +346,7 @@ class Account extends CommonObject if (! $this->ref) { $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); + dolibarr_syslog("Account::update ".$this->error); return -1; } if (! $this->label) $this->label = "???"; @@ -368,7 +370,7 @@ class Account extends CommonObject $sql .= " WHERE rowid = ".$this->id; - dolibarr_syslog("Account::update sql=$sql"); + dolibarr_syslog("Account::update sql=".$sql); $result = $this->db->query($sql); if ($result) { @@ -384,29 +386,24 @@ class Account extends CommonObject /* - * \brief Mise a jour compte, partie RIB + * \brief Update BBAN (RIB) account fields * \param user Object utilisateur qui modifie * \return int <0 si ko, >0 si ok */ - function update_rib($user='') + function update_bban($user='') { global $langs; // Chargement librairie pour acces fonction controle RIB require_once(DOL_DOCUMENT_ROOT.'/lib/bank.lib.php'); - dolibarr_syslog("Account::update $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix"); - - // Verification parametres - if (! verif_rib($this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban_prefix)) { - $this->error="Le contr�le de la cl� indique que les informations de votre compte bancaire sont incorrectes."; - return 0; - } + dolibarr_syslog("Account::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); + // Check parameters if (! $this->ref) { $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); - return -1; + return -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; @@ -416,13 +413,13 @@ class Account extends CommonObject $sql .= ",number='".$this->number."'"; $sql .= ",cle_rib='".$this->cle_rib."'"; $sql .= ",bic='".$this->bic."'"; - $sql .= ",iban_prefix = '".$this->iban_prefix."'"; + $sql .= ",iban_prefix = '".$this->iban."'"; $sql .= ",domiciliation='".addslashes($this->domiciliation)."'"; $sql .= ",proprio = '".addslashes($this->proprio)."'"; $sql .= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'"; $sql .= " WHERE rowid = ".$this->id; - dolibarr_syslog("Account::update_rib sql=$sql"); + dolibarr_syslog("Account::update_bban sql=$sql"); $result = $this->db->query($sql); if ($result) @@ -446,7 +443,7 @@ class Account extends CommonObject function fetch($id,$ref='') { $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,"; - $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix,"; + $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,"; $sql.= " domiciliation, proprio, adresse_proprio,"; $sql.= " account_number, currency_code,"; $sql.= " min_allowed, min_desired, comment"; @@ -478,7 +475,8 @@ class Account extends CommonObject $this->number = $obj->number; $this->cle_rib = $obj->cle_rib; $this->bic = $obj->bic; - $this->iban_prefix = $obj->iban_prefix; + $this->iban = $obj->iban; + $this->iban_prefix = $obj->iban; // deprecated $this->domiciliation = $obj->domiciliation; $this->proprio = $obj->proprio; $this->adresse_proprio = $obj->adresse_proprio; @@ -747,12 +745,32 @@ class Account extends CommonObject return $result; } + /** + * \brief Return account country code + * \return String country code + */ + function getCountryCode() + { + global $mysoc; + + if (! empty($this->iban)) + { + // If IBAN defined, we can know country of account from it + if (eregi("^([a-zA-Z][a-zA-Z])",$this->iban,$reg)) return $reg[1]; + } + + // We return country code + if (! empty($mysoc->pays_code)) return $mysoc->pays_code; + + return ''; + } + } /** - \class AccountLine - \brief Classe permettant la gestion des lignes de transactions bancaires + * \class AccountLine + * \brief Classe permettant la gestion des lignes de transactions bancaires */ class AccountLine { @@ -997,6 +1015,7 @@ class AccountLine return $result; } + } ?> diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php index faaee1564da..e4dbf63f415 100644 --- a/htdocs/compta/bank/bankid_fr.php +++ b/htdocs/compta/bank/bankid_fr.php @@ -48,14 +48,15 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) $account->number = trim($_POST["number"]); $account->cle_rib = trim($_POST["cle_rib"]); $account->bic = trim($_POST["bic"]); - $account->iban_prefix = trim($_POST["iban_prefix"]); + $account->iban = trim($_POST["iban_prefix"]); + $account->iban_prefix = trim($_POST["iban_prefix"]); // deprecated $account->domiciliation = trim($_POST["domiciliation"]); $account->proprio = trim($_POST["proprio"]); $account->adresse_proprio = trim($_POST["adresse_proprio"]); if ($account->id) { - $result = $account->update_rib($user); + $result = $account->update_bban($user); if ($result >= 0) { $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu @@ -122,6 +123,13 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') print '
'; } + // Check BBAN + if (! checkBanForAccount($account)) + { + print '
'.$langs->trans("RIBControlError").'

'; + } + + print ''; // Ref @@ -144,22 +152,28 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') print ''; print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + } + print ''; print ''; print ''; - print ''; - print ''; - print ''; - + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + } + print ''; print ''; @@ -245,22 +259,30 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure print ''; print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - + // BBAN + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + } + print ''; print ''; print ''; - print ''; - print ''; - print ''; + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + } + // IBAN print ''; print ''; diff --git a/htdocs/compta/prelevement/bon-prelevement.class.php b/htdocs/compta/prelevement/bon-prelevement.class.php index 3940a0035de..949688d23e8 100644 --- a/htdocs/compta/prelevement/bon-prelevement.class.php +++ b/htdocs/compta/prelevement/bon-prelevement.class.php @@ -1152,22 +1152,6 @@ class BonPrelevement extends CommonObject { $result = -2; } - /* - $nbfactures = sizeof($this->factures); - for ($i = 0 ; $i < $nbfactures ; $i++) - { - $fac = new Facture($this->db); - $fac->fetch($this->factures[$i]); - $fac->fetch_client(); - $fac->client->rib(); - if ($fac->client->bank_account->verif()) { - $this->total = $this->total + $fac->total_ttc; - $this->EnregDestinataire($fac); - }else{ - print $fac->client->bank_account->error_message; - print $fac->client->nom; } - } - */ /* * Pied de page total diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 9319897cdd5..1e38fbbc92f 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -2422,7 +2422,8 @@ class Facture extends CommonObject $soc = new Societe($this->db); $soc->id = $this->socid; - $soc->rib(); + $soc->load_ban(); + if ($this->statut > 0 && $this->paye == 0 && $this->mode_reglement_id == 3) { $sql = 'SELECT count(*) FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 155fbd1307f..5c149def123 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -27,7 +27,7 @@ CurrentBalance=Current balance FutureBalance=Future balance ShowAllTimeBalance=Show balance from start Reconciliation=Reconciliation -RIB=RIB +RIB=Bank Account Number IBAN=IBAN number BIC=BIC/SWIFT number StandingOrders=Standing orders @@ -43,7 +43,7 @@ IOMonthlyReporting=Monthly reporting BankAccountDomiciliation=Account address BankAccountOwner=Account owner name BankAccountOwnerAddress=Account owner address -RIBControlError=Control of key says informations for this account number are not complete or wrong. +RIBControlError=Inetgrity checks of values fails. This means information for this account number are not complete or wrong (check country, numbers and IBAN). CreateAccount=Create account StandingOrderToProcess=To process StandingOrderProcessed=Processed diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 4e4a823d465..123224c55d6 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -106,7 +106,7 @@ ProfId4PT=Prof Id 4 (Conservatory) ProfId1TN=Prof Id 1 (RC) ProfId2TN=Prof Id 2 (Fiscal matricule) ProfId3TN=Prof Id 3 (Douane code) -ProfId4TN=Prof Id 4 (RIB) +ProfId4TN=Prof Id 4 (BAN) VATIntra=VAT number VATIntraShort=VAT number VATIntraVeryShort=VAT @@ -226,7 +226,7 @@ ProspectsByStatus=Prospects by status BillingContact=Billing contact NbOfAttachedFiles=Number of attached files AttachANewFile=Attach a new file -NoRIB=No RIB defined +NoRIB=No BAN defined NoParentCompany=None ExportImport=Import-Export ExportCardToFormat=Export card to format diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7b9a2afe7ea..0a84ba83bb2 100755 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -29,5 +29,5 @@ LastWithdrawalReceipt=Last %s withdrawing receipts MakeWithdrawRequest=Make a withdraw request ThirdPartyBankCode=Third party bank code ThirdPartyDeskCode=Third party desk code -NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid RIB. +NoInvoiceCouldBeWithdrawed=No invoice withdrawed with success. Check that invoice are on companies with a valid BAN. ClassCredited=Classer crédité \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index c4552d5f523..64456e2d96d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -663,7 +663,7 @@ ForceInvoiceDate=Forcer la date de facture DisableRepeatable=Désactiver les factures récurrentes SuggestedPaymentModesIfNotDefinedInInvoice=Modes de paiements suggérés par défaut si non défini au niveau de la facture EnableEditDeleteValidInvoice=Activer la possibilité de rééditer/supprimer une facture validée sans paiement -SuggestPaymentByRIBOnAccount=Proposer paiement par RIB sur le compte +SuggestPaymentByRIBOnAccount=Proposer paiement par virement sur le compte SuggestPaymentByChequeToAddress=Proposer paiement par chèque à l'ordre et adresse de FreeLegalTextOnInvoices=Mention complémentaire sur les factures WatermarkOnDraftInvoices=Filigrane sur les brouillons de factures (aucun si vide) diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index d0d01b9431e..9c58d485ce1 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -27,7 +27,7 @@ CurrentBalance=Solde actuel FutureBalance=Solde futur ShowAllTimeBalance=Afficher solde depuis début Reconciliation=Rapprochement -RIB=RIB +RIB=Numéro compte IBAN=Identifiant IBAN BIC=Identifiant BIC/SWIFT StandingOrders=Prélèvements @@ -43,7 +43,7 @@ IOMonthlyReporting=Rapport mensuel E/S BankAccountDomiciliation=Domiciliation du compte BankAccountOwner=Nom du propriétaire du compte BankAccountOwnerAddress=Adresse du propriétaire du compte -RIBControlError=Le contrôle de la clé indique que les informations de ce compte bancaire sont incomplètes ou incorrectes. +RIBControlError=Les contrôles indiquent que les informations de ce compte bancaire sont incomplètes ou incorrectes (vérifier le pays, les numéros de compte ou IBAN). CreateAccount=Créer compte StandingOrderToProcess=À traiter StandingOrderProcessed=Traités diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 69f73af0c02..7f709bb3927 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -106,7 +106,7 @@ ProfId4PT=Id prof. 4 (Conservatory) ProfId1TN=Id prof. 1 (RC) ProfId2TN=Id prof. 2 (Matricule fiscale) ProfId3TN=Id prof. 3 (Code en douane) -ProfId4TN=Id prof. 4 (RIB) +ProfId4TN=Id prof. 4 (BAN) VATIntra=Numéro de TVA VATIntraShort=Num TVA VATIntraVeryShort=N° TVA @@ -226,7 +226,7 @@ ProspectsByStatus=Prospects par BillingContact=Contact facturation NbOfAttachedFiles=Nombre de fichiers joints AttachANewFile=Joindre un nouveau fichier -NoRIB=Aucun RIB défini +NoRIB=Aucun BAN (RIB) défini NoParentCompany=Aucune ExportImport=Import-Export ExportCardToFormat=Exporter fiche au format diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang index a4b12aea10c..b045c211105 100755 --- a/htdocs/langs/fr_FR/withdrawals.lang +++ b/htdocs/langs/fr_FR/withdrawals.lang @@ -29,5 +29,5 @@ LastWithdrawalReceipt=Les %s derniers bons de pr MakeWithdrawRequest=Faire une demande de prélèvement ThirdPartyBankCode=Code banque du tiers ThirdPartyDeskCode=Code guichet du tiers -NoInvoiceCouldBeWithdrawed=Aucune facture prélevable, prélevé avec succès. Vérifiez que les factures sont sur des sociétés dont le RIB est correctement renseigné. +NoInvoiceCouldBeWithdrawed=Aucune facture prélevable, prélevé avec succès. Vérifiez que les factures sont sur des sociétés dont le BAN(RIB) est correctement renseigné. ClassCredited=Classer crédité \ No newline at end of file diff --git a/htdocs/lib/bank.lib.php b/htdocs/lib/bank.lib.php index b3de1af521d..a2842320904 100644 --- a/htdocs/lib/bank.lib.php +++ b/htdocs/lib/bank.lib.php @@ -81,29 +81,32 @@ function bank_prepare_head($obj) /** - \brief Verifie le RIB d'un compte bancaire grace à sa clé - \param code_banque code banque - \param code_guichet code guichet - \param num_compte numero de compte - \param cle cle - \param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays - \return int true si les infos sont bonnes, false si la clé ne correspond pas -*/ -function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban) + * \brief Check account number informations for a bank account + * \param code_banque code banque + * \param code_guichet code guichet + * \param num_compte numero de compte + * \param cle cle + * \param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays + * \return int true si les infos sont bonnes, false si erreur + */ +function checkBanForAccount($account) { - if (eregi("^FR",$iban)) + $country_code=$account->getCountryCode(); + + dolibarr_syslog("Bank.lib::checkBanForAccount account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); + + + if ($country_code == 'FR') { // Cas de la France $coef = array(62, 34, 3) ; // Concatenation des differents codes. - $rib = strtolower(trim($code_banque).trim($code_guichet).trim($num_compte).trim($cle)); + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->num_compte).trim($account->cle)); // On remplace les eventuelles lettres par des chiffres. - //Ne marche pas - //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); - + //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678923456789"); // Separation du rib en 3 groupes de 7 + 1 groupe de 2. @@ -124,7 +127,19 @@ function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban) return false; } + + if ($country_code == 'BE') // Belgium rules + { + } + // No particular rule + // If account is CompanyBankAccount class, we use number + // If account is Account class, we use num_compte + if (empty($account->num_compte) && empty($account->number)) + { + return false; + } + return true; } diff --git a/htdocs/soc.php b/htdocs/soc.php index 5a53fd81d6c..07896165cfe 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -36,6 +36,7 @@ require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); $langs->load("companies"); $langs->load("commercial"); $langs->load("bills"); +$langs->load("banks"); // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; @@ -1154,7 +1155,7 @@ else $soc->typent= $arr[$soc->typent_code]; print ''; - // RIB + // Ban print '
'.$langs->trans("BankName").''.$account->bank.'
'.$langs->trans("BankCode").''.$account->code_banque.'
'.$langs->trans("DeskCode").''.$account->code_guichet.'
'.$langs->trans("BankCode").''.$account->code_banque.'
'.$langs->trans("DeskCode").''.$account->code_guichet.'
'.$langs->trans("BankAccountNumber").''.$account->number.'
'.$langs->trans("BankAccountNumberKey").''.$account->cle_rib.'
'.$langs->trans("BankAccountNumberKey").''.$account->cle_rib.'
'.$langs->trans("IBAN").''.$account->iban_prefix.'
'.$langs->trans("BankCode").'
'.$langs->trans("DeskCode").'
'.$langs->trans("BankCode").'
'.$langs->trans("DeskCode").'
'.$langs->trans("BankAccountNumber").'
'.$langs->trans("BankAccountNumberKey").'
'.$langs->trans("BankAccountNumberKey").'
'.$langs->trans("IBAN").'
'.$langs->trans("Type").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'
'; print ''; - // Maison mère + // Parent company print '"; + + print ''; + + print ''; + print '
'; print $langs->trans('RIB'); @@ -1169,7 +1170,7 @@ else print $soc->display_rib(); print '
'; print '\n"; - print ''; + print '\n"; + + print '
'; print $langs->trans('ParentCompany'); @@ -1185,7 +1186,8 @@ else { $socm = new Societe($db); $socm->fetch($soc->parent); - print ''.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.''.($socm->code_client?"(".$socm->code_client.")":"").' - '.$socm->ville; + print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); + print $socm->ville?' - '.$socm->ville:''; } else { print $langs->trans("NoParentCompany"); diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 6a6e8632f6f..35d1e5042c5 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1361,12 +1361,14 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php"; - $bac = new CompanyBankAccount($this->db, $this->id); - $bac->fetch(); + $bac = new CompanyBankAccount($this->db); + $bac->socid = $this->id; + $bac->fetch($this->id); if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib) { - $rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." (".$bac->cle_rib.")"; + $rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number; + $rib.=($bac->cle_rib?" (".$bac->cle_rib.")":""); } else { @@ -1375,23 +1377,24 @@ class Societe extends CommonObject return $rib; } - - function rib() + /** + * Load this->bank_account attribut + */ + function load_ban() { require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php"; $bac = new CompanyBankAccount($this->db, $this->id); - $bac->fetch(); + $bac->fetch($this->id); $this->bank_account = $bac; - return 1; } function verif_rib() { - $this->rib(); + $this->load_ban(); return $this->bank_account->verif(); } diff --git a/htdocs/societe/lien.php b/htdocs/societe/lien.php index 802f548a567..d4ce2717943 100644 --- a/htdocs/societe/lien.php +++ b/htdocs/societe/lien.php @@ -185,12 +185,10 @@ if($_GET["socid"]) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."c_typent as te"; $sql.= " WHERE s.fk_typent = te.id"; - if (strlen(trim($_GET["search_nom"]))) { $sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'"; } - $sql .= " ORDER BY s.nom ASC " . $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); @@ -201,7 +199,7 @@ if($_GET["socid"]) $params = "&socid=".$_GET["socid"]; - print_barre_liste($title, $page, "lien.php",$params,$sortfield,$sortorder,'',$num); + print_barre_liste($title, $page, "lien.php",$params,$sortfield,$sortorder,'',$num,0,''); // Lignes des titres print ''; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index b0f9aec24fd..cb8f180048e 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -19,18 +19,20 @@ */ /** - \file htdocs/societe/rib.php - \ingroup societe - \brief Onglet rib de societe - \version $Id$ -*/ - + * \file htdocs/societe/rib.php + * \ingroup societe + * \brief BAN tab for companies + * \version $Id$ + */ + require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); require_once DOL_DOCUMENT_ROOT."/companybankaccount.class.php"; $langs->load("companies"); $langs->load("banks"); +$langs->load("bills"); // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; @@ -43,52 +45,57 @@ $soc->fetch($_GET["socid"]); /* -* Actions -*/ + * Actions + */ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) { - // Modification - $account = new CompanyBankAccount($db, $soc->id); + // Modification + $account = new CompanyBankAccount($db); - $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_prefix = $_POST["iban_prefix"]; - $account->domiciliation = $_POST["domiciliation"]; - $account->proprio = $_POST["proprio"]; - $account->adresse_proprio = $_POST["adresse_proprio"]; + $account->socid = $soc->id; - $result = $account->update($user); - if (! $result) - { - $message=$account->error(); - $_GET["action"]='edit'; // Force chargement page edition - } - else - { - $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu - } + $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_prefix = $_POST["iban_prefix"]; + $account->domiciliation = $_POST["domiciliation"]; + $account->proprio = $_POST["proprio"]; + $account->adresse_proprio = $_POST["adresse_proprio"]; + + $result = $account->update($user); + if (! $result) + { + $message=$account->error(); + $_GET["action"]='edit'; // Force chargement page edition + } + else + { + $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu + } } + /* -* View -*/ + * View + */ + llxHeader(); $head=societe_prepare_head2($soc); - + dolibarr_fiche_head($head, 'rib', $langs->trans("ThirdParty")); -$account = new CompanyBankAccount($db, $soc->id); -$account->fetch(); +$account = new CompanyBankAccount($db); +$account->socid=$soc->id; +$account->fetch($soc->id); /* ************************************************************************** */ @@ -99,64 +106,75 @@ $account->fetch(); if ($_GET["socid"] && $_GET["action"] != 'edit') { - if (!$account->verif()) - { - print '
'.$langs->trans("RIBControlError").'

'; - } + // Check BBAN + if (! checkBanForAccount($account)) + { + print '
'.$langs->trans("RIBControlError").'

'; + } - print '
'; + print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + } - print ''; - print ''; + print ''; + print ''; + print ''; + + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + } - print '\n"; + print ''; + print ''; - print '\n"; + print ''; + print ''; - print '\n"; + print '\n"; - print '
'.$langs->trans("Bank").''.$account->bank.'
'.$langs->trans("Bank").''.$account->bank.'
'.$langs->trans("RIB").''.$langs->trans("BankCode").''.$langs->trans("DeskCode").''.$langs->trans("BankAccountNumber").''.$langs->trans("BankAccountNumberKey").'
 '.$account->code_banque.''.$account->code_guichet.''.$account->number.''.$account->cle_rib.'
'.$langs->trans("BankCode").''.$account->code_banque.'
'.$langs->trans("IBAN").''.$account->iban_prefix.'
'.$langs->trans("DeskCode").''.$account->code_guichet.'
'.$langs->trans("BIC").''.$account->bic.'
'.$langs->trans("BankAccountNumber").''.$account->number.'
'.$langs->trans("BankAccountNumberKey").''.$account->cle_rib.'
'.$langs->trans("BankAccountDomiciliation").''; - print $account->domiciliation; - print "
'.$langs->trans("IBAN").''.$account->iban_prefix.'
'.$langs->trans("BankAccountOwner").''; - print $account->proprio; - print "
'.$langs->trans("BIC").''.$account->bic.'
'.$langs->trans("BankAccountOwnerAddress").''; - print $account->adresse_proprio; - print "
'.$langs->trans("BankAccountDomiciliation").''; + print $account->domiciliation; + print "
'; + print '
'.$langs->trans("BankAccountOwner").''; + print $account->proprio; + print "
'.$langs->trans("BankAccountOwnerAddress").''; + print $account->adresse_proprio; + print "
'; + + print ''; - /* - * Barre d'actions - * - */ - print '
'; + /* + * Barre d'actions + * + */ + print '
'; - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Modify").''; - } + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Modify").''; + } - print '
'; + print '
'; } @@ -169,54 +187,69 @@ if ($_GET["socid"] && $_GET["action"] != 'edit') if ($_GET["socid"] && $_GET["action"] == 'edit' && $user->rights->societe->creer) { - $form = new Form($db); + $form = new Form($db); - if ($message) { print "$message

\n"; } + if ($message) { print "$message

\n"; } - print '
'; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; + print '
'; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // BBAN + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + } + + print ''; + print ''; + print ''; - print ''; - print ''; + if ($account->getCountryCode() == 'FR') + { + print ''; + print ''; + print ''; + } - print '"; + // IBAN + print ''; + print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; - print '"; + print '"; - print ''; + print ''; + print ''; + print "\n"; - print ''; - print '
'.$langs->trans("Bank").'
'.$langs->trans("Bank").'
'.$langs->trans("RIB").''.$langs->trans("BankCode").''.$langs->trans("DeskCode").''.$langs->trans("BankAccountNumber").''.$langs->trans("BankAccountNumberKey").'
 
'.$langs->trans("BankCode").'
'.$langs->trans("IBAN").'
'.$langs->trans("DeskCode").'
'.$langs->trans("BankAccountNumber").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountNumberKey").'
'.$langs->trans("BankAccountDomiciliation").''; - print "
'.$langs->trans("IBAN").'
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountOwnerAddress").''; - print "
'.$langs->trans("BankAccountDomiciliation").''; + print "
'; - print '   '; - print '
'.$langs->trans("BankAccountOwner").'
'; + print '
'.$langs->trans("BankAccountOwnerAddress").''; + print "
'; + print '   '; + print '
'; } diff --git a/htdocs/telephonie/client/new.php b/htdocs/telephonie/client/new.php index 02c5989cf70..ccba9dfb8d4 100644 --- a/htdocs/telephonie/client/new.php +++ b/htdocs/telephonie/client/new.php @@ -24,11 +24,11 @@ */ /** - \file htdocs/telephonie/client/new.php - \ingroup telephonie - \brief Creation d'un nouveau client - \version $Revision$ -*/ + \file htdocs/telephonie/client/new.php + \ingroup telephonie + \brief Creation d'un nouveau client + \version $Revision$ + */ require("pre.inc.php"); @@ -44,7 +44,8 @@ $langs->load("companies"); $soc = new Societe($db); $contact = new Contact($db); -$rib = new CompanyBankAccount($db, 0); +$rib = new CompanyBankAccount($db); + /* * Actions @@ -52,558 +53,558 @@ $rib = new CompanyBankAccount($db, 0); if ($_POST["action"] == 'add') { - $error = 0; - $verif = "ok"; - $mesg = ''; + $error = 0; + $verif = "ok"; + $mesg = ''; - $contact->name = $_POST["cnom"]; - $contact->firstname = $_POST["cprenom"]; - $contact->email = strtolower($_POST["cmail"]); + $contact->name = $_POST["cnom"]; + $contact->firstname = $_POST["cprenom"]; + $contact->email = strtolower($_POST["cmail"]); - if (strlen(trim($_POST["nom"])) == 0) - { - $mesg = "Nom de société incorrect"; - $verif = "nok"; - } - - if (strlen(trim($_POST["code_client"])) <> 6 && $verif == 'ok') - { - $mesg = "Code client incorrect"; - $verif = "nok"; - } - - if (strlen(trim($_POST["adresse"])) == 0 && $verif == 'ok') - { - $mesg = "Adresse de société manquante"; - $verif = "nok"; - } - - if (strlen(trim($_POST["cp"])) == 0 && $verif == 'ok') - { - $mesg = "Code postal manquant"; - $verif = "nok"; - } - - if (strlen(trim($_POST["ville"])) == 0 && $verif == 'ok') - { - $mesg = "Ville manquante"; - $verif = "nok"; - } - - $rib->code_banque = $_POST["rib_banque"]; - $rib->code_guichet = $_POST["rib_guichet"]; - $rib->number = $_POST["rib_compte"]; - $rib->cle_rib = $_POST["rib_cle"]; - $rib->iban_prefix = $_POST["rib_iban"]; - $rib->proprio = $_POST["titulaire"]; - - - if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok') - { - if (strlen(trim($_POST["rib_banque"])) <> 5 && $verif == 'ok') + if (strlen(trim($_POST["nom"])) == 0) { - $mesg = "Rib code banque incomplet"; - $verif = "nok"; + $mesg = "Nom de société incorrect"; + $verif = "nok"; } - if (strlen(trim($_POST["rib_guichet"])) <> 5 && $verif == 'ok') + if (strlen(trim($_POST["code_client"])) <> 6 && $verif == 'ok') { - $mesg = "Rib code agence incomplet"; - $verif = "nok"; + $mesg = "Code client incorrect"; + $verif = "nok"; } - if (strlen(trim($_POST["titulaire"])) == 0 && $verif == 'ok') + if (strlen(trim($_POST["adresse"])) == 0 && $verif == 'ok') { - $mesg = "Vous devez indiquer le titulaire du compte"; - $verif = "nok"; + $mesg = "Adresse de société manquante"; + $verif = "nok"; } - if ($rib->verif() <> 1 && $verif == 'ok') + if (strlen(trim($_POST["cp"])) == 0 && $verif == 'ok') { - $mesg = "Rib incorrect ".$rib->error_message; - $verif = "nok"; - } - } - - if (strlen(trim($_POST["cmail"])) > 0 && $verif == 'ok') - { - - if (strlen(trim($_POST["cnom"])) == 0 && $verif == 'ok') - { - $mesg = "Nom de contact manquant"; - $verif = "nok"; + $mesg = "Code postal manquant"; + $verif = "nok"; } - if (!ValidEmail(trim($contact->email)) && $verif == 'ok') + if (strlen(trim($_POST["ville"])) == 0 && $verif == 'ok') { - $mesg = "Email invalide"; - $verif = "nok"; + $mesg = "Ville manquante"; + $verif = "nok"; } - if (!check_mail(trim($contact->email)) && $verif == 'ok') + $rib->code_banque = $_POST["rib_banque"]; + $rib->code_guichet = $_POST["rib_guichet"]; + $rib->number = $_POST["rib_compte"]; + $rib->cle_rib = $_POST["rib_cle"]; + $rib->iban_prefix = $_POST["rib_iban"]; + $rib->iban = $_POST["rib_iban"]; + $rib->proprio = $_POST["titulaire"]; + + + if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok') { - $mesg = "Email invalide (domaine invalide)"; - $verif = "nok"; - } - } + if (strlen(trim($_POST["rib_banque"])) <> 5 && $verif == 'ok') + { + $mesg = "Rib code banque incomplet"; + $verif = "nok"; + } + if (strlen(trim($_POST["rib_guichet"])) <> 5 && $verif == 'ok') + { + $mesg = "Rib code agence incomplet"; + $verif = "nok"; + } - if (strlen(trim($_POST["cli"])) <> 9 && $verif == 'ok') - { - $mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect"; - $verif = "nok"; - } - - if (strlen(trim($_POST["cliend"])) > 0 && strlen(trim($_POST["cliend"])) <> 9 && $verif == 'ok') - { - $mesg = "Numéro de ligne dernier SDA (0".$_POST["cliend"].") incorrect"; - $verif = "nok"; - } + if (strlen(trim($_POST["titulaire"])) == 0 && $verif == 'ok') + { + $mesg = "Vous devez indiquer le titulaire du compte"; + $verif = "nok"; + } - $p = array("1","2","3","4","5"); - - if (!in_array(substr(trim($_POST["cli"]),0,1), $p) && $verif == 'ok') - { - $mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect"; - $verif = "nok"; - } - - $ligne = new LigneTel($db); - $ligne->fetch("0".trim($_POST["cli"])); - if ($ligne->id > 0 && $verif == 'ok') - { - $mesg = "La ligne #1 : 0".$_POST["cli"]." existe déjà !"; - $verif = "nok"; - } - - - /* Ligne #2 */ - - if (strlen(trim($_POST["cli2"])) > 0 && $verif == 'ok') - { - if (strlen(trim($_POST["cli2"])) <> 9 && $verif == 'ok') - { - $mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect"; - $verif = "nok"; - } - - if (!in_array(substr(trim($_POST["cli2"]),0,1), $p) && $verif == 'ok') - { - $mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect"; - $verif = "nok"; + if ($rib->verif() <> 1 && $verif == 'ok') + { + $mesg = "Rib incorrect ".$rib->error_message; + $verif = "nok"; + } } - $ligne = new LigneTel($db); - $ligne->fetch("0".trim($_POST["cli2"])); - if ($ligne->id > 0 && $verif == 'ok') + if (strlen(trim($_POST["cmail"])) > 0 && $verif == 'ok') { - $mesg = "La ligne #2 : 0".$_POST["cli2"]." existe déjà !"; - $verif = "nok"; - } - } - /* Ligne #3 */ - if (strlen(trim($_POST["cli3"])) > 0 && $verif == 'ok') - { - if (strlen(trim($_POST["cli3"])) <> 9 && $verif == 'ok') - { - $mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect"; - $verif = "nok"; - } - - if (!in_array(substr(trim($_POST["cli3"]),0,1), $p) && $verif == 'ok') - { - $mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect"; - $verif = "nok"; + if (strlen(trim($_POST["cnom"])) == 0 && $verif == 'ok') + { + $mesg = "Nom de contact manquant"; + $verif = "nok"; + } + + if (!ValidEmail(trim($contact->email)) && $verif == 'ok') + { + $mesg = "Email invalide"; + $verif = "nok"; + } + + if (!check_mail(trim($contact->email)) && $verif == 'ok') + { + $mesg = "Email invalide (domaine invalide)"; + $verif = "nok"; + } } - $ligne = new LigneTel($db); - $ligne->fetch("0".trim($_POST["cli3"])); - if ($ligne->id > 0 && $verif == 'ok') - { - $mesg = "La ligne #3 : 0".$_POST["cli3"]." existe déjà !"; - $verif = "nok"; - } - } - /* Verif Tarif */ - if (strlen(trim($_POST["france"])) > 0 && $verif == "ok") - { - $temporel = ereg_replace(",",".",trim($_POST["france"])); - - if(! is_numeric($temporel)) + if (strlen(trim($_POST["cli"])) <> 9 && $verif == 'ok') { - $error = 1030; - $verif = "nok"; - $mesg .= "Tarif France Invalide"; + $mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect"; + $verif = "nok"; } - else - { - if ($temporel > 0.04 ) - { - $error = 1031; - $verif = "nok"; - $mesg .= "Tarif France Invalide : $temporel > 0.04 !"; - } - - if ($temporel < 0.016 ) - { - $error = 1031; - $verif = "nok"; - $mesg .= "Tarif France Invalide : $temporel < 0.016 !"; - } - } - } - if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok") - { - $temporel = ereg_replace(",",".",trim($_POST["mobil"])); - - if(! is_numeric($temporel)) - { - $error++; - $verif = "nok"; - $mesg .= "Tarif Mobile Invalide"; - } - else - { - if ($temporel > 0.40 ) - { - $error = 1033; - $verif = "nok"; - $mesg .= "Tarif Mobile Invalide : $temporel > 0.40 !"; - } - if ($temporel < 0.14 ) - { - $error = 1034; - $verif = "nok"; - $mesg .= "Tarif Mobile Invalide : $temporel < 0.14 !"; - } - } - } - /* Fin Verif Tarif */ + if (strlen(trim($_POST["cliend"])) > 0 && strlen(trim($_POST["cliend"])) <> 9 && $verif == 'ok') + { + $mesg = "Numéro de ligne dernier SDA (0".$_POST["cliend"].") incorrect"; + $verif = "nok"; + } - $soc->nom = $_POST["nom"]; - $soc->adresse = $_POST["adresse"]; - $soc->cp = $_POST["cp"]; - $soc->ville = $_POST["ville"]; - $soc->pays_id = $_POST["pays_id"]; - $soc->tel = $_POST["tel"]; - $soc->fax = $_POST["fax"]; - $soc->url = ereg_replace( "http://", "", $_POST["url"] ); - $soc->code_client = $_POST["code_client"]; - $soc->code_fournisseur = $_POST["code_fournisseur"]; - $soc->codeclient_modifiable = $_POST["codeclient_modifiable"]; - $soc->codefournisseur_modifiable = $_POST["codefournisseur_modifiable"]; - $soc->client = 1; - $soc->fournisseur = 0; + $p = array("1","2","3","4","5"); - if (!$error && $verif == "ok") - { - $soc->code_client = $_POST["code_client"]."00"; - $result = $soc->create($user); - - if ($result == 0) + if (!in_array(substr(trim($_POST["cli"]),0,1), $p) && $verif == 'ok') { - $soc->AddPerms(1,1,1,1); - $soc->AddPerms(5,1,1,1); - $soc->AddPerms(9,1,1,1); - $soc->AddPerms($user->id,1,1,1); - $soc->AddPerms($_POST["commercial_sign"],1,0,0); + $mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect"; + $verif = "nok"; } - else + + $ligne = new LigneTel($db); + $ligne->fetch("0".trim($_POST["cli"])); + if ($ligne->id > 0 && $verif == 'ok') { - $mesg = nl2br($soc->error) . " (result $result)\n"; - $error = 1035; + $mesg = "La ligne #1 : 0".$_POST["cli"]." existe déjà !"; + $verif = "nok"; } - } - - if (!$error && $verif == "ok") - { - $contact->socid = $soc->id; - - if ( $contact->create($user) > 0) - { - - } - else - { - $error = 1024; - } - } - if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok' && !$error) - { - $rib->socid = $soc->id; + /* Ligne #2 */ - if ( $rib->update($user) > 0) + if (strlen(trim($_POST["cli2"])) > 0 && $verif == 'ok') { - - } - else - { - $error = 1025; - } - } + if (strlen(trim($_POST["cli2"])) <> 9 && $verif == 'ok') + { + $mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect"; + $verif = "nok"; + } - if (!$error && $verif == "ok") - { - $contrat = new TelephonieContrat($db); - - $contrat->client_comm = $soc->id; - $contrat->client = $soc->id; - $contrat->client_facture = $soc->id; - $contrat->commercial_sign = $_POST["commercial_sign"]; - - if ( $contrat->create($user,'oui',$_POST["mode_paiement"]) == 0) - { - $contrat->add_contact_facture($contact->id); - } - else - { - $error = 1026; - } - } - - if(!$error && $verif == "ok") - { - $contrat->commercial_sign_id = $_POST["commercial_sign"]; - $contrat->addpo($_POST["montantpo"], $user); - } + if (!in_array(substr(trim($_POST["cli2"]),0,1), $p) && $verif == 'ok') + { + $mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect"; + $verif = "nok"; + } - /* Ligne 1 */ + $ligne = new LigneTel($db); + $ligne->fetch("0".trim($_POST["cli2"])); + if ($ligne->id > 0 && $verif == 'ok') + { + $mesg = "La ligne #2 : 0".$_POST["cli2"]." existe déjà !"; + $verif = "nok"; + } + } + /* Ligne #3 */ - $ligne = new LigneTel($db); - $ligne->contrat = $contrat->id; - $ligne->numero = "0".$_POST["cli"]; - $ligne->client_comm = $soc->id; - $ligne->client = $soc->id; - $ligne->client_facture = $soc->id; - $ligne->fournisseur = $_POST["fournisseur"]; - $ligne->commercial_sign = $_POST["commercial_sign"]; - $ligne->commercial_suiv = $_POST["commercial_sign"]; - $ligne->concurrent = $_POST["concurrent"]; - $ligne->remise = "0"; - $ligne->note = $_POST["note"]; - - if(!$error && $verif == "ok") - { - if (strlen(trim($_POST["cli"])) == 9) + if (strlen(trim($_POST["cli3"])) > 0 && $verif == 'ok') { - + if (strlen(trim($_POST["cli3"])) <> 9 && $verif == 'ok') + { + $mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect"; + $verif = "nok"; + } + + if (!in_array(substr(trim($_POST["cli3"]),0,1), $p) && $verif == 'ok') + { + $mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect"; + $verif = "nok"; + } + + $ligne = new LigneTel($db); + $ligne->fetch("0".trim($_POST["cli3"])); + if ($ligne->id > 0 && $verif == 'ok') + { + $mesg = "La ligne #3 : 0".$_POST["cli3"]." existe déjà !"; + $verif = "nok"; + } + } + + /* Verif Tarif */ + if (strlen(trim($_POST["france"])) > 0 && $verif == "ok") + { + $temporel = ereg_replace(",",".",trim($_POST["france"])); + + if(! is_numeric($temporel)) + { + $error = 1030; + $verif = "nok"; + $mesg .= "Tarif France Invalide"; + } + else + { + if ($temporel > 0.04 ) + { + $error = 1031; + $verif = "nok"; + $mesg .= "Tarif France Invalide : $temporel > 0.04 !"; + } + + if ($temporel < 0.016 ) + { + $error = 1031; + $verif = "nok"; + $mesg .= "Tarif France Invalide : $temporel < 0.016 !"; + } + } + } + if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok") + { + $temporel = ereg_replace(",",".",trim($_POST["mobil"])); + + if(! is_numeric($temporel)) + { + $error++; + $verif = "nok"; + $mesg .= "Tarif Mobile Invalide"; + } + else + { + if ($temporel > 0.40 ) + { + $error = 1033; + $verif = "nok"; + $mesg .= "Tarif Mobile Invalide : $temporel > 0.40 !"; + } + if ($temporel < 0.14 ) + { + $error = 1034; + $verif = "nok"; + $mesg .= "Tarif Mobile Invalide : $temporel < 0.14 !"; + } + } + } + + /* Fin Verif Tarif */ + + $soc->nom = $_POST["nom"]; + $soc->adresse = $_POST["adresse"]; + $soc->cp = $_POST["cp"]; + $soc->ville = $_POST["ville"]; + $soc->pays_id = $_POST["pays_id"]; + $soc->tel = $_POST["tel"]; + $soc->fax = $_POST["fax"]; + $soc->url = ereg_replace( "http://", "", $_POST["url"] ); + $soc->code_client = $_POST["code_client"]; + $soc->code_fournisseur = $_POST["code_fournisseur"]; + $soc->codeclient_modifiable = $_POST["codeclient_modifiable"]; + $soc->codefournisseur_modifiable = $_POST["codefournisseur_modifiable"]; + $soc->client = 1; + $soc->fournisseur = 0; + + if (!$error && $verif == "ok") + { + $soc->code_client = $_POST["code_client"]."00"; + $result = $soc->create($user); + + if ($result == 0) + { + $soc->AddPerms(1,1,1,1); + $soc->AddPerms(5,1,1,1); + $soc->AddPerms(9,1,1,1); + $soc->AddPerms($user->id,1,1,1); + $soc->AddPerms($_POST["commercial_sign"],1,0,0); + } + else + { + $mesg = nl2br($soc->error) . " (result $result)\n"; + $error = 1035; + } + } + + if (!$error && $verif == "ok") + { + $contact->socid = $soc->id; + + if ( $contact->create($user) > 0) + { + + } + else + { + $error = 1024; + } + } + + + if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok' && !$error) + { + $rib->socid = $soc->id; + if ( $rib->update($user) > 0) + { + + } + else + { + $error = 1025; + } + } + + if (!$error && $verif == "ok") + { + $contrat = new TelephonieContrat($db); + + $contrat->client_comm = $soc->id; + $contrat->client = $soc->id; + $contrat->client_facture = $soc->id; + $contrat->commercial_sign = $_POST["commercial_sign"]; + + if ( $contrat->create($user,'oui',$_POST["mode_paiement"]) == 0) + { + $contrat->add_contact_facture($contact->id); + } + else + { + $error = 1026; + } + } + + if(!$error && $verif == "ok") + { + $contrat->commercial_sign_id = $_POST["commercial_sign"]; + $contrat->addpo($_POST["montantpo"], $user); + } + + /* Ligne 1 */ + + $ligne = new LigneTel($db); + $ligne->contrat = $contrat->id; + $ligne->numero = "0".$_POST["cli"]; + $ligne->client_comm = $soc->id; + $ligne->client = $soc->id; + $ligne->client_facture = $soc->id; + $ligne->fournisseur = $_POST["fournisseur"]; + $ligne->commercial_sign = $_POST["commercial_sign"]; + $ligne->commercial_suiv = $_POST["commercial_sign"]; + $ligne->concurrent = $_POST["concurrent"]; + $ligne->remise = "0"; + $ligne->note = $_POST["note"]; + + if(!$error && $verif == "ok") + { + if (strlen(trim($_POST["cli"])) == 9) + { + if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) - { - - } + { + + } else - { - $error = 1027; - $mesg.= "Impossible de créer la ligne #1 0".$_POST["cli"]; - } + { + $error = 1027; + $mesg.= "Impossible de créer la ligne #1 0".$_POST["cli"]; + } + } } - } - - /* SDA */ - if(!$error && $verif == "ok") - { - if (strlen(trim($_POST["cli"])) == 9 && strlen(trim($_POST["cliend"])) == 9) + /* SDA */ + + if(!$error && $verif == "ok") { + if (strlen(trim($_POST["cli"])) == 9 && strlen(trim($_POST["cliend"])) == 9) + { $cbegin = trim($_POST["cli"]) + 1; $cend = trim($_POST["cliend"]); $cli = $cbegin; while ($cli <= $cend) - { - $ligne = new LigneTel($db); - $ligne->contrat = $contrat->id; - $ligne->numero = "0".$cli; - $ligne->client_comm = $soc->id; - $ligne->client = $soc->id; - $ligne->client_facture = $soc->id; - $ligne->fournisseur = $_POST["fournisseur"]; - $ligne->commercial_sign = $_POST["commercial_sign"]; - $ligne->commercial_suiv = $_POST["commercial_sign"]; - $ligne->concurrent = $_POST["concurrent"]; - $ligne->remise = "0"; - $ligne->note = $_POST["note"]; - - if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) - { - + { + $ligne = new LigneTel($db); + $ligne->contrat = $contrat->id; + $ligne->numero = "0".$cli; + $ligne->client_comm = $soc->id; + $ligne->client = $soc->id; + $ligne->client_facture = $soc->id; + $ligne->fournisseur = $_POST["fournisseur"]; + $ligne->commercial_sign = $_POST["commercial_sign"]; + $ligne->commercial_suiv = $_POST["commercial_sign"]; + $ligne->concurrent = $_POST["concurrent"]; + $ligne->remise = "0"; + $ligne->note = $_POST["note"]; + + if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) + { + + } + else + { + $error = 1027; + $mesg.= "Impossible de créer la ligne 0$cli"; + } + + $cli++; + } } - else + } + + /* Ligne 2 */ + + $ligne = new LigneTel($db); + $ligne->contrat = $contrat->id; + $ligne->numero = "0".$_POST["cli2"]; + $ligne->client_comm = $soc->id; + $ligne->client = $soc->id; + $ligne->client_facture = $soc->id; + $ligne->fournisseur = $_POST["fournisseur"]; + $ligne->commercial_sign = $_POST["commercial_sign"]; + $ligne->commercial_suiv = $_POST["commercial_sign"]; + $ligne->concurrent = $_POST["concurrent"]; + $ligne->remise = "0"; + $ligne->note = $_POST["note"]; + + if(!$error && $verif == "ok") + { + if (strlen(trim($_POST["cli2"])) == 9) { - $error = 1027; - $mesg.= "Impossible de créer la ligne 0$cli"; + + if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) + { + + } + else + { + //$error++; + $error = 1028; + $mesg.= "Impossible de créer la ligne #2 0".$_POST["cli2"]; + } } - - $cli++; - } } - } - - /* Ligne 2 */ - $ligne = new LigneTel($db); - $ligne->contrat = $contrat->id; - $ligne->numero = "0".$_POST["cli2"]; - $ligne->client_comm = $soc->id; - $ligne->client = $soc->id; - $ligne->client_facture = $soc->id; - $ligne->fournisseur = $_POST["fournisseur"]; - $ligne->commercial_sign = $_POST["commercial_sign"]; - $ligne->commercial_suiv = $_POST["commercial_sign"]; - $ligne->concurrent = $_POST["concurrent"]; - $ligne->remise = "0"; - $ligne->note = $_POST["note"]; - - if(!$error && $verif == "ok") - { - if (strlen(trim($_POST["cli2"])) == 9) + /* Ligne 3 */ + $ligne = new LigneTel($db); + $ligne->contrat = $contrat->id; + $ligne->numero = "0".$_POST["cli3"]; + $ligne->client_comm = $soc->id; + $ligne->client = $soc->id; + $ligne->client_facture = $soc->id; + $ligne->fournisseur = $_POST["fournisseur"]; + $ligne->commercial_sign = $_POST["commercial_sign"]; + $ligne->commercial_suiv = $_POST["commercial_sign"]; + $ligne->concurrent = $_POST["concurrent"]; + $ligne->remise = "0"; + $ligne->note = $_POST["note"]; + + if(!$error && $verif == "ok") { - + if (strlen(trim($_POST["cli3"])) == 9) + { + if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) - { - - } + { + + } else - { - //$error++; - $error = 1028; - $mesg.= "Impossible de créer la ligne #2 0".$_POST["cli2"]; - } + { + //$error++; + $error = 1029; + $mesg.= "Impossible de créer la ligne #3 0".$_POST["cli3"]; + } + } } - } - /* Ligne 3 */ - $ligne = new LigneTel($db); - $ligne->contrat = $contrat->id; - $ligne->numero = "0".$_POST["cli3"]; - $ligne->client_comm = $soc->id; - $ligne->client = $soc->id; - $ligne->client_facture = $soc->id; - $ligne->fournisseur = $_POST["fournisseur"]; - $ligne->commercial_sign = $_POST["commercial_sign"]; - $ligne->commercial_suiv = $_POST["commercial_sign"]; - $ligne->concurrent = $_POST["concurrent"]; - $ligne->remise = "0"; - $ligne->note = $_POST["note"]; - - if(!$error && $verif == "ok") - { - if (strlen(trim($_POST["cli3"])) == 9) + /* DEBUT TARIFS */ + if (strlen(trim($_POST["france"])) > 0 && $verif == "ok") { - - if ( $ligne->create($user, $_POST["mode_paiement"]) == 0) - { - - } - else - { - //$error++; - $error = 1029; - $mesg.= "Impossible de créer la ligne #3 0".$_POST["cli3"]; - } - } - } + $temporel = ereg_replace(",",".",trim($_POST["france"])); - /* DEBUT TARIFS */ - if (strlen(trim($_POST["france"])) > 0 && $verif == "ok") - { - $temporel = ereg_replace(",",".",trim($_POST["france"])); - - if (!$error) - { + if (!$error) + { $db->begin(); - + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; $sql .= " (1293,".$soc->id.",'".$temporel."','0',".$user->id.")"; - + if (! $db->query($sql) ) - { - $error++; - } - + { + $error++; + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; $sql .= " (1293,".$soc->id.",'".$temporel."','0',".$user->id.",now())"; - + if (! $db->query($sql) ) - { - $error++; - } - + { + $error++; + } + if ( $error == 0 ) - { - $db->commit(); - } + { + $db->commit(); + } else - { - $db->rollback(); - $mesg = "Erreur tarifs !"; - } + { + $db->rollback(); + $mesg = "Erreur tarifs !"; + } + } } - } - /* mobiles */ - if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok") - { - $mobil_ids = array(1289,1290,1291,1292); - foreach ($mobil_ids as $mobil_id) + /* mobiles */ + if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok") { + $mobil_ids = array(1289,1290,1291,1292); + foreach ($mobil_ids as $mobil_id) + { $temporel = ereg_replace(",",".",trim($_POST["mobil"])); - + if (!$error) - { - $db->begin(); - - $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; - $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; - $sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")"; - - if (! $db->query($sql) ) - { - $error++; + { + $db->begin(); + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; + $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; + $sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")"; + + if (! $db->query($sql) ) + { + $error++; + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; + $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; + $sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())"; + + if (! $db->query($sql) ) + { + $error++; + } + + if ( $error == 0 ) + { + $db->commit(); + } + else + { + $db->rollback(); + $mesg = "Erreur tarifs !"; + } + } } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; - $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; - $sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())"; - - if (! $db->query($sql) ) - { - $error++; - } - - if ( $error == 0 ) - { - $db->commit(); - } - else - { - $db->rollback(); - $mesg = "Erreur tarifs !"; - } - } } - } - /* FIN TARIFS */ + /* FIN TARIFS */ + + if (!$error && $verif == "ok") + { + Header("Location: ".DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id); + } + else + { + $mesg .= " (numéro erreur : $error)"; + } - if (!$error && $verif == "ok") - { - Header("Location: ".DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id); - } - else - { - $mesg .= " (numéro erreur : $error)"; - } - } /** @@ -618,243 +619,243 @@ $form = new Form($db); if ($user->rights->telephonie->ligne->creer) { - dolibarr_fiche_head($head, $hselected, 'Nouveau client'); - /* + dolibarr_fiche_head($head, $hselected, 'Nouveau client'); + /* - */ + */ - if ($mesg) - { - print '
'; - print $mesg; - print '
'; - } - else - { - - } - - $focus = " onfocus=\"this.className='focus';\" onblur=\"this.className='normal';\" "; - - - print '
'; - print ''; - print ''; - print ''; - - print '
'; - print '
'; - print "Société\n"; - - print ''; - - print '"; - - // On positionne pays_id, pays_code et libelle du pays choisi - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:''); - if ($soc->pays_id) - { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; - $resql=$db->query($sql); - if ($resql) + if ($mesg) { - $obj = $db->fetch_object($resql); + print '
'; + print $mesg; + print '
'; } - else + else { - dolibarr_print_error($db); + } - $soc->pays_code=$obj->code; - $soc->pays=$obj->libelle; - } - - print ''; - - print ''; - - print ''; - - print ''; - print ''; - - print "
'.$langs->trans('Name').''; - print ''; - - print "Attention ce formulaire n'est a utiliser uniquement pour les nouveaux clients.
'.$langs->trans('CustomerCode').''; - print '00
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - print ' '; - - print $langs->trans('Town').' 
'.$langs->trans('Phone').''.$langs->trans('Fax').'
\n"; - print "

\n"; - print '
'; - print "Coordonnées bancaires\n"; - print ''; - - print ''; - - print ''; - - print ''; - - print "
Titulaire du compte
RIB'; - print ''; - print ''; - print ''; - print ''; - print '  IBAN  '; - print ''; - print '
Règlement'; - print ''; - print '
\n"; - print "

\n"; - - print '
'; - print "Contact\n"; - print ''; - - print ''; - print ''; - print ''; - - print "
'.$langs->trans('Name').''.$langs->trans('Firstname').'
'.$langs->trans('Mail').'
\n"; - print "

\n"; - - print '
'; - print "Commercial\n"; - print ''; - print ''; - - print ''; - print ''; - - print "
Commercial Signature'; - $ff = array(); - $sql = "SELECT u.rowid, u.firstname, u.name"; - $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql .= " WHERE u.rowid = ug.fk_user"; - $sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'"; - $sql .= " ORDER BY name "; - if ( $db->query( $sql) ) - { - $num = $db->num_rows(); - if ( $num > 0 ) - { - while ($row = $db->fetch_row($resql)) - { - $ff[$row[0]] = $row[1] . " " . $row[2]; - } - } - $db->free(); - - } - - $form->select_array("commercial_sign",$ff,$ligne->commercial_sign); - - print 'PO mensuelle'; - print ' euros HT
\n"; - print "

\n"; - - print '
'; - print "Lignes téléphoniques à présélectionner\n"; - - print ''; - - print ''; - - print ''; + $focus = " onfocus=\"this.className='focus';\" onblur=\"this.className='normal';\" "; - - print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print '
'; + print '
'; + print "Société\n"; - print '
'; - - print ''; - - print "
Ligne téléphonique #10Derniere SDA0
Ligne téléphonique #20
Ligne téléphonique #30
Fournisseur'; - $ff = array(); - $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom "; - $resql = $db->query($sql); - if ($resql) - { - while ($row = $db->fetch_row($resql)) - { - $ff[$row[0]] = $row[1]; - } - $db->free($resql); - } - - $def =$ligne->fournisseur?$ligne->fournisseur:TELEPHONIE_FOURNISSEUR_DEFAUT_ID; - - $form->select_array("fournisseur",$ff,$def); - print 'Fournisseur précédent'; - $ff = array(); - $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid "; - $resql = $db->query( $sql) ; - if ($resql) - { - $num = $db->num_rows($resql); - if ( $num > 0 ) - { - while ($row = $db->fetch_row($resql)) - { - $ff[$row[0]] = $row[1]; - } - } - $db->free(); - - } - $form->select_array("concurrent",$ff,$ligne->concurrent); - print '
\n"; - print "

\n"; - - /* DEBUT TARIFS */ - - print '
'; - print "Tarifs\n"; - if ($user->rights->telephonie->tarif->client_modifier) - { print ''; - - print ''; - - print ''; - + + print '"; + + // On positionne pays_id, pays_code et libelle du pays choisi + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:''); + if ($soc->pays_id) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dolibarr_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$obj->libelle; + } + + print ''; + + print ''; + + print ''; + + print ''; + print ''; + print "
FranceLaissez vide si tarifs par défaut
MobilesTous réseaux confondus
'.$langs->trans('Name').''; + print ''; + + print "Attention ce formulaire n'est a utiliser uniquement pour les nouveaux clients.
'.$langs->trans('CustomerCode').''; + + print '00
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; + print ' '; + + print $langs->trans('Town').' 
'.$langs->trans('Phone').''.$langs->trans('Fax').'
\n"; - } - else - { - print "Vous n'avez pas les droits pour modifier les tarifs"; - } - print "

\n"; + print "
\n"; + print '
'; + print "Coordonnées bancaires\n"; + print ''; - /* FIN TARIFS */ + print ''; - print ''."\n"; - - print ''."\n"; - print "\n"; + print ''; + + print ''; + + print "
Titulaire du compte
RIB'; + print ''; + print ''; + print ''; + print ''; + print '  IBAN  '; + print ''; + print '
Règlement'; + print ''; + print '
\n"; + print "

\n"; + + print '
'; + print "Contact\n"; + print ''; + + print ''; + print ''; + print ''; + + print "
'.$langs->trans('Name').''.$langs->trans('Firstname').'
'.$langs->trans('Mail').'
\n"; + print "

\n"; + + print '
'; + print "Commercial\n"; + print ''; + print ''; + + print ''; + print ''; + + print "
Commercial Signature'; + $ff = array(); + $sql = "SELECT u.rowid, u.firstname, u.name"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE u.rowid = ug.fk_user"; + $sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'"; + $sql .= " ORDER BY name "; + if ( $db->query( $sql) ) + { + $num = $db->num_rows(); + if ( $num > 0 ) + { + while ($row = $db->fetch_row($resql)) + { + $ff[$row[0]] = $row[1] . " " . $row[2]; + } + } + $db->free(); + + } + + $form->select_array("commercial_sign",$ff,$ligne->commercial_sign); + + print 'PO mensuelle'; + print ' euros HT
\n"; + print "

\n"; + + print '
'; + print "Lignes téléphoniques à présélectionner\n"; + + print ''; + + print ''; + + print ''; + + + + print ''; + + print ''; + + print ''; + + print ''; + + print "
Ligne téléphonique #10Derniere SDA0
Ligne téléphonique #20
Ligne téléphonique #30
Fournisseur'; + $ff = array(); + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom "; + $resql = $db->query($sql); + if ($resql) + { + while ($row = $db->fetch_row($resql)) + { + $ff[$row[0]] = $row[1]; + } + $db->free($resql); + } + + $def =$ligne->fournisseur?$ligne->fournisseur:TELEPHONIE_FOURNISSEUR_DEFAUT_ID; + + $form->select_array("fournisseur",$ff,$def); + print 'Fournisseur précédent'; + $ff = array(); + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid "; + $resql = $db->query( $sql) ; + if ($resql) + { + $num = $db->num_rows($resql); + if ( $num > 0 ) + { + while ($row = $db->fetch_row($resql)) + { + $ff[$row[0]] = $row[1]; + } + } + $db->free(); + + } + $form->select_array("concurrent",$ff,$ligne->concurrent); + print '
\n"; + print "

\n"; + + /* DEBUT TARIFS */ + + print '
'; + print "Tarifs\n"; + if ($user->rights->telephonie->tarif->client_modifier) + { + print ''; + + print ''; + + print ''; + + print "
FranceLaissez vide si tarifs par défaut
MobilesTous réseaux confondus
\n"; + } + else + { + print "Vous n'avez pas les droits pour modifier les tarifs"; + } + print "

\n"; + + /* FIN TARIFS */ + + print ''."\n"; + + print ''."\n"; + print "
\n"; } diff --git a/htdocs/telephonie/facturation/FacturationEmission.class.php b/htdocs/telephonie/facturation/FacturationEmission.class.php index e6a9e996cea..4206b502597 100644 --- a/htdocs/telephonie/facturation/FacturationEmission.class.php +++ b/htdocs/telephonie/facturation/FacturationEmission.class.php @@ -802,7 +802,7 @@ class FacturationEmission { $fac->fetch($facid); $fac->fetch_client(); - $fac->client->rib(); + $fac->client->load_ban(); $message = ""; diff --git a/htdocs/telephonie/ligne/commande.php b/htdocs/telephonie/ligne/commande.php index 8e88ecd9a4b..4f5a569fdbe 100644 --- a/htdocs/telephonie/ligne/commande.php +++ b/htdocs/telephonie/ligne/commande.php @@ -105,11 +105,11 @@ if ($_GET["id"] or $_GET["numero"]) } print ''; - print "'; - print "'; + print "'; + print "'; print "'; print "'; - print "'; + print "'; print '
Num�ro correct ".$ok_commande .'
Commandes ouvertes aupr�s du fournisseur ".$ftx->commande_enable .'
Numero correct ".$ok_commande .'
Commandes ouvertes aupres du fournisseur ".$ftx->commande_enable .'
Permission pour l'utilisateur de commander des lignes ".$user->rights->telephonie->ligne_commander.'
Statut de la ligne compatible ".($ligne->statut == 1 or $ligne->statut == -1) .'
Rib ok ou mode de r�glement par virement ".($client_facture->verif_rib() or $ligne->mode_paiement == 'vir').'
Rib ok ou mode de reglement par virement ".($client_facture->verif_rib() or $ligne->mode_paiement == 'vir').'
'; } @@ -121,5 +121,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/telephonie/script/facturation-emission.php b/htdocs/telephonie/script/facturation-emission.php index a0b10ce6853..b6ba051290a 100644 --- a/htdocs/telephonie/script/facturation-emission.php +++ b/htdocs/telephonie/script/facturation-emission.php @@ -788,7 +788,7 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact $fac->fetch($facid); $fac->fetch_client(); - $fac->client->rib(); + $fac->client->load_ban(); $message = ""; @@ -809,7 +809,8 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact if (!$error && !$cancel_facture) { - $db->query("COMMIT"); + $db->commit(); + /* $soc * $ligne */ @@ -832,8 +833,7 @@ function facture_contrat($db, $user, $contrat_id, $factel_ids, $datetime, &$fact } else { - $db->query("ROLLBACK"); - dolibarr_syslog("ROLLBACK de la transaction $error"); + $db->rollback(); } }