mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
217 lines
5.6 KiB
PHP
217 lines
5.6 KiB
PHP
|
|
<?php
|
|||
|
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|||
|
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
|||
|
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
|||
|
|
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
|
|||
|
|
*
|
|||
|
|
* 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$
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
\file htdocs/includes/modules/dons/modules_don.php
|
|||
|
|
\ingroup don
|
|||
|
|
\brief Fichier contenant la classe m<EFBFBD>re de generation des dons
|
|||
|
|
\version $Revision$
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
require_once(FPDF_PATH.'fpdf.php');
|
|||
|
|
require_once(DOL_DOCUMENT_ROOT."/don.class.php");
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
\class ModeleDon
|
|||
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de dons
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
class ModeleDon extends FPDF
|
|||
|
|
{
|
|||
|
|
var $error='';
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* \brief Renvoi le dernier message d'erreur de cr<EFBFBD>ation de facture
|
|||
|
|
*/
|
|||
|
|
function pdferror()
|
|||
|
|
{
|
|||
|
|
return $this->error;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* \brief Renvoi la liste des mod<EFBFBD>les actifs
|
|||
|
|
* \param db Handler de base
|
|||
|
|
*/
|
|||
|
|
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 ModeleNumRefDons
|
|||
|
|
\brief Classe m<EFBFBD>re des mod<EFBFBD>les de num<EFBFBD>rotation des r<EFBFBD>f<EFBFBD>rences de facture
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
class ModeleNumRefDons
|
|||
|
|
{
|
|||
|
|
var $error='';
|
|||
|
|
|
|||
|
|
/** \brief Renvoi la description par defaut du modele de num<EFBFBD>rotation
|
|||
|
|
* \return string Texte descripif
|
|||
|
|
*/
|
|||
|
|
function info()
|
|||
|
|
{
|
|||
|
|
global $langs;
|
|||
|
|
$langs->load("bills");
|
|||
|
|
return $langs->trans("NoDescription");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** \brief Renvoi un exemple de num<EFBFBD>rotation
|
|||
|
|
* \return string Example
|
|||
|
|
*/
|
|||
|
|
function getExample()
|
|||
|
|
{
|
|||
|
|
global $langs;
|
|||
|
|
$langs->load("bills");
|
|||
|
|
return $langs->trans("NoExample");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** \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");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
\brief Cr<EFBFBD>e un don sur disque en fonction du mod<EFBFBD>le de DON_ADDON_PDF
|
|||
|
|
\param db objet base de donn<EFBFBD>e
|
|||
|
|
\param donid id de la facture <EFBFBD> cr<EFBFBD>er
|
|||
|
|
\param message message
|
|||
|
|
\return int 0 si KO, 1 si OK
|
|||
|
|
*/
|
|||
|
|
function don_create($db, $donid, $message="")
|
|||
|
|
{
|
|||
|
|
global $langs;
|
|||
|
|
$langs->load("bills");
|
|||
|
|
|
|||
|
|
define("DON_ADDON",'html_cerfafr');
|
|||
|
|
|
|||
|
|
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/dons/";
|
|||
|
|
|
|||
|
|
if (defined("DON_ADDON") && DON_ADDON)
|
|||
|
|
{
|
|||
|
|
$file = DON_ADDON.".modules.php";
|
|||
|
|
|
|||
|
|
$classname = DON_ADDON;
|
|||
|
|
require_once($dir.$file);
|
|||
|
|
|
|||
|
|
$obj = new $classname($db);
|
|||
|
|
|
|||
|
|
$obj->message = $message;
|
|||
|
|
|
|||
|
|
if ( $obj->write_file($donid) > 0)
|
|||
|
|
{
|
|||
|
|
// Succ<63>s de la cr<63>ation de la facture. On g<>n<EFBFBD>re le fichier meta
|
|||
|
|
don_meta_create($db, $donid);
|
|||
|
|
|
|||
|
|
// et on supprime l'image correspondant au preview
|
|||
|
|
don_delete_preview($db, $donid);
|
|||
|
|
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dolibarr_syslog("Erreur dans don_create");
|
|||
|
|
dolibarr_print_error($db,$obj->pdferror());
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
print $langs->trans("Error")." ".$langs->trans("Error_DON_ADDON_PDF_NotDefined");
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
\brief Cr<EFBFBD><EFBFBD> un meta fichier <EFBFBD> c<EFBFBD>t<EFBFBD> de la facture sur le disque pour faciliter les recherches en texte plein. Pourquoi ? tout simplement parcequ'en fin d'exercice quand je suis avec mon comptable je n'ai pas de connexion internet "rapide" pour retrouver en 2 secondes une facture non pay<61>e ou compliqu<71>e <20> g<>rer ... avec un rgrep c'est vite fait bien fait [eric seigne]
|
|||
|
|
\param db Objet base de donn<EFBFBD>e
|
|||
|
|
\param donid Id du don <EFBFBD> cr<EFBFBD>er
|
|||
|
|
\param message Message
|
|||
|
|
*/
|
|||
|
|
function don_meta_create($db, $donid, $message="")
|
|||
|
|
{
|
|||
|
|
global $langs,$conf;
|
|||
|
|
|
|||
|
|
$don = new Don($db);
|
|||
|
|
$don->id=$donid;
|
|||
|
|
$don->fetch($donid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
\brief Supprime l'image de pr<EFBFBD>visualitation, pour le cas de r<EFBFBD>g<EFBFBD>n<EFBFBD>ration de facture
|
|||
|
|
\param db Objet base de donn<EFBFBD>e
|
|||
|
|
\param donid Id du don
|
|||
|
|
*/
|
|||
|
|
function don_delete_preview($db, $donid)
|
|||
|
|
{
|
|||
|
|
global $langs,$conf;
|
|||
|
|
|
|||
|
|
$don = new Don($db);
|
|||
|
|
$don->id=$donid;
|
|||
|
|
$don->fetch($donid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
?>
|