From cc5556872378b04333f2cb16b95a73b2f57d1919 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Aug 2010 16:47:17 +0000 Subject: [PATCH] Replace javascript by jQuery --- htdocs/adherents/card_subscriptions.php | 4 +- htdocs/adherents/fiche.php | 30 +- htdocs/admin/company.php | 14 +- htdocs/compta/bank/fiche.php | 28 +- htdocs/contact/fiche.php | 28 +- htdocs/core/class/html.form.class.php | 6 +- .../barcode/html.formbarcode.class.php | 29 +- .../modules/barcode/admin/barcode.php | 1 + htdocs/lib/lib_head.js | 40 - htdocs/societe/soc.php | 1967 +++++++++-------- 10 files changed, 1109 insertions(+), 1038 deletions(-) diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 0babb24352e..7ab25dd2f20 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -378,7 +378,7 @@ if ($action == 'addsubscription' && $user->rights->adherent->cotisation->creer) if ($conf->use_javascript_ajax) { - print ''; + print ''."\n"; } print '
'; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index b704c3d3c09..5736dfa240a 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -665,6 +665,20 @@ if ($action == 'create') } if ($mesg) print '
'.$mesg.'
'; + + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print ''; print ''; print ''; @@ -733,7 +747,7 @@ if ($action == 'create') // Country $adh->pays_id=$adh->pays_id?$adh->pays_id:$mysoc->pays_id; print ''.$langs->trans("Country").''; - $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + $html->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$adh->pays_id,'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -850,6 +864,18 @@ if ($action == 'edit') if ($mesg) print '
'.$mesg.'
'; + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + $rowspan=17; $rowspan+=sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; @@ -929,7 +955,7 @@ if ($action == 'edit') // Country print ''.$langs->trans("Country").''; - $html->select_pays(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id,'pays',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + $html->select_pays(isset($_POST["pays"])?$_POST["pays"]:$adh->pays_id,'pays'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 02c1c272bd0..3a35c59f42d 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -267,6 +267,14 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit') /** * Edition des parametres */ + print "\n".''."\n"; print ''; print ''; @@ -292,11 +300,12 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit') print ''.$langs->trans("CompanyTown").''; print ''."\n"; + // Country $var=!$var; print ''.$langs->trans("Country").''; $pays_selected=$pays_id; //if (empty($pays_selected)) $pays_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - $form->select_pays($pays_selected,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); + $form->select_pays($pays_selected,'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''."\n"; @@ -362,8 +371,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit') print ''; print ''; - - + // Note $var=!$var; print ''.$langs->trans("Note").''; print ''; diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index a6daa794784..37e14695111 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -181,6 +181,18 @@ if ($_REQUEST["action"] == 'create') if ($message) { print "$message
\n"; } + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + print ''; print ''; print ''; @@ -238,7 +250,7 @@ if ($_REQUEST["action"] == 'create') $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$account->pays_code; } else if (empty($selectedcode)) $selectedcode=$mysoc->pays_code; - $form->select_pays($selectedcode,'account_country_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + $form->select_pays($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -448,6 +460,18 @@ else if ($message) { print "$message
\n"; } + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + print ''; print ''; print ''; @@ -494,7 +518,7 @@ else $selectedcode=$account->pays_code; if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; else if (empty($selectedcode)) $selectedcode=$mysoc->pays_code; - $form->select_pays($selectedcode,'account_country_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + $form->select_pays($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 2ddc89814bd..87e2958602b 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -300,6 +300,18 @@ if ($user->rights->societe->contact->creer) // Affiche les erreurs dol_htmloutput_errors($mesg,$errors); + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + print '
'; print ''; print ''; @@ -346,7 +358,7 @@ if ($user->rights->societe->contact->creer) // Country if (dol_strlen(trim($contact->fk_pays)) == 0) $contact->fk_pays = $objsoc->pays_id; // Predefined with third party print ''.$langs->trans("Country").''; - $form->select_pays((isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays),'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + $form->select_pays((isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays),'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -418,6 +430,18 @@ if ($user->rights->societe->contact->creer) // Affiche les erreurs dol_htmloutput_errors($mesg,$errors); + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + print ''; print ''; print ''; @@ -459,7 +483,7 @@ if ($user->rights->societe->contact->creer) // Country print ''.$langs->trans("Country").''; - $form->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + $form->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays,'pays_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 379e117df8b..d54837f8ff8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -274,7 +274,7 @@ class Form $resql=$this->db->query($sql); if ($resql) { - print ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -1569,7 +1569,7 @@ class Form $this->load_cache_types_paiements(); - print ''; if ($empty) print ''; foreach($this->cache_types_paiements as $id => $arraytypes) { @@ -1710,7 +1710,7 @@ class Form $i = 0; if ($num) { - print ''; if ($useempty) { print ''; diff --git a/htdocs/includes/barcode/html.formbarcode.class.php b/htdocs/includes/barcode/html.formbarcode.class.php index 8f2fe10f0e8..5ff233d6b41 100644 --- a/htdocs/includes/barcode/html.formbarcode.class.php +++ b/htdocs/includes/barcode/html.formbarcode.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008 Laurent Destailleur + * Copyright (C) 2008-2010 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,17 +20,16 @@ */ /** - \file htdocs/core/class/html.form.class.php - \brief Fichier de la classe des fonctions pr�d�finie de composants html + \file htdocs/includes/barcode/html.formbarcode.class.php + \brief Fichier de la classe des fonctions predefinie de composants html \version $Revision$ */ /** \class Form - \brief Classe permettant la g�n�ration de composants html + \brief Classe permettant la generation de composants html */ - class FormBarCode { var $db; @@ -63,6 +62,20 @@ class FormBarCode $disable = ''; + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + //onChange="barcode_coder_save(\''.$idForm.'\') + } + // We check if barcode is already selected by default if ((($conf->product->enabled || $conf->service->enabled) && $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE == $code_id) || ($conf->societe->enabled && $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY == $code_id)) @@ -70,11 +83,11 @@ class FormBarCode $disable = 'disabled="disabled"'; } - $select_encoder = ''; + $select_encoder = ''; $select_encoder.= ''; $select_encoder.= ''; $select_encoder.= ''; - $select_encoder.= ''; $select_encoder.= ''; $select_encoder.= ''; foreach($barcodelist as $key => $value) @@ -100,7 +113,7 @@ class FormBarCode $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql.= " WHERE coder <> '0'"; $sql.= " AND entity = ".$conf->entity; - $sql.= " ORDER BY rowid"; + $sql.= " ORDER BY code"; $result = $this->db->query($sql); if ($result) diff --git a/htdocs/includes/modules/barcode/admin/barcode.php b/htdocs/includes/modules/barcode/admin/barcode.php index c417d60b92b..47e095b2cb8 100644 --- a/htdocs/includes/modules/barcode/admin/barcode.php +++ b/htdocs/includes/modules/barcode/admin/barcode.php @@ -140,6 +140,7 @@ print "\n"; $sql = "SELECT rowid, code as encoding, libelle, coder, example"; $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql.= " WHERE entity = ".$conf->entity; +$sql.= " ORDER BY code"; dol_syslog("admin/barcode.php sql=".$sql); $resql=$db->query($sql); diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index c5e5b6b6aef..0b9eb29f52e 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -11,20 +11,6 @@ // -/*================================================================= - Purpose: Resubmit page when barcode choice is changed (admin page) - Input: formNameID - Author: Laurent Destailleur - Licence: GPL -==================================================================*/ -function barcode_coder_save(formNameID) -{ - var formName = document.getElementById(formNameID); - formName.action.value='setcoder'; - formName.submit(); -} - - /*================================================================= Purpose: Pour la fonction de saisie auto des villes Input: postalcode,objecttown,objectcountry,objectstate @@ -43,32 +29,6 @@ function autofilltownfromzip_PopupPostalCode(url_root, postalcode,objecttown,obj } -/*================================================================= -Purpose: To resubmit pages when country is changed -Input: postalcode,objecttown,objectcountry,objectstate -Author: Eric Seigne -Licence: GPL -==================================================================*/ -function company_save_refresh_edit() -{ - document.formsoc.action.value="edit"; - document.formsoc.submit(); -} - -function company_save_refresh_create() -{ - document.formsoc.action.value="create"; - document.formsoc.submit(); -} - -function company_save_refresh() -{ - document.form_index.action.value="updateedit"; - document.form_index.submit(); -} - - - /*================================================================= Purpose: Pour la saisie des dates par calendrier Input: base "/theme/eldy" diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 92d7fc4e48f..66a4dd61449 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -59,236 +59,236 @@ $soc = new Societe($db); if ($_POST["getcustomercode"]) { - // We defined value code_client - $_POST["code_client"]="Acompleter"; + // We defined value code_client + $_POST["code_client"]="Acompleter"; } if ($_POST["getsuppliercode"]) { - // We defined value code_fournisseur - $_POST["code_fournisseur"]="Acompleter"; + // We defined value code_fournisseur + $_POST["code_fournisseur"]="Acompleter"; } // Add new third party if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) { - require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); - $error=0; + require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); + $error=0; - if ($_POST["action"] == 'update') - { - // Load properties of company - $soc->fetch($socid); - } + if ($_POST["action"] == 'update') + { + // Load properties of company + $soc->fetch($socid); + } - if ($_REQUEST["private"] == 1) - { - $soc->particulier = $_REQUEST["private"]; + if ($_REQUEST["private"] == 1) + { + $soc->particulier = $_REQUEST["private"]; - $soc->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]); - $soc->nom_particulier = $_POST["nom"]; - $soc->prenom = $_POST["prenom"]; - $soc->civilite_id = $_POST["civilite_id"]; - } - else - { - $soc->nom = $_POST["nom"]; - } - $soc->address = $_POST["adresse"]; - $soc->adresse = $_POST["adresse"]; // TODO obsolete - $soc->cp = $_POST["cp"]; - $soc->ville = $_POST["ville"]; - $soc->pays_id = $_POST["pays_id"]; - $soc->departement_id = $_POST["departement_id"]; - $soc->tel = $_POST["tel"]; - $soc->fax = $_POST["fax"]; - $soc->email = trim($_POST["email"]); - $soc->url = $_POST["url"]; - $soc->siren = $_POST["idprof1"]; - $soc->siret = $_POST["idprof2"]; - $soc->ape = $_POST["idprof3"]; - $soc->idprof4 = $_POST["idprof4"]; - $soc->prefix_comm = $_POST["prefix_comm"]; - $soc->code_client = $_POST["code_client"]; - $soc->code_fournisseur = $_POST["code_fournisseur"]; - $soc->capital = $_POST["capital"]; - $soc->gencod = $_POST["gencod"]; + $soc->nom = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]); + $soc->nom_particulier = $_POST["nom"]; + $soc->prenom = $_POST["prenom"]; + $soc->civilite_id = $_POST["civilite_id"]; + } + else + { + $soc->nom = $_POST["nom"]; + } + $soc->address = $_POST["adresse"]; + $soc->adresse = $_POST["adresse"]; // TODO obsolete + $soc->cp = $_POST["cp"]; + $soc->ville = $_POST["ville"]; + $soc->pays_id = $_POST["pays_id"]; + $soc->departement_id = $_POST["departement_id"]; + $soc->tel = $_POST["tel"]; + $soc->fax = $_POST["fax"]; + $soc->email = trim($_POST["email"]); + $soc->url = $_POST["url"]; + $soc->siren = $_POST["idprof1"]; + $soc->siret = $_POST["idprof2"]; + $soc->ape = $_POST["idprof3"]; + $soc->idprof4 = $_POST["idprof4"]; + $soc->prefix_comm = $_POST["prefix_comm"]; + $soc->code_client = $_POST["code_client"]; + $soc->code_fournisseur = $_POST["code_fournisseur"]; + $soc->capital = $_POST["capital"]; + $soc->gencod = $_POST["gencod"]; - $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_assuj = $_POST["assujtva_value"]; - // Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + // Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - $soc->tva_intra = $_POST["tva_intra"]; + $soc->tva_intra = $_POST["tva_intra"]; - $soc->forme_juridique_code = $_POST["forme_juridique_code"]; - $soc->effectif_id = $_POST["effectif_id"]; - if ($_REQUEST["private"] == 1) - { - $soc->typent_id = 8; // TODO predict another method if the field "special" change of rowid - } - else - { - $soc->typent_id = $_POST["typent_id"]; - } - $soc->client = $_POST["client"]; - $soc->fournisseur = $_POST["fournisseur"]; - $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; + $soc->forme_juridique_code = $_POST["forme_juridique_code"]; + $soc->effectif_id = $_POST["effectif_id"]; + if ($_REQUEST["private"] == 1) + { + $soc->typent_id = 8; // TODO predict another method if the field "special" change of rowid + } + else + { + $soc->typent_id = $_POST["typent_id"]; + } + $soc->client = $_POST["client"]; + $soc->fournisseur = $_POST["fournisseur"]; + $soc->fournisseur_categorie = $_POST["fournisseur_categorie"]; - $soc->commercial_id = $_POST["commercial_id"]; - $soc->default_lang = $_POST["default_lang"]; + $soc->commercial_id = $_POST["commercial_id"]; + $soc->default_lang = $_POST["default_lang"]; - // Check parameters - if (empty($_POST["cancel"])) - { - if (! empty($soc->email) && ! isValidEMail($soc->email)) - { - $error = 1; - $langs->load("errors"); - $soc->error = $langs->trans("ErrorBadEMail",$soc->email); - $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; - } - if (! empty($soc->url) && ! isValidUrl($soc->url)) - { - $error = 1; - $langs->load("errors"); - $soc->error = $langs->trans("ErrorBadUrl",$soc->url); - $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; - } - if ($soc->fournisseur && ! $conf->fournisseur->enabled) - { - $error = 1; - $langs->load("errors"); - $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled"); - $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; - } - } + // Check parameters + if (empty($_POST["cancel"])) + { + if (! empty($soc->email) && ! isValidEMail($soc->email)) + { + $error = 1; + $langs->load("errors"); + $soc->error = $langs->trans("ErrorBadEMail",$soc->email); + $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; + } + if (! empty($soc->url) && ! isValidUrl($soc->url)) + { + $error = 1; + $langs->load("errors"); + $soc->error = $langs->trans("ErrorBadUrl",$soc->url); + $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; + } + if ($soc->fournisseur && ! $conf->fournisseur->enabled) + { + $error = 1; + $langs->load("errors"); + $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled"); + $_GET["action"] = $_POST["action"]=='add'?'create':'edit'; + } + } - if (! $error) - { - if ($_POST["action"] == 'add') - { - $db->begin(); + if (! $error) + { + if ($_POST["action"] == 'add') + { + $db->begin(); - if (empty($soc->client)) $soc->code_client=''; - if (empty($soc->fournisseur)) $soc->code_fournisseur=''; + if (empty($soc->client)) $soc->code_client=''; + if (empty($soc->fournisseur)) $soc->code_fournisseur=''; - $result = $soc->create($user); - if ($result >= 0) - { - if ($soc->particulier) - { - dol_syslog("This thirdparty is a personal people",LOG_DEBUG); - $contact=new Contact($db); + $result = $soc->create($user); + if ($result >= 0) + { + if ($soc->particulier) + { + dol_syslog("This thirdparty is a personal people",LOG_DEBUG); + $contact=new Contact($db); - $contact->civilite_id = $soc->civilite_id; - $contact->name=$soc->nom_particulier; - $contact->firstname=$soc->prenom; - $contact->address=$soc->address; - $contact->cp=$soc->cp; - $contact->ville=$soc->ville; - $contact->fk_pays=$soc->fk_pays; - $contact->socid=$soc->id; // fk_soc - $contact->status=1; - $contact->email=$soc->email; - $contact->priv=0; + $contact->civilite_id = $soc->civilite_id; + $contact->name=$soc->nom_particulier; + $contact->firstname=$soc->prenom; + $contact->address=$soc->address; + $contact->cp=$soc->cp; + $contact->ville=$soc->ville; + $contact->fk_pays=$soc->fk_pays; + $contact->socid=$soc->id; // fk_soc + $contact->status=1; + $contact->email=$soc->email; + $contact->priv=0; - $result=$contact->create($user); - } - } - else - { - $mesg=$soc->error; - } + $result=$contact->create($user); + } + } + else + { + $mesg=$soc->error; + } - if ($result >= 0) - { - $db->commit(); + if ($result >= 0) + { + $db->commit(); - if ( $soc->client == 1 ) - { - Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id); - return; - } - else - { - if ( $soc->fournisseur == 1 ) - { - Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id); - return; - } - else - { - Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$soc->id); - return; - } - } - exit; - } - else - { - $db->rollback(); + if ( $soc->client == 1 ) + { + Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id); + return; + } + else + { + if ( $soc->fournisseur == 1 ) + { + Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id); + return; + } + else + { + Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$soc->id); + return; + } + } + exit; + } + else + { + $db->rollback(); - $langs->load("errors"); - $mesg=$langs->trans($soc->error); - $_GET["action"]='create'; - } - } + $langs->load("errors"); + $mesg=$langs->trans($soc->error); + $_GET["action"]='create'; + } + } - if ($_POST["action"] == 'update') - { - if ($_POST["cancel"]) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; - } + if ($_POST["action"] == 'update') + { + if ($_POST["cancel"]) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } - $oldsoc=new Societe($db); - $result=$oldsoc->fetch($socid); + $oldsoc=new Societe($db); + $result=$oldsoc->fetch($socid); - // To not set code if third party is not concerned. But if it had values, we keep them. - if (empty($soc->client) && empty($oldsoc->code_client)) $soc->code_client=''; - if (empty($soc->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->code_fournisseur=''; - //var_dump($soc);exit; + // To not set code if third party is not concerned. But if it had values, we keep them. + if (empty($soc->client) && empty($oldsoc->code_client)) $soc->code_client=''; + if (empty($soc->fournisseur)&& empty($oldsoc->code_fournisseur)) $soc->code_fournisseur=''; + //var_dump($soc);exit; - $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); - if ($result >= 0) - { - Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); - exit; - } - else - { - $soc->id = $socid; - $reload = 0; + $result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable()); + if ($result >= 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); + exit; + } + else + { + $soc->id = $socid; + $reload = 0; - $mesg = $soc->error; - $_GET["action"]= "edit"; - } - } - } + $mesg = $soc->error; + $_GET["action"]= "edit"; + } + } + } } if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->supprimer) { - $soc = new Societe($db); - $soc->fetch($socid); - $result = $soc->delete($socid); + $soc = new Societe($db); + $soc->fetch($socid); + $result = $soc->delete($socid); - if ($result >= 0) - { - Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$soc->nom.""); - exit; - } - else - { - $reload = 0; - $langs->load("errors"); - $mesg=$langs->trans($soc->error); - $_GET["action"]=''; - } + if ($result >= 0) + { + Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$soc->nom.""); + exit; + } + else + { + $reload = 0; + $langs->load("errors"); + $mesg=$langs->trans($soc->error); + $_GET["action"]=''; + } } @@ -297,46 +297,46 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && */ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { - if (is_numeric($_REQUEST['model'])) - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); - } - else - { - require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); + if (is_numeric($_REQUEST['model'])) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model")); + } + else + { + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php'); - $soc = new Societe($db); - $soc->fetch($socid); - $soc->fetch_thirdparty(); + $soc = new Societe($db); + $soc->fetch($socid); + $soc->fetch_thirdparty(); - /*if ($_REQUEST['model']) - { - $fac->setDocModel($user, $_REQUEST['model']); - } - */ + /*if ($_REQUEST['model']) + { + $fac->setDocModel($user, $_REQUEST['model']); + } + */ - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } - } + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$fac->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=thirdparty_doc_create($db, $soc->id, '', $_REQUEST['model'], $outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + Header ('Location: '.$_SERVER["PHP_SELF"].'?socid='.$soc->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } + } } @@ -358,101 +358,100 @@ $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("Se if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] || $_GET["action"] == 'create' || $_POST["action"] == 'create') { - /* - * Sheet mode creation - */ - if ($user->rights->societe->creer) - { - // Load object modCodeTiers - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeClient = new $module; - $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; - if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeFournisseur = new $module; + /* + * Sheet mode creation + */ + if ($user->rights->societe->creer) + { + // Load object modCodeTiers + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeClient = new $module; + $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; + if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeFournisseur = new $module; - /* - * Company Fact creation mode - */ - if ($_GET["type"]=='f') { $soc->fournisseur=1; } - if ($_GET["type"]=='c') { $soc->client=1; } - if ($_GET["type"]=='p') { $soc->client=2; } - if ($_GET["type"]=='cp') { $soc->client=3; } - if ($_REQUEST["private"]==1) { $soc->particulier=1; } + /* + * Company Fact creation mode + */ + if ($_GET["type"]=='f') { $soc->fournisseur=1; } + if ($_GET["type"]=='c') { $soc->client=1; } + if ($_GET["type"]=='p') { $soc->client=2; } + if ($_GET["type"]=='cp') { $soc->client=3; } + if ($_REQUEST["private"]==1) { $soc->particulier=1; } - $soc->nom=$_POST["nom"]; - $soc->prenom=$_POST["prenom"]; - $soc->particulier=$_REQUEST["private"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]?$_POST["client"]:$soc->client; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->fournisseur; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; - $soc->address=$_POST["adresse"]; // TODO obsolete - $soc->cp=$_POST["cp"]; - $soc->ville=$_POST["ville"]; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->email=$_POST["email"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->gencod=$_POST["gencod"]; - $soc->siren=$_POST["idprof1"]; - $soc->siret=$_POST["idprof2"]; - $soc->ape=$_POST["idprof3"]; - $soc->idprof4=$_POST["idprof4"]; - $soc->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':''); - $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':''); + $soc->nom=$_POST["nom"]; + $soc->prenom=$_POST["prenom"]; + $soc->particulier=$_REQUEST["private"]; + $soc->prefix_comm=$_POST["prefix_comm"]; + $soc->client=$_POST["client"]?$_POST["client"]:$soc->client; + $soc->code_client=$_POST["code_client"]; + $soc->fournisseur=$_POST["fournisseur"]?$_POST["fournisseur"]:$soc->fournisseur; + $soc->code_fournisseur=$_POST["code_fournisseur"]; + $soc->adresse=$_POST["adresse"]; + $soc->address=$_POST["adresse"]; // TODO obsolete + $soc->cp=$_POST["cp"]; + $soc->ville=$_POST["ville"]; + $soc->departement_id=$_POST["departement_id"]; + $soc->tel=$_POST["tel"]; + $soc->fax=$_POST["fax"]; + $soc->email=$_POST["email"]; + $soc->url=$_POST["url"]; + $soc->capital=$_POST["capital"]; + $soc->gencod=$_POST["gencod"]; + $soc->siren=$_POST["idprof1"]; + $soc->siret=$_POST["idprof2"]; + $soc->ape=$_POST["idprof3"]; + $soc->idprof4=$_POST["idprof4"]; + $soc->typent_id=($_POST["typent_id"]&&!$_POST["cleartype"])?$_POST["typent_id"]:($_REQUEST["private"]?'TE_PRIVATE':''); + $soc->effectif_id=($_POST["effectif_id"]&&!$_POST["cleartype"])?$_POST["effectif_id_id"]:($_REQUEST["private"]?'EF1-5':''); - $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_assuj = $_POST["assujtva_value"]; - //Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + //Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - $soc->tva_intra=$_POST["tva_intra"]; + $soc->tva_intra=$_POST["tva_intra"]; - $soc->commercial_id=$_POST["commercial_id"]; - $soc->default_lang=$_POST["default_lang"]; + $soc->commercial_id=$_POST["commercial_id"]; + $soc->default_lang=$_POST["default_lang"]; - // We set pays_id, pays_code and label for the selected country - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - if ($soc->pays_id) - { - $sql = "SELECT code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; - $sql.= " WHERE rowid = ".$soc->pays_id; - $resql=$db->query($sql); - if ($resql) - { - $obj = $db->fetch_object($resql); - } - else - { - dol_print_error($db); - } - $soc->pays_code=$obj->code; - $soc->pays=$obj->libelle; - } + // We set pays_id, pays_code and label for the selected country + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + if ($soc->pays_id) + { + $sql = "SELECT code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; + $sql.= " WHERE rowid = ".$soc->pays_id; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$obj->libelle; + } - print_fiche_titre($langs->trans("NewCompany")); + print_fiche_titre($langs->trans("NewCompany")); - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''."\n"; + jQuery("#selectpays_id").change(function() { + document.formsoc.action.value="create"; + document.formsoc.submit(); + }); + });'; + print ''."\n"; - print "
\n"; - print $langs->trans("ThirdPartyType").':   '; - print ' '.$langs->trans("Company/Fundation"); - print '     '; - print ' '.$langs->trans("Individual"); - print ' ('.$langs->trans("ToCreateContactWithSameName").')'; - print "
\n"; - print "
\n"; - } + print "
\n"; + print $langs->trans("ThirdPartyType").':   '; + print ' '.$langs->trans("Company/Fundation"); + print '     '; + print ' '.$langs->trans("Individual"); + print ' ('.$langs->trans("ToCreateContactWithSameName").')'; + print "
\n"; + print "
\n"; + } - dol_htmloutput_errors($soc->error,$soc->errors); + dol_htmloutput_errors($soc->error,$soc->errors); - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; + print ''; + print ''; + print ''; + print ''; + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - print ''; + print '
'; - // Name, firstname - if ($soc->particulier) - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else - { - print ''; - print ''; - } + // Name, firstname + if ($soc->particulier) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + } - // Prospect/Customer - print ''; + // Prospect/Customer + print ''; - print ''; + print ''; - // Supplier - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Category - if ($soc->fournisseur) - { - $load = $soc->LoadSupplierCateg(); - if ( $load == 0) - { - if (sizeof($soc->SupplierCategories) > 0) - { - print ''; - print ''; - } - } - } + // Category + if ($soc->fournisseur) + { + $load = $soc->LoadSupplierCateg(); + if ( $load == 0) + { + if (sizeof($soc->SupplierCategories) > 0) + { + print ''; + print ''; + } + } + } - // Barcode - if ($conf->global->MAIN_MODULE_BARCODE) - { - print ''; - } + // Barcode + if ($conf->global->MAIN_MODULE_BARCODE) + { + print ''; + } - // Address - print ''; + // Address + print ''; - // Zip / Town - print ''; - print ''; + // Zip / Town + print ''; + print ''; - // Country - print ''; + // Country + print ''; - // State - print ''; + // State + print ''; - // Phone / Fax - print ''; - print ''; + // Phone / Fax + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print ''; - // IdProf1 (SIREN for France) - $idprof=$langs->transcountry('ProfId1',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf2 (SIRET for France) - $idprof=$langs->transcountry('ProfId2',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; - print ''; - // IdProf3 (APE for France) - $idprof=$langs->transcountry('ProfId3',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - // IdProf4 (NU for France) - $idprof=$langs->transcountry('ProfId4',$soc->pays_code); - if ($idprof!='-') - { - print ''; - } - else print ''; - print ''; + print ''; + // IdProf1 (SIREN for France) + $idprof=$langs->transcountry('ProfId1',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf2 (SIRET for France) + $idprof=$langs->transcountry('ProfId2',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; + print ''; + // IdProf3 (APE for France) + $idprof=$langs->transcountry('ProfId3',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + // IdProf4 (NU for France) + $idprof=$langs->transcountry('ProfId4',$soc->pays_code); + if ($idprof!='-') + { + print ''; + } + else print ''; + print ''; - // Legal Form - print ''; - print ''; + // Legal Form + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - if ($conf->global->MAIN_MULTILANGS) - { - print ''; - print ''; - } + if ($conf->global->MAIN_MULTILANGS) + { + print ''; + print ''; + } - // Assujeti TVA - $html = new Form($db); - print ''; - print ''; - print ''; - print ''; + // Assujeti TVA + $html = new Form($db); + print ''; + print ''; + print ''; + print ''; - print ''; + print ''; - // Code TVA - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - } + // Code TVA + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + } - // Local Taxes - if($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - print ''; + // Local Taxes + if($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + { + print ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - print ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - print ''; - } - } + } + elseif($mysoc->localtax1_assuj=="1") + { + print ''; + } + elseif($mysoc->localtax2_assuj=="1") + { + print ''; + } + } - if ($user->rights->societe->client->voir) - { - // Assign a Name - print ''; - print ''; - print ''; - } + if ($user->rights->societe->client->voir) + { + // Assign a Name + print ''; + print ''; + print ''; + } - print ''."\n"; + print ''."\n"; - print '
'.$langs->trans('LastName').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans("UserTitle").''; - print $formcompany->select_civilite($contact->civilite_id).' 
'.$langs->trans('Name').''.$langs->trans('Prefix').'
'.$langs->trans('LastName').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans("UserTitle").''; + print $formcompany->select_civilite($contact->civilite_id).' 
'.$langs->trans('Name').''.$langs->trans('Prefix').'
'.$langs->trans('ProspectCustomer').'
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; - print '
'; - $tmpcode=$soc->code_client; - if ($modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); - print ''; - print ''; - $s=$modCodeClient->getToolTip($langs,$soc,0); - print $form->textwithpicto('',$s,1); - print '
'; + print '
'.$langs->trans('CustomerCode').''; + print '
'; + $tmpcode=$soc->code_client; + if ($modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); + print ''; + print ''; + $s=$modCodeClient->getToolTip($langs,$soc,0); + print $form->textwithpicto('',$s,1); + print '
'; - print '
'.$langs->trans('Supplier').''; - print $form->selectyesno("fournisseur",$soc->fournisseur,1); - print ''.$langs->trans('SupplierCode').''; - print '
'; - $tmpcode=$soc->code_fournisseur; - if ($modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); - print ''; - print ''; - $s=$modCodeFournisseur->getToolTip($langs,$soc,1); - print $form->textwithpicto('',$s,1); - print '
'; + // Supplier + print '
'.$langs->trans('Supplier').''; + print $form->selectyesno("fournisseur",$soc->fournisseur,1); + print ''.$langs->trans('SupplierCode').''; + print '
'; + $tmpcode=$soc->code_fournisseur; + if ($modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); + print ''; + print ''; + $s=$modCodeFournisseur->getToolTip($langs,$soc,1); + print $form->textwithpicto('',$s,1); + print '
'; - print '
'.$langs->trans('SupplierCategory').''; - print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1); - print '
'.$langs->trans('SupplierCategory').''; + print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,$_POST["fournisseur_categorie"],1); + print '
'.$langs->trans('Gencod').''; - print $soc->gencod; - print '
'.$langs->trans('Gencod').''; + print $soc->gencod; + print '
'.$langs->trans('Address').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; - if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' '; - print ''.$langs->trans('Town').'
'.$langs->trans('Zip').''; + if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' '; + print ''.$langs->trans('Town').'
'.$langs->trans('Country').''; - $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id,'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; - if ($soc->pays_id) - { - $formcompany->select_departement($soc->departement_id,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('State').''; + if ($soc->pays_id) + { + $formcompany->select_departement($soc->departement_id,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$idprof.''; - $soc->show_input_id_prof(1,'idprof1',$soc->siren); - print '  '.$idprof.''; - $soc->show_input_id_prof(2,'idprof2',$soc->siret); - print '  
'.$idprof.''; - $soc->show_input_id_prof(3,'idprof3',$soc->ape); - print '  '.$idprof.''; - $soc->show_input_id_prof(4,'idprof4',$soc->idprof4); - print '  
'.$idprof.''; + $soc->show_input_id_prof(1,'idprof1',$soc->siren); + print '  '.$idprof.''; + $soc->show_input_id_prof(2,'idprof2',$soc->siret); + print '  
'.$idprof.''; + $soc->show_input_id_prof(3,'idprof3',$soc->ape); + print '  '.$idprof.''; + $soc->show_input_id_prof(4,'idprof4',$soc->idprof4); + print '  
'.$langs->trans('JuridicalStatus').''; - if ($soc->pays_id) - { - $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans('JuridicalStatus').''; + if ($soc->pays_id) + { + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("Type").''."\n"; - print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''.$langs->trans("Staff").''; - print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans("Type").''."\n"; + print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''.$langs->trans("Staff").''; + print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans("DefaultLang").''."\n"; - $formadmin->select_lang(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); - print '
'.$langs->trans("DefaultLang").''."\n"; + $formadmin->select_lang(($soc->default_lang?$soc->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); + print '
'.$langs->trans('VATIsUsed').''; - print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation - print ''.$langs->trans('VATIntra').''; - $s =''; - $s.=' '; - if ($conf->use_javascript_ajax) - { - $s.=''.$langs->trans("VATIntraCheck").''; - print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - print '
'.$langs->trans('VATIsUsed').''; + print $html->selectyesno('assujtva_value',1,1); // Assujeti par defaut en creation + print ''.$langs->trans('VATIntra').''; + $s =''; + $s.=' '; + if ($conf->use_javascript_ajax) + { + $s.=''.$langs->trans("VATIntraCheck").''; + print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $html->selectyesno('localtax1assuj_value',0,1); - print ''.$langs->trans("LocalTax2IsUsedES").''; - print $html->selectyesno('localtax2assuj_value',0,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $html->selectyesno('localtax1assuj_value',0,1); + print ''.$langs->trans("LocalTax2IsUsedES").''; + print $html->selectyesno('localtax2assuj_value',0,1); + print '
'.$langs->trans("LocalTax1IsUsedES").''; - print $html->selectyesno('localtax1assuj_value',0,1); - print '
'.$langs->trans("LocalTax2IsUsedES").''; - print $html->selectyesno('localtax2assuj_value',0,1); - print '
'.$langs->trans("LocalTax1IsUsedES").''; + print $html->selectyesno('localtax1assuj_value',0,1); + print '
'.$langs->trans("LocalTax2IsUsedES").''; + print $html->selectyesno('localtax2assuj_value',0,1); + print '
'.$langs->trans("AllocateCommercial").''; - $form->select_users($soc->commercial_id,'commercial_id',1); - print '
'.$langs->trans("AllocateCommercial").''; + $form->select_users($soc->commercial_id,'commercial_id',1); + print '
'; - print ''; - print '
'; + print ''; + print '
'."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; - } + } } elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') { - /* - * Company Fact Mode edition - */ - print_fiche_titre($langs->trans("EditCompany")); + /* + * Company Fact Mode edition + */ + print_fiche_titre($langs->trans("EditCompany")); - if ($socid) - { - // Load object modCodeTiers - $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeClient = new $module; - // We verified if the tag prefix is used - if ($modCodeClient->code_auto) - { - $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); - } - $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; - if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeFournisseur = new $module; - // On verifie si la balise prefix est utilisee - if ($modCodeFournisseur->code_auto) - { - $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); - } + if ($socid) + { + // Load object modCodeTiers + $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (! $module) dolibarr_error('',$langs->trans("ErrorModuleThirdPartyCodeInCompanyModuleNotDefined")); + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeClient = new $module; + // We verified if the tag prefix is used + if ($modCodeClient->code_auto) + { + $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); + } + $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; + if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeFournisseur = new $module; + // On verifie si la balise prefix est utilisee + if ($modCodeFournisseur->code_auto) + { + $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); + } - if ($reload || ! $_POST["nom"]) - { - $soc = new Societe($db); - $soc->id = $socid; - $soc->fetch($socid); - } - else - { - $soc->id=$_POST["socid"]; - $soc->nom=$_POST["nom"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; // TODO obsolete - $soc->address=$_POST["adresse"]; - $soc->cp=$_POST["cp"]; - $soc->ville=$_POST["ville"]; - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->email=$_POST["email"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->siren=$_POST["idprof1"]; - $soc->siret=$_POST["idprof2"]; - $soc->ape=$_POST["idprof3"]; - $soc->idprof4=$_POST["idprof4"]; - $soc->typent_id=$_POST["typent_id"]; - $soc->effectif_id=$_POST["effectif_id"]; - $soc->gencod=$_POST["gencod"]; - $soc->forme_juridique_code=$_POST["forme_juridique_code"]; - $soc->default_lang=$_POST["default_lang"]; + if ($reload || ! $_POST["nom"]) + { + $soc = new Societe($db); + $soc->id = $socid; + $soc->fetch($socid); + } + else + { + $soc->id=$_POST["socid"]; + $soc->nom=$_POST["nom"]; + $soc->prefix_comm=$_POST["prefix_comm"]; + $soc->client=$_POST["client"]; + $soc->code_client=$_POST["code_client"]; + $soc->fournisseur=$_POST["fournisseur"]; + $soc->code_fournisseur=$_POST["code_fournisseur"]; + $soc->adresse=$_POST["adresse"]; // TODO obsolete + $soc->address=$_POST["adresse"]; + $soc->cp=$_POST["cp"]; + $soc->ville=$_POST["ville"]; + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + $soc->departement_id=$_POST["departement_id"]; + $soc->tel=$_POST["tel"]; + $soc->fax=$_POST["fax"]; + $soc->email=$_POST["email"]; + $soc->url=$_POST["url"]; + $soc->capital=$_POST["capital"]; + $soc->siren=$_POST["idprof1"]; + $soc->siret=$_POST["idprof2"]; + $soc->ape=$_POST["idprof3"]; + $soc->idprof4=$_POST["idprof4"]; + $soc->typent_id=$_POST["typent_id"]; + $soc->effectif_id=$_POST["effectif_id"]; + $soc->gencod=$_POST["gencod"]; + $soc->forme_juridique_code=$_POST["forme_juridique_code"]; + $soc->default_lang=$_POST["default_lang"]; - $soc->tva_assuj = $_POST["assujtva_value"]; - $soc->tva_intra=$_POST["tva_intra"]; + $soc->tva_assuj = $_POST["assujtva_value"]; + $soc->tva_intra=$_POST["tva_intra"]; - //Local Taxes - $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; - $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; + //Local Taxes + $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; + $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; - // We set pays_id, and pays_code label of the chosen country - 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 - { - dol_print_error($db); - } - $soc->pays_code=$obj->code; - $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; - } - } + // We set pays_id, and pays_code label of the chosen country + 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 + { + dol_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + } - dol_htmloutput_errors($soc->error,$soc->errors); + dol_htmloutput_errors($soc->error,$soc->errors); - print '
'; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } - print ''; + print ''; + print ''; + print ''; + print ''; + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - // Name - print ''; + print '
'.$langs->trans('Name').'
'; - // Prefix - print ''; + // Name + print ''; - // Prospect/Customer - print ''; - print ''; - print '
'.$langs->trans("Prefix").''; - // It does not change the prefix mode using the auto numbering prefix - if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $soc->prefix_comm) - { - print ''; - print $soc->prefix_comm; - } - else - { - print ''; - } - print '
'.$langs->trans('Name').'
'.$langs->trans('ProspectCustomer').''.$langs->trans('CustomerCode').''; + // Prefix + print '
'.$langs->trans("Prefix").''; + // It does not change the prefix mode using the auto numbering prefix + if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $soc->prefix_comm) + { + print ''; + print $soc->prefix_comm; + } + else + { + print ''; + } + print '
'; - if ((!$soc->code_client || $soc->code_client == -1) && $modCodeClient->code_auto) - { - $tmpcode=$soc->code_client; - if (empty($tmpcode) && $modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); - print ''; - } - else if ($soc->codeclient_modifiable()) - { - print ''; - } - else - { - print $soc->code_client; - print ''; - } - print ''; - $s=$modCodeClient->getToolTip($langs,$soc,0); - print $form->textwithpicto('',$s,1); - print '
'; + // Prospect/Customer + print ''.$langs->trans('ProspectCustomer').''; + print ''.$langs->trans('CustomerCode').''; - print ''; + print '
'; + if ((!$soc->code_client || $soc->code_client == -1) && $modCodeClient->code_auto) + { + $tmpcode=$soc->code_client; + if (empty($tmpcode) && $modCodeClient->code_auto) $tmpcode=$modCodeClient->getNextValue($soc,0); + print ''; + } + else if ($soc->codeclient_modifiable()) + { + print ''; + } + else + { + print $soc->code_client; + print ''; + } + print ''; + $s=$modCodeClient->getToolTip($langs,$soc,0); + print $form->textwithpicto('',$s,1); + print '
'; - // Supplier - print ''; - print ''.$langs->trans('Supplier').''; - print $form->selectyesno("fournisseur",$soc->fournisseur,1); - print ''; - print ''.$langs->trans('SupplierCode').''; + print ''; - print '
'; - if ((!$soc->code_fournisseur || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto) - { - $tmpcode=$soc->code_fournisseur; - if (empty($tmpcode) && $modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); - print ''; - } - else if ($soc->codefournisseur_modifiable()) - { - print ''; - } - else - { - print $soc->code_fournisseur; - print ''; - } - print ''; - $s=$modCodeFournisseur->getToolTip($langs,$soc,1); - print $form->textwithpicto('',$s,1); - print '
'; + // Supplier + print ''; + print ''.$langs->trans('Supplier').''; + print $form->selectyesno("fournisseur",$soc->fournisseur,1); + print ''; + print ''.$langs->trans('SupplierCode').''; - print ''; + print '
'; + if ((!$soc->code_fournisseur || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto) + { + $tmpcode=$soc->code_fournisseur; + if (empty($tmpcode) && $modCodeFournisseur->code_auto) $tmpcode=$modCodeFournisseur->getNextValue($soc,1); + print ''; + } + else if ($soc->codefournisseur_modifiable()) + { + print ''; + } + else + { + print $soc->code_fournisseur; + print ''; + } + print ''; + $s=$modCodeFournisseur->getToolTip($langs,$soc,1); + print $form->textwithpicto('',$s,1); + print '
'; - // Category - if ($soc->fournisseur) - { - $load = $soc->LoadSupplierCateg(); - if ( $load == 0) - { - if (sizeof($soc->SupplierCategories) > 0) - { - print ''; - print ''.$langs->trans('SupplierCategory').''; - print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,'',1); - print ''; - } - } - } + print ''; - if ($conf->global->MAIN_MODULE_BARCODE) - { - print ''.$langs->trans('Gencod').''; - print ''; - } + // Category + if ($soc->fournisseur) + { + $load = $soc->LoadSupplierCateg(); + if ( $load == 0) + { + if (sizeof($soc->SupplierCategories) > 0) + { + print ''; + print ''.$langs->trans('SupplierCategory').''; + print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,'',1); + print ''; + } + } + } - // Address - print ''.$langs->trans('Address').''; + if ($conf->global->MAIN_MODULE_BARCODE) + { + print ''.$langs->trans('Gencod').''; + print ''; + } - // Zip / Town - print ''.$langs->trans('Zip').''; - if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' '; - print ''; - print ''.$langs->trans('Town').''; + // Address + print ''.$langs->trans('Address').''; - // Country - print ''.$langs->trans('Country').''; - $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''; + // Zip / Town + print ''.$langs->trans('Zip').''; + if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' '; + print ''; + print ''.$langs->trans('Town').''; - // Department - print ''.$langs->trans('State').''; - $formcompany->select_departement($soc->departement_id,$soc->pays_code); - print ''; + // Country + print ''.$langs->trans('Country').''; + $form->select_pays($soc->pays_id,'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''; - // Phone / Fax - print ''.$langs->trans('Phone').''; - print ''.$langs->trans('Fax').''; + // Department + print ''.$langs->trans('State').''; + $formcompany->select_departement($soc->departement_id,$soc->pays_code); + print ''; - // EMail / Web - print ''.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''; - print ''.$langs->trans('Web').''; + // Phone / Fax + print ''.$langs->trans('Phone').''; + print ''.$langs->trans('Fax').''; - print ''; - // IdProf1 (SIREN for France) - $idprof=$langs->transcountry('ProfId1',$soc->pays_code); - if ($idprof!='-') - { - print ''.$idprof.''; - $soc->show_input_id_prof(1,'idprof1',$soc->siren); - print ''; - } - else print '  '; - // IdProf2 (SIRET for France) - $idprof=$langs->transcountry('ProfId2',$soc->pays_code); - if ($idprof!='-') - { - print ''.$idprof.''; - $soc->show_input_id_prof(2,'idprof2',$soc->siret); - print ''; - } - else print '  '; - print ''; - print ''; - // IdProf3 (APE for France) - $idprof=$langs->transcountry('ProfId3',$soc->pays_code); - if ($idprof!='-') - { - print ''.$idprof.''; - $soc->show_input_id_prof(3,'idprof3',$soc->ape); - print ''; - } - else print '  '; - // IdProf4 (NU for France) - $idprof=$langs->transcountry('ProfId4',$soc->pays_code); - if ($idprof!='-') - { - print ''.$idprof.''; - $soc->show_input_id_prof(4,'idprof4',$soc->idprof4); - print ''; - } - else print '  '; - print ''; + // EMail / Web + print ''.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''; + print ''.$langs->trans('Web').''; - // VAT payers - print ''.$langs->trans('VATIsUsed').''; - print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); - print ''; + print ''; + // IdProf1 (SIREN for France) + $idprof=$langs->transcountry('ProfId1',$soc->pays_code); + if ($idprof!='-') + { + print ''.$idprof.''; + $soc->show_input_id_prof(1,'idprof1',$soc->siren); + print ''; + } + else print '  '; + // IdProf2 (SIRET for France) + $idprof=$langs->transcountry('ProfId2',$soc->pays_code); + if ($idprof!='-') + { + print ''.$idprof.''; + $soc->show_input_id_prof(2,'idprof2',$soc->siret); + print ''; + } + else print '  '; + print ''; + print ''; + // IdProf3 (APE for France) + $idprof=$langs->transcountry('ProfId3',$soc->pays_code); + if ($idprof!='-') + { + print ''.$idprof.''; + $soc->show_input_id_prof(3,'idprof3',$soc->ape); + print ''; + } + else print '  '; + // IdProf4 (NU for France) + $idprof=$langs->transcountry('ProfId4',$soc->pays_code); + if ($idprof!='-') + { + print ''.$idprof.''; + $soc->show_input_id_prof(4,'idprof4',$soc->idprof4); + print ''; + } + else print '  '; + print ''; - // VAT Code - if ($conf->use_javascript_ajax) - { - print "\n"; - print ''; - print "\n"; - } - print ''.$langs->trans('VATIntra').''; - print ''; - $s =''; - $s.=' '; - if ($conf->use_javascript_ajax) - { - $s.=''.$langs->trans("VATIntraCheck").''; - print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); - } - else - { - print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; - } - print ''; - print ''; + // VAT payers + print ''.$langs->trans('VATIsUsed').''; + print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); + print ''; - // Local Taxes - if($mysoc->pays_code=='ES') - { - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - print ''.$langs->trans("LocalTax1IsUsedES").''; - print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); - print ''.$langs->trans("LocalTax2IsUsedES").''; - print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); - print ''; + // VAT Code + if ($conf->use_javascript_ajax) + { + print "\n"; + print ''; + print "\n"; + } + print ''.$langs->trans('VATIntra').''; + print ''; + $s =''; + $s.=' '; + if ($conf->use_javascript_ajax) + { + $s.=''.$langs->trans("VATIntraCheck").''; + print $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); + } + else + { + print $s.'id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; + } + print ''; + print ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - print ''.$langs->trans("LocalTax1IsUsedES").''; - print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); - print ''; + // Local Taxes + if($mysoc->pays_code=='ES') + { + if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") + { + print ''.$langs->trans("LocalTax1IsUsedES").''; + print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); + print ''.$langs->trans("LocalTax2IsUsedES").''; + print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); + print ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - print ''.$langs->trans("LocalTax2IsUsedES").''; - print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); - print ''; - } - } + } + elseif($mysoc->localtax1_assuj=="1") + { + print ''.$langs->trans("LocalTax1IsUsedES").''; + print $form->selectyesno('localtax1assuj_value',$soc->localtax1_assuj,1); + print ''; - print ''.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).''; + } + elseif($mysoc->localtax2_assuj=="1") + { + print ''.$langs->trans("LocalTax2IsUsedES").''; + print $form->selectyesno('localtax2assuj_value',$soc->localtax2_assuj,1); + print ''; + } + } - print ''.$langs->trans('JuridicalStatus').''; - $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); - print ''; + print ''.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).''; - print ''.$langs->trans("Type").''; - print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''; - print ''.$langs->trans("Staff").''; - print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print ''; + print ''.$langs->trans('JuridicalStatus').''; + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + print ''; - if ($conf->global->MAIN_MULTILANGS) - { - print ''.$langs->trans("DefaultLang").''."\n"; - $formadmin->select_lang($soc->default_lang,'default_lang',0,0,1); - print ''; - print ''; - } + print ''.$langs->trans("Type").''; + print $form->selectarray("typent_id",$formcompany->typent_array(0), $soc->typent_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''; + print ''.$langs->trans("Staff").''; + print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''; - print ''; - print '
'; + if ($conf->global->MAIN_MULTILANGS) + { + print ''.$langs->trans("DefaultLang").''."\n"; + $formadmin->select_lang($soc->default_lang,'default_lang',0,0,1); + print ''; + print ''; + } - print '
'; - print ''; - print '     '; - print ''; - print '
'; + print ''; + print '
'; - print '
'; - } + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; + } } else { - /* - * Company Fact Sheet mode visu - */ - $soc = new Societe($db); - $soc->id = $socid; - $result=$soc->fetch($socid); - if ($result < 0) - { - dol_print_error($db,$soc->error); - exit; - } + /* + * Company Fact Sheet mode visu + */ + $soc = new Societe($db); + $soc->id = $socid; + $result=$soc->fetch($socid); + if ($result < 0) + { + dol_print_error($db,$soc->error); + exit; + } - $head = societe_prepare_head($soc); + $head = societe_prepare_head($soc); - dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company'); + dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company'); - $html = new Form($db); + $html = new Form($db); - // Confirm delete third party - if ($_GET["action"] == 'delete') - { - $html = new Form($db); - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); - if ($ret == 'html') print '
'; - } + // Confirm delete third party + if ($_GET["action"] == 'delete') + { + $html = new Form($db); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,2); + if ($ret == 'html') print '
'; + } - // Template - // TODO utiliser la classe canvas - include(DOL_DOCUMENT_ROOT."/societe/canvas/default/tpl/view.tpl.php"); + // Template + // TODO utiliser la classe canvas + include(DOL_DOCUMENT_ROOT."/societe/canvas/default/tpl/view.tpl.php"); - /* - * Actions - */ - if ($_GET["action"] == '') - { - print '
'; + /* + * Actions + */ + if ($_GET["action"] == '') + { + print '
'; - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Modify").''; - } + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Modify").''; + } - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans("AddContact").''; - } + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans("AddContact").''; + } - if ($user->rights->societe->supprimer) - { - print ''.$langs->trans('Delete').''; - } + if ($user->rights->societe->supprimer) + { + print ''.$langs->trans('Delete').''; + } - print '
'; - print '
'; - } + print '
'; + print '
'; + } - print ''; + print ''; + print ''; + print '
'; - print ''; // ancre + print ''; - print ''; - print ''; - print '
'; + print ''; // ancre - /* - * Documents generes - */ - $filedir=$conf->societe->dir_output.'/'.$soc->id; - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$soc->id; - $genallowed=$user->rights->societe->creer; - $delallowed=$user->rights->societe->supprimer; + /* + * Documents generes + */ + $filedir=$conf->societe->dir_output.'/'.$soc->id; + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$soc->id; + $genallowed=$user->rights->societe->creer; + $delallowed=$user->rights->societe->supprimer; - $var=true; + $var=true; - $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); + $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); - print ''; - print '
'; + print '
'; + print '
'; - print '
'; + print '
'; - // Contacts list - $result=show_contacts($conf,$langs,$db,$soc); + // Contacts list + $result=show_contacts($conf,$langs,$db,$soc); - // Projects list - $result=show_projects($conf,$langs,$db,$soc); + // Projects list + $result=show_projects($conf,$langs,$db,$soc); } $db->close();