* Copyright (C) 2004-2005 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."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); $langs->load('companies'); $langs->load('projects'); $langs->load('propal'); $user->getrights('propale'); $user->getrights('fichinter'); $user->getrights('commande'); $user->getrights('projet'); $socid = isset($_GET["id"])?$_GET["id"]:$_GET["socid"]; // Fonctionne si on passe id ou socid if ($_GET["action"] == 'cstc') { $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; $sql .= " WHERE idp = ".$_GET["id"]; $db->query($sql); } /* * Sécurité si un client essaye d'accéder à une autre fiche que la sienne */ if ($user->societe_id > 0) { $socid = $user->societe_id; } llxHeader(); /********************************************************************************* * * Mode fiche * * *********************************************************************************/ if ($socid > 0) { $societe = new Societe($db, $socid); $result = $societe->fetch($socid); if ($result < 0) { dolibarr_print_error($db); exit; } /* TODO Finir verification PagesJaunes * print '
'; * print ''; * print ''; * print ''; * print '
'; */ $h=0; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Company"); $h++; $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$societe->id; $head[$h][1] = $langs->trans("Prospect"); $hselected=$h; $h++; if (file_exists(DOL_DOCUMENT_ROOT.'/sl/')) { $head[$h][0] = DOL_URL_ROOT.'/sl/fiche.php?id='.$societe->id; $head[$h][1] = 'Fiche catalogue'; $h++; } if ($societe->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Supplier"); $h++; } if ($conf->compta->enabled) { $langs->load("compta"); $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Accountancy"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Note"); $h++; if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Documents"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Notifications"); dolibarr_fiche_head($head, $hselected, $societe->nom); /* * */ print "\n"; print '\n"; print '"; print "
'; print ''; print ''; print '"; print ''; print ''; print ''; print '"; if ($societe->rubrique) { print ""; } print ''; 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->statut_commercial.' '; print ''; print img_action(0,-1); print ' '; print img_action(0,0); print ' '; print img_action(0,1); print ' '; print img_action(0,2); print ' '; print img_action(0,3); print ''; print '
'; print ''; /* * */ print "
'; /* * * Propales * */ $var = true; print ''; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.remise, ".$db->pdate("p.datep")." as dp, 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 WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; $sql .= " AND s.idp = $societe->id ORDER BY p.datep DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num >0 ) { print "'; $var=!$var; } $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; while ($i < $num && $i < 2) { $objp = $db->fetch_object(); print ""; print "\n"; print "\n"; print "\n"; $var=!$var; $i++; } $db->free(); } print "
"; print ''; print ''; print '
'.$langs->trans("LastProposals").''.$langs->trans("AllPropals").' ('.$num.')
'; print '
propalid\">"; print img_object($langs->trans("ShowPropal"),"propal"); print " $objp->ref\n"; if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { print " > 15 jours"; } print "".strftime("%d %B %Y",$objp->dp)."".price($objp->price)."$objp->statut
"; 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 '
'; /* * * Liste des contacts * */ if (defined("MAIN_MODULE_CLICKTODIAL") && MAIN_MODULE_CLICKTODIAL==1) { $user->fetch_clicktodial(); // lecture des infos de clicktodial } print ''; print ''; print ''; print ''; print ''; $sql = "SELECT p.idp, 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 ORDER by p.datec"; $result = $db->query($sql); $i = 0 ; $num = $db->num_rows(); $tag = True; 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("Name").'Poste'.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").' 
'; print ''; print img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.' '; if ($obj->note) { print "
".nl2br($obj->note); } print "
$obj->poste '; /* * Lien click to dial */ if (strlen($obj->phone) && $user->clicktodial_enabled == 1) { print ''; print img_phone_out("Appel émis") ; } print ''; print ' '.dolibarr_print_phone($obj->phone).' '.$obj->fax.' '.$obj->email.' "; print ''; print img_edit(); print '
"; /* * Listes des actions a faire */ $var=true; print '
'; print ''; print ''; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid, a.note "; $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"; $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); while ($i < $num) { $var = !$var; $obj = $db->fetch_object($resql); print ""; if ($oldyear == strftime("%Y",$obj->da) ) { //print ''; print '\n"; } else { print '\n"; $oldyear = strftime("%Y",$obj->da); } if ($oldmonth == strftime("%Y%b",$obj->da) ) { print '\n"; } else { print "\n"; $oldmonth = strftime("%Y%b",$obj->da); } print "\n"; print "\n"; print ''; print ''; /* * Contact pour cette action * */ print ''; } else { print ' '; } /* * */ print ''; print "\n"; if ($obj->note) { print ""; print ''; } $i++; } print "
'.$langs->trans("ActionsToDo").'
|' .strftime("%Y",$obj->da)."' .strftime("%Y",$obj->da)."' .strftime("%b",$obj->da)."" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)." '; if ($obj->propalrowid) { print ''; $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''; } else { print ''.img_object($langs->trans("ShowAction"),"task").' '; $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''; } print ''; if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''.$contact->fullname.''; print ''; print $obj->code.'
 '.stripslashes($obj->note).'
"; $db->free($resql); } else { dolibarr_print_error($db); } /* * Listes des actions effectuees */ $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid, a.note "; $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"; $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); if ($num) { print '
'; print ''; print ''; print ''; print '
'.$langs->trans("ActionsDone").'
'; print ''; $oldyear=''; $oldmonth=''; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($resql); 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"; 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"; if ($i < 2 && strlen($obj->note)) { print ""; print ''; } $i++; } print "
|" .strftime("%Y",$obj->da)."|" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)." '; if ($obj->propalrowid) { print ''.img_file().' '.$obj->libelle.''; } else { print ''.img_object($langs->trans("ShowTask"),"task").' '.$obj->libelle.''; } print ''.$contact->fullname.' '.$obj->code.'
 '; print stripslashes(nl2br($obj->note)); print '
"; print "
"; } $db->free(); } else { dolibarr_print_error($db); } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>