* Copyright (C) 2004 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$ * */ require("./pre.inc.php"); $user->getrights('propale'); $user->getrights('fichinter'); $user->getrights('commande'); $user->getrights('projet'); 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; } /* * */ if ($_GET["action"] == 'add_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$_GET["socidp"]." AND fk_user=".$user->id; if (! $db->query($sql) ) { print $db->error(); } $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES (".$_GET["socidp"].", now(),".$user->id.");"; if (! $db->query($sql) ) { print $db->error(); } } if ($_GET["action"] == 'del_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; $result = $db->query($sql); } print_titre("Espace commercial"); print ''; print ''; print '
'; /* * Recherche Propal */ if ($conf->propal->enabled) { print '
'; print ''; print ''; print "'; print "
Rechercher une proposition
"; print 'Num. :  

\n"; $sql = "SELECT p.rowid, p.ref"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= " WHERE p.fk_statut = 0"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num > 0 ) { print ''; print ""; print ""; while ($i < $num) { $obj = $db->fetch_object( $i); $var=!$var; print ""; $i++; } print "
Propositions commerciales brouillons
rowid."\">".$obj->ref."

"; } } } /* * Commandes à valider */ if ($conf->commande->enabled) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0"; if ($socidp) { $sql .= " AND c.fk_soc = $socidp"; } if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { print ''; print ''; print ''; $i = 0; $var = False; while ($i < $num) { $obj = $db->fetch_object($i); print ""; print ''; $i++; $var=!$var; } print "
'.$langs->trans("OrdersToValid").'
rowid\">$obj->ref'.$obj->nom.'

"; } } } /* * Bookmark * */ $sql = "SELECT s.idp, s.nom,b.rowid as bid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; if ($socidp) { $sql .= " AND s.idp = $socidp"; } $sql .= " ORDER BY lower(s.nom) ASC"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { $i = 0; print ''; print ""; print ""; print "\n"; while ($i < $num) { $obj = $db->fetch_object( $i); $var = !$var; print ""; print ''; print ''; print ''; $i++; } print '
Bookmark
'.$obj->nom.''; print '
'; } } print '
'; /* * Dernières actions commerciales effectuées * */ $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, 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"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } $sql .= " ORDER BY a.datea DESC limit 5"; if ( $db->query($sql) ) { $num = $db->num_rows(); print ''; print ''; $var = true; $i = 0; while ($i < $num ) { $obj = $db->fetch_object($i); $var=!$var; print ""; print ""; print ""; print ''; $i++; } // TODO Ajouter rappel pour "il y a des contrats à mettre en service" // TODO Ajouter rappel pour "il y a des contrats qui arrivent à expiration" print "
Dernières actions effectuées
id\">".img_file()." "; print "id\">$obj->libelle $obj->label".strftime("%d %b %Y",$obj->da)."'.$obj->sname.'

"; $db->free(); } else { print $db->error(); } /* * Actions commerciales a faire * */ $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, 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"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } $sql .= " ORDER BY a.datea ASC"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num > 0) { print ''; print ''; $var = true; $i = 0; while ($i < $num ) { $obj = $db->fetch_object($i); $var=!$var; print ""; print ""; print '"; print ''; $i++; } // TODO Ajouter rappel pour "il y a des contrats à mettre en service" // TODO Ajouter rappel pour "il y a des contrats qui arrivent à expiration" print "
Actions à faire
id\">".img_file()." "; print "id\">$obj->libelle $obj->label'. strftime("%d %b %Y",$obj->da); if (date("U",$obj->da) < time()) { print img_warning(); } print "'.$obj->sname.'

"; } $db->free(); } else { print $db->error(); } /* * Derniers contrat * */ if ($conf->contrat->enabled) { $labelservice[0]="Hors service"; $labelservice[1]="En service"; $labelservice[2]="Cloturé"; $sql = "SELECT s.nom, s.idp, c.enservice, c.rowid, p.ref, c.mise_en_service as datemes, c.fin_validite as datefin, c.date_cloture as dateclo"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."product as p WHERE c.fk_soc = s.idp and c.fk_product = p.rowid"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit(5, 0); if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num > 0) { print ''; print ''; $i = 0; $var=false; while ($i < $num) { $obj = $db->fetch_object( $i); print ""; print "\n"; print "\n"; $var=!$var; $i++; } print "
Les 5 derniers contrats
rowid."\">".img_file()." "; print "rowid."\">".$obj->ref."idp\">$obj->nom".$labelservice[$obj->enservice]."

"; } } else { print $db->error(); } } /* * Dernières propales ouvertes * */ if ($conf->propal->enabled) { $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 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); if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num > 0) { print ''; print ''; $var=false; while ($i < $num) { $obj = $db->fetch_object( $i); print ""; print "\n"; print "\n"; print "\n"; $var=!$var; $i++; } print "
Les 5 dernières propositions commerciales ouvertes
propalid."\">".img_file()." "; print "propalid."\">".$obj->ref."idp\">$obj->nom"; print strftime("%e %b %Y",$obj->dp)."".price($obj->price)."

"; } } } /* * Dernières propales fermées * */ if ($conf->propal->enabled) { $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 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); if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print ''; print ''; $var=False; while ($i < $num) { $objp = $db->fetch_object( $i); print ""; print ''; print "\n"; $now = time(); $lim = 3600 * 24 * 15 ; if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { print ""; } else { print ""; } print "\n"; print "\n"; print "\n"; print "\n"; $i++; $var=!$var; } print "
Les 5 dernières propositions commerciales fermées
'; print ''.img_file().''; print ' '.$objp->ref.'idp\">$objp->nom > 15 jours "; print strftime("%e %b %Y",$objp->dp)."".price($objp->price)."$objp->statut
"; $db->free(); } } print '
'; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>