* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * 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 3 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, see . */ /** * \file htdocs/comm/prospect/index.php * \ingroup commercial * \brief Home page of propest area */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; $langs->load("propal"); if ($user->societe_id > 0) { $socid = $user->societe_id; } /* * View */ $companystatic=new Societe($db); llxHeader(); print_fiche_titre($langs->trans("ProspectionArea")); //print ''; //print '
'; print '
'; if (! empty($conf->propal->enabled)) { $var=false; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("SearchAProposal").'
'; print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; } /* * Prospects par statut * */ $sql = "SELECT count(*) as cc, st.libelle, st.id"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st "; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.client IN (2, 3)"; $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $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").'
'; print ''; print img_action($langs->trans("Show"),$obj->id).' '; print $langs->trans("StatusProspect".$obj->id); print ''.$obj->cc.'

"; } } /* * Liste des propal brouillons */ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $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 ''.img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.''; print ''; print price($obj->price); print "
'.$langs->trans("Total")."".price($total)."

"; } $db->free($resql); } } //print '
'; print '
'; /* * Actions commerciales a faire */ if (! empty($conf->agenda->enabled)) show_array_actions_to_do(10); /* * Dernieres propales ouvertes */ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; $sql.= " p.rowid as propalid, p.total as total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."c_propalst as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; $sql.= " AND p.fk_statut = 1"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; $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").'
'; print ''; print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'"; $companystatic->id=$obj->socid; $companystatic->name=$obj->name; $companystatic->client=$obj->client; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'',44); print ""; print dol_print_date($db->jdate($obj->dp),'day')."".price($obj->total_ttc)."
'.$langs->trans("Total")."".price($total)."

"; } } else { dol_print_error($db); } } /* * Societes a contacter * */ $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_stcomm = 1"; $sql.= " AND s.entity IN (".getEntity($companystatic->element, 1).")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " ORDER BY s.tms ASC"; $sql.= $db->plimit(15, 0); $resql=$db->query($sql); if ($resql) { $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 ''; $i++; } print "
'.$langs->trans("ProspectToContact").'
'; $companystatic->id=$obj->socid; $companystatic->name=$obj->name; $companystatic->client=$obj->client; $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'prospect',44); print '

"; } } //print '
'; print ''; llxFooter(); $db->close();