*
* 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 prédéfinie de composants html fichiers
\version $Id$
*/
/**
\class FormFile
\brief Classe permettant la génération de composants html fichiers
*/
class FormFile
{
var $db;
var $error;
/**
* \brief Constructeur
* \param DB handler d'accès base de donnée
*/
function FormFile($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Affiche formulaire ajout fichier
* \param url Url
* \param titre Titre zone
* \param addcancel 1=Ajoute un bouton 'Annuler'
* \param sectionid If upload must be done inside a particular ECM section
* \return int <0 si ko, >0 si ok
*/
function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0)
{
global $conf,$langs;
if ($conf->upload != 0)
{
print "\n\n\n";
if (! $titre) $titre=$langs->trans("AttachANewFile");
print_titre($titre);
print '
';
print '
';
print "\n\n\n";
}
return 1;
}
/**
* \brief Affiche la cartouche de la liste des documents d'une propale, facture...
* \param modulepart propal=propal, facture=facture, ...
* \param filename Sous rep à scanner (vide si filedir deja complet)
* \param filedir Repertoire à scanner
* \param urlsource Url page origine
* \param genallowed Génération autorisée (1/0 ou array des formats)
* \param delallowed Suppression autorisée (1/0)
* \param modelselected Modele à pré-sélectionner par défaut
* \param modelliste Tableau des modeles possibles
* \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini
* \param iconPDF N'affiche que l'icone PDF avec le lien (1/0)
* \remarks Le fichier de facture détaillée est de la forme
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
* \return int <0 si ko, nbre de fichiers affichés si ok
*/
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0)
{
// 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 = '';
$modelliste = '';
$forcenomultilang=0;
}
$filename = sanitize_string($filename);
$headershown=0;
$i=0;
// Affiche en-tete tableau
if ($genallowed)
{
$modellist=array();
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.'/expedition/mods/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.'/livraison/mods/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 == '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.'/fourn/commande/modules/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
{
// ??
}
}
else
{
dolibarr_print_error($this->db,'Bad value for modulepart');
return -1;
}
$headershown=1;
$html = new Form($db);
print '