diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php new file mode 100644 index 00000000000..a1f4357c9a3 --- /dev/null +++ b/htdocs/expedition/commande.php @@ -0,0 +1,341 @@ + + * + * 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('commande'); +$user->getrights('expedition'); +if (!$user->rights->commande->lire) + accessforbidden(); + +require("../project.class.php"); +require("../propal.class.php"); +require("../product/stock/entrepot.class.php"); +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} +/* + * + */ + +if ($HTTP_POST_VARS["action"] == 'confirm_valid' && $HTTP_POST_VARS["confirm"] == yes && $user->rights->commande->valider) +{ + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + $result = $commande->cloture($user); +} + +llxHeader('','Fiche commande',''); + +$html = new Form($db); + +/* *************************************************************************** */ +/* */ +/* Mode vue et edition */ +/* */ +/* *************************************************************************** */ + +if ($id > 0) +{ + $commande = New Commande($db); + if ( $commande->fetch($id) > 0) + { + $commande->livraison_array(); + + $soc = new Societe($db); + $soc->fetch($commande->soc_id); + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); + + print_titre("Commande : ".$commande->ref); + + /* + * Commande + */ + print '
\n"; + + /* + * Alerte de seuil + * + */ + if ($reste_a_livrer_total > 0 && defined("MAIN_MODULE_STOCK")) + { + print '| '.$obja->label.' | '.$obja->entrepot.' | Stock : '.$obja->reel.' | '; + print "
| - | '; + print '- | '; + + if ($user->rights->expedition->valider && $reste_a_livrer_total == 0) + { + print 'Clôturer | '; + } + else + { + print '- | '; + } + + print '- | '; + print '- | '; + print "
| Description | '; + print 'Quan. livrée | '; + print 'Expédition | '; + + print "|
| '; + print ''.stripslashes(nl2br($objp->description)).' | '; + } + else + { + print "".stripslashes(nl2br($objp->description))." | \n"; + } + print ''.$objp->qty_livre.' | '; + print ''.$objp->ref.' | '; + $i++; + } + + print '
';
+/*
+ *
+ */
+
+/*
+ * Expeditions à valider
+ */
+$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id FROM llx_expedition as e, llx_societe as s, llx_commande as c";
+$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 0";
+if ($socidp)
+{
+ $sql .= " AND c.fk_soc = $socidp";
+}
+
+print '
"; + +/* + * + */ +print ' | ';
+
+/*
+ * Commandes à traiter
+ */
+$sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM llx_commande as c, llx_societe as s";
+$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 1";
+if ($socidp)
+{
+ $sql .= " AND c.fk_soc = $socidp";
+}
+
+if ( $db->query($sql) )
+{
+ $num = $db->num_rows();
+ if ($num)
+ {
+ $i = 0;
+ print '
"; + } +} + +/* + * Commandes à traiter + */ +$sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM llx_commande as c, llx_societe as s"; +$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 2"; +if ($socidp) +{ + $sql .= " AND c.fk_soc = $socidp"; +} + +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + if ($num) + { + $i = 0; + print '
"; + } +} + + + +/* + * Expeditions à valider + */ +$sql = "SELECT e.rowid, e.ref, s.nom, s.idp, c.ref as commande_ref, c.rowid as commande_id FROM llx_expedition as e, llx_societe as s, llx_commande as c"; +$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.idp AND e.fk_statut = 1"; +if ($socidp) +{ + $sql .= " AND c.fk_soc = $socidp"; +} +$sql .= " ORDER BY c.rowid DESC"; +$sql .= $db->plimit(5, 0); +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + if ($num) + { + $i = 0; + print '
"; + } +} + +print ' | ||||||||||||||||||||
| rowid\">$objp->ref | \n"; + print "idp\">$objp->nom | \n"; + + $now = time(); + $lim = 3600 * 24 * 15 ; + + if ( ($now - $objp->date_expedition) > $lim && $objp->statutid == 1 ) + { + print "> 15 jours | "; + } + else + { + print ""; + } + + print " | "; + $y = strftime("%Y",$objp->date_expedition); + $m = strftime("%m",$objp->date_expedition); + + print strftime("%d",$objp->date_expedition)."\n"; + print " "; + print strftime("%B",$objp->date_expedition)."\n"; + print " "; + print strftime("%Y",$objp->date_expedition)." | \n"; + + print "$objp->statut | \n"; + print "