From 373340307caee9c2ff32eacf0585006e11221ecd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Aug 2006 20:51:38 +0000 Subject: [PATCH] =?UTF-8?q?Possibilit=E9=20d'affecter=20=E0=20une=20soci?= =?UTF-8?q?=E9t=E9=20un=20contact=20qui=20n'est=20affect=E9=20a=20aucune.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/contact.php | 14 +- htdocs/contact.class.php | 8 +- htdocs/contact/fiche.php | 993 +++++++++++++++++++------------------ htdocs/contact/index.php | 11 +- htdocs/html.form.class.php | 3 +- 5 files changed, 519 insertions(+), 510 deletions(-) diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 059c904d3d8..137ef34b37b 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Éric Seigne - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,6 @@ * * $Id$ * $Source$ - * */ /** @@ -86,13 +85,12 @@ if ($type == "f") $sql = "SELECT s.idp, s.nom, st.libelle as stcomm"; $sql .= ", p.idp as cidp, p.name, p.firstname, p.email, p.phone"; if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", sc.fk_soc, sc.fk_user"; -$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql .= " , ".MAIN_DB_PREFIX."socpeople as p"; -$sql .= " , ".MAIN_DB_PREFIX."c_stcomm as st"; -if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql .= " WHERE s.fk_stcomm = st.id AND s.idp = p.fk_soc"; +$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st,"; +if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; +$sql .= " ".MAIN_DB_PREFIX."socpeople as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.idp = p.fk_soc"; +$sql .= " WHERE s.fk_stcomm = st.id"; if (!$user->rights->commercial->client->voir && !$socidp) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($type == "c") $sql .= " AND s.client = 1"; if ($type == "p") $sql .= " AND s.client = 2"; if ($type == "f") $sql .= " AND s.fournisseur = 1"; diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 61c8eb2b2b4..fc1c8d017cd 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -131,7 +131,7 @@ class Contact $this->email=trim($this->email); $this->phone_pro=trim($this->phone_pro); - if ($this->phone_pro && $this->socid > 0) + if (! $this->phone_pro && $this->socid > 0) { $soc = new Societe($this->db); $soc->fetch($this->socid); @@ -139,7 +139,9 @@ class Contact } $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; - $sql .= " civilite='".addslashes($this->civilite_id)."'"; + if ($this->socid > 0) $sql .= " fk_soc='".addslashes($this->socid)."'"; + if ($this->socid == -1) $sql .= " fk_soc=null"; + $sql .= ", civilite='".addslashes($this->civilite_id)."'"; $sql .= ", name='".addslashes($this->name)."'"; $sql .= ", firstname='".addslashes($this->firstname)."'"; $sql .= ", address='".addslashes($this->address)."'"; @@ -160,7 +162,7 @@ class Contact $result = $this->db->query($sql); if (! $result) { - $this->error=$this->db->error(); + $this->error=$this->db->error().' sql='.$sql; return -1; } diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 2500a9c8163..a925a282f6a 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -54,35 +54,35 @@ if ($user->societe_id > 0) // Protection restriction commercial if ($contactid && !$user->rights->commercial->client->voir) { - $sql = "SELECT sc.fk_soc, sp.fk_soc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp"; - $sql .= " WHERE sp.idp = ".$contactid; - if (!$user->rights->commercial->client->voir && !$user->societe_id > 0) - { - $sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id; - } - if ($user->societe_id > 0) $sql .= " AND sp.fk_soc = ".$socid; - - if ( $db->query($sql) ) - { - if ( $db->num_rows() == 0) accessforbidden(); - } + $sql = "SELECT sc.fk_soc, sp.fk_soc"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."socpeople as sp"; + $sql .= " WHERE sp.idp = ".$contactid; + if (!$user->rights->commercial->client->voir && !$user->societe_id > 0) + { + $sql .= " AND sc.fk_soc = sp.fk_soc AND sc.fk_user = ".$user->id; + } + if ($user->societe_id > 0) $sql .= " AND sp.fk_soc = ".$socid; + + if ( $db->query($sql) ) + { + if ( $db->num_rows() == 0) accessforbidden(); + } } if ($user->rights->societe->contact->creer) { - if ($_GET["action"] == 'create_user' && $user->admin) - { - // Recuperation contact actuel - $contact = new Contact($db); - $result = $contact->fetch($_GET["id"]); - - // Creation user - $nuser = new User($db); - $nuser->nom = $contact->name; - $nuser->prenom = $contact->firstname; - $nuser->create_from_contact($contact); - } + if ($_GET["action"] == 'create_user' && $user->admin) + { + // Recuperation contact actuel + $contact = new Contact($db); + $result = $contact->fetch($_GET["id"]); + + // Creation user + $nuser = new User($db); + $nuser->nom = $contact->name; + $nuser->prenom = $contact->firstname; + $nuser->create_from_contact($contact); + } } if ($user->rights->societe->contact->creer) @@ -132,15 +132,15 @@ if ($user->rights->societe->contact->creer) if ($user->rights->societe->contact->supprimer) { - if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') + if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') { $contact = new Contact($db); - + $contact->old_name = $_POST["old_name"]; $contact->old_firstname = $_POST["old_firstname"]; - + $result = $contact->delete($_GET["id"]); - + Header("Location: index.php"); exit; } @@ -148,36 +148,36 @@ if ($user->rights->societe->contact->supprimer) if ($user->rights->societe->contact->creer) { - if ($_POST["action"] == 'update') + if ($_POST["action"] == 'update') { $contact = new Contact($db); - + $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_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->note = $_POST["note"]; - + $result = $contact->update($_POST["contactid"], $user); - - if ($contact->error) + + if ($contact->error) { $error = $contact->error; } @@ -202,522 +202,529 @@ if ($socid) /* - * Onglets - */ +* Onglets +*/ if ($_GET["id"] > 0) { - // Si edition contact deja existant - $contact = new Contact($db); - $return=$contact->fetch($_GET["id"], $user); - if ($return < 0) - { - dolibarr_print_error('',$contact->error); - } - - $h=0; - $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("General"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("PersonalInformations"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("ExportImport"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; - $head[$h][1] = $langs->trans("Info"); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); + // Si edition contact deja existant + $contact = new Contact($db); + $return=$contact->fetch($_GET["id"], $user); + if ($return < 0) + { + dolibarr_print_error('',$contact->error); + } + + $h=0; + $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("General"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("PersonalInformations"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("ExportImport"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); } /* - * Confirmation de la suppression du contact - * - */ +* Confirmation de la suppression du contact +* +*/ if ($user->rights->societe->contact->supprimer) { - if ($_GET["action"] == 'delete') - { - $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Êtes-vous sûr de vouloir supprimer ce contact ?","confirm_delete"); - print '
'; - } + if ($_GET["action"] == 'delete') + { + $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Êtes-vous sûr de vouloir supprimer ce contact ?","confirm_delete"); + print '
'; + } } if ($user->rights->societe->contact->creer) { - if ($_GET["action"] == 'create') - { - /* - * Fiche en mode creation - * - */ - print_fiche_titre($langs->trans("AddContact")); + if ($_GET["action"] == 'create') + { + /* + * Fiche en mode creation + * + */ + print_fiche_titre($langs->trans("AddContact")); - // Affiche les erreurs - if (sizeof($error)) - { - print "
"; - print join("
",$error); - print "
\n"; - } + // Affiche les erreurs + if (sizeof($error)) + { + print "
"; + print join("
",$error); + print "
\n"; + } - print '
'; - print '
'; - print ''; - print ''; + print '
'; + print ''; + print ''; + print '
'; - if ($socid) - { - // On remplit avec le numéro de la société par défaut - if (strlen(trim($contact->phone_pro)) == 0) - { - $contact->phone_pro = $objsoc->tel; - } + if ($socid) + { + // On remplit avec le numéro de la société par défaut + if (strlen(trim($contact->phone_pro)) == 0) + { + $contact->phone_pro = $objsoc->tel; + } - print ''; - print ''; - print ''; - print ''; - } - else { - print ''; - } + print ''; + print ''; + print ''; + print ''; + } + else { + print ''; + } - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - print "
'.$langs->trans("Company").''.$objsoc->nom.'
'.$langs->trans("Company").''; - //print $form->select_societes('','socid',''); - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("Company").''.$objsoc->nom.'
'.$langs->trans("Company").''; + //print $form->select_societes('','socid',''); + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; - print $form->select_civilite($contact->civilite_id); - print '
'.$langs->trans("UserTitle").''; + print $form->select_civilite($contact->civilite_id); + print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
Poste/Fonction
Poste/Fonction
'.$langs->trans("Address").'
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; + print '
'.$langs->trans("Country").''; - $form->select_pays($contact->fk_pays); - print '
'.$langs->trans("Country").''; + $form->select_pays($contact->fk_pays); + print '
Tel ProTel Perso
Tel ProTel Perso
Portable'.$langs->trans("Fax").'
Portable'.$langs->trans("Fax").'
'.$langs->trans("Email").'
'.$langs->trans("Email").'
Jabberid
Jabberid
'.$langs->trans("Note").'
'.$langs->trans("Note").'

"; + print ''; + print "
"; - print "
"; - } - elseif ($_GET["action"] == 'edit' && $_GET["id"]) - { - /* - * Fiche en mode edition - * - */ + print ""; + } + elseif ($_GET["action"] == 'edit' && $_GET["id"]) + { + /* + * Fiche en mode edition + * + */ - // Affiche les erreurs - if (sizeof($error)) - { - print "
"; - print join("
",$error); - print "
\n"; - } + // Affiche les erreurs + if (sizeof($error)) + { + print "
"; + print join("
",$error); + print "
\n"; + } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; - if ($contact->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + print ''; + print ''; + print ''; +/* + if ($contact->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); - print ''; - } - else - { - print ''; - } - print ''; + print ''; + } + else + { + print ''; + } +*/ + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - if ($conf->mailing->enabled) - { - $langs->load("mails"); - print ''; - print ''; - } - else - { - print ''; - } - print ''; + print ''; + if ($conf->mailing->enabled) + { + $langs->load("mails"); + print ''; + print ''; + } + else + { + print ''; + } + print ''; - print ''; + 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 ''; - print '
'.$langs->trans("Company").''; + print $form->select_societes($contact->socid?$contact->socid:-1,'socid','',1); + print '
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; - print $form->select_civilite($contact->civilite_id); - print '
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + print $form->select_civilite($contact->civilite_id); + print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'
Poste/Fonction
Poste/Fonction
'.$langs->trans("Address").'
'.$langs->trans("Address").'
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; + print '
'.$langs->trans("Country").''; - $form->select_pays($contact->fk_pays); - print '
'.$langs->trans("Country").''; + $form->select_pays($contact->fk_pays); + print '
Tel ProTel Perso
Tel ProTel Perso
Portable'.$langs->trans("Fax").'
Portable'.$langs->trans("Fax").'
'.$langs->trans("EMail").''.$langs->trans("NbOfEMailingsReceived").''.$contact->getNbOfEMailings().' 
'.$langs->trans("EMail").''.$langs->trans("NbOfEMailingsReceived").''.$contact->getNbOfEMailings().' 
Jabberid
Jabberid
'.$langs->trans("Note").''; - print '
'.$langs->trans("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) print ''.$contact->user_login.''; - else print $langs->trans("NoDolibarrAccess"); - print '
'; + $contact->load_ref_elements(); - print "
"; - } + if ($conf->commande->enabled) + { + print ''.$langs->trans("ContactForOrders").''; + print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); + print ''; + } + + if ($conf->propal->enabled) + { + print ''.$langs->trans("ContactForProposals").''; + print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); + print ''; + } + + if ($conf->contrat->enabled) + { + print ''.$langs->trans("ContactForContracts").''; + print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); + print ''; + } + + if ($conf->facture->enabled) + { + print ''.$langs->trans("ContactForInvoices").''; + print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print ''; + } + + print ''.$langs->trans("DolibarrLogin").''; + if ($contact->user_id) print ''.$contact->user_login.''; + else print $langs->trans("NoDolibarrAccess"); + print ''; + + print ''; + print ''; + + print ""; + } } if ($_GET["id"] && $_GET["action"] != 'edit') { - /* - * Fiche en mode visualisation - * - */ - - print ''; - - if ($contact->socid > 0) - { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); + /* + * Fiche en mode visualisation + * + */ - print ''; - } - else - { - print ''; - } - - print ''; - - print ''; - print ''; - - print ''; - - print ''; - - print ''; - - print ''; + print '
'.$langs->trans("Company").''.$objsoc->getNomUrl(1).'
'.$langs->trans("Company").''; - print $langs->trans("ContactNotLinkedToCompany"); - print '
'.$langs->trans("UserTitle").''; - print $form->civilite_name($contact->civilite_id); - print '
'.$langs->trans("Lastname").''.$contact->name.''.$langs->trans("Firstname").''.$contact->firstname.'
Poste/Fonction'.$contact->poste.'
'.$langs->trans("Address").''.$contact->address.'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$contact->cp.' '; - print $contact->ville.'
'.$langs->trans("Country").''; - print $contact->pays; - print '
'; - print ''; - print ''; - - print ''; - print ''; - - print ''; - if ($conf->mailing->enabled) - { - $langs->load("mails"); - print ''; - print ''; - } - else - { - print ''; - } - print ''; + if ($contact->socid > 0) + { + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); - 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 "
Tel Pro'.$contact->phone_pro.'Tel Perso'.$contact->phone_perso.'
Portable'.$contact->phone_mobile.''.$langs->trans("Fax").''.$contact->fax.'
'.$langs->trans("EMail").''; - if ($contact->email && ! ValidEmail($contact->email)) - { - print ''.$langs->trans("ErrorBadEMail",$contact->email).""; - } - else - { - print $contact->email; - } - print ''.$langs->trans("NbOfEMailingsReceived").''.$contact->getNbOfEMailings().' 
Jabberid'.$contact->jabberid.'
'.$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) print ''.$contact->user_login.''; - else print $langs->trans("NoDolibarrAccess"); - print '
"; - - print ""; - - - // Barre d'actions - if (! $user->societe_id) - { - print '
'; - - if ($user->rights->societe->contact->creer) - { - print ''.$langs->trans('Edit').''; - } - - if (! $contact->user_id && $user->admin) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } - - if ($user->rights->societe->contact->supprimer) - { - print ''.$langs->trans('Delete').''; - } - - print "

"; - } - - - // Historique des actions sur ce contact - print_titre ($langs->trans("TasksHistoryForThisContact")); - $histo=array(); - $numaction = 0 ; - - // Recherche histo sur actioncomm - $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, a.note, a.percent as percent,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.rowid as user_id, u.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; - $sql.= " WHERE fk_contact = ".$contact->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action"; - $sql.= " ORDER BY a.datea DESC, a.id DESC"; - - $resql=$db->query($sql); - if ($resql) - { - $i = 0 ; - $num = $db->num_rows($resql); - $var=true; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $histo[$numaction]=array('type'=>'action','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent, - 'acode'=>$obj->acode,'libelle'=>$obj->libelle, - 'userid'=>$obj->user_id,'code'=>$obj->code); - $numaction++; - $i++; - } - } - else - { - dolibarr_print_error($db); - } + print ''.$langs->trans("Company").''.$objsoc->getNomUrl(1).''; + } + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } - // Recherche histo sur mailing - $sql = "SELECT m.rowid as id, ".$db->pdate("mc.date_envoi")." as da, m.titre as note, '100' as percent,"; - $sql.= " 'AC_EMAILING' as acode,"; - $sql.= " u.rowid as user_id, u.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u "; - $sql.= " WHERE mc.email = '".addslashes($contact->email)."'"; - $sql.= " AND mc.statut = 1"; - $sql.= " AND u.rowid = m.fk_user_valid"; - $sql.= " AND mc.fk_mailing=m.rowid"; - $sql.= " ORDER BY mc.date_envoi DESC, m.rowid DESC"; + print ''.$langs->trans("UserTitle").''; + print $form->civilite_name($contact->civilite_id); + print ''; - $resql=$db->query($sql); - if ($resql) - { - $i = 0 ; - $num = $db->num_rows($resql); - $var=true; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $histo[$numaction]=array('type'=>'mailing','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent, - 'acode'=>$obj->acode,'libelle'=>$obj->libelle, - 'userid'=>$obj->user_id,'code'=>$obj->code); - $numaction++; - $i++; - } - } - else - { - dolibarr_print_error($db); - } + print ''.$langs->trans("Lastname").''.$contact->name.''; + print ''.$langs->trans("Firstname").''.$contact->firstname.''; - // Affichage actions sur contact - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; - foreach ($histo as $key=>$value) - { - $var=!$var; - print ""; + print ''; - // Date - print ""; + print ''; - // Status/Percent - if ($histo[$key]['percent'] < 100) { - print ""; - } - else { - print ""; - } + print ''; - // Action - print ''; + print ''; + print ''; - // Note - print ''; + print ''; + print ''; - // Author - print '"; - print "\n"; - } - print "
'.$langs->trans("Date").''.$langs->trans("Status").''.$langs->trans("Actions").''.$langs->trans("Comments").''.$langs->trans("Author").'
Poste/Fonction'.$contact->poste.'
'.$langs->trans("Address").''.$contact->address.'
". dolibarr_print_date($histo[$key]['date'],"%d %b %Y %H:%M") ."
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$contact->cp.' '; + print $contact->ville.'
".$histo[$key]['percent']."%".$langs->trans("Done")."
'.$langs->trans("Country").''; + print $contact->pays; + print '
'; - if ($histo[$key]['type']=='action') - { - print ''.img_object($langs->trans("ShowTask"),"task").' '; - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['libelle']); - print dolibarr_trunc($libelle,30); - print ''; - } - if ($histo[$key]['type']=='mailing') - { - print ''.img_object($langs->trans("ShowEMailing"),"email").' '; - $transcode=$langs->trans("Action".$histo[$key]['acode']); - $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); - print dolibarr_trunc($libelle,30); - print ''; - } - print '
Tel Pro'.$contact->phone_pro.'Tel Perso'.$contact->phone_perso.'
'.dolibarr_trunc($histo[$key]['note'], 30).'
Portable'.$contact->phone_mobile.''.$langs->trans("Fax").''.$contact->fax.'
'; - if ($histo[$key]['code']) - { - print ''.img_object($langs->trans("ShowUser"),'user').' '.$histo[$key]['code'].''; - } - else print " "; - print "
"; - - print '
'; + print ''.$langs->trans("EMail").''; + if ($contact->email && ! ValidEmail($contact->email)) + { + print ''.$langs->trans("ErrorBadEMail",$contact->email).""; + } + else + { + print $contact->email; + } + print ''; + if ($conf->mailing->enabled) + { + $langs->load("mails"); + print ''.$langs->trans("NbOfEMailingsReceived").''; + print ''.$contact->getNbOfEMailings().''; + } + else + { + print ' '; + } + print ''; + + print 'Jabberid'.$contact->jabberid.''; + + print ''.$langs->trans("Note").''; + print nl2br($contact->note); + print ''; + + $contact->load_ref_elements(); + + if ($conf->commande->enabled) + { + print ''.$langs->trans("ContactForOrders").''; + print $contact->ref_commande?$contact->ref_commande:$langs->trans("NoContactForAnyOrder"); + print ''; + } + + if ($conf->propal->enabled) + { + print ''.$langs->trans("ContactForProposals").''; + print $contact->ref_propal?$contact->ref_propal:$langs->trans("NoContactForAnyProposal"); + print ''; + } + + if ($conf->contrat->enabled) + { + print ''.$langs->trans("ContactForContracts").''; + print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract"); + print ''; + } + + if ($conf->facture->enabled) + { + print ''.$langs->trans("ContactForInvoices").''; + print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice"); + print ''; + } + + print ''.$langs->trans("DolibarrLogin").''; + if ($contact->user_id) print ''.$contact->user_login.''; + else print $langs->trans("NoDolibarrAccess"); + print ''; + + print ""; + + print ""; + + + // Barre d'actions + if (! $user->societe_id) + { + print '
'; + + if ($user->rights->societe->contact->creer) + { + print ''.$langs->trans('Edit').''; + } + + if (! $contact->user_id && $user->admin && $contact->socid > 0) + { + print ''.$langs->trans("CreateDolibarrLogin").''; + } + + if ($user->rights->societe->contact->supprimer) + { + print ''.$langs->trans('Delete').''; + } + + print "

"; + } + + + // Historique des actions sur ce contact + print_titre ($langs->trans("TasksHistoryForThisContact")); + $histo=array(); + $numaction = 0 ; + + // Recherche histo sur actioncomm + $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, a.note, a.percent as percent,"; + $sql.= " c.code as acode, c.libelle,"; + $sql.= " u.rowid as user_id, u.code"; + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; + $sql.= " WHERE fk_contact = ".$contact->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action"; + $sql.= " ORDER BY a.datea DESC, a.id DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $i = 0 ; + $num = $db->num_rows($resql); + $var=true; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $histo[$numaction]=array('type'=>'action','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent, + 'acode'=>$obj->acode,'libelle'=>$obj->libelle, + 'userid'=>$obj->user_id,'code'=>$obj->code); + $numaction++; + $i++; + } + } + else + { + dolibarr_print_error($db); + } + + // Recherche histo sur mailing + $sql = "SELECT m.rowid as id, ".$db->pdate("mc.date_envoi")." as da, m.titre as note, '100' as percent,"; + $sql.= " 'AC_EMAILING' as acode,"; + $sql.= " u.rowid as user_id, u.code"; + $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u "; + $sql.= " WHERE mc.email = '".addslashes($contact->email)."'"; + $sql.= " AND mc.statut = 1"; + $sql.= " AND u.rowid = m.fk_user_valid"; + $sql.= " AND mc.fk_mailing=m.rowid"; + $sql.= " ORDER BY mc.date_envoi DESC, m.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $i = 0 ; + $num = $db->num_rows($resql); + $var=true; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $histo[$numaction]=array('type'=>'mailing','id'=>$obj->id,'date'=>$obj->da,'note'=>$obj->note,'percent'=>$obj->percent, + 'acode'=>$obj->acode,'libelle'=>$obj->libelle, + 'userid'=>$obj->user_id,'code'=>$obj->code); + $numaction++; + $i++; + } + } + else + { + dolibarr_print_error($db); + } + + // Affichage actions sur contact + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + foreach ($histo as $key=>$value) + { + $var=!$var; + print ""; + + // Date + print ""; + + // Status/Percent + if ($histo[$key]['percent'] < 100) { + print ""; + } + else { + print ""; + } + + // Action + print ''; + + // Note + print ''; + + // Author + print '"; + print "\n"; + } + print "
'.$langs->trans("Date").''.$langs->trans("Status").''.$langs->trans("Actions").''.$langs->trans("Comments").''.$langs->trans("Author").'
". dolibarr_print_date($histo[$key]['date'],"%d %b %Y %H:%M") ."".$histo[$key]['percent']."%".$langs->trans("Done")."'; + if ($histo[$key]['type']=='action') + { + print ''.img_object($langs->trans("ShowTask"),"task").' '; + $transcode=$langs->trans("Action".$histo[$key]['acode']); + $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['libelle']); + print dolibarr_trunc($libelle,30); + print ''; + } + if ($histo[$key]['type']=='mailing') + { + print ''.img_object($langs->trans("ShowEMailing"),"email").' '; + $transcode=$langs->trans("Action".$histo[$key]['acode']); + $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:'Send mass mailing'); + print dolibarr_trunc($libelle,30); + print ''; + } + print ''.dolibarr_trunc($histo[$key]['note'], 30).''; + if ($histo[$key]['code']) + { + print ''.img_object($langs->trans("ShowUser"),'user').' '.$histo[$key]['code'].''; + } + else print " "; + print "
"; + + print '
'; } $db->close(); diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php index c142553970a..e822c065b4f 100644 --- a/htdocs/contact/index.php +++ b/htdocs/contact/index.php @@ -62,12 +62,13 @@ if ($page < 0) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; +$langs->load("companies"); $titre=$langs->trans("ListOfContacts"); -if ($type == "c") { $titre=$langs->trans("ListOfCustomersContacts"); } -if ($type == "f") { $titre=$langs->trans("ListOfSuppliersContacts"); } -if ($view == 'phone') { $text="(Vue Téléphones)"; } -if ($view == 'mail') { $text="(Vue EMail)"; } -if ($view == 'recent') { $text="(Récents)"; } +if ($type == "c") { $titre=$langs->trans("ListOfContacts").' ('.$langs->trans("ThirdPartyCustomers").')'; } +if ($type == "f") { $titre=$langs->trans("ListOfSuppliersContacts").' ('.$langs->trans("ThirdPartySuppliers").')'; } +if ($view == 'phone') { $text="( Vue Téléphones)"; } +if ($view == 'mail') { $text=" (Vue EMail)"; } +if ($view == 'recent') { $text=" (Récents)"; } $titre = $titre." $text"; if ($_POST["button_removefilter"]) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 8c28be0ecf5..6cd70cc2e69 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -456,7 +456,7 @@ class Form * \param htmlname Nom champ formulaire * \param filter Criteres optionnels de filtre */ - function select_societes($selected='',$htmlname='soc_id',$filter='') + function select_societes($selected='',$htmlname='soc_id',$filter='',$showempty=0) { // On recherche les societes $sql = "SELECT s.idp, s.nom FROM"; @@ -468,6 +468,7 @@ class Form if ($resql) { print '