*
* 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.
*/
/**
* \file htdocs/html.formfile.class.php
* \brief Fichier de la classe des fonctions predefinie de composants html fichiers
* \version $Id$
*/
/**
* \class FormFile
* \brief Classe permettant la generation de composants html fichiers
*/
class FormFile
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'acces base de donnee
*/
function FormFile($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Show file add form
* \param url Url
* \param title Title zone
* \param addcancel 1=Add 'Cancel' button
* \param sectionid If upload must be done inside a particular ECM section
* \param perm Value of permission to allow upload
* \return int <0 si ko, >0 si ok
*/
function form_attach_new_file($url,$title='',$addcancel=0, $sectionid=0, $perm=1)
{
global $conf,$langs;
print "\n\n\n";
if (! $title) $title=$langs->trans("AttachANewFile");
print_titre($title);
print '
';
if (empty($sectionid)) print '
';
print "\n\n\n";
return 1;
}
/**
* \brief Show the box with list of available documents for object
* \param modulepart propal=propal, facture=facture, ...
* \param filename Sub dir to scan (Example: '9/9', 'FA9999'). Use '' if filedir already complete)
* \param filedir Dir to scan
* \param urlsource Url of origin page (for return)
* \param genallowed Generation is allowed (1/0 or array of formats)
* \param delallowed Remove is allowed (1/0)
* \param modelselected Model to preselect by default
* \param allowgenifempty Show warning if no model activated
* \param forcenomultilang Do not show language option (even if MAIN_MULTILANGS defined)
* \param iconPDF Show only PDF icon with link (1/0)
* \param maxfilenamelength Max length for filename shown
* \param noform Do not output html form tags
* \param param More param on http links
* \param title Title to show on top of form
* \param buttonlabel Label on submit button
* \param codelang Default language code to use on lang combo box if multilang is enabled
* \return int <0 if KO, number of shown files if OK
*/
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
// filedir = conf->...dir_ouput."/".get_exdir(id)
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
global $langs,$bc,$conf;
$var=true;
if ($iconPDF == 1)
{
$genallowed = '';
$delallowed = 0;
$modelselected = '';
$forcenomultilang=0;
}
$filename = dol_sanitizeFileName($filename);
$headershown=0;
$showempty=0;
$i=0;
print "\n".''."\n";
//print 'filedir='.$filedir;
// Affiche en-tete tableau
if ($genallowed)
{
$modellist=array();
if ($modulepart == 'company')
{
$showempty=1;
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/societe/modules_societe.class.php');
$model=new ModeleThirdPartyDoc();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'propal')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php');
$model=new ModelePDFPropales();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'commande')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php');
$model=new ModelePDFCommandes();
$modellist=$model->liste_modeles($this->db);
}
}
elseif ($modulepart == 'expedition')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/expedition/pdf/ModelePdfExpedition.class.php');
$model=new ModelePDFExpedition();
$modellist=$model->liste_modeles($this->db);
}
}
elseif ($modulepart == 'livraison')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/livraison/modules_livraison.php');
$model=new ModelePDFDeliveryOrder();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'ficheinter')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php');
$model=new ModelePDFFicheinter();
$modellist=$model->liste_modeles($this->db);
}
}
elseif ($modulepart == 'facture')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
$model=new ModelePDFFactures();
$modellist=$model->liste_modeles($this->db);
}
}
elseif ($modulepart == 'project')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/project/modules_project.php');
$model=new ModelePDFProjects();
$modellist=$model->liste_modeles($this->db);
}
}
elseif ($modulepart == 'export')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php');
$model=new ModeleExports();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'commande_fournisseur')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php');
$model=new ModelePDFSuppliersOrders();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'facture_fournisseur')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php');
$model=new ModelePDFFacturesSuppliers();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'remisecheque')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
// ??
}
}
elseif ($modulepart == 'donation')
{
if (is_array($genallowed)) $modellist=$genallowed;
else
{
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/dons/modules_don.php');
$model=new ModeleDon();
$modellist=$model->liste_modeles($this->db);
}
}
else if ($modulepart == 'unpaid')
{
$modellist='';
}
else
{
dol_print_error($this->db,'Bad value for modulepart');
return -1;
}
$headershown=1;
$html = new Form($db);
$buttonlabeltoshow=$buttonlabel;
if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate');
if (empty($noform)) print '