From cd9ab46501eea066158c178a31d81fb93c924be6 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 24 Nov 2003 10:16:25 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/compta/commande.php | 257 +++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 htdocs/compta/commande.php diff --git a/htdocs/compta/commande.php b/htdocs/compta/commande.php new file mode 100644 index 00000000000..403aa940945 --- /dev/null +++ b/htdocs/compta/commande.php @@ -0,0 +1,257 @@ + + * + * 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'); +if (!$user->rights->commande->lire) + accessforbidden(); + +require("../project.class.php"); +require("../propal.class.php"); +require("../commande/commande.class.php"); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} +/* + * + */ + +llxHeader(); + +$html = new Form($db); + +/* *************************************************************************** */ +/* */ +/* Mode vue et edition */ +/* */ +/* *************************************************************************** */ + +if ($_GET["id"] > 0) +{ + $commande = New Commande($db); + if ( $commande->fetch($_GET["id"]) > 0) + { + $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 ''; + print ""; + print "'; + + print '"; + + print ""; + print "\n"; + + print '"; + + print ""; + + print '"; + + print ''; + print ''; + print ''; + + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + if ($commande->note) + { + print '"; + } + + print "
Client"; + print ''.$soc->nom.''; + print $commande->statuts[$commande->statut]; + print "
Date".strftime("%A %d %B %Y",$commande->date)."Source : ' . $commande->sources[$commande->source] ; + if ($commande->source == 0) + { + /* Propale */ + $propal = new Propal($db); + $propal->fetch($commande->propale_id); + print ' -> '.$propal->ref.''; + } + print "
Auteur$author->fullnameProjet : '; + if ($commande->projet_id > 0) + { + $projet = New Project($db); + $projet->fetch($commande->projet_id); + print ''.$projet->title.''; + } + print " 
Montant'.price($commande->total_ht).''.MAIN_MONNAIE.' HTNote
Remise globale'; + + print $commande->remise_percent.' % '; + + print '
TVA'.price($commande->total_tva).''.MAIN_MONNAIE.'
Total'.price($commande->total_ttc).''.MAIN_MONNAIE.' TTC
Note : '.nl2br($commande->note)."
"; + + /* + * Lignes de commandes + * + */ + echo '
'; + + $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice"; + $sql .= " FROM llx_commandedet as l WHERE l.fk_commande =".$commande->id." ORDER BY l.rowid"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + print ""; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + print ''; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + + print ''; + + print ""; + + + $i++; + $var=!$var; + } + $db->free(); + } + else + { + print $db->error(); + } + print '
DescriptionTvaQuantitéRemiseP.U.  
'; + print ''.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.' %'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice)."  
'; + /* + * Barre d'actions + */ + + if ($user->societe_id == 0) + { + print '

'; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print "
'; + print 'Facturer'; + print '----
"; + } + print "

\n"; + + /* + * Documents générés + * + */ + $file = FAC_OUTPUTDIR . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; + + if (file_exists($file)) + { + print "
"; + print_titre("Documents"); + print ''; + + print ""; + print ''; + print ''; + print ''; + print ''; + + print "
Commande PDFref."/".$commande->ref.'.pdf">'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; + print '
'; + + + /* + * + * + */ + print "
"; + } + /* + * + * + */ + + } + else + { + /* Commande non trouvée */ + print "Commande inexistante ou accés refusé"; + } +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>