2004-10-20 00:24:10 +02:00
|
|
|
|
<?php
|
2003-06-19 14:39:06 +02:00
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-08-15 19:33:05 +02:00
|
|
|
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-06-19 14:39:06 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
* or see http://www.gnu.org/
|
|
|
|
|
|
*
|
|
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-08-15 19:33:05 +02:00
|
|
|
|
/*! \file htdocs/includes/modules/propale/modules_propale.php
|
2004-10-20 00:24:10 +02:00
|
|
|
|
\ingroup propale
|
|
|
|
|
|
\brief Fichier contenant la classe m<EFBFBD>re de generation des propales en PDF
|
2004-08-18 16:26:33 +02:00
|
|
|
|
et la classe m<EFBFBD>re de num<EFBFBD>rotation des propales
|
2004-10-20 00:24:10 +02:00
|
|
|
|
\version $Revision$
|
2004-08-15 19:33:05 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! \class ModelePDFPropales
|
2004-10-20 00:24:10 +02:00
|
|
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de propale
|
2004-08-15 19:33:05 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class ModelePDFPropales extends FPDF
|
|
|
|
|
|
{
|
2004-08-18 16:26:33 +02:00
|
|
|
|
var $error='';
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
\brief Renvoi le dernier message d'erreur de cr<EFBFBD>ation de propale
|
|
|
|
|
|
*/
|
|
|
|
|
|
function pdferror()
|
2004-08-15 19:33:05 +02:00
|
|
|
|
{
|
2004-08-18 16:26:33 +02:00
|
|
|
|
return $this->error;
|
2004-08-15 19:33:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-18 16:26:33 +02:00
|
|
|
|
/*!\class ModeleNumRefPropales
|
|
|
|
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de num<EFBFBD>rotation des r<EFBFBD>f<EFBFBD>rences de propales
|
2004-08-15 19:33:05 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class ModeleNumRefPropales
|
|
|
|
|
|
{
|
|
|
|
|
|
var $error='';
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Renvoi la description par defaut du modele de num<EFBFBD>rotation
|
|
|
|
|
|
* \return string Texte descripif
|
|
|
|
|
|
*/
|
2004-08-15 19:38:54 +02:00
|
|
|
|
function info()
|
2004-08-15 19:33:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
$langs->load("propale");
|
|
|
|
|
|
return $langs->trans("NoDescription");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Renvoi un exemple de num<EFBFBD>rotation
|
|
|
|
|
|
* \return string Example
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getExample()
|
|
|
|
|
|
{
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
$langs->load("propale");
|
|
|
|
|
|
return $langs->trans("NoExample");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
\brief Renvoi le dernier message d'erreur de cr<EFBFBD>ation de propale
|
|
|
|
|
|
*/
|
|
|
|
|
|
function numreferror()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
\brief Cr<EFBFBD>e une propale sur disque en fonction du mod<EFBFBD>le de PROPALE_ADDON_PDF
|
|
|
|
|
|
\param db objet base de donn<EFBFBD>e
|
|
|
|
|
|
\param facid id de la facture <EFBFBD> cr<EFBFBD>er
|
2004-08-15 20:18:25 +02:00
|
|
|
|
\param modele force le modele <EFBFBD> utiliser ('' par defaut)
|
2004-08-15 19:33:05 +02:00
|
|
|
|
*/
|
2003-07-07 15:44:09 +02:00
|
|
|
|
function propale_pdf_create($db, $facid, $modele='')
|
2003-06-19 14:39:06 +02:00
|
|
|
|
{
|
2004-08-15 19:33:05 +02:00
|
|
|
|
global $langs;
|
|
|
|
|
|
$langs->load("propale");
|
|
|
|
|
|
|
2003-06-23 15:57:58 +02:00
|
|
|
|
$dir = DOL_DOCUMENT_ROOT."/includes/modules/propale/";
|
2003-06-19 14:39:06 +02:00
|
|
|
|
|
2004-08-15 19:33:05 +02:00
|
|
|
|
// Positionne modele sur le nom du modele de facture <20> utiliser
|
2003-07-07 17:54:15 +02:00
|
|
|
|
if (! strlen($modele))
|
2003-06-19 14:39:06 +02:00
|
|
|
|
{
|
2004-08-15 19:33:05 +02:00
|
|
|
|
if (defined("PROPALE_ADDON_PDF") && PROPALE_ADDON_PDF)
|
2003-07-07 15:44:09 +02:00
|
|
|
|
{
|
|
|
|
|
|
$modele = PROPALE_ADDON_PDF;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-15 19:33:05 +02:00
|
|
|
|
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_PDF_NotDefined");
|
2003-07-07 15:44:09 +02:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2003-06-19 14:39:06 +02:00
|
|
|
|
|
2004-08-15 19:33:05 +02:00
|
|
|
|
// Charge le modele
|
2003-07-07 15:44:09 +02:00
|
|
|
|
$file = "pdf_propale_".$modele.".modules.php";
|
2003-07-07 17:54:15 +02:00
|
|
|
|
if (file_exists($dir.$file))
|
2003-07-07 15:44:09 +02:00
|
|
|
|
{
|
2003-07-07 18:28:32 +02:00
|
|
|
|
$classname = "pdf_propale_".$modele;
|
2003-07-07 15:44:09 +02:00
|
|
|
|
require_once($dir.$file);
|
|
|
|
|
|
|
2003-06-19 14:39:06 +02:00
|
|
|
|
$obj = new $classname($db);
|
|
|
|
|
|
|
2004-08-15 19:33:05 +02:00
|
|
|
|
if ( $obj->write_pdf_file($facid) > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-12-23 18:52:48 +01:00
|
|
|
|
dolibarr_syslog("Erreur dans propale_pdf_create");
|
2004-08-15 19:33:05 +02:00
|
|
|
|
dolibarr_print_error($db,$obj->pdferror());
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2003-06-19 14:39:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2004-08-15 19:33:05 +02:00
|
|
|
|
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
|
2003-06-19 14:39:06 +02:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|