diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 1881b5a0086..c9c12731818 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2005 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,7 +20,6 @@ * * $Id$ * $Source$ - * */ /** @@ -86,7 +85,10 @@ class Contact } $sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (datec, fk_soc, name, fk_user)"; - $sql.= " VALUES (now(),$this->socid,'$this->name',$user->id)"; + $sql.= " VALUES (now(),"; + if ($this->socid > 0) $sql.= " $this->socid,"; + else $sql.= "null,"; + $sql.= "'$this->name',$user->id)"; if ($this->db->query($sql) ) { diff --git a/htdocs/contact/exportimport.php b/htdocs/contact/exportimport.php index 5a9a126f95c..6d39f023548 100644 --- a/htdocs/contact/exportimport.php +++ b/htdocs/contact/exportimport.php @@ -79,6 +79,12 @@ if ($contact->socid > 0) print ''.$langs->trans("Company").''.$objsoc->nom_url.''; } +else +{ + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; +} print ''.$langs->trans("UserTitle").''; print $contact->civilite_id; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 985de580acb..6d8c8606cca 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -19,7 +19,6 @@ * * $Id$ * $Source$ - * */ /** @@ -114,36 +113,36 @@ if ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') 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) + $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) { - $error = $contact->error; + $error = $contact->error; } } @@ -244,7 +243,8 @@ if ($_GET["action"] == 'create') } else { print ''.$langs->trans("Company").''; - print $form->select_societes('','socid',''); + //print $form->select_societes('','socid',''); + print $langs->trans("ContactNotLinkedToCompany"); print ''; } @@ -282,7 +282,7 @@ if ($_GET["action"] == 'create') print $form->selectyesno("facturation",$contact->facturation); print ''; - print ''; + print ''; print "
"; print ""; @@ -309,7 +309,12 @@ elseif ($_GET["action"] == 'edit') print ''.$langs->trans("Company").''.$objsoc->nom_url.''; } - + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } print ''.$langs->trans("UserTitle").''; print $form->select_civilite($contact->civilite_id); print ''; @@ -347,151 +352,157 @@ elseif ($_GET["action"] == 'edit') print $form->selectyesno("facturation",$contact->facturation); print ''; - print ''; + print ''; print "
"; print ""; } else { - /* - * Visualisation de la fiche - * - */ + /* + * Visualisation de la fiche + * + */ - print ''; - - if ($contact->socid > 0) + print '
'; + + if ($contact->socid > 0) { - $objsoc = new Societe($db); - $objsoc->fetch($contact->socid); - - print ''; + $objsoc = new Societe($db); + $objsoc->fetch($contact->socid); + + print ''; } - - print ''; - - 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 "
'.$langs->trans("Company").''.$objsoc->nom_url.'
'.$langs->trans("Company").''.$objsoc->nom_url.'
'.$langs->trans("UserTitle").''; - //TODO Aller chercher le libellé de la civilite a partir de l'id $contact->civilite_id - //print '
Titre : '.$contact->civilite."
"; - print $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("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print '
'.$langs->trans("UserTitle").''; + //TODO Aller chercher le libellé de la civilite a partir de l'id $contact->civilite_id + //print '
Titre : '.$contact->civilite."
"; + print $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 '
Tel Pro'.$contact->phone_pro.'Tel Perso'.$contact->phone_perso.'
Portable'.$contact->phone_mobile.''.$langs->trans("Fax").''.$contact->fax.'
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)."
"; - } + if ($contact->email && ! ValidEmail($contact->email)) + { + print '
'.$langs->trans("ErrorBadEMail",$contact->email)."
"; + } else { print $contact->email; } - print '
Jabberid'.$contact->jabberid.'
'.$langs->trans("Note").''; - print nl2br($contact->note); - print '
'.$langs->trans("BillingContact").''; - print yn($contact->facturation); - print '
"; - - print ""; - - - // Barre d'actions - if (! $user->societe_id) + print ''; + + print 'Jabberid'.$contact->jabberid.''; + + print ''.$langs->trans("Note").''; + print nl2br($contact->note); + print ''; + + print ''.$langs->trans("BillingContact").''; + print yn($contact->facturation); + print ''; + + print ""; + + print ""; + + + // Barre d'actions + if (! $user->societe_id) { - print '
'; - - print ''.$langs->trans('Edit').''; - - if (! $contact->user_id && $user->admin) - { - print ''.$langs->trans("CreateDolibarrLogin").''; - } - - print ''.$langs->trans('Delete').''; - - print "

"; - } - - - // Historique des actions vers ce contact - print_titre ($langs->trans("TasksHistoryForThisContact")); + print '
'; - print ''; + print ''.$langs->trans('Edit').''; - print ""; - print ""; - print ""; - - $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; - $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 "; - - if ($contactid) - { - $sql .= " AND fk_contact = $contactid"; - } - $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) + if (! $contact->user_id && $user->admin) { - $obj = $db->fetch_object($resql); - $var=!$var; - print ""; - - print ""; - if ($obj->propalrowid) + print ''.$langs->trans("CreateDolibarrLogin").''; + } + + print ''.$langs->trans('Delete').''; + + print "
"; + } + + + // Historique des actions vers ce contact + print_titre ($langs->trans("TasksHistoryForThisContact")); + + print '
".$langs->trans("Date")."".$langs->trans("Actions")."".$langs->trans("CreatedBy")."
". strftime("%d %b %Y %H:%M", $obj->da) ."
'; + + print ""; + print ""; + print ""; + + $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; + $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 "; + + if ($contactid) + { + $sql .= " AND fk_contact = $contactid"; + } + $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); + $var=!$var; + print ""; + + print ""; + if ($obj->propalrowid) { - print ""; - } - else - { - print ""; + print ""; } - - print ""; - print "\n"; - $i++; + else + { + print ""; + } + + print ""; + print "\n"; + $i++; } } - else + else { - dolibarr_print_error($db); + dolibarr_print_error($db); } - print "
".$langs->trans("Date")."".$langs->trans("Actions")."".$langs->trans("CreatedBy")."
". strftime("%d %b %Y %H:%M", $obj->da) ."propalrowid."\">".$obj->libelle."$obj->libellepropalrowid."\">".$obj->libelle."$obj->code 
$obj->libelle$obj->code 
"; + print ""; } diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php index 8905cf56530..29c72b86393 100644 --- a/htdocs/contact/index.php +++ b/htdocs/contact/index.php @@ -232,8 +232,17 @@ if ($result) print img_object($langs->trans("ShowContact"),"contact"); print ' '.$obj->name.''; print ''.$obj->firstname.''; - print ''; - print img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,44).''; + print ''; + if ($obj->idp) + { + print ''; + print img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,40).''; + } + else + { + print ' '; + } + print ''; print ''.dolibarr_print_phone($obj->phone).' '; if ($_GET["view"] == 'phone') diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 90d1fea0781..f2593db4459 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -111,14 +111,20 @@ if ($_GET["action"] == 'edit') print ''.$langs->trans("Company").''.$objsoc->nom_url.''; } - - print ''.$langs->trans("UserTitle").''; - print $contact->civilite_id; - print ''; - - print ''.$langs->trans("Lastname").''.$contact->nom.''; - print ''.$langs->trans("Firstname").''.$contact->prenom.''; - + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + + print ''.$langs->trans("UserTitle").''; + print $contact->civilite_id; + print ''; + + print ''.$langs->trans("Lastname").''.$contact->nom.''; + print ''.$langs->trans("Firstname").''.$contact->prenom.''; + print ''.$langs->trans("Birthday").''; $html=new Form($db); @@ -161,12 +167,19 @@ else print ''.$langs->trans("Company").''.$objsoc->nom_url.''; } - print ''.$langs->trans("UserTitle").''; - print $contact->civilite_id; - print ''; - - print ''.$langs->trans("Lastname").''.$contact->name.''; - print ''.$langs->trans("Firstname").''.$contact->firstname.''; + else + { + print ''.$langs->trans("Company").''; + print $langs->trans("ContactNotLinkedToCompany"); + print ''; + } + + print ''.$langs->trans("UserTitle").''; + print $contact->civilite_id; + print ''; + + print ''.$langs->trans("Lastname").''.$contact->name.''; + print ''.$langs->trans("Firstname").''.$contact->firstname.''; if ($contact->birthday && $contact->birthday > 0) { print ''.$langs->trans("Birthdate").''.dolibarr_print_date($contact->birthday); diff --git a/htdocs/includes/menus/barre_left/eldy.php b/htdocs/includes/menus/barre_left/eldy.php index 220b2909c7d..8b35d5bb9de 100644 --- a/htdocs/includes/menus/barre_left/eldy.php +++ b/htdocs/includes/menus/barre_left/eldy.php @@ -163,15 +163,20 @@ class MenuLeft { $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 1, $user->rights->societe->creer); $newmenu->add_submenu(DOL_URL_ROOT."/comm/prospect/prospects.php?leftmenu=prospects", $langs->trans("List"), 1, $user->rights->societe->lire); - $newmenu->add_submenu(DOL_URL_ROOT."/comm/contact.php?leftmenu=prospects&type=p", $langs->trans("Contacts"), 1, $user->rights->societe->lire); + $newmenu->add_submenu(DOL_URL_ROOT."/comm/contact.php?leftmenu=prospects&type=p", $langs->trans("Contacts"), 1, $user->rights->societe->lire); // Clients $newmenu->add(DOL_URL_ROOT."/comm/index.php?leftmenu=customers", $langs->trans("Customers"), 0, $user->rights->societe->creer); - $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 1, $user->rights->societe->creer); + $newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 1, $user->rights->societe->creer); $newmenu->add_submenu(DOL_URL_ROOT."/comm/clients.php?leftmenu=customers", $langs->trans("List"), 1, $user->rights->societe->lire); - $newmenu->add_submenu(DOL_URL_ROOT."/comm/contact.php?leftmenu=customers&type=c", $langs->trans("Contacts"), 1, $user->rights->societe->lire); + $newmenu->add_submenu(DOL_URL_ROOT."/comm/contact.php?leftmenu=customers&type=c", $langs->trans("Contacts"), 1, $user->rights->societe->lire); + // Contacts + $newmenu->add(DOL_URL_ROOT."/contact/index.php?leftmenu=contacts", $langs->trans("Contacts"), 0, $user->rights->societe->lire); + $newmenu->add_submenu(DOL_URL_ROOT."/contact/fiche.php?leftmenu=contacts&action=create", $langs->trans("NewContact"), 1, $user->rights->societe->creer); + $newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->lire); + // Actions $newmenu->add(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions", $langs->trans("Actions"), 0); if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?status=todo", $langs->trans("MenuToDoActions"), 1); diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 7729a79384f..6d027f0f3d1 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -110,4 +110,5 @@ FileWasRemoved=Files was removed NoRIB=No RIB defined NoParentCompany=None ExportImport=Import-Export -ExportCardToFormat=Export card to format \ No newline at end of file +ExportCardToFormat=Export card to format +ContactNotLinkedToCompany=Contact not linked to any company \ No newline at end of file diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 3927509d08f..3c253f70f7b 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -110,4 +110,5 @@ FileWasRemoved=Le fichier a NoRIB=Aucun RIB défini NoParentCompany=Aucune ExportImport=Import-Export -ExportCardToFormat=Exporter fiche au format \ No newline at end of file +ExportCardToFormat=Exporter fiche au format +ContactNotLinkedToCompany=Contact non lié à une société \ No newline at end of file