From 74e6caf43bf5b12dfb62733c0d654e73f2d7577b Mon Sep 17 00:00:00 2001 From: Andre Cianfarani Date: Wed, 8 Feb 2006 15:13:50 +0000 Subject: [PATCH] modifs pour export pdf --- htdocs/commande/commande.class.php | 62 ++++++++++++++++++++++++++++++ htdocs/commande/fiche.php | 31 +++++++++++---- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 4f6f5336125..57649e02154 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -467,9 +467,57 @@ class Commande $this->facturee = $obj->facture; $this->note = $obj->note; $this->projet_id = $obj->fk_projet; + $this->db->free(); if ($this->statut == 0) $this->brouillon = 1; + // exp pdf ----------- + $this->lignes = array(); + $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; + $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; + $sql.= ' WHERE l.fk_commande = '.$this->id; + $sql.= ' ORDER BY l.rowid'; + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + + while ($i < $num) + { + $objp = $this->db->fetch_object($result); + + $ligne = new CommandeLigne(); + + $ligne->desc = $objp->description; // Description ligne + $ligne->qty = $objp->qty; + $ligne->tva_tx = $objp->tva_tx; + $ligne->subprice = $objp->subprice; + $ligne->remise_percent = $objp->remise_percent; + $ligne->price = $objp->price; + $ligne->product_id = $objp->rowid; + + $ligne->libelle = $objp->label; // Label produit + $ligne->product_desc = $objp->product_desc; // Description produit + $ligne->ref = $objp->ref; + + $this->lignes[$i] = $ligne; + //dolibarr_syslog("1 ".$ligne->desc); + //dolibarr_syslog("2 ".$ligne->product_desc); + $i++; + } + $this->db->free($result); + } + else + { + dolibarr_syslog("Propal::Fetch Erreur lecture des produits"); + return -1; + } + + + // -------- exp pdf // /* * Propale associée */ @@ -992,8 +1040,22 @@ class Commande class CommandeLigne { + // From llx_propaldet + var $qty; + var $tva_tx; + var $subprice; + var $remise_percent; + var $price; + var $product_id; + var $desc; // Description ligne + + // From llx_product + var $libelle; // Label produit + var $product_desc; // Description produit + var $ref; function CommandeLigne() { + } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 933cc7e6e10..d17166a7856 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2004 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2006 Andre Cianfarani * * 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 @@ -29,6 +30,7 @@ */ require('./pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); $langs->load('orders'); $langs->load('sendings'); @@ -216,13 +218,13 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') } } -if ($_GET['action'] == 'pdf') +if ($_GET['action'] == 'builddoc' || $_POST['action'] == 'builddoc') { /* * Generation de la commande * définit dans /includes/modules/commande/modules_commande.php */ - commande_pdf_create($db, $_GET['id']); + commande_pdf_create($db, $_GET['id'],$_POST['model']); } @@ -772,7 +774,7 @@ else /* * Ajouter une ligne */ - if ($commande->statut == 0 && $user->rights->commande->creer && $_GET['action'] == '') + if ($commande->statut == 0 && $user->rights->commande->creer && ($_GET['action'] == '' || $_GET['action'] == 'builddoc')) { print ''; print ''.$langs->trans('Description').''; @@ -834,7 +836,7 @@ else /* * Boutons actions */ - if ($user->societe_id == 0 && $commande->statut < 3 && $_GET['action'] == '') + if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET['action'] == '' || $_GET['action'] == 'builddoc')) { print '
'; @@ -872,6 +874,11 @@ else print ''.$langs->trans('CancelOrder').''; } } + // Build PDF + if ($user->rights->commande->creer) + { + print ''.$langs->trans("BuildPDF").''; + } print '
'; } @@ -884,11 +891,18 @@ else * Documents générés * */ - $file = $conf->commande->dir_output . '/' . $commande->ref . '/' . $commande->ref . '.pdf'; - $relativepath = $commande->ref.'/'.$commande->ref.'.pdf'; + $comref = sanitize_string($commande->ref); + $comref = str_replace("(","",$comref); + $comref = str_replace(")","",$comref); + $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->dir_output . '/' . $comref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; + $genallowed=$user->rights->commande->creer; + $delallowed=$user->rights->commande->supprimer; $var=true; - + /* if (file_exists($file)) { print_titre($langs->trans('Documents')); @@ -901,7 +915,8 @@ else print ''; print '
'; } - + */ + $html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed); /* * Liste des factures */