2
0
forked from Wavyzz/dolibarr

Qual: Mise en commun dans la methode html->show_documents du code des zones d'affichages des documents PDF gnrs.

(Afin de prparer la gnration des PDF incluant le choix du model  la vole).
This commit is contained in:
Laurent Destailleur
2005-08-23 19:31:25 +00:00
parent 58caa5e242
commit bbb6fc162c
12 changed files with 222 additions and 235 deletions

View File

@@ -29,7 +29,6 @@
*/
require("./pre.inc.php");
require("./propal_model_pdf.class.php");
$langs->load("propal");
$langs->load("projects");
@@ -197,9 +196,10 @@ if ($_GET["action"] == 'create')
print '<td>Mod<6F>le</td>';
print '<td>';
$html = new Form($db);
$modelpdf = new Propal_Model_pdf($db);
$html->select_array("modelpdf",$modelpdf->liste_array(),PROPALE_ADDON_PDF);
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php');
$model=new ModelePDFPropales();
$liste=$model->liste_modeles($this->db);
$html->select_array("modelpdf",$liste,PROPALE_ADDON_PDF);
print "</td></tr></table>";
print '<br>';

View File

@@ -42,7 +42,6 @@ $langs->load('bills');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php');
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
require_once('./propal_model_pdf.class.php');
require_once('../propal.class.php');
require_once('../actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
@@ -888,46 +887,20 @@ if ($_GET['propalid'] > 0)
print '<table width="100%"><tr><td width="50%" valign="top">';
/*
* Documents
*/
if ($propal->brouillon == 1)
{
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="setpdfmodel">';
}
print_titre($langs->trans('Documents'));
print '<table class="border" width="100%">';
$propref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
$relativepath = $propref.'/'.$propref.'.pdf';
/*
* Documents g<>n<EFBFBD>r<EFBFBD>s
*/
$filename=sanitize_string($propal->ref);
$filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref);
$urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id;
$genallowed=$user->rights->propale->creer;
$delallowed=$user->rights->propale->supprimer;
$var=true;
if (file_exists($file))
{
print '<tr '.$bc[$var].'><td>'.$langs->trans('Propal').' PDF</td>';
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$propal->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'</td></tr>';
}
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
print '<tr '.$bc[$var].'><td>Mod<6F>le</td><td align="right">';
$html = new Form($db);
$modelpdf = new Propal_Model_pdf($db);
$html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf);
print '</td><td colspan="2"><input type="submit" value="'.$langs->trans('Save').'">';
print '</td></tr>';
}
print "</table>\n";
if ($propal->brouillon == 1)
{
print '</form>';
}
print "<br>\n";
$form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
/*

View File

@@ -1,67 +0,0 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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.
*
*/
class Propal_Model_Pdf {
var $nom;
function Propal_Model_Pdf($DB)
{
$this->db = $DB ;
}
/*
*
*
*
*/
function liste_array()
{
$projets = array();
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."propal_model_pdf";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
$projets[$obj->nom] = $obj->nom;
$i++;
}
}
return $projets;
}
else
{
print $this->db->error();
}
}
}
?>

View File

@@ -1389,48 +1389,19 @@ else
/*
* Documents g<>n<EFBFBD>r<EFBFBD>s
* Le fichier de facture d<>taill<6C>e est de la forme
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
*/
$facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
$relativepath = "${facref}/${facref}.pdf";
$filename=sanitize_string($fac->ref);
$filedir=$conf->facture->dir_output . "/" . sanitize_string($fac->ref);
$urlsource=$_SERVER["PHP_SELF"]."?facid=".$fac->id;
// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer);
// $delallowed=$user->rights->facture->supprimer;
$genallowed=0;
$delallowed=0;
$var=true;
if (file_exists($file))
{
print "<br>\n";
print_titre("Documents");
print '<table class="border" width="100%">';
print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '</tr>';
$dir = $conf->facture->dir_output . "/" . $facref . "/";
$handle=opendir($dir);
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.$file) && substr($file, -10) == 'detail.pdf')
{
print "<tr $bc[$var]><td>Facture d<>taill<6C>e</td>";
$relativepathdetail = "${facref}/$file";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$file.'</a></td>';
print '<td align="right">'.filesize($dir.$file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($dir.$file)).'</td>';
print '</tr>';
}
}
print "</table>\n";
}
$html->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed);
/*

View File

@@ -454,27 +454,18 @@ if ($_GET["propalid"])
print '<table width="100%"><tr><td width="50%" valign="top">';
/*
* Documents
* Documents g<>n<EFBFBD>r<EFBFBD>s
*/
print_titre($langs->trans('Documents'));
print '<table class="border" width="100%">';
$propref = sanitize_string($propal->ref);
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
$relativepath = $propref.'/'.$propref.'.pdf';
$filename=sanitize_string($propal->ref);
$filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref);
$urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id;
$genallowed=0;
$delallowed=0;
$var=true;
if (file_exists($file))
{
print '<tr '.$bc[$var].'><td>'.$langs->trans('Propal').' PDF</td>';
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$propal->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'</td></tr>';
}
print "</table>\n";
print "<br>\n";
$form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed);
/*

View File

@@ -104,7 +104,8 @@ if ($_GET["id"] > 0)
$h++;
}
dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref");
dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref");
/*
* Confirmation de la validation
*
@@ -143,13 +144,14 @@ if ($_GET["id"] > 0)
print '<tr><td colspan="3">'.nl2br($commande->note)."</td></tr>";
}
print '</table><br />';
print '</table>';
/*
* Lignes de commandes
*
*/
echo '<table class="liste" width="100%">';
echo '<br><table class="liste" width="100%">';
$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 ";
@@ -233,7 +235,6 @@ if ($_GET["id"] > 0)
if (! $num)
{
print $langs->trans("None").'<br>';
print '<br>';
}
}
@@ -248,7 +249,6 @@ if ($_GET["id"] > 0)
*/
if ($reste_a_livrer_total > 0 && $commande->brouillon == 0)
{
print '<form method="post" action="fiche.php">';
print '<input type="hidden" name="action" value="create">';
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';

View File

@@ -31,6 +31,7 @@
require("./pre.inc.php");
$langs->load("bills");
if (!$user->rights->expedition->lire)
accessforbidden();
@@ -444,28 +445,10 @@ else
dolibarr_print_error($db);
}
print "</table><br>\n";
print "</table>\n";
print "\n</div>\n";
/*
*
*/
$file = $expedition->pdf_filename;
if (file_exists($file))
{
print_titre($langs->trans("Documents"));
print '<table class="border" width="50%">';
print "<tr $bc[$var]><td>".$langs->trans("Sending")." PDF</td>";
$b = ereg_replace($conf->expedition->dir_output."/","",$file);
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=expedition&file='.urlencode($b).'">'.basename($file).'</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.dolibarr_print_date(filemtime($file),"%d %B %Y %H:%M:%S").'</td></tr>';
print "</table>";
}
/*
*
@@ -489,10 +472,27 @@ else
print '</div>';
}
/*
* Documents g<>n<EFBFBD>r<EFBFBD>s
*/
$filename=sanitize_string($expedition->id);
$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id;
//$genallowed=$user->rights->expedition->creer;
//$delallowed=$user->rights->expedition->supprimer;
$genallowed=0;
$delallowed=0;
$var=true;
print "<br>\n";
$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
/*
* D<>j<EFBFBD> livr<76>
*
*
*/
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande";
$sql .= " , ed.qty as qty_livre, e.ref";

View File

@@ -1386,11 +1386,15 @@ class Form
$liste=array();
if ($modulepart == 'propal')
{
$liste=$this->select("ee","select nom as id, nom as lib from ".MAIN_DB_PREFIX."propal_model_pdf");
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php');
$model=new ModelePDFPropales();
$liste=$model->liste_modeles($this->db);
}
elseif ($modulepart == 'facture')
{
$liste=$this->select("");
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
$model=new ModelePDFFactures();
$liste=$model->liste_modeles($this->db);
}
else
{

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,8 @@
*
*/
/** \file htdocs/includes/modules/commande/modules_commande.php
/**
\file htdocs/includes/modules/commande/modules_commande.php
\ingroup commande
\brief Fichier contenant la classe m<>re de generation des commandes en PDF
et la classe m<>re de num<75>rotation des commandes
@@ -32,7 +33,8 @@
/** \class ModelePDFCommandes
/**
\class ModelePDFCommandes
\brief Classe m<>re des mod<6F>les de commandes
*/
@@ -48,11 +50,39 @@ class ModelePDFCommandes extends FPDF
return $this->error;
}
/**
* \brief Renvoi la liste des mod<6F>les actifs
*/
function liste_modeles($db)
{
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
}
/** \class ModeleNumRefCommandes
/**
\class ModeleNumRefCommandes
\brief Classe m<>re des mod<6F>les de num<75>rotation des r<>f<EFBFBD>rences de commandes
*/

View File

@@ -36,7 +36,8 @@ require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); // Requis ca
/** \class ModelePDFFactures
/**
\class ModelePDFFactures
\brief Classe m<>re des mod<6F>les de facture
*/
@@ -45,13 +46,40 @@ class ModelePDFFactures extends FPDF
var $error='';
/**
\brief Renvoi le dernier message d'erreur de cr<63>ation de facture
* \brief Renvoi le dernier message d'erreur de cr<63>ation de facture
*/
function pdferror()
{
return $this->error;
}
/**
* \brief Renvoi la liste des mod<6F>les actifs
*/
function liste_modeles($db)
{
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
}

View File

@@ -40,7 +40,8 @@ class ModelePDFFicheinter extends FPDF
{
var $error='';
/** \brief Constructeur
/**
\brief Constructeur
*/
function ModelePDFFicheinter()
{
@@ -55,10 +56,38 @@ class ModelePDFFicheinter extends FPDF
return $this->error;
}
/**
* \brief Renvoi la liste des mod<6F>les actifs
*/
function liste_modeles($db)
{
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
}
/** \class ModeleNumRefFicheinter
/**
\class ModeleNumRefFicheinter
\brief Classe m<>re des mod<6F>les de num<75>rotation des r<>f<EFBFBD>rences de fiches d'intervention
*/

View File

@@ -41,17 +41,45 @@ class ModelePDFPropales extends FPDF
var $error='';
/**
\brief Renvoi le dernier message d'erreur de cr<63>ation de propale
* \brief Renvoi le dernier message d'erreur de cr<63>ation de propale
*/
function pdferror()
{
return $this->error;
}
/**
* \brief Renvoi la liste des mod<6F>les actifs
*/
function liste_modeles($db)
{
$liste=array();
$sql ="SELECT nom as id, nom as lib";
$sql.=" FROM ".MAIN_DB_PREFIX."propal_model_pdf";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
}
/**\class ModeleNumRefPropales
/**
\class ModeleNumRefPropales
\brief Classe m<>re des mod<6F>les de num<75>rotation des r<>f<EFBFBD>rences de propales
*/