From ab53d438ce8f9afc12ea4da64302b0f61d406ef2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 3 Nov 2010 11:39:40 +0000 Subject: [PATCH] Works on contact canvas in relation to the thirdparty canvas module --- .../actions_contactcard_common.class.php | 425 +++--- .../actions_contactcard_default.class.php | 9 +- .../default/tpl/contactcard_create.tpl.php | 95 ++ .../default/tpl/contactcard_edit.tpl.php | 125 ++ .../default/tpl/contactcard_view.tpl.php | 103 ++ htdocs/contact/fiche.php | 1324 +++++++++-------- htdocs/core/class/canvas.class.php | 19 +- htdocs/core/class/html.form.class.php | 62 +- .../install/mysql/migration/2.9.0-3.0.0.sql | 4 +- htdocs/install/mysql/tables/llx_societe.sql | 106 +- htdocs/install/mysql/tables/llx_socpeople.sql | 65 +- .../canvas/actions_card_common.class.php | 6 +- 12 files changed, 1438 insertions(+), 905 deletions(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index a9556194080..bbe9979891a 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -55,8 +55,8 @@ class ActionsContactCardCommon */ function assign_values($action='') { - global $conf, $langs, $user, $mysoc, $canvas; - global $form, $formadmin, $formcompany; + global $conf, $langs, $user, $canvas; + global $form, $formcompany, $objsoc; foreach($this->object as $key => $value) { @@ -65,183 +65,147 @@ class ActionsContactCardCommon if ($action == 'create' || $action == 'edit') { - // Load object modCodeClient - $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; - $this->tpl['auto_customercode'] = $modCodeClient->code_auto; - // We verified if the tag prefix is used - if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); - - // Load object modCodeFournisseur - $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; - $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto; - // We verified if the tag prefix is used - if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed(); - - // TODO create a function - $this->tpl['select_customertype'] = ''; - - // Customer - $this->tpl['customercode'] = $this->object->code_client; - if ((!$this->object->code_client || $this->object->code_client == -1) && $modCodeClient->code_auto) $this->tpl['customercode'] = $modCodeClient->getNextValue($this->object,0); - $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable(); - $s=$modCodeClient->getToolTip($langs,$this->object,0); - $this->tpl['help_customercode'] = $form->textwithpicto('',$s,1); - - // Supplier - $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1); - $this->tpl['suppliercode'] = $this->object->code_fournisseur; - if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1); - $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable(); - $s=$modCodeFournisseur->getToolTip($langs,$this->object,1); - $this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1); - - $this->object->LoadSupplierCateg(); - $this->tpl['suppliercategory'] = $this->object->SupplierCategories; - $this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1); - + if ($conf->use_javascript_ajax) + { + $this->tpl['ajax_selectpays'] = "\n".''."\n"; + } + + if (is_object($objsoc) && $objsoc->id > 0) + { + $this->tpl['company'] = $objsoc->getNomUrl(1); + $this->tpl['company_id'] = $objsoc->id; + } + else + { + $this->tpl['company'] = $form->select_company($this->object->socid,'socid','',1); + } + + // Civility + $this->tpl[select_civility] = $formcompany->select_civility($this->object->civilite_id); + + // Predefined with third party + if ($objsoc->typent_code == 'TE_PRIVATE') + { + if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; + if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->cp; + if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->ville; + if (dol_strlen(trim($this->object->phone_pro)) == 0) $this->object->phone_pro = $objsoc->tel; + if (dol_strlen(trim($this->object->fax)) == 0) $this->object->fax = $objsoc->fax; + if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; + } + // Zip $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->cp,'zipcode',array('town','selectpays_id','departement_id'),6); // Town $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->ville,'town',array('zipcode','selectpays_id','departement_id')); + + if (dol_strlen(trim($this->object->fk_pays)) == 0) $this->object->fk_pays = $objsoc->pays_id; // Country - $this->tpl['select_country'] = $form->select_country($this->object->pays_id,'pays_id'); + $this->tpl['select_country'] = $form->select_country($this->object->fk_pays,'pays_id'); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); // State - if ($this->object->pays_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code); + if ($this->object->fk_pays) $this->tpl['select_state'] = $formcompany->select_state($this->object->departement_id,$this->object->pays_code); else $this->tpl['select_state'] = $countrynotdefined; - - // Language - if ($conf->global->MAIN_MULTILANGS) $this->tpl['select_lang'] = $formadmin->select_language(($this->object->default_lang?$this->object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1); - - // VAT - $this->tpl['yn_assujtva'] = $form->selectyesno('assujtva_value',$this->tpl['tva_assuj'],1); // Assujeti par defaut en creation - - // Select users - $this->tpl['select_users'] = $form->select_dolusers($this->object->commercial_id,'commercial_id',1); - - // Local Tax - // TODO mettre dans une classe propre au pays - if($mysoc->pays_code=='ES') - { - $this->tpl['localtax'] = ''; - - if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") - { - $this->tpl['localtax'].= ''.$langs->trans("LocalTax1IsUsedES").''; - $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1); - $this->tpl['localtax'].= ''.$langs->trans("LocalTax2IsUsedES").''; - $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1); - $this->tpl['localtax'].= ''; - } - elseif($mysoc->localtax1_assuj=="1") - { - $this->tpl['localtax'].= ''.$langs->trans("LocalTax1IsUsedES").''; - $this->tpl['localtax'].= $form->selectyesno('localtax1assuj_value',$this->object->localtax1_assuj,1); - $this->tpl['localtax'].= ''; - } - elseif($mysoc->localtax2_assuj=="1") - { - $this->tpl['localtax'].= ''.$langs->trans("LocalTax2IsUsedES").''; - $this->tpl['localtax'].= $form->selectyesno('localtax2assuj_value',$this->object->localtax1_assuj,1); - $this->tpl['localtax'].= ''; - } - } - + + // Public or private + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + $this->tpl['select_visibility'] = $form->selectarray('priv',$selectarray,$this->object->priv,0); + } + + if ($action == 'view' || $action == 'edit') + { + // Emailing + if ($conf->mailing->enabled) + { + $langs->load("mails"); + $this->tpl['nb_emailing'] = $object->getNbOfEMailings(); + } + + // Linked element + $this->tpl['contact_element'] = array(); + $i=0; + + $this->object->load_ref_elements(); + + if ($conf->commande->enabled) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForOrders"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande?$this->object->ref_commande:$langs->trans("NoContactForAnyOrder"); + $i++; + } + if ($conf->propal->enabled) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal?$this->object->ref_propal:$langs->trans("NoContactForAnyProposal"); + $i++; + } + if ($conf->contrat->enabled) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForContracts"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_contrat?$this->object->ref_contrat:$langs->trans("NoContactForAnyContract"); + $i++; + } + if ($conf->facture->enabled) + { + $this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForInvoices"); + $this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_facturation?$this->object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + $i++; + } + + // Dolibarr user + if ($this->object->user_id) + { + $dolibarr_user=new User($this->db); + $result=$dolibarr_user->fetch($this->object->user_id); + $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); + } + else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); } if ($action == 'view') { - $this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom'); + $this->tpl['showrefnav'] = $form->showrefnav($this->object,'id'); + + if (is_object($objsoc) && $this->object->socid > 0) + { + $objsoc->fetch($this->object->socid); + $this->tpl['company'] = $objsoc->getNomUrl(1); + } + else + { + $this->tpl['company'] = $langs->trans("ContactNotLinkedToCompany"); + } + + $this->tpl['civility'] = $this->object->getCivilityLabel(); - $this->tpl['checkcustomercode'] = $this->object->check_codeclient(); - $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur(); - $this->tpl['address'] = dol_nl2br($this->object->address); + $this->tpl['address'] = dol_nl2br($this->object->address); + + $this->tpl['zip'] = ($this->object->cp?$this->object->cp.' ':''); $img=picto_from_langcode($this->pays_code); - if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->pays,$langs->trans("CountryIsInEEC"),1,0); $this->tpl['country'] = ($img?$img.' ':'').$this->pays; - $this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL'); + $this->tpl['phone_pro'] = dol_print_phone($this->object->phone_pro,$this->object->pays_code,0,$this->object->id,'AC_TEL'); + $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso,$this->object->pays_code,0,$this->object->id,'AC_TEL'); + $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile,$this->object->pays_code,0,$this->object->id,'AC_TEL'); $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX'); $this->tpl['email'] = dol_print_email($this->object->email,0,$this->object->id,'AC_EMAIL'); - $this->tpl['url'] = dol_print_url($this->object->url); - - $this->tpl['tva_assuj'] = yn($this->object->tva_assuj); - - // Third party type - $arr = $formcompany->typent_array(1); - $this->tpl['typent'] = $arr[$this->object->typent_code]; - - if ($conf->global->MAIN_MULTILANGS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); - //$s=picto_from_langcode($this->default_lang); - //print ($s?$s.' ':''); - $langs->load("languages"); - $this->tpl['default_lang'] = ($this->default_lang?$langs->trans('Language_'.$this->object->default_lang):''); - } - - $this->tpl['image_edit'] = img_edit(); - - $this->tpl['display_rib'] = $this->object->display_rib(); - - // Sales representatives - // TODO move in business class - $sql = "SELECT count(sc.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sc.fk_soc =".$this->object->id; - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $obj = $this->db->fetch_object($resql); - $this->tpl['sales_representatives'] = $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected"); - } - else - { - dol_print_error($this->db); - } - - // Linked member - if ($conf->adherent->enabled) - { - $langs->load("members"); - $adh=new Adherent($this->db); - $result=$adh->fetch('','',$this->object->id); - if ($result > 0) - { - $adh->ref=$adh->getFullName($langs); - $this->tpl['linked_member'] = $adh->getNomUrl(1); - } - else - { - $this->tpl['linked_member'] = $langs->trans("UserNotLinkedToMember"); - } - } + + $this->tpl['visibility'] = $this->object->LibPubPriv($this->object->priv); + + $this->tpl['note'] = nl2br($this->object->note); } } @@ -252,47 +216,34 @@ class ActionsContactCardCommon { global $langs, $mysoc; - $this->object->id = $_POST["socid"]; - $this->object->nom = $_POST["nom"]; - $this->object->prefix_comm = $_POST["prefix_comm"]; - $this->object->client = $_POST["client"]; - $this->object->code_client = $_POST["code_client"]; - $this->object->fournisseur = $_POST["fournisseur"]; - $this->object->code_fournisseur = $_POST["code_fournisseur"]; - $this->object->adresse = $_POST["adresse"]; // TODO obsolete - $this->object->address = $_POST["adresse"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; + + $this->object->socid = $_POST["socid"]; + $this->object->name = $_POST["name"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civilite_id = $_POST["civilite_id"]; + $this->object->poste = $_POST["poste"]; + $this->object->address = $_POST["address"]; $this->object->cp = $_POST["cp"]; $this->object->ville = $_POST["ville"]; - $this->object->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - $this->object->departement_id = $_POST["departement_id"]; - $this->object->tel = $_POST["tel"]; + $this->object->fk_pays = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + $this->object->fk_departement = $_POST["departement_id"]; + $this->object->phone_pro = $_POST["phone_pro"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; $this->object->fax = $_POST["fax"]; $this->object->email = $_POST["email"]; - $this->object->url = $_POST["url"]; - $this->object->capital = $_POST["capital"]; - $this->object->siren = $_POST["idprof1"]; - $this->object->siret = $_POST["idprof2"]; - $this->object->ape = $_POST["idprof3"]; - $this->object->idprof4 = $_POST["idprof4"]; - $this->object->typent_id = $_POST["typent_id"]; - $this->object->effectif_id = $_POST["effectif_id"]; - $this->object->gencod = $_POST["gencod"]; - $this->object->forme_juridique_code = $_POST["forme_juridique_code"]; - $this->object->default_lang = $_POST["default_lang"]; - $this->object->commercial_id = $_POST["commercial_id"]; + $this->object->jabberid = $_POST["jabberid"]; + $this->object->priv = $_POST["priv"]; + $this->object->note = $_POST["note"]; - $this->object->tva_assuj = $_POST["assujtva_value"]?$_POST["assujtva_value"]:1; - $this->object->tva_intra = $_POST["tva_intra"]; - - //Local Taxes - $this->object->localtax1_assuj = $_POST["localtax1assuj_value"]; - $this->object->localtax2_assuj = $_POST["localtax2assuj_value"]; // We set pays_id, and pays_code label of the chosen country // TODO move in business class - if ($this->object->pays_id) + if ($this->object->fk_pays) { - $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->pays_id; + $sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_pays WHERE rowid = ".$this->object->fk_pays; $resql=$this->db->query($sql); if ($resql) { @@ -310,11 +261,109 @@ class ActionsContactCardCommon /** * Load data control */ - function doActions($socid) + function doActions($id) { global $conf, $user, $langs; + // Creation utilisateur depuis contact + if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes' && $user->rights->user->user->creer) + { + // Recuperation contact actuel + $result = $this->object->fetch($id); + + if ($result > 0) + { + // Creation user + $nuser = new User($this->db); + $result=$nuser->create_from_contact($this->object,$_POST["login"]); + + if ($result < 0) + { + $msg=$nuser->error; + } + } + else + { + $msg=$object->error; + } + } + // Creation contact + if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer) + { + $this->assign_post(); + + if (! $_POST["name"]) + { + array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"))); + $_GET["action"] = $_POST["action"] = 'create'; + } + + if ($_POST["name"]) + { + $id = $this->object->create($user); + if ($id > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $errors=array($this->object->error); + $_GET["action"] = $_POST["action"] = 'create'; + } + } + } + + if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer) + { + $result=$this->object->fetch($id); + + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; + + $result = $this->object->delete(); + if ($result > 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg=$this->object->error; + } + } + + if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + { + if (empty($_POST["name"])) + { + $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $error++; + $_GET["action"] = $_POST["action"] = 'edit'; + } + + if (! sizeof($errors)) + { + $this->object->fetch($_POST["contactid"]); + + $this->object->oldcopy=dol_clone($this->object); + + $this->assign_post(); + + $result = $this->object->update($_POST["contactid"], $user); + + if ($result > 0) + { + $this->object->old_name=''; + $this->object->old_firstname=''; + } + else + { + $mesg=$this->object->error; + } + } + } } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 6cac724dc38..4ff7090c53b 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -53,9 +53,8 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $out=''; - if ($action == 'view') $out.= $langs->trans("ThirdParty"); - if ($action == 'edit') $out.= $langs->trans("EditCompany"); - if ($action == 'create') $out.= $langs->trans("NewCompany"); + if ($action == 'view' || $action == 'edit') $out.= $langs->trans("Contact"); + if ($action == 'create') $out.= $langs->trans("AddContact"); return $out; } @@ -72,9 +71,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * Execute actions * @param Id of object (may be empty for creation) */ - function doActions($socid) + function doActions($id) { - $return = parent::doActions($socid); + $return = parent::doActions($id); return $return; } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php index e2ea4262409..9f8bcd57457 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php @@ -21,6 +21,101 @@ +tpl['ajax_selectpays']; ?> +
+ +
"> + + +control->tpl['company_id']) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
trans("Lastname").' / '.$langs->trans("Label"); ?>trans("Firstname"); ?>
trans("Company"); ?>control->tpl['company']; ?>
trans("UserTitle"); ?>control->tpl['select_civility']; ?>
trans("PostOrFunction"); ?>
trans("Address"); ?>
trans("Zip").' / '.$langs->trans("Town"); ?>control->tpl['select_zip'].' '.$this->control->tpl['select_town']; ?>
trans("Country"); ?>control->tpl['select_country'].$this->control->tpl['info_admin']; ?>
trans('State'); ?>control->tpl['select_state']; ?>
trans("PhonePro"); ?>trans("PhonePerso"); ?>
trans("PhoneMobile"); ?>trans("Fax"); ?>
trans("Email"); ?>
trans("Jabberid"); ?>
trans("ContactVisibility"); ?>control->tpl['select_civility']; ?>
trans("Note"); ?>
">

+ +
\ No newline at end of file diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index e2ea4262409..9bf2e2e90ab 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -21,6 +21,131 @@ +tpl['ajax_selectpays']; ?> +
+ +
"> +"> + + + + +control->tpl['company_id']) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + control->tpl['nb_emailing']) { ?> + + + + + + + + + + + + + + + + + + + + + + +control->tpl['contact_element'] as $element) { ?> + + + + + + + + + + + + + + + +
trans("Ref"); ?>control->tpl['ref']; ?>
trans("Lastname").' / '.$langs->trans("Label"); ?>trans("Firstname"); ?>
trans("Company"); ?>control->tpl['company']; ?>
trans("UserTitle"); ?>control->tpl['select_civility']; ?>
trans("PostOrFunction"); ?>
trans("Address"); ?>
trans("Zip").' / '.$langs->trans("Town"); ?>control->tpl['select_zip'].' '.$this->control->tpl['select_town']; ?>
trans("Country"); ?>control->tpl['select_country'].$this->control->tpl['info_admin']; ?>
trans('State'); ?>control->tpl['select_state']; ?>
trans("PhonePro"); ?>trans("PhonePerso"); ?>
trans("PhoneMobile"); ?>trans("Fax"); ?>
trans("Email"); ?>trans("NbOfEMailingsReceived"); ?>control->tpl['nb_emailing']; ?> 
trans("Jabberid"); ?>
trans("ContactVisibility"); ?>control->tpl['select_visibility']; ?>
trans("Note"); ?>
trans("DolibarrLogin"); ?>control->tpl['dolibarr_user']; ?>
+ ">  + "> +

+ +
\ No newline at end of file diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index e2ea4262409..0b0ae5e922f 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -21,6 +21,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + control->tpl['nb_emailing']) { ?> + + + + + + + + + + + + + + + + + + + + + +control->tpl['contact_element'] as $element) { ?> + + + + + + + + + + + +
trans("Ref"); ?>control->tpl['showrefnav']; ?>
trans("Lastname"); ?>control->tpl['name']; ?>trans("Firstname"); ?>control->tpl['firstname']; ?>
trans("Company"); ?>control->tpl['company']; ?>
trans("UserTitle"); ?>control->tpl['civility']; ?>
trans("PostOrFunction" ); ?>control->tpl['poste']; ?>
trans("Address"); ?>control->tpl['address']; ?>
trans("Zip").' / '.$langs->trans("Town"); ?>control->tpl['zip'].$this->control->tpl['ville']; ?>
trans("Country"); ?>control->tpl['country']; ?>
trans('State'); ?>control->tpl['departement']; ?>
trans("PhonePro"); ?>control->tpl['phone_pro']; ?>trans("PhonePerso"); ?>control->tpl['phone_perso']; ?>
trans("PhoneMobile"); ?>control->tpl['phone_mobile']; ?>trans("Fax"); ?>control->tpl['fax']; ?>
trans("EMail"); ?>control->tpl['email']; ?>trans("NbOfEMailingsReceived"); ?>control->tpl['nb_emailing']; ?> 
trans("Jabberid"); ?>control->tpl['jabberid']; ?>
trans("ContactVisibility"); ?>control->tpl['visibility']; ?>
trans("Note"); ?>control->tpl['note']; ?>
trans("DolibarrLogin"); ?>control->tpl['dolibarr_user']; ?>
+ + \ No newline at end of file diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index e0dd4dd58c0..f93ae6c8a64 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -38,168 +38,189 @@ $langs->load("companies"); $langs->load("users"); $errors = array(); -$socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"]; +$socid = GETPOST("socid"); // Security check -$contactid = isset($_GET["id"])?$_GET["id"]:''; +$id = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contact', $contactid, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission +$object = new Contact($db); + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +if (!empty($id)) $object->getCanvas($id); +$canvas = (!empty($object->canvas)?$object->canvas:GETPOST("canvas")); +if (! empty($canvas)) +{ + require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); + $objcanvas = new Canvas($db); + + $objcanvas->getCanvas('thirdparty','contactcard',$canvas); + + // Security check + $result = $objcanvas->restrictedArea($user, 'contact', $id, 'socpeople'); +} +else +{ + // Security check + $result = restrictedArea($user, 'contact', $id, 'socpeople'); // If we create a contact with no company (shared contacts), no check on write permission +} /* * Actions */ -// Creation utilisateur depuis contact -if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) +// If canvas is defined, because on url, or because contact was created with canvas feature on, +// we use the canvas feature. +// If canvas is not defined, we use standard feature. +if (! empty($canvas)) { - // Recuperation contact actuel - $contact = new Contact($db); - $result = $contact->fetch($_GET["id"]); + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- - if ($result > 0) - { - // Creation user - $nuser = new User($db); - $result=$nuser->create_from_contact($contact,$_POST["login"]); - - if ($result < 0) - { - $msg=$nuser->error; - } - } - else - { - $msg=$contact->error; - } + // Load data control + $objcanvas->doActions($id); } - -// Creation contact -if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer) +else { - $contact = new Contact($db); - - $contact->socid = $_POST["socid"]; - - $contact->name = $_POST["name"]; - $contact->firstname = $_POST["firstname"]; - $contact->civilite_id = $_POST["civilite_id"]; - $contact->poste = $_POST["poste"]; - $contact->address = $_POST["address"]; - $contact->cp = $_POST["cp"]; - $contact->ville = $_POST["ville"]; - $contact->fk_pays = $_POST["pays_id"]; - $contact->fk_departement = $_POST["departement_id"]; - $contact->email = $_POST["email"]; - $contact->phone_pro = $_POST["phone_pro"]; - $contact->phone_perso = $_POST["phone_perso"]; - $contact->phone_mobile = $_POST["phone_mobile"]; - $contact->fax = $_POST["fax"]; - $contact->jabberid = $_POST["jabberid"]; - $contact->priv = $_POST["priv"]; - - $contact->note = $_POST["note"]; - - if (! $_POST["name"]) - { - array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"))); - $_GET["action"] = 'create'; - $_POST["action"] = 'create'; - $_REQUEST["action"] = 'create'; - } - - if ($_POST["name"]) - { - $id = $contact->create($user); - if ($id > 0) - { - Header("Location: fiche.php?id=".$id); - exit; - } - else - { - $errors=array($contact->error); - $_GET["action"] = 'create'; - $_POST["action"] = 'create'; - $_REQUEST["action"] = 'create'; - } - } -} - -if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->contact->supprimer) -{ - $contact = new Contact($db); - $result=$contact->fetch($_GET["id"]); - - $contact->old_name = $_POST["old_name"]; - $contact->old_firstname = $_POST["old_firstname"]; - - $result = $contact->delete(); - if ($result > 0) + // Creation utilisateur depuis contact + if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer) { - Header("Location: index.php"); - exit; - } - else - { - $mesg=$contact->error; - } -} - -if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) -{ - if (empty($_POST["name"])) - { - $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); - $error++; - $_GET["action"] = 'edit'; - $_POST["action"] = 'edit'; - $_REQUEST["action"] = 'edit'; - } - - if (! sizeof($errors)) - { - $contact = new Contact($db); - $contact->fetch($_POST["contactid"]); - - $contact->oldcopy=dol_clone($contact); - - $contact->old_name = $_POST["old_name"]; - $contact->old_firstname = $_POST["old_firstname"]; - - $contact->socid = $_POST["socid"]; - $contact->name = $_POST["name"]; - $contact->firstname = $_POST["firstname"]; - $contact->civilite_id = $_POST["civilite_id"]; - $contact->poste = $_POST["poste"]; - - $contact->address = $_POST["address"]; - $contact->cp = $_POST["cp"]; - $contact->ville = $_POST["ville"]; - $contact->fk_departement= $_POST["departement_id"]; - $contact->fk_pays = $_POST["pays_id"]; - - $contact->email = $_POST["email"]; - $contact->phone_pro = $_POST["phone_pro"]; - $contact->phone_perso = $_POST["phone_perso"]; - $contact->phone_mobile = $_POST["phone_mobile"]; - $contact->fax = $_POST["fax"]; - $contact->jabberid = $_POST["jabberid"]; - $contact->priv = $_POST["priv"]; - - $contact->note = $_POST["note"]; - - $result = $contact->update($_POST["contactid"], $user); - + // Recuperation contact actuel + $result = $object->fetch($_GET["id"]); + if ($result > 0) { - $contact->old_name=''; - $contact->old_firstname=''; + // Creation user + $nuser = new User($db); + $result=$nuser->create_from_contact($object,$_POST["login"]); + + if ($result < 0) + { + $msg=$nuser->error; + } } else { - $mesg=$contact->error; + $msg=$object->error; + } + } + + // Creation contact + if ($_POST["action"] == 'add' && $user->rights->societe->contact->creer) + { + $object->socid = $_POST["socid"]; + + $object->name = $_POST["name"]; + $object->firstname = $_POST["firstname"]; + $object->civilite_id = $_POST["civilite_id"]; + $object->poste = $_POST["poste"]; + $object->address = $_POST["address"]; + $object->cp = $_POST["cp"]; + $object->ville = $_POST["ville"]; + $object->fk_pays = $_POST["pays_id"]; + $object->fk_departement = $_POST["departement_id"]; + $object->email = $_POST["email"]; + $object->phone_pro = $_POST["phone_pro"]; + $object->phone_perso = $_POST["phone_perso"]; + $object->phone_mobile = $_POST["phone_mobile"]; + $object->fax = $_POST["fax"]; + $object->jabberid = $_POST["jabberid"]; + $object->priv = $_POST["priv"]; + $object->note = $_POST["note"]; + + if (! $_POST["name"]) + { + array_push($errors,$langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname").' / '.$langs->transnoentities("Label"))); + $_GET["action"] = $_POST["action"] = 'create'; + } + + if ($_POST["name"]) + { + $id = $object->create($user); + if ($id > 0) + { + Header("Location: fiche.php?id=".$id); + exit; + } + else + { + $errors=array($object->error); + $_GET["action"] = $_POST["action"] = 'create'; + } + } + } + + if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes' && $user->rights->societe->contact->supprimer) + { + $result=$object->fetch($_GET["id"]); + + $object->old_name = $_POST["old_name"]; + $object->old_firstname = $_POST["old_firstname"]; + + $result = $object->delete(); + if ($result > 0) + { + Header("Location: index.php"); + exit; + } + else + { + $mesg=$object->error; + } + } + + if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer) + { + if (empty($_POST["name"])) + { + $errors=array($langs->trans("ErrorFieldRequired",$langs->transnoentities("Name").' / '.$langs->transnoentities("Label"))); + $error++; + $_GET["action"] = $_POST["action"] = 'edit'; + } + + if (! sizeof($errors)) + { + $object->fetch($_POST["contactid"]); + + $object->oldcopy=dol_clone($object); + + $object->old_name = $_POST["old_name"]; + $object->old_firstname = $_POST["old_firstname"]; + + $object->socid = $_POST["socid"]; + $object->name = $_POST["name"]; + $object->firstname = $_POST["firstname"]; + $object->civilite_id = $_POST["civilite_id"]; + $object->poste = $_POST["poste"]; + + $object->address = $_POST["address"]; + $object->cp = $_POST["cp"]; + $object->ville = $_POST["ville"]; + $object->fk_departement= $_POST["departement_id"]; + $object->fk_pays = $_POST["pays_id"]; + + $object->email = $_POST["email"]; + $object->phone_pro = $_POST["phone_pro"]; + $object->phone_perso = $_POST["phone_perso"]; + $object->phone_mobile = $_POST["phone_mobile"]; + $object->fax = $_POST["fax"]; + $object->jabberid = $_POST["jabberid"]; + $object->priv = $_POST["priv"]; + $object->note = $_POST["note"]; + + $result = $object->update($_POST["contactid"], $user); + + if ($result > 0) + { + $object->old_name=''; + $object->old_firstname=''; + } + else + { + $mesg=$object->error; + } } } } @@ -222,537 +243,658 @@ if ($socid > 0) $objsoc->fetch($socid); } - -/* - * Onglets - */ -if ($_GET["id"] > 0) +if (! empty($canvas)) { - // Si edition contact deja existant - $contact = new Contact($db); - $return=$contact->fetch($_GET["id"], $user); - if ($return <= 0) + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- + + if ($user->rights->societe->contact->creer) { - dol_print_error('',$contact->error); - $_GET["id"]=0; - } - - /* - * Affichage onglets - */ - $head = contact_prepare_head($contact); - - dol_fiche_head($head, 'general', $langs->trans("Contact"), 0, 'contact'); -} - - -/* - * Confirmation de la suppression du contact - */ -if ($user->rights->societe->contact->supprimer) -{ - if ($_GET["action"] == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1); - if ($ret == 'html') print '
'; - } -} - -if ($user->rights->societe->contact->creer) -{ - if ($_GET["action"] == 'create' || $_POST["action"] == 'create') - { - /* - * Fiche en mode creation - */ - $contact->fk_departement = $_POST["departement_id"]; - - // We set pays_id, pays_code and label for the selected country - $contact->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; - if ($contact->fk_pays) + if (GETPOST("action") == 'create') { - $sql = "SELECT code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; - $sql.= " WHERE rowid = ".$contact->fk_pays; - $resql=$db->query($sql); - if ($resql) + // Set action type + $objcanvas->setAction(GETPOST("action")); + + // Card header + $title = $objcanvas->getTitle(); + print_fiche_titre($title); + + // Assign _POST data + $objcanvas->assign_post(); + + // Assign template values + $objcanvas->assign_values(); + + dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); + + // Display canvas + $objcanvas->display_canvas(); + } + else if (GETPOST("id") && GETPOST("action") == 'edit') + { + /* + * Mode edition + */ + + // Set action type + $objcanvas->setAction(GETPOST("action")); + + // Fetch object + $result=$objcanvas->fetch($id); + if ($result > 0) { - $obj = $db->fetch_object($resql); + // Card header + $head = contact_prepare_head($objcanvas->control->object); + $title = $objcanvas->getTitle(); + dol_fiche_head($head, 'general', $title, 0, 'contact'); + + if ($_POST["name"]) + { + // Assign _POST data + $objcanvas->assign_post(); + } + + // Assign values + $objcanvas->assign_values(); + + // Display canvas + $objcanvas->display_canvas(); } else { - dol_print_error($db); + dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); } - $contact->pays_code=$obj->code; - $contact->pays=$obj->libelle; + } + } + + if (GETPOST("id") && GETPOST("action") != 'edit') + { + // Set action type + $objcanvas->setAction('view'); - print_fiche_titre($langs->trans("AddContact")); - - // Affiche les erreurs - dol_htmloutput_errors($mesg,$errors); - - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } - - print '
'; - print '
'; - print ''; - print ''; - print ''; - - // Name - print ''; - print ''; - - // Company - if ($socid > 0) + // Fetch object + $result=$objcanvas->fetch($id); + if ($result > 0) { - print ''; - print ''; - print ''; - print ''; - } - else { - print ''; - } + // Card header + $head = contact_prepare_head($objcanvas->control->object); + $title = $objcanvas->getTitle(); + dol_fiche_head($head, 'general', $title, 0, 'contact'); - // Civility - print ''; + // Assign values + $objcanvas->assign_values(); - print ''; + // Display canvas + $objcanvas->display_canvas(); + + // Barre d'actions + if (! $user->societe_id) + { + print '
'; + + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } + + if (! $object->user_id && $user->rights->user->user->creer) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } - // Address - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->address)) == 0) $contact->address = $objsoc->address; // Predefined with third party - print '
'; - - // Zip / Town - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->cp)) == 0) $contact->cp = $objsoc->cp; // Predefined with third party - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->ville)) == 0) $contact->ville = $objsoc->ville; // Predefined with third party - print ''; - - // Country - if (dol_strlen(trim($contact->fk_pays)) == 0) $contact->fk_pays = $objsoc->pays_id; // Predefined with third party - print ''; - - // State - print ''; - - // Phone / Fax - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->phone_pro)) == 0) $contact->phone_pro = $objsoc->tel; // Predefined with third party - print ''; - print ''; - - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->fax)) == 0) $contact->fax = $objsoc->fax; // Predefined with third party - print ''; - print ''; - - // EMail - if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($contact->email)) == 0) $contact->email = $objsoc->email; // Predefined with third party - print ''; - - // Jabberid - print ''; - - // Visibility - print ''; - - // Note - print ''; - - print ''; - print "
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Company").''; - print $objsoc->getNomUrl(1); - print '
'.$langs->trans("Company").''; - print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:'','socid','',1); - //print $form->select_societes('','socid',''); - //print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; - print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$contact->civilite_id); - print '
'.$langs->trans("PostOrFunction").'poste).'">
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> '; - print 'ville).'" maxlength="80">
'.$langs->trans("Country").''; - $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 '
'.$langs->trans('State').''; - if ($contact->fk_pays) - { - $formcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$contact->fk_departement,$contact->pays_code); + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; + } + + print "
"; + } + + print show_actions_todo($conf,$langs,$db,$objsoc,$object); + + print show_actions_done($conf,$langs,$db,$objsoc,$object); } else { - print $countrynotdefined; - } - print '
'.$langs->trans("PhonePro").'phone_pro).'">'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">'.$langs->trans("Fax").'fax).'">
'.$langs->trans("Email").'email).'">
Jabberidjabberid).'">
'.$langs->trans("ContactVisibility").''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv',$selectarray,(isset($_POST["priv"])?$_POST["priv"]:$contact->priv),0); - print '
'.$langs->trans("Note").'

"; - - print "
"; + dol_htmloutput_errors($objcanvas->error,$objcanvas->errors); + } } - elseif ($_REQUEST["action"] == 'edit' && $_REQUEST["id"]) + +} +else +{ + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- + + /* + * Confirmation de la suppression du contact + */ + if ($user->rights->societe->contact->supprimer) { - /* - * Fiche en mode edition - */ - - // We set pays_id, and pays_code label of the chosen country - if (isset($_POST["pays_id"]) || $contact->fk_pays) + if ($_GET["action"] == 'delete') { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays_id"])?$_POST["pays_id"]:$contact->fk_pays); - $resql=$db->query($sql); - if ($resql) + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteContact"),$langs->trans("ConfirmDeleteContact"),"confirm_delete",'',0,1); + if ($ret == 'html') print '
'; + } + } + + /* + * Onglets + */ + if ($_GET["id"] > 0) + { + // Si edition contact deja existant + $contact = new Contact($db); + $return=$contact->fetch($_GET["id"], $user); + if ($return <= 0) + { + dol_print_error('',$contact->error); + $_GET["id"]=0; + } + + /* + * Affichage onglets + */ + $head = contact_prepare_head($contact); + + dol_fiche_head($head, 'general', $langs->trans("Contact"), 0, 'contact'); + } + + if ($user->rights->societe->contact->creer) + { + if (GETPOST("action") == 'create') + { + /* + * Fiche en mode creation + */ + $object->fk_departement = $_POST["departement_id"]; + + // We set pays_id, pays_code and label for the selected country + $object->fk_pays=$_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; + if ($object->fk_pays) { - $obj = $db->fetch_object($resql); + $sql = "SELECT code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_pays"; + $sql.= " WHERE rowid = ".$object->fk_pays; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $object->pays_code=$obj->code; + $object->pays=$obj->libelle; + } + + print_fiche_titre($langs->trans("AddContact")); + + // Affiche les erreurs + dol_htmloutput_errors($mesg,$errors); + + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print '
'; + print '
'; + print ''; + print ''; + print ''; + + // Name + print ''; + print ''; + + // Company + if ($socid > 0) + { + print ''; + print ''; + print ''; + print ''; + } + else { + print ''; + } + + // Civility + print ''; + + print ''; + + // Address + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party + print ''; + + // Zip / Town + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->cp)) == 0) $object->cp = $objsoc->cp; // Predefined with third party + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->ville)) == 0) $object->ville = $objsoc->ville; // Predefined with third party + print ''; + + // Country + if (dol_strlen(trim($object->fk_pays)) == 0) $object->fk_pays = $objsoc->pays_id; // Predefined with third party + print ''; + + // State + print ''; + + // Phone / Fax + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->tel; // Predefined with third party + print ''; + print ''; + + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party + print ''; + print ''; + + // EMail + if (($objsoc->typent_code == 'TE_PRIVATE') && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party + print ''; + + // Jabberid + print ''; + + // Visibility + print ''; + + // Note + print ''; + + print ''; + print "
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Company").''; + print $objsoc->getNomUrl(1); + print '
'.$langs->trans("Company").''; + print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:'','socid','',1); + //print $form->select_societes('','socid',''); + //print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id); + print '
'.$langs->trans("PostOrFunction").'poste).'">
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> '; + print 'ville).'" maxlength="80">
'.$langs->trans("Country").''; + $form->select_pays((isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays),'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + if ($object->fk_pays) + { + $formcompany->select_departement(isset($_POST["departement_id"])?$_POST["departement_id"]:$object->fk_departement,$object->pays_code); } else { - dol_print_error($db); + print $countrynotdefined; } - $contact->pays_code=$obj->code; - $contact->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + print '
'.$langs->trans("PhonePro").'phone_pro).'">'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">'.$langs->trans("Fax").'fax).'">
'.$langs->trans("Email").'email).'">
Jabberidjabberid).'">
'.$langs->trans("ContactVisibility").''; + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv',$selectarray,(isset($_POST["priv"])?$_POST["priv"]:$object->priv),0); + print '
'.$langs->trans("Note").'

"; + + print "
"; } - - // Affiche les erreurs - dol_htmloutput_errors($mesg,$errors); - - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + elseif (GETPOST("action") == 'edit' && GETPOST("id")) + { + /* + * Fiche en mode edition + */ + + // We set pays_id, and pays_code label of the chosen country + if (isset($_POST["pays_id"]) || $object->fk_pays) + { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays); + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + } + else + { + dol_print_error($db); + } + $object->pays_code=$obj->code; + $object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + } + + // Affiche les erreurs + dol_htmloutput_errors($mesg,$errors); + + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Ref + print ''; + + // Name + print ''; + print ''; + + // Company + print ''; + print ''; + print ''; + + // Civility + print ''; + + print ''; + + // Address + print ''; + + // Zip / Town + print ''; + + // Country + print ''; + + // Department + print ''; + + // Phone + print ''; + print ''; + + print ''; + print ''; + + // EMail + print ''; + if ($conf->mailing->enabled) + { + $langs->load("mails"); + print ''; + print ''; + } + else + { + print ''; + } + print ''; + + // Jabberid + print ''; + + // Visibility + print ''; + + print ''; + + $object->load_ref_elements(); + + if ($conf->commande->enabled) + { + print ''; + } + + if ($conf->propal->enabled) + { + print ''; + } + + if ($conf->contrat->enabled) + { + print ''; + } + + if ($conf->facture->enabled) + { + print ''; + } + + // Login Dolibarr + print ''; + + print ''; + print '
'.$langs->trans("Ref").''; + print $object->ref; + print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Company").''; + print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($object->socid?$object->socid:-1),'socid','',1); + print '
'.$langs->trans("UserTitle").''; + print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id); + print '
'.$langs->trans("PostOrFunction" ).'poste).'">
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> '; + print 'ville).'" maxlength="80">
'.$langs->trans("Country").''; + $form->select_pays(isset($_POST["pays_id"])?$_POST["pays_id"]:$object->fk_pays,'pays_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + $formcompany->select_departement($object->fk_departement,$object->pays_code); + print '
'.$langs->trans("PhonePro").'phone_pro).'">'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">'.$langs->trans("Fax").'fax).'">
'.$langs->trans("EMail").'email).'">'.$langs->trans("NbOfEMailingsReceived").''.$object->getNbOfEMailings().' 
Jabberidjabberid).'">
'.$langs->trans("ContactVisibility").''; + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('priv',$selectarray,$object->priv,0); + print '
'.$langs->trans("Note").''; + print '
'.$langs->trans("ContactForOrders").''; + print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder"); + print '
'.$langs->trans("ContactForProposals").''; + print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); + print '
'.$langs->trans("ContactForContracts").''; + print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); + print '
'.$langs->trans("ContactForInvoices").''; + print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print '
'.$langs->trans("DolibarrLogin").''; + if ($object->user_id) + { + $dolibarr_user=new User($db); + $result=$dolibarr_user->fetch($object->user_id); + print $dolibarr_user->getLoginUrl(1); + } + else print $langs->trans("NoDolibarrAccess"); + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print "
"; + } + } + + if (GETPOST("id") && GETPOST("action") != 'edit') + { + $objsoc = new Societe($db); + + /* + * Fiche en mode visualisation + */ + if ($msg) + { + $langs->load("errors"); + print '
'.$langs->trans($msg).'
'; + } + + if ($_GET["action"] == 'create_user') + { + $login=strtolower(substr($object->prenom, 0, 4)) . strtolower(substr($object->nom, 0, 4)); + + // Create a form array + $formquestion=array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)); + + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion); + if ($ret == 'html') print '
'; + } + print ''; - + // Ref - print ''; - + // Name - print ''; - print ''; - + print ''; + print ''; + // Company - print ''; - print ''; - print ''; - - // Civility - print ''; - - print ''; - + + // Civility + print ''; + + print ''; + // Address - print ''; - - // Zip / Town - print ''; - + print ''; + + // Zip Town + print ''; + // Country print ''; - + // Department - print ''; - + print ''; + // Phone - print ''; - print ''; - - print ''; - print ''; - - // EMail - print ''; + print ''; + print ''; + + print ''; + print ''; + + // Email + print ''; if ($conf->mailing->enabled) { $langs->load("mails"); print ''; - print ''; + print ''; } else { print ''; } print ''; - + // Jabberid - print ''; - - // Visibility + print ''; + print ''; - + print ''; - - $contact->load_ref_elements(); - + print nl2br($object->note); + print ''; + + $object->load_ref_elements(); + if ($conf->commande->enabled) { print ''; } - + if ($conf->propal->enabled) { print ''; } - + if ($conf->contrat->enabled) { print ''; } - + if ($conf->facture->enabled) { print ''; } - - // Login Dolibarr + print ''; - - print ''; - print '
'.$langs->trans("Ref").''; - print $contact->ref; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'id'); print '
'.$langs->trans("Lastname").' / '.$langs->trans("Label").'name).'">'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Lastname").''.$object->name.''.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Company").''; - print $form->select_societes(isset($_POST["socid"])?$_POST["socid"]:($contact->socid?$contact->socid:-1),'socid','',1); - print '
'.$langs->trans("UserTitle").''; - print $formcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$contact->civilite_id); + print '
'.$langs->trans("Company").''; + if ($object->socid > 0) + { + $objsoc->fetch($object->socid); + print $objsoc->getNomUrl(1); + } + else + { + print $langs->trans("ContactNotLinkedToCompany"); + } print '
'.$langs->trans("PostOrFunction" ).'poste).'">
'.$langs->trans("UserTitle").''; + print $object->getCivilityLabel(); + print '
'.$langs->trans("PostOrFunction" ).''.$object->poste.'
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> '; - print 'ville).'" maxlength="80">
'.$langs->trans("Address").''.nl2br($object->address).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; + print $object->cp; + if ($object->cp) print ' '; + print $object->ville.'
'.$langs->trans("Country").''; - $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); + $img=picto_from_langcode($object->pays_code); + if ($img) print $img.' '; + print $object->pays; print '
'.$langs->trans('State').''; - $formcompany->select_departement($contact->fk_departement,$contact->pays_code); - print '
'.$langs->trans('State').''.$object->departement.'
'.$langs->trans("PhonePro").'phone_pro).'">'.$langs->trans("PhonePerso").'phone_perso).'">
'.$langs->trans("PhoneMobile").'phone_mobile).'">'.$langs->trans("Fax").'fax).'">
'.$langs->trans("EMail").'email).'">
'.$langs->trans("PhonePro").''.dol_print_phone($object->phone_pro,$object->pays_code,$object->id,$object->socid,'AC_TEL').''.$langs->trans("PhonePerso").''.dol_print_phone($object->phone_perso,$object->pays_code,$object->id,$object->socid,'AC_TEL').'
'.$langs->trans("PhoneMobile").''.dol_print_phone($object->phone_mobile,$object->pays_code,$object->id,$object->socid,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($object->fax,$object->pays_code,$object->id,$object->socid,'AC_FAX').'
'.$langs->trans("EMail").''.dol_print_email($object->email,$object->id,$object->socid,'AC_EMAIL').''.$langs->trans("NbOfEMailingsReceived").''.$contact->getNbOfEMailings().''.$object->getNbOfEMailings().' 
Jabberidjabberid).'">
Jabberid'.$object->jabberid.'
'.$langs->trans("ContactVisibility").''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('priv',$selectarray,$contact->priv,0); + print $object->LibPubPriv($object->priv); print '
'.$langs->trans("Note").''; - print '
'.$langs->trans("ContactForOrders").''; - print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); + print $object->ref_commande?$object->ref_commande:$langs->trans("NoContactForAnyOrder"); print '
'.$langs->trans("ContactForProposals").''; - print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); + print $object->ref_propal?$object->ref_propal:$langs->trans("NoContactForAnyProposal"); print '
'.$langs->trans("ContactForContracts").''; - print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); + print $object->ref_contrat?$object->ref_contrat:$langs->trans("NoContactForAnyContract"); print '
'.$langs->trans("ContactForInvoices").''; - print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print $object->ref_facturation?$object->ref_facturation:$langs->trans("NoContactForAnyInvoice"); print '
'.$langs->trans("DolibarrLogin").''; - if ($contact->user_id) + if ($object->user_id) { $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($contact->user_id); + $result=$dolibarr_user->fetch($object->user_id); print $dolibarr_user->getLoginUrl(1); } else print $langs->trans("NoDolibarrAccess"); print '
'; - print ''; - print '   '; - print ''; - print '
'; - - print ""; - } -} - -if ($_REQUEST["id"] && $_REQUEST["action"] != 'edit') -{ - $objsoc = new Societe($db); - - /* - * Fiche en mode visualisation - * - */ - if ($msg) - { - $langs->load("errors"); - print '
'.$langs->trans($msg).'
'; - } - - if ($_GET["action"] == 'create_user') - { - $login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4)); - - // Create a form array - $formquestion=array( - array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)); - - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$contact->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion); - if ($ret == 'html') print '
'; - } - - print ''; - - // Ref - print ''; - - // Name - print ''; - print ''; - - // Company - print ''; - - // Civility - print ''; - - print ''; - - // Address - print ''; - - // Zip Town - print ''; - - // Country - print ''; - - // Department - print ''; - - // Phone - print ''; - print ''; - - print ''; - print ''; - - // Email - print ''; - if ($conf->mailing->enabled) - { - $langs->load("mails"); - print ''; - print ''; - } - else - { - print ''; - } - print ''; - - // Jabberid - print ''; - - print ''; - - print ''; - - $contact->load_ref_elements(); - - if ($conf->commande->enabled) - { - print ''; - } - - if ($conf->propal->enabled) - { - print ''; - } - - if ($conf->contrat->enabled) - { - print ''; - } - - if ($conf->facture->enabled) - { - print ''; - } - - print ''; - - print "
'.$langs->trans("Ref").''; - print $form->showrefnav($contact,'id'); - print '
'.$langs->trans("Lastname").''.$contact->name.''.$langs->trans("Firstname").''.$contact->firstname.'
'.$langs->trans("Company").''; - if ($contact->socid > 0) - { - $objsoc->fetch($contact->socid); - print $objsoc->getNomUrl(1); - } - else - { - print $langs->trans("ContactNotLinkedToCompany"); - } - print '
'.$langs->trans("UserTitle").''; - print $contact->getCivilityLabel(); - print '
'.$langs->trans("PostOrFunction" ).''.$contact->poste.'
'.$langs->trans("Address").''.nl2br($contact->address).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $contact->cp; - if ($contact->cp) print ' '; - print $contact->ville.'
'.$langs->trans("Country").''; - $img=picto_from_langcode($contact->pays_code); - if ($img) print $img.' '; - print $contact->pays; - print '
'.$langs->trans('State').''.$contact->departement.'
'.$langs->trans("PhonePro").''.dol_print_phone($contact->phone_pro,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').''.$langs->trans("PhonePerso").''.dol_print_phone($contact->phone_perso,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').'
'.$langs->trans("PhoneMobile").''.dol_print_phone($contact->phone_mobile,$contact->pays_code,$contact->id,$contact->socid,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($contact->fax,$contact->pays_code,$contact->id,$contact->socid,'AC_FAX').'
'.$langs->trans("EMail").''.dol_print_email($contact->email,$contact->id,$contact->socid,'AC_EMAIL').''.$langs->trans("NbOfEMailingsReceived").''.$contact->getNbOfEMailings().' 
Jabberid'.$contact->jabberid.'
'.$langs->trans("ContactVisibility").''; - print $contact->LibPubPriv($contact->priv); - print '
'.$langs->trans("Note").''; - print nl2br($contact->note); - print '
'.$langs->trans("ContactForOrders").''; - print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); - print '
'.$langs->trans("ContactForProposals").''; - print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); - print '
'.$langs->trans("ContactForContracts").''; - print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); - print '
'.$langs->trans("ContactForInvoices").''; - print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); - print '
'.$langs->trans("DolibarrLogin").''; - if ($contact->user_id) - { - $dolibarr_user=new User($db); - $result=$dolibarr_user->fetch($contact->user_id); - print $dolibarr_user->getLoginUrl(1); - } - else print $langs->trans("NoDolibarrAccess"); - print '
"; - - print ""; - - - // Barre d'actions - if (! $user->societe_id) - { - print '
'; - - if ($user->rights->societe->contact->creer) + + print ""; + + print "
"; + + // Barre d'actions + if (! $user->societe_id) { - print ''.$langs->trans('Modify').''; + print '
'; + + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Modify').''; + } + + if (! $object->user_id && $user->rights->user->user->creer) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } + + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; + } + + print "

"; } - - if (! $contact->user_id && $user->rights->user->user->creer) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } - - if ($user->rights->societe->contact->supprimer) - { - print ''.$langs->trans('Delete').''; - } - - print "
"; + + print show_actions_todo($conf,$langs,$db,$objsoc,$object); + + print show_actions_done($conf,$langs,$db,$objsoc,$object); } - - - print show_actions_todo($conf,$langs,$db,$objsoc,$contact); - - print show_actions_done($conf,$langs,$db,$objsoc,$contact); } $db->close(); diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index dba98f4e22b..6ac06991d55 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -84,9 +84,9 @@ class Canvas * Execute actions * @param Id of object (may be empty for creation) */ - function doActions($socid) + function doActions($id) { - return $this->control->doActions($socid); + return $this->control->doActions($id); } /** @@ -118,13 +118,19 @@ class Canvas { $childmodule = $this->aliasmodule = $this->module = $regs[2]; $this->canvas = $regs[1]; - - // For compatibility - if ($childmodule == 'thirdparty') $childmodule = $this->aliasmodule = 'societe'; - if ($targetmodule == 'thirdparty') $targetmodule = 'societe'; + } + + // For compatibility + if ($childmodule == 'thirdparty') $childmodule = $this->aliasmodule = 'societe'; + if ($targetmodule == 'thirdparty') $targetmodule = 'societe'; + if ($childmodule == 'contact') + { + $childmodule = 'societe'; + $this->targetmodule = 'contact'; } //print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'
'; + //print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'
'; //print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'
'; if (! $conf->$childmodule->enabled || ! $conf->$targetmodule->enabled) accessforbidden(); @@ -159,6 +165,7 @@ class Canvas } else { + //print 'access ko'; accessforbidden(); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ced87e8760e..1982648b352 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -485,19 +485,35 @@ class Form print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); } - + /** - * \brief Output html form to select a third party - * \param selected Preselected type - * \param htmlname Name of field in form - * \param filter Optionnal filters criteras - * \param showempty Add an empty field - * \param showtype Show third party type in combolist (customer, prospect or supplier) - * \param forcecombo Force to use combo box + * Output html form to select a third party + * @param selected Preselected type + * @param htmlname Name of field in form + * @param filter Optionnal filters criteras + * @param showempty Add an empty field + * @param showtype Show third party type in combolist (customer, prospect or supplier) + * @param forcecombo Force to use combo box */ function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) + { + print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo); + } + + /** + * Output html form to select a third party + * @param selected Preselected type + * @param htmlname Name of field in form + * @param filter Optionnal filters criteras + * @param showempty Add an empty field + * @param showtype Show third party type in combolist (customer, prospect or supplier) + * @param forcecombo Force to use combo box + */ + function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) { global $conf,$user,$langs; + + $out=''; // On recherche les societes $sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; @@ -524,26 +540,26 @@ class Form $socid = $obj->rowid?$obj->rowid:''; } - print "\n".''."\n"; - print ''; - print ''; + $out.= ''; + $out.= '
'; + $out.= "\n".''."\n"; + $out.= ''; + $out.= ''; - print ''; - print '
'; if ($socid == 0) { - print ''; + $out.= ''; } else { - print ''; + $out.= ''; } - print ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '', $minLength); - print '
'; + $out.= ajax_autocompleter(($socid?$socid:-1),$htmlname,DOL_URL_ROOT.'/societe/ajaxcompanies.php?filter='.urlencode($filter), '', $minLength); + $out.= '
'; } else { - print ''; + if ($showempty) $out.=$out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -562,22 +578,24 @@ class Form } if ($selected > 0 && $selected == $obj->rowid) { - print ''; + $out.= ''; } else { - print ''; + $out.= ''; } $i++; } } - print ''; + $out.= ''; } } else { dol_print_error($this->db); } + + return $out; } diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql index 6fd8182a779..4450fe1ab52 100644 --- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql +++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql @@ -94,4 +94,6 @@ create table llx_c_ziptown )type=innodb; ALTER TABLE llx_c_ziptown ADD INDEX idx_c_ziptown_fk_county (fk_county); -ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county FOREIGN KEY (fk_county) REFERENCES llx_c_departements (rowid); \ No newline at end of file +ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_county FOREIGN KEY (fk_county) REFERENCES llx_c_departements (rowid); + +ALTER TABLE llx_socpeople ADD COLUMN canvas varchar(32) DEFAULT 'default@contact' after default_lang; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index b44880289f3..57eeaa6224a 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -24,59 +24,59 @@ create table llx_societe ( rowid integer AUTO_INCREMENT PRIMARY KEY, - statut tinyint DEFAULT 0, -- statut + statut tinyint DEFAULT 0, -- statut parent integer, tms timestamp, - datec datetime, -- creation date - datea datetime, -- activation date - nom varchar(60), -- company name - entity integer DEFAULT 1 NOT NULL, -- multi company id - code_client varchar(15), -- code client - code_fournisseur varchar(15), -- code founisseur - code_compta varchar(15), -- code compta client - code_compta_fournisseur varchar(15), -- code compta founisseur - address varchar(255), -- company adresse - cp varchar(10), -- zipcode - ville varchar(50), -- town - fk_departement integer DEFAULT 0, -- - fk_pays integer DEFAULT 0, -- - tel varchar(20), -- phone number - fax varchar(20), -- fax number - url varchar(255), -- - email varchar(128), -- - fk_secteur integer DEFAULT 0, -- - fk_effectif integer DEFAULT 0, -- - fk_typent integer DEFAULT 0, -- - fk_forme_juridique integer DEFAULT 0, -- forme juridique INSEE - siren varchar(16), -- IDProf1: siren ou RCS pour france - siret varchar(16), -- IDProf2: siret pour france - ape varchar(16), -- IDProf3: code ape pour france - idprof4 varchar(16), -- IDProf4: nu pour france - tva_intra varchar(20), -- tva - capital real, -- capital de la societe - description text, -- - fk_stcomm smallint DEFAULT 0, -- commercial statut - note text, -- - services tinyint DEFAULT 0, -- - prefix_comm varchar(5), -- prefix commercial - client tinyint DEFAULT 0, -- client 0/1/2 - fournisseur tinyint DEFAULT 0, -- fournisseur 0/1 - supplier_account varchar(32), -- compte client chez un fournisseur - fk_prospectlevel varchar(12), -- prospect level (in llx_c_prospectlevel) - customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1 - customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1) - supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1) - fk_user_creat integer NULL, -- utilisateur qui a cree l'info - fk_user_modif integer, -- utilisateur qui a modifie l'info - remise_client real DEFAULT 0, -- remise systematique pour le client - mode_reglement tinyint, -- mode de reglement - cond_reglement tinyint, -- condition de reglement - tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA - localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 - localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2 - gencod varchar(255), -- barcode - price_level integer NULL, -- level of price for multiprices - default_lang varchar(6), -- default language - canvas varchar(32) DEFAULT 'default', -- type of canvas - import_key varchar(14) -- import key + datec datetime, -- creation date + datea datetime, -- activation date + nom varchar(60), -- company name + entity integer DEFAULT 1 NOT NULL, -- multi company id + code_client varchar(15), -- code client + code_fournisseur varchar(15), -- code founisseur + code_compta varchar(15), -- code compta client + code_compta_fournisseur varchar(15), -- code compta founisseur + address varchar(255), -- company adresse + cp varchar(10), -- zipcode + ville varchar(50), -- town + fk_departement integer DEFAULT 0, -- + fk_pays integer DEFAULT 0, -- + tel varchar(20), -- phone number + fax varchar(20), -- fax number + url varchar(255), -- + email varchar(128), -- + fk_secteur integer DEFAULT 0, -- + fk_effectif integer DEFAULT 0, -- + fk_typent integer DEFAULT 0, -- + fk_forme_juridique integer DEFAULT 0, -- forme juridique INSEE + siren varchar(16), -- IDProf1: siren ou RCS pour france + siret varchar(16), -- IDProf2: siret pour france + ape varchar(16), -- IDProf3: code ape pour france + idprof4 varchar(16), -- IDProf4: nu pour france + tva_intra varchar(20), -- tva + capital real, -- capital de la societe + description text, -- + fk_stcomm smallint DEFAULT 0, -- commercial statut + note text, -- + services tinyint DEFAULT 0, -- + prefix_comm varchar(5), -- prefix commercial + client tinyint DEFAULT 0, -- client 0/1/2 + fournisseur tinyint DEFAULT 0, -- fournisseur 0/1 + supplier_account varchar(32), -- compte client chez un fournisseur + fk_prospectlevel varchar(12), -- prospect level (in llx_c_prospectlevel) + customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1 + customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1) + supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1) + fk_user_creat integer NULL, -- utilisateur qui a cree l'info + fk_user_modif integer, -- utilisateur qui a modifie l'info + remise_client real DEFAULT 0, -- remise systematique pour le client + mode_reglement tinyint, -- mode de reglement + cond_reglement tinyint, -- condition de reglement + tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA + localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 + localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2 + gencod varchar(255), -- barcode + price_level integer NULL, -- level of price for multiprices + default_lang varchar(6), -- default language + canvas varchar(32) DEFAULT 'default@thirdparty', -- type of canvas + import_key varchar(14) -- import key )type=innodb; diff --git a/htdocs/install/mysql/tables/llx_socpeople.sql b/htdocs/install/mysql/tables/llx_socpeople.sql index 17c08e3340d..f8fbd0ec9a9 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.sql @@ -1,7 +1,7 @@ -- ============================================================================ -- Copyright (C) 2001-2004 Rodolphe Quiedeville -- Copyright (C) 2008 Laurent Destailleur --- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2005-2010 Regis Houssin -- -- 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 @@ -22,39 +22,32 @@ create table llx_socpeople ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - fk_soc integer, -- lien vers la societe - entity integer DEFAULT 1 NOT NULL, -- multi company id - civilite varchar(6), - name varchar(50), - firstname varchar(50), - address varchar(255), - cp varchar(25), - ville varchar(255), - fk_departement integer, - fk_pays integer DEFAULT 0, - birthday date, - poste varchar(80), - phone varchar(30), - phone_perso varchar(30), - phone_mobile varchar(30), - fax varchar(30), - email varchar(255), - jabberid varchar(255), - priv smallint NOT NULL DEFAULT 0, - fk_user_creat integer DEFAULT 0, -- user qui a creel'enregistrement - fk_user_modif integer, - note text, - default_lang varchar(6), - import_key varchar(14) + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + tms timestamp, + fk_soc integer, -- lien vers la societe + entity integer DEFAULT 1 NOT NULL, -- multi company id + civilite varchar(6), + name varchar(50), + firstname varchar(50), + address varchar(255), + cp varchar(25), + ville varchar(255), + fk_departement integer, + fk_pays integer DEFAULT 0, + birthday date, + poste varchar(80), + phone varchar(30), + phone_perso varchar(30), + phone_mobile varchar(30), + fax varchar(30), + email varchar(255), + jabberid varchar(255), + priv smallint NOT NULL DEFAULT 0, + fk_user_creat integer DEFAULT 0, -- user qui a creel'enregistrement + fk_user_modif integer, + note text, + default_lang varchar(6), + canvas varchar(32) DEFAULT 'default@contact', -- type of canvas + import_key varchar(14) )type=innodb; - --- --- List of codes for the field entity --- --- 1 : first company contact --- 2 : second company contact --- 3 : etc... --- \ No newline at end of file diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 8bdf74a5085..0c25309e9bd 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -187,9 +187,9 @@ class ActionsCardCommon $this->tpl['checksuppliercode'] = $this->object->check_codefournisseur(); $this->tpl['address'] = dol_nl2br($this->object->address); - $img=picto_from_langcode($this->pays_code); - if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->pays,$langs->trans("CountryIsInEEC"),1,0); - $this->tpl['country'] = ($img?$img.' ':'').$this->pays; + $img=picto_from_langcode($this->object->pays_code); + if ($this->object->isInEEC()) $this->tpl['country'] = $form->textwithpicto(($img?$img.' ':'').$this->object->country,$langs->trans("CountryIsInEEC"),1,0); + $this->tpl['country'] = ($img?$img.' ':'').$this->object->country; $this->tpl['phone'] = dol_print_phone($this->object->tel,$this->object->pays_code,0,$this->object->id,'AC_TEL'); $this->tpl['fax'] = dol_print_phone($this->object->fax,$this->object->pays_code,0,$this->object->id,'AC_FAX');