From 84a0a63c9623a611adfbe6bddb94c47cce8385f0 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 14 Apr 2005 15:41:53 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/compta/commande/fiche.php | 360 +++++++++++++++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 htdocs/compta/commande/fiche.php diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php new file mode 100644 index 00000000000..f95689b6d51 --- /dev/null +++ b/htdocs/compta/commande/fiche.php @@ -0,0 +1,360 @@ + + * Copyright (C) 2004-2005 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$ + * + */ + +/** + \file htdocs/compta/commande.php + \ingroup commande + \brief Fiche commande + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("companies"); +$langs->load("bills"); + +$user->getrights('facture'); + +if (! $user->rights->commande->lire) accessforbidden(); + +require_once DOL_DOCUMENT_ROOT."/project.class.php"; +require_once DOL_DOCUMENT_ROOT."/propal.class.php"; + + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} +/* + * + */ + +if ($_GET["action"] == 'facturee') +{ + $commande = new Commande($db); + $commande->fetch($_GET["id"]); + $commande->classer_facturee(); +} + + +llxHeader('',$langs->trans("OrderCard"),"Commande"); + + + +$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(); + + $h=0; + $head[0][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; + $head[0][1] = $langs->trans("OrderCard"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; + $head[$h][1] = $langs->trans("ComptaCard"); + $hselected = $h; + $h++; + + dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref"); + + /* + * Commande + */ + print ''; + print ""; + print ''; + + print '"; + + print ''; + print "\n"; + + print '"; + + print ''; + + print '"; + + // Ligne de 3 colonnes + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print "
".$langs->trans("Customer")."'; + print ''.$soc->nom.''; + print $commande->statuts[$commande->statut]; + print "
'.$langs->trans("Date").'".strftime("%A %d %B %Y",$commande->date)."'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; + if ($commande->source == 0) + { + /* Propale */ + $propal = new Propal($db); + $propal->fetch($commande->propale_id); + print ' -> '.$propal->ref.''; + } + print "
'.$langs->trans("Author").''.$author->fullname.''; + if ($conf->projet->enabled) { + print $langs->trans("Project").' : '; + if ($commande->projet_id > 0) + { + $projet = New Project($db); + $projet->fetch($commande->projet_id); + print ''.$projet->title.''; + } + else + { + print 'Classer la commande'; + } + } + print " 
'.$langs->trans("AmountHT").''.price($commande->total_ht).''.$conf->monnaie.''.$langs->trans("Note").' :
'.nl2br($commande->note).'
'.$langs->trans("GlobalDiscount").''; + print $commande->remise_percent.' % '; + print '
'.$langs->trans("VAT").''.price($commande->total_tva).''.$conf->monnaie.'
'.$langs->trans("TotalTTC").''.price($commande->total_ttc).''.$conf->monnaie.'
"; + + /* + * 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 ".MAIN_DB_PREFIX."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(); + 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 + { + dolibarr_print_error($db); + } + print '
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Discount").''.$langs->trans("PriceU").'  
'; + print ''.img_object($langs->trans("ShowProduct"),"product").' '.stripslashes(nl2br($objp->description)).'".stripslashes(nl2br($objp->description))."'.$objp->tva_tx.' %'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice)."  
'; + + /* + * Documents générés + * + */ + $file = $conf->facture->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; + $relativepath = $commande->ref."/".$commande->ref.".pdf"; + + $var=true; + + if (file_exists($file)) + { + print "
"; + print_titre("Documents"); + print ''; + + print ""; + print ''; + print ''; + print ''; + print ''; + + print "
".$langs->trans("Order")." PDF'.$commande->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; + print '
'; + /* + * + * + */ + print "
"; + } + + /* + * Factures associees + */ + $sql = "SELECT f.facnumber, f.total,".$db->pdate("f.datef")." as df, f.rowid as facid, f.fk_user_author, f.paye"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as fp WHERE fp.fk_facture = f.rowid AND fp.fk_commande = ".$commande->id; + + if ($db->query($sql)) + { + $num_fac_asso = $db->num_rows(); + $i = 0; $total = 0; + + if ($num_fac_asso > 0) + { + print "
"; + if ($num_fac_asso > 1) + { + print_titre("Factures associées"); + } + else + { + print_titre("Facture associée"); + } + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + while ($i < $num_fac_asso) + { + $objp = $db->fetch_object(); + $var=!$var; + print ""; + print "\n"; + print "\n"; + if ($objp->fk_user_author <> $user->id) + { + $fuser = new User($db, $objp->fk_user_author); + $fuser->fetch(); + print "\n"; + } + else + { + print "\n"; + } + print ''; + print ""; + $total = $total + $objp->total; + $i++; + } + print "\n"; + print "
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Author").''.$langs->trans("Price").'
facid\">$objp->facnumber"; + if ($objp->paye) + { + print " (payée)"; + } + print "".strftime("%d %B %Y",$objp->df)."".$fuser->fullname."".$user->fullname."'.price($objp->total).'
".$langs->trans("TotalHT").": $total ".$conf->monnaie."
"; + } + $db->free(); + } + else + { + dolibarr_print_error($db); + } + /* + * + * + */ + print '
'; + + /* + * Barre d'actions + */ + + if (! $user->societe_id && ! $commande->facturee) + { + print "
\n"; + + if ($commande->statut <> 0 && $user->rights->facture->creer) + { + print ''.$langs->trans("GenerateBill").''; + } + + if ($num_fac_asso) + { + if ($user->rights->commande->creer) + print ''.$langs->trans("ClassifyBilled").''; + } + print '
'; + } + + + } + else + { + /* Commande non trouvée */ + print "Commande inexistante ou accés refusé"; + } +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>