* 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/index.php \ingroup commercial \brief Page acceuil de la zone prospection \version $Revision$ */ require("./pre.inc.php"); $langs->load("propal"); $user->getrights('propale'); if ($user->societe_id > 0) { $socidp = $user->societe_id; } llxHeader(); function valeur($sql) { global $db; if ( $db->query($sql) ) { if ( $db->num_rows() ) { $valeur = $db->result(0,0); } $db->free(); } return $valeur; } /* * */ print_titre($langs->trans("ProspectionArea")); print ''; print ''; print '
'; if ($conf->propal->enabled) { $var=false; print ''; print ''; print ''; print ''; print "
'.$langs->trans("SearchAProposal").'
'; print $langs->trans("Ref").':

\n"; } /* * Prospects par status * */ $sql = "SELECT count(*) as cc, st.libelle, st.id"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st "; $sql .= " WHERE s.fk_stcomm = st.id AND s.client=2"; $sql .= " GROUP BY st.id"; $sql .= " ORDER BY st.id"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num > 0 ) { $var=true; print ''; print ''; print ''; while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print ""; $i++; } print "
'.$langs->trans("ProspectsByStatus").'
id."\">"; print img_action($langs->trans("Show"),$obj->id).' '; print $langs->trans("StatusProspect".$obj->id); print "".$obj->cc."

"; } } /* * Liste des propal brouillons */ if ($conf->propal->enabled && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp"; $resql=$db->query($sql); if ($resql) { $var=true; $total=0; $num = $db->num_rows($resql); $i = 0; if ($num > 0) { print ''; print ''; print ''; while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print '"; $i++; $total += $obj->price; } if ($total>0) { $var=!$var; print '"; } print "
'.$langs->trans("ProposalsDraft").'
'; print "rowid."\">".img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.""; print ''; print price($obj->price); print "
'.$langs->trans("Total")."".price($total)."

"; } $db->free($resql); } } /* * Actions commerciales a faire * */ print '
'; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc AND a.fk_user_action = $user->id"; $sql .= " ORDER BY a.datea DESC"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { $var=true; print ''; print ''; print ''; print "\n"; $i = 0; while ($i < $num ) { $obj = $db->fetch_object($resql); $var=!$var; print ""; $transcode=$langs->trans("Action".$obj->code); $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle); print ''; print ''; $i++; } print "
'.$langs->trans("ActionsToDo").'
".dolibarr_print_date($obj->da)."".img_object($langs->trans("ShowAction"),"task").' '.$libelle.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->sname.'

"; } $db->free($resql); } else { dolibarr_print_error($db); } /* * Dernières propales ouvertes * */ if ($conf->propal->enabled && $user->rights->propale->lire) { $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$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"; $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1"; if ($socidp) $sql .= " AND s.idp = $socidp"; $sql .= " ORDER BY p.rowid DESC"; $sql .= $db->plimit(5, 0); $resql=$db->query($sql); if ($resql) { $total = 0; $num = $db->num_rows($resql); $i = 0; if ($num > 0) { $var=true; print ''; print ''; while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print "'; print "\n"; print "\n"; print "\n"; $i++; $total += $obj->price; } if ($total>0) { print '"; } print "
'.$langs->trans("ProposalsOpened").'
rowid."\">"; print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.""; print dolibarr_print_date($obj->dp)."".price($obj->price)."
'.$langs->trans("Total")."".price($total)."

"; } } } /* * Sociétés à contacter * */ $sql = "SELECT s.nom, s.idp"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.fk_stcomm = 1"; $sql .= " ORDER BY s.tms ASC"; $sql .= $db->plimit(15, 0); if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num > 0 ) { $var=true; print ''; print ''; while ($i < $num) { $obj = $db->fetch_object(); $var=!$var; print "'; $i++; } print "
'.$langs->trans("ProspectToContact").'
idp."\">"; print img_object($langs->trans("ShowCompany"),"company"); print ' '.$obj->nom.'

"; } } print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>