From 81b6ff392335bf2ec5d271b4d87d3fd2b326320c Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 26 Jan 2005 18:12:52 +0000 Subject: [PATCH] =?UTF-8?q?Nouvelle=20m=E9thode=20de=20commande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/telephonie/ligne/commande/fiche.php | 124 +++++++++++++-------- 1 file changed, 76 insertions(+), 48 deletions(-) diff --git a/htdocs/telephonie/ligne/commande/fiche.php b/htdocs/telephonie/ligne/commande/fiche.php index 7a70d1f17ac..f1dd501692f 100644 --- a/htdocs/telephonie/ligne/commande/fiche.php +++ b/htdocs/telephonie/ligne/commande/fiche.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2005 Rodolphe Quiedeville * * 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 @@ -27,25 +27,38 @@ $page = $_GET["page"]; $sortorder = $_GET["sortorder"]; $sortfield = $_GET["sortfield"]; -if ($_GET["action"] == "create") +if ($user->rights->telephonie->ligne_commander) { - - $fourntel = new FournisseurTelephonie($db,1); - if ( $fourntel->fetch() == 0) + if ($_GET["action"] == "create" && $_GET["fournid"] > 0) { - $ct = new CommandeTableur($db, $user, $fourntel); - - $result = $ct->create(); - + + $fourn = new FournisseurTelephonie($db); + + $result = $fourn->fetch($_GET["fournid"]); + if ($result == 0) { - Header("Location: archives.php"); + $result = $fourn->CreateCommande($user); } - elseif ($result == -3) + + /* + $fourntel = new FournisseurTelephonie($db,1); + if ( $fourntel->fetch(1) == 0) { - /* Erreur */ - $mesg_erreur = "Email fournisseur non définit"; + $ct = new CommandeTableur($db, $user, $fourntel); + + $result = $ct->create(); + + if ($result == 0) + { + Header("Location: archives.php"); } + elseif ($result == -3) + { + $mesg_erreur = "Email fournisseur non définit"; + } + } + */ } } @@ -63,38 +76,61 @@ if ($user->societe_id > 0) $socidp = $user->societe_id; } -if ($sortorder == "") { - $sortorder="ASC"; -} -if ($sortfield == "") { - $sortfield="s.nom"; -} - /* - * Recherche + * Mode Liste + * * * */ -if ($mode == 'search') { - if ($mode-search == 'soc') { - $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; - $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; - } - - if ( $db->query($sql) ) { - if ( $db->num_rows() == 1) { - $obj = $db->fetch_object(0); - $socid = $obj->idp; + +$sql = "SELECT count(l.ligne), f.rowid, f.nom"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ",".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; +$sql .= ",".MAIN_DB_PREFIX."telephonie_fournisseur as f"; +$sql .= ",".MAIN_DB_PREFIX."societe as sf"; +$sql .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid AND l.statut IN (1,4) "; +$sql .= " AND l.fk_soc_facture = sf.idp"; +$sql .= " GROUP BY f.rowid, f.nom ASC"; + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Commande", $page, "liste.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + + $ligne = new LigneTel($db); + + while ($i < $num) + { + $row = $db->fetch_row(); + $var=!$var; + + print ""; + print ''; + print '\n"; + + print '\n"; + print "\n"; + $i++; } - $db->free(); - } + print "
FournisseurNb Lignes 
'.$row[2].''.$row[0]."'; + print 'Créer la commande'; + print "

"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; } - -if ($page == -1) { $page = 0 ; } - -$offset = $conf->liste_limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; /* * Mode Liste @@ -109,7 +145,7 @@ $sql .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; $sql .= " , ".MAIN_DB_PREFIX."societe as sf"; $sql .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid AND l.statut IN (1,4) "; $sql .= " AND l.fk_soc_facture = sf.idp"; -$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= " ORDER BY s.nom ASC "; $result = $db->query($sql); if ($result) @@ -117,8 +153,6 @@ if ($result) $num = $db->num_rows(); $i = 0; - print_barre_liste("Commande", $page, "liste.php", "", $sortfield, $sortorder, '', $num); - print ''; print '
Ligne'; print 'StatutClient'; @@ -155,12 +189,6 @@ else print $db->error() . ' ' . $sql; } -if ($num > 0) -{ - print "
\n
\n"; - print 'Créer la commande'; - print '
'; -} $db->close();