2004-10-20 00:24:10 +02:00
|
|
|
|
<?php
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-06-11 15:32:01 +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$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/includes/modules/fichinter/modules_fichinter.php
|
2004-08-15 18:38:21 +02:00
|
|
|
|
\ingroup ficheinter
|
|
|
|
|
|
\brief Fichier contenant la classe m<EFBFBD>re de generation des fiches interventions en PDF
|
|
|
|
|
|
et la classe m<EFBFBD>re de num<EFBFBD>rotation des fiches interventions
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-09-03 17:14:34 +02:00
|
|
|
|
require_once(FPDF_PATH.'fpdf.php');
|
2004-08-15 18:38:21 +02:00
|
|
|
|
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\class ModelePDFFicheinter
|
|
|
|
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de fiche intervention
|
2004-08-15 18:38:21 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class ModelePDFFicheinter extends FPDF
|
|
|
|
|
|
{
|
|
|
|
|
|
var $error='';
|
|
|
|
|
|
|
2005-08-23 21:31:25 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Constructeur
|
2004-08-15 18:38:21 +02:00
|
|
|
|
*/
|
|
|
|
|
|
function ModelePDFFicheinter()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-23 21:31:25 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\brief Renvoi le dernier message d'erreur de cr<EFBFBD>ation de fiche intervention
|
|
|
|
|
|
*/
|
2004-08-15 18:38:21 +02:00
|
|
|
|
function pdferror()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->error;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-08-23 21:31:25 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* \brief Renvoi la liste des mod<EFBFBD>les actifs
|
|
|
|
|
|
*/
|
|
|
|
|
|
function liste_modeles($db)
|
|
|
|
|
|
{
|
2006-04-29 00:54:02 +02:00
|
|
|
|
$type='ficheinter';
|
2005-08-23 21:31:25 +02:00
|
|
|
|
$liste=array();
|
2006-04-29 00:54:02 +02:00
|
|
|
|
$sql ="SELECT nom as id, nom as lib";
|
|
|
|
|
|
$sql.=" FROM ".MAIN_DB_PREFIX."document_model";
|
|
|
|
|
|
$sql.=" WHERE type = '".$type."'";
|
2005-08-23 21:31:25 +02:00
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-15 18:38:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-08-23 21:31:25 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\class ModeleNumRefFicheinter
|
|
|
|
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de num<EFBFBD>rotation des r<EFBFBD>f<EFBFBD>rences de fiches d'intervention
|
2004-08-15 18:38:21 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class ModeleNumRefFicheinter
|
|
|
|
|
|
{
|
|
|
|
|
|
var $error='';
|
|
|
|
|
|
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/** \brief Renvoi la description par defaut du modele de num<EFBFBD>rotation
|
2004-08-15 18:38:21 +02:00
|
|
|
|
* \return string Texte descripif
|
|
|
|
|
|
*/
|
2004-08-15 19:38:54 +02:00
|
|
|
|
function info()
|
2004-08-15 18:38:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
$langs->load("ficheinter");
|
|
|
|
|
|
return $langs->trans("NoDescription");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/** \brief Renvoi un exemple de num<EFBFBD>rotation
|
2004-08-15 18:38:21 +02:00
|
|
|
|
* \return string Example
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getExample()
|
|
|
|
|
|
{
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
$langs->load("ficheinter");
|
|
|
|
|
|
return $langs->trans("NoExample");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2005-11-11 21:11:57 +01:00
|
|
|
|
/** \brief Test si les num<EFBFBD>ros d<EFBFBD>j<EFBFBD> en vigueur dans la base ne provoquent pas de
|
|
|
|
|
|
* de conflits qui empechera cette num<EFBFBD>rotation de fonctionner.
|
|
|
|
|
|
* \return boolean false si conflit, true si ok
|
|
|
|
|
|
*/
|
|
|
|
|
|
function canBeActivated()
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief Renvoi prochaine valeur attribu<EFBFBD>e
|
|
|
|
|
|
* \return string Valeur
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getNextValue()
|
|
|
|
|
|
{
|
|
|
|
|
|
global $langs;
|
|
|
|
|
|
return $langs->trans("NotAvailable");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-08-15 18:38:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-02 22:14:13 +02:00
|
|
|
|
/**
|
2004-08-15 18:38:21 +02:00
|
|
|
|
\brief Cr<EFBFBD>e une fiche intervention sur disque en fonction du mod<EFBFBD>le de FICHEINTER_ADDON_PDF
|
2006-03-22 00:47:01 +01:00
|
|
|
|
\param db objet base de donn<EFBFBD>e
|
|
|
|
|
|
\param id id de la fiche <EFBFBD> cr<EFBFBD>er
|
|
|
|
|
|
\param modele force le modele <EFBFBD> utiliser ('' par defaut)
|
|
|
|
|
|
\param outputlangs objet lang a utiliser pour traduction
|
|
|
|
|
|
\return int 0 si KO, 1 si OK
|
2004-08-15 18:38:21 +02:00
|
|
|
|
*/
|
2006-04-29 03:28:16 +02:00
|
|
|
|
function fichinter_pdf_create($db, $id, $modele='', $outputlangs='')
|
2003-06-11 15:32:01 +02:00
|
|
|
|
{
|
2006-03-22 00:47:01 +01:00
|
|
|
|
global $conf,$langs;
|
|
|
|
|
|
$langs->load("ficheinter");
|
|
|
|
|
|
|
|
|
|
|
|
$dir = DOL_DOCUMENT_ROOT."/includes/modules/fichinter/";
|
|
|
|
|
|
|
|
|
|
|
|
// Positionne modele sur le nom du modele de facture <20> utiliser
|
|
|
|
|
|
if (! strlen($modele))
|
2004-08-15 18:38:21 +02:00
|
|
|
|
{
|
2006-03-22 00:47:01 +01:00
|
|
|
|
if ($conf->global->FICHEINTER_ADDON_PDF)
|
|
|
|
|
|
{
|
|
|
|
|
|
$modele = $conf->global->FICHEINTER_ADDON_PDF;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_PDF_NotDefined");
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2004-08-15 18:38:21 +02:00
|
|
|
|
}
|
2006-03-22 00:47:01 +01:00
|
|
|
|
|
|
|
|
|
|
// Charge le modele
|
|
|
|
|
|
$file = "pdf_".$modele.".modules.php";
|
|
|
|
|
|
if (file_exists($dir.$file))
|
2004-08-15 18:38:21 +02:00
|
|
|
|
{
|
2006-03-22 00:47:01 +01:00
|
|
|
|
$classname = "pdf_".$modele;
|
|
|
|
|
|
require_once($dir.$file);
|
|
|
|
|
|
|
|
|
|
|
|
$obj = new $classname($db);
|
|
|
|
|
|
|
2006-06-18 17:48:28 +02:00
|
|
|
|
if ($obj->write_pdf_file($id,$outputlangs) > 0)
|
2006-03-22 00:47:01 +01:00
|
|
|
|
{
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dolibarr_print_error($db,$obj->pdferror());
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
|
|
|
|
|
|
return 0;
|
2004-08-15 18:38:21 +02:00
|
|
|
|
}
|
2003-06-11 15:32:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|