diff --git a/htdocs/telephonie/stats/commerciaux/commercialpo.php b/htdocs/telephonie/stats/commerciaux/commercialpo.php new file mode 100644 index 00000000000..6f09622039d --- /dev/null +++ b/htdocs/telephonie/stats/commerciaux/commercialpo.php @@ -0,0 +1,162 @@ + + * + * 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"); + +if ($user->distributeur_id && $user->responsable_distributeur_id == 0) +{ + accessforbidden(); +} + +if ($user->distributeur_id) +{ + $_GET["id"] = $user->distributeur_id; +} + +llxHeader(); + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; +$sortfield = $_GET["sortfield"]; +if ($sortorder == "") $sortorder="DESC"; +if ($sortfield == "") $sortfield="p.datepo"; + +/* + * + * + */ + +if ($_GET["commid"]) +{ + $h = 0; + $comm = new User($db, $_GET["commid"]); + $comm->fetch(); + + $head[$h][0] = DOL_URL_ROOT.'/telephonie/stats/commerciaux/commercial.php?commid='.$comm->id; + $head[$h][1] = $comm->fullname; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/telephonie/stats/commerciaux/commercialca.php?commid='.$comm->id; + $head[$h][1] = "CA"; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/telephonie/stats/commerciaux/lignes.php?commid='.$comm->id; + $head[$h][1] = "Lignes"; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/telephonie/stats/commerciaux/commercialpo.php?commid='.$comm->id; + $head[$h][1] = "Prises d'ordres"; + $hselected = $h; + $h++; + + dolibarr_fiche_head($head, $hselected, "Commerciaux"); + + if ($page == -1) { $page = 0 ; } + + $offset = $conf->liste_limit * $page ; + $pageprev = $page - 1; + $pagenext = $page + 1; + + /* + * Mode Liste + * + */ + + $sql = "SELECT s.idp, s.nom, p.fk_contrat, p.montant, p.avance_duree, p.avance_pourcent"; + $sql .= ", p.rem_pour_prev, p.rem_pour_autr, p.mode_paiement"; + $sql .= " , ".$db->pdate("p.datepo") . " as datepo"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p"; + $sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c"; + $sql .= " , ".MAIN_DB_PREFIX."societe as s"; + + $sql .= " WHERE p.fk_commercial =".$_GET["commid"]; + $sql .= " AND c.fk_soc = s.idp"; + $sql .= " AND p.fk_contrat = c.rowid"; + $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print_barre_liste("Prises d'ordre", $page, "po.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print_liste_field_titre("Client","po.php","s.nom","","&id=".$_GET["id"]); + print_liste_field_titre("Contrat","po.php","p.fk_contrat","","&id=".$_GET["id"]); + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + + print '\n"; + print '\n"; + print '\n"; + + print '\n"; + + print '\n"; + print '\n"; + if ($obj->mode_paiement == 'pre') + { + print '\n"; + print ''; + } + else + { + print '\n"; + print ''; + } + + + print "\n"; + $i++; + } + print "
DateMontantAvance DuréeAvance %Rem %MdP
'; + print img_file(); + print ' '; + + print ''.$obj->nom."'.$obj->fk_contrat."'.strftime("%e %b %Y",$obj->datepo)."'.sprintf("%01.2f",$obj->montant)."'.$obj->avance_duree."'.$obj->avance_pourcent." %'.$obj->rem_pour_prev." %Prelev'.$obj->rem_pour_autr." %Autre
"; + $db->free(); + } + else + { + print $db->error() . ' ' . $sql; + } + +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>