modifs pour export pdf

This commit is contained in:
Andre Cianfarani 2006-02-08 15:13:50 +00:00
parent 04c34cc00d
commit 74e6caf43b
2 changed files with 85 additions and 8 deletions

View File

@ -467,9 +467,57 @@ class Commande
$this->facturee = $obj->facture; $this->facturee = $obj->facture;
$this->note = $obj->note; $this->note = $obj->note;
$this->projet_id = $obj->fk_projet; $this->projet_id = $obj->fk_projet;
$this->db->free(); $this->db->free();
if ($this->statut == 0) if ($this->statut == 0)
$this->brouillon = 1; $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 * Propale associée
*/ */
@ -992,8 +1040,22 @@ class Commande
class CommandeLigne 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() function CommandeLigne()
{ {
} }
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,6 +30,7 @@
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
$langs->load('orders'); $langs->load('orders');
$langs->load('sendings'); $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 * Generation de la commande
* définit dans /includes/modules/commande/modules_commande.php * 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 * 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 '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>'; print '<td>'.$langs->trans('Description').'</td>';
@ -834,7 +836,7 @@ else
/* /*
* Boutons actions * 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 '<div class="tabsAction">'; print '<div class="tabsAction">';
@ -872,6 +874,11 @@ else
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&amp;action=annuler">'.$langs->trans('CancelOrder').'</a>'; print '<a class="butActionDelete" href="fiche.php?id='.$id.'&amp;action=annuler">'.$langs->trans('CancelOrder').'</a>';
} }
} }
// Build PDF
if ($user->rights->commande->creer)
{
print '<a class="butAction" href="fiche.php?id='.$commande->id.'&amp;action=builddoc">'.$langs->trans("BuildPDF").'</a>';
}
print '</div>'; print '</div>';
} }
@ -884,11 +891,18 @@ else
* Documents générés * Documents générés
* *
*/ */
$file = $conf->commande->dir_output . '/' . $commande->ref . '/' . $commande->ref . '.pdf'; $comref = sanitize_string($commande->ref);
$relativepath = $commande->ref.'/'.$commande->ref.'.pdf'; $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; $var=true;
/*
if (file_exists($file)) if (file_exists($file))
{ {
print_titre($langs->trans('Documents')); print_titre($langs->trans('Documents'));
@ -901,7 +915,8 @@ else
print '</table>'; print '</table>';
print '<br>'; print '<br>';
} }
*/
$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed);
/* /*
* Liste des factures * Liste des factures
*/ */