* 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/comm/prospect/fiche.php \ingroup prospect \brief Page de la fiche prospect \version $Revision$ */ require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/prospect.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); $langs->load('companies'); $langs->load('projects'); $langs->load('propal'); $user->getrights('propale'); $user->getrights('fichinter'); $user->getrights('commande'); $user->getrights('projet'); $user->getrights("commercial"); $socid = isset($_GET["id"])?$_GET["id"]:$_GET["socid"]; // Fonctionne si on passe id ou socid if ($socid == '') accessforbidden(); // Protection quand utilisateur externe if ($user->societe_id > 0) { $socid = $user->societe_id; } // Protection restriction commercial if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) { $sql = "SELECT sc.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.rowid AND sc.fk_user = ".$user->id." AND s.client = 2"; if ( $db->query($sql) ) { if ( $db->num_rows() == 0) accessforbidden(); } } /* * Actions */ if ($_GET["action"] == 'cstc') { $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; $sql .= " WHERE rowid = ".$_GET["id"]; $db->query($sql); } /********************************************************************************* * * Mode fiche * *********************************************************************************/ llxHeader(); if ($socid > 0) { $societe = new Prospect($db, $socid); $result = $societe->fetch($socid); if ($result < 0) { dolibarr_print_error($db); exit; } /* * Affichage onglets */ $head = societe_prepare_head($societe); dolibarr_fiche_head($head, 'prospect', $societe->nom); /* TODO Finir verification PagesJaunes * print '
'; * print ''; * print ''; * print ''; * print '
'; */ print "\n"; print '\n"; print '"; print "
'; print ''; print ''; print '"; print ''; print ''; print ''; print '"; if ($societe->rubrique) { print ""; } print ''; // Status print ''; print ''; print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans('Zip').' / '.$langs->trans('Town').''.$societe->cp." ".$societe->ville.'
'.$langs->trans('Country').''.$societe->pays.'
'.$langs->trans("Phone").''.$societe->tel.' Fax'.$societe->fax.' 
'.$langs->trans("Web")."url\">$societe->url 
Rubrique".$societe->rubrique."
'.$langs->trans('JuridicalStatus').''.$societe->forme_juridique.'
'.$langs->trans("Status").''.$societe->getLibStatut(4).''; if ($societe->stcomm_id != -1) print ''.img_action(0,-1).''; if ($societe->stcomm_id != 0) print ''.img_action(0,0).''; if ($societe->stcomm_id != 1) print ''.img_action(0,1).''; if ($societe->stcomm_id != 2) print ''.img_action(0,2).''; if ($societe->stcomm_id != 3) print ''.img_action(0,3).''; print '
'; print "
'; // Nbre max d'éléments des petites listes $MAXLIST=5; $tableaushown=0; $propal_static=new Propal($db); /* * Dernieres propales * */ print ''; $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.price, p.ref, p.remise, "; $sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite,"; $sql.= " c.label as statut, c.id as statutid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql.= " AND s.rowid = ".$societe->id; $sql.= " ORDER BY p.datep DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $i = 0; $num = $db->num_rows($resql); if ($num > 0) { $tableaushown=1; print ''; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')
propalid\">"; print img_object($langs->trans("ShowPropal"),"propal"); print " $objp->ref\n"; if ( ($objp->dp < time() - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1 ) { print " ".img_warning(); } print "".dolibarr_print_date($objp->dp,"day")."".price($objp->price)."".$propal_static->LibStatut($objp->fk_statut,5)."
"; print "
\n\n"; /* * Barre d'action * */ print '
'; print ''.$langs->trans("AddContact").''; print ''.$langs->trans("AddAction").''; if ($conf->propal->enabled && defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE && $user->rights->propale->creer) { print ''.$langs->trans("AddProp").''; } if ($conf->projet->enabled && $user->rights->projet->creer) { print ''.$langs->trans("AddProject").''; } print '
'; print '
'; if ($conf->clicktodial->enabled) { $user->fetch_clicktodial(); // lecture des infos de clicktodial } /* * * Liste des contacts * */ print ''; print ''; print ''; print ''; print ""; print ''; print ""; $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " WHERE p.fk_soc = ".$societe->id; $sql.= " ORDER by p.datec"; $result = $db->query($sql); $i = 0 ; $num = $db->num_rows($result); $var=1; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $i++; $tag = !$tag; } print "
'.$langs->trans("Firstname").' '.$langs->trans("Lastname").''.$langs->trans("Poste").''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'  
'; print ''.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.' '; if (trim($obj->note)) { print '
'.nl2br(trim($obj->note)); } print '
'.$obj->poste.' '.$obj->phone; if (strlen($obj->phone) && $user->clicktodial_enabled == 1) { print ''; print img_phone_out("Appel émis") ; } print ''.$obj->fax.' '.$obj->email.' '; if ($user->rights->societe->contact->creer) { print "rowid."\">"; print img_edit(); print ''; } else print ' '; print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print '
"; print "
"; /* * Listes des actions a faire * */ print ''; print ''; $sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, c.code as acode, c.libelle, u.login, 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 a.fk_soc = ".$societe->id; $sql .= " AND u.rowid = a.fk_user_author"; $sql .= " AND c.id=a.fk_action AND a.percent < 100"; $sql .= " ORDER BY a.datep DESC, a.id DESC"; $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $var=true; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); print ""; if ($oldyear == strftime("%Y",$obj->dp) ) { print ''; } else { print '\n"; $oldyear = strftime("%Y",$obj->dp); } if ($oldmonth == strftime("%Y%b",$obj->dp) ) { print ''; } else { print '\n"; $oldmonth = strftime("%Y%b",$obj->dp); } print '\n"; print '\n"; if (date("U",$obj->dp) < time()) { print ""; } else { print ''; } // Status/Percent print ''; if ($obj->propalrowid) { print ''; } else { print ''; } print ""; // Contact pour cette action if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''; } else { print ''; } print ''; print "\n"; $i++; } $db->free($result); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsToDo").' 
|'.strftime("%Y",$obj->dp)."|' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp)."".img_warning("Late")."  '.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print '$obj->label'.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'

"; /* * Listes des actions effectuées */ print ''; print ''; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, fk_contact, u.login, 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 a.fk_soc = ".$societe->id; $sql .= " AND u.rowid = a.fk_user_author"; $sql .= " AND c.id=a.fk_action AND a.percent = 100"; $sql .= " ORDER BY a.datea DESC, a.id DESC"; $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $var=true; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); print ""; if ($oldyear == strftime("%Y",$obj->da) ) { print ''; } else { print '\n"; $oldyear = strftime("%Y",$obj->da); } if ($oldmonth == strftime("%Y%b",$obj->da) ) { print ''; } else { print '\n"; $oldmonth = strftime("%Y%b",$obj->da); } print '\n"; print '\n"; // Espace print ''; // Action print ''; print ''; // Contact pour cette action if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''; } else { print ''; } print ''; print "\n"; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsDone").'
|'.strftime("%Y",$obj->da)."|'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)." '; print ''.img_object($langs->trans("ShowTask"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''; print ''; if ($obj->propalrowid) { print ''.img_object($langs->trans("ShowPropal"),"propal"); print $langs->trans("Propal"); print ''; } else print ' '; print ''.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>