* Copyright (C) 2003 Brian Fraval * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * 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. */ /** * \file htdocs/societe/soc.php * \ingroup societe * \brief Third party card page * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $langs->load("companies"); $langs->load("commercial"); $langs->load("bills"); $langs->load("banks"); $langs->load("users"); if ($conf->notification->enabled) $langs->load("mails"); $action = GETPOST('action'); $confirm = GETPOST('confirm'); // Security check $socid = GETPOST("socid"); if ($user->societe_id) $socid=$user->societe_id; $soc = new Societe($db); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) if (!empty($socid)) $soc->getCanvas($socid); $canvas = (!empty($soc->canvas)?$soc->canvas:GETPOST("canvas")); if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('thirdparty','card',$canvas); // Security check $result = $objcanvas->restrictedArea($user, 'societe', $socid); } else { // Security check $result = restrictedArea($user, 'societe', $socid); } /* * Actions */ // If canvas actions are defined, because on url, or because contact was created with canvas feature on, we use the canvas feature. // If canvas actions are not defined, we use standard feature. if (method_exists($objcanvas->control,'doActions')) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- $objcanvas->doActions($socid); if (empty($objcanvas->error) && (empty($objcanvas->errors) || sizeof($objcanvas->errors) == 0)) { if ($action=='add') { $objcanvas->action='create'; $action='create'; } if ($action=='update') { $objcanvas->action='view'; $action='view'; } } else { if ($action=='add') { $objcanvas->action='create'; $action='create'; } if ($action=='update') { $objcanvas->action='edit'; $action='edit'; } } } else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- if ($_POST["getcustomercode"]) { // We defined value code_client $_POST["code_client"]="Acompleter"; } if ($_POST["getsuppliercode"]) { // We defined value code_fournisseur $_POST["code_fournisseur"]="Acompleter"; } // Add new third party if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); $error=0; if ($action == 'update') { // Load properties of company $soc->fetch($socid); } if ($_REQUEST["private"] == 1) { $soc->particulier = $_REQUEST["private"]; $soc->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["prenom"].' '.$_POST["nom"]):trim($_POST["nom"].' '.$_POST["prenom"]); $soc->nom = $soc->name; // TODO obsolete $soc->nom_particulier = $_POST["nom"]; $soc->prenom = $_POST["prenom"]; $soc->civilite_id = $_POST["civilite_id"]; } else { $soc->name = $_POST["nom"]; $soc->nom = $soc->name; // TODO obsolete } $soc->address = $_POST["adresse"]; $soc->adresse = $_POST["adresse"]; // TODO obsolete $soc->zip = $_POST["zipcode"]; $soc->cp = $_POST["zipcode"]; // TODO obsolete $soc->town = $_POST["town"]; $soc->ville = $_POST["town"]; // TODO obsolete $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_intra = $_POST["tva_intra"]; $soc->tva_assuj = $_POST["assujtva_value"]; $soc->status = $_POST["status"]; // Local Taxes $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; $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"]; // 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); $action = ($action=='add'?'create':'edit'); } if (! empty($soc->url) && ! isValidUrl($soc->url)) { $error = 1; $langs->load("errors"); $soc->error = $langs->trans("ErrorBadUrl",$soc->url); $action = ($action=='add'?'create':'edit'); } if ($soc->fournisseur && ! $conf->fournisseur->enabled) { $error = 1; $langs->load("errors"); $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled"); $action = ($action=='add'?'create':'edit'); } } if (! $error) { if ($action == 'add') { $db->begin(); 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); $contact->civilite_id = $soc->civilite_id; $contact->name=$soc->nom_particulier; $contact->firstname=$soc->prenom; $contact->address=$soc->address; $contact->zip=$soc->zip; $contact->cp=$soc->cp; $contact->town=$soc->town; $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 { $error=$soc->error; } if ($result >= 0) { $db->commit(); $url=$_SERVER["PHP_SELF"]."?socid=".$soc->id; if (($soc->client == 1 || $soc->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id; else if ($soc->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id; Header("Location: ".$url); exit; } else { $db->rollback(); $langs->load("errors"); $error=$langs->trans($soc->error); $action='create'; } } if ($action == 'update') { if ($_POST["cancel"]) { Header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); exit; } $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; $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; $error = $soc->error; $action= "edit"; } } } } // Delete third party if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { $soc->fetch($socid); $result = $soc->delete($socid); if ($result >= 0) { Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$soc->nom.""); exit; } else { $langs->load("errors"); $error=$langs->trans($soc->error); $action=''; } } /* * Generate document */ if ($action == 'builddoc') // En get ou en post { if (is_numeric(GETPOST('model'))) { $error=$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(); // 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; } } } } /* * View */ $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $form = new Form($db); $formfile = new FormFile($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (! empty($objcanvas->template_dir)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- if ($action == 'create') { $objcanvas->assign_post(); // Assign POST data $objcanvas->assign_values($action); // Set value for templates $objcanvas->display_canvas($action); // Show template } elseif ($action == 'edit') { $objcanvas->fetch($socid); // Reload object if (! empty($_POST)) { $objcanvas->assign_post(); // Assign POST data } $objcanvas->assign_values($action); // Set value for templates $objcanvas->display_canvas($action); // Show template } else { $result=$objcanvas->fetch($socid); // Relaod object $objcanvas->assign_values(); // Assign values $objcanvas->display_canvas(); // Show template // TODO Move this also into template print ''; print ''; print ''; print '
'; print ''; // ancre /* * Documents generes */ $filedir=$conf->societe->dir_output.'/'.$socid; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$socid; $genallowed=$user->rights->societe->creer; $delallowed=$user->rights->societe->supprimer; $var=true; $somethingshown=$formfile->show_documents('company',$socid,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$objcanvas->control->object->default_lang); print '
'; print '
'; // Subsidiaries list $result=show_subsidiaries($conf,$langs,$db,$objcanvas->control->object); // Contacts list $result=show_contacts($conf,$langs,$db,$objcanvas->control->object); // Projects list $result=show_projects($conf,$langs,$db,$objcanvas->control->object); } } else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- if ($action == 'create') { /* * Creation */ // 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"]=='cp') { $soc->client=3; } if (GETPOST("type")!='f') $soc->client=3; if (GETPOST("type")=='c') { $soc->client=1; } if (GETPOST("type")=='p') { $soc->client=2; } if ($conf->fournisseur->enabled && (GETPOST("type")=='f' || GETPOST("type")=='')) { $soc->fournisseur=1; } if (GETPOST("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"]; // TODO obsolete $soc->address=$_POST["adresse"]; $soc->cp=$_POST["zipcode"]; $soc->ville=$_POST["town"]; $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"]; $soc->effectif_id=$_POST["effectif_id"]; $soc->tva_assuj = $_POST["assujtva_value"]; $soc->status= $_POST["status"]; //Local Taxes $soc->localtax1_assuj = $_POST["localtax1assuj_value"]; $soc->localtax2_assuj = $_POST["localtax2assuj_value"]; $soc->tva_intra=$_POST["tva_intra"]; $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; } /* Show create form */ print_fiche_titre($langs->trans("NewCompany")); if ($conf->use_javascript_ajax) { print "\n".''."\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); print '
'; print ''; print ''; print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; print ''; // Name, firstname if ($soc->particulier) { print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } print ''; } else { print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } print ''; } // If javascript on, we show option individual if ($conf->use_javascript_ajax) { print ''; print ''; print ''; print ''; } // Prospect/Customer print ''; print ''; if ($conf->fournisseur->enabled) { // Supplier print ''; print ''; print ''; // Category if ($soc->fournisseur) { $load = $soc->LoadSupplierCateg(); if ( $load == 0) { if (sizeof($soc->SupplierCategories) > 0) { print ''; print ''; } } } } // Status print ''; // Barcode if ($conf->global->MAIN_MODULE_BARCODE) { print ''; } // Address print ''; // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // Phone / Fax 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 ''; // Legal Form print ''; print ''; // Type print ''; print ''; if ($conf->global->MAIN_MULTILANGS) { print ''; print ''; } // Assujeti TVA $html = new Form($db); print ''; print ''; print ''; print ''; print ''; // Local Taxes // TODO add specific function by country 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 ''; } } if ($user->rights->societe->client->voir) { // Assign a Name print ''; print ''; print ''; } print ''."\n"; print '
'.$langs->trans('LastName').''.$langs->trans('Prefix').'
'.$langs->trans('ThirdPartyName').''.$langs->trans('Prefix').'
'.$langs->trans('FirstName').' 
'.$langs->trans("UserTitle").''; print $formcompany->select_civilite($contact->civilite_id).' 
'.$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('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('Status').''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),1); print '
'.$langs->trans('Gencod').''; print $soc->gencod; print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); print ''.$langs->trans('Town').''; print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); 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('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->monnaie).'
'.$idprof.''; print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); print '  
'.$idprof.''; print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); 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("ThirdPartyType").''."\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"; print $formadmin->select_language(($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 = ''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.=' '; if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; 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 '
'; print ''; print '
'."\n"; print '
'."\n"; } elseif ($action == 'edit') { /* * 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 (! $_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["zipcode"]; $soc->ville=$_POST["town"]; $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->status=$_POST["status"]; //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; } } dol_htmloutput_errors($soc->error,$soc->errors); if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; print ''; // Name print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } // Prospect/Customer print ''; print ''; // Supplier if ($conf->fournisseur->enabled) { print ''; print ''; print ''; // Category if ($conf->categorie->enabled && $soc->fournisseur) { $load = $soc->LoadSupplierCateg(); if ( $load == 0) { if (sizeof($soc->SupplierCategories) > 0) { print ''; print ''; } } } } // Status print ''; // Barcode if ($conf->global->MAIN_MODULE_BARCODE) { print ''; } // Address print ''; // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // Phone / Fax print ''; print ''; // EMail / Web 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 ''; // VAT payers print ''; // VAT Code print ''; print ''; print ''; // Local Taxes // TODO add specific function by country 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 ''; } } print ''; print ''; print ''; print ''; if ($conf->global->MAIN_MULTILANGS) { print ''; print ''; } print '
'.$langs->trans('ThirdPartyName').'
'.$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('ProspectCustomer').''.$langs->trans('CustomerCode').''; 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 '
'; print '
'.$langs->trans('Supplier').''; print $form->selectyesno("fournisseur",$soc->fournisseur,1); print ''.$langs->trans('SupplierCode').''; 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 '
'; print '
'.$langs->trans('SupplierCategory').''; print $form->selectarray("fournisseur_categorie",$soc->SupplierCategories,'',1); print '
'.$langs->trans("Status").''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$soc->status); print '
'.$langs->trans('Gencod').''; print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').''; print $formcompany->select_ziptown($soc->cp,'zipcode',array('town','selectpays_id','departement_id'),6); print ''.$langs->trans('Town').''; print $formcompany->select_ziptown($soc->ville,'town',array('zipcode','selectpays_id','departement_id')); 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').''; $formcompany->select_departement($soc->departement_id,$soc->pays_code); print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('EMail').($conf->global->SOCIETE_MAIL_REQUIRED?'*':'').''.$langs->trans('Web').'
'.$idprof.''; print $formcompany->get_input_id_prof(1,'idprof1',$soc->siren,$soc->pays_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(2,'idprof2',$soc->siret,$soc->pays_code); print '  
'.$idprof.''; print $formcompany->get_input_id_prof(3,'idprof3',$soc->ape,$soc->pays_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(4,'idprof4',$soc->idprof4,$soc->pays_code); print '  
'.$langs->trans('VATIsUsed').''; print $form->selectyesno('assujtva_value',$soc->tva_assuj,1); print ''.$langs->trans('VATIntra').''; $s =''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.='   '; if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; 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 '
'.$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 '
'.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans('JuridicalStatus').''; $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); print '
'.$langs->trans("ThirdPartyType").''; 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"; print $formadmin->select_language($soc->default_lang,'default_lang',0,0,1); print '
'; print '
'; print '
'; print ''; print '     '; print ''; print '
'; print '
'; } } else { /* * View */ $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); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"),0,'company'); $html = new Form($db); // Confirm delete third party if ($action == 'delete' || $conf->use_javascript_ajax) { $html = new Form($db); $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete",'',0,"action-delete"); if ($ret == 'html') print '
'; } dol_htmloutput_errors($error,$errors); print ''; // Name print ''; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } if ($soc->client) { print ''; } if ($conf->fournisseur->enabled && $soc->fournisseur) { print ''; } // Status print ''; print ''; // Barcode if ($conf->global->MAIN_MODULE_BARCODE) { print ''; } // Address print ""; print '"; print '"; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) print ''; print ''; print ''; // EMail print ''; // Web print ''; // ProfId1 (SIREN for France) $profid=$langs->transcountry('ProfId1',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId2 (SIRET for France) $profid=$langs->transcountry('ProfId2',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId3 (APE for France) $profid=$langs->transcountry('ProfId3',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // ProfId4 (NU for France) $profid=$langs->transcountry('ProfId4',$soc->pays_code); if ($profid!='-') { print ''; } else print ''; // VAT payers $html = new Form($db); print ''; // VAT Code print ''; print ''; // Local Taxes // TODO add specific function by country 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 ''; } } // Capital print ''; // Legal print ''; // Type + Staff $arr = $formcompany->typent_array(1); $soc->typent= $arr[$soc->typent_code]; print ''; // Default language if ($conf->global->MAIN_MULTILANGS) { require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); print ''; } // Ban if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT)) { print ''; print ''; } // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { print ''; print ''; } // Commercial print ''; print ''; // Module Adherent if ($conf->adherent->enabled) { $langs->load("members"); print ''; print ''; print "\n"; } print '
'.$langs->trans('ThirdPartyName').''; print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); print '
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $soc->code_client; if ($soc->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $soc->code_fournisseur; if ($soc->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'.$langs->trans("Status").''; print $soc->getLibStatut(2); print '
'.$langs->trans('Gencod').''.$soc->gencod.'
".$langs->trans('Address').""; dol_print_address($soc->address,'gmap','thirdparty',$soc->id); print "
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans("Country").''; $img=picto_from_langcode($soc->pays_code); if ($soc->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$soc->pays,$langs->trans("CountryIsInEEC"),1,0); else print ($img?$img.' ':'').$soc->pays; print '
'.$langs->trans('State').''.$soc->departement.'
'.$langs->trans('Phone').''.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id,'AC_FAX').'
'.$langs->trans('EMail').''; print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); print ''.$langs->trans('Web').''; print dol_print_url($soc->url); print '
'.$profid.''; print $soc->siren; if ($soc->siren) { if ($soc->id_prof_check(1,$soc) > 0) print '   '.$soc->id_prof_url(1,$soc); else print ' ('.$langs->trans("ErrorWrongValue").')'; } print '
  '.$profid.''; print $soc->siret; if ($soc->siret) { if ($soc->id_prof_check(2,$soc) > 0) print '   '.$soc->id_prof_url(2,$soc); else print ' ('.$langs->trans("ErrorWrongValue").')'; } print '
  
'.$profid.''; print $soc->ape; if ($soc->ape) { if ($soc->id_prof_check(3,$soc) > 0) print '   '.$soc->id_prof_url(3,$soc); else print ' ('.$langs->trans("ErrorWrongValue").')'; } print '
  '.$profid.''; print $soc->idprof4; if ($soc->idprof4) { if ($soc->id_prof_check(4,$soc) > 0) print '   '.$soc->id_prof_url(4,$soc); else print ' ('.$langs->trans("ErrorWrongValue").')'; } print '
  
'; print $langs->trans('VATIsUsed'); print ''; print yn($soc->tva_assuj); print ''.$langs->trans('VATIntra').''; if ($soc->tva_intra) { $s=''; $s.=$soc->tva_intra; $s.=''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.='   '; if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; } else { print ' '; } print '
'.$langs->trans("LocalTax1IsUsedES").''; print yn($soc->localtax1_assuj); print ''.$langs->trans("LocalTax2IsUsedES").''; print yn($soc->localtax2_assuj); print '
'.$langs->trans("LocalTax1IsUsedES").''; print yn($soc->localtax1_assuj); print '
'.$langs->trans("LocalTax2IsUsedES").''; print yn($soc->localtax2_assuj); print '
'.$langs->trans('Capital').''; if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie); else print ' '; print '
'.$langs->trans('JuridicalStatus').''.$soc->forme_juridique.'
'.$langs->trans("ThirdPartyType").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'
'.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($soc->default_lang); //print ($s?$s.' ':''); $langs->load("languages"); $labellang = ($soc->default_lang?$langs->trans('Language_'.$soc->default_lang):''); print $labellang; print '
'; print '
'; print $langs->trans('RIB'); print ''; if ($user->rights->societe->creer) print ''.img_edit().''; else print ' '; print '
'; print '
'; print $soc->display_rib(); print '
'; print '
'; print $langs->trans('ParentCompany'); print ''; if ($user->rights->societe->creer) print ''.img_edit() .''; else print ' '; print '
'; print '
'; if ($soc->parent) { $socm = new Societe($db); $socm->fetch($soc->parent); print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); print $socm->ville?' - '.$socm->ville:''; } else { print $langs->trans("NoParentCompany"); } print '
'; print '
'; print $langs->trans('SalesRepresentatives'); print ''; if ($user->rights->societe->creer) print ''.img_edit().''; else print ' '; print '
'; print '
'; $listsalesrepresentatives=$soc->getSalesRepresentatives($user); $nbofsalesrepresentative=sizeof($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { print ''; print $nbofsalesrepresentative; print ''; } else if ($nbofsalesrepresentative > 0) { $userstatic=new User($db); $i=0; foreach($listsalesrepresentatives as $val) { $userstatic->id=$val['id']; $userstatic->nom=$val['name']; $userstatic->prenom=$val['firstname']; print $userstatic->getNomUrl(1); $i++; if ($i < $nbofsalesrepresentative) print ', '; } } else print $langs->trans("NoSalesRepresentativeAffected"); print '
'.$langs->trans("LinkedToDolibarrMember").''; $adh=new Adherent($db); $result=$adh->fetch('','',$soc->id); if ($result > 0) { $adh->ref=$adh->getFullName($langs); print $adh->getNomUrl(1); } else { print $langs->trans("UserNotLinkedToMember"); } print '
'; print "\n"; /* * Actions */ print '
'."\n"; if ($user->rights->societe->creer) { print ''.$langs->trans("Modify").''."\n"; } if ($user->rights->societe->contact->creer) { print ''.$langs->trans("AddContact").''."\n"; } if ($conf->projet->enabled && $user->rights->projet->creer) { print ''.$langs->trans("AddProject").''."\n"; } if ($user->rights->societe->supprimer) { if ($conf->use_javascript_ajax) { print ''.$langs->trans('Delete').''."\n"; } else { print ''.$langs->trans('Delete').''."\n"; } } print '
'."\n"; print '
'; 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; $var=true; $somethingshown=$formfile->show_documents('company',$soc->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$soc->default_lang); print ''; print '
'; print '
'; // Subsidiaries list $result=show_subsidiaries($conf,$langs,$db,$soc); // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $result=show_contacts($conf,$langs,$db,$soc); } // Projects list $result=show_projects($conf,$langs,$db,$soc); } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>