Qual: Factorisation du code du formulaire de soumission de document.
On utilise la variable $conf->upload comme limite partout
This commit is contained in:
parent
e35500e5a5
commit
5e209d9f38
@ -162,27 +162,8 @@ if ($propalid > 0)
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
|
||||
// Affiche formulaire upload
|
||||
if ($conf->global->MAIN_UPLOAD_DOC)
|
||||
{
|
||||
print_titre($langs->trans("AttachANewFile"));
|
||||
|
||||
print '<form name="userfile" action="document.php?propalid='.$propal->id.'" enctype="multipart/form-data" method="POST">';
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input class="flat" type="file" name="userfile" size="80">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
|
||||
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('document.php?propalid='.$propal->id);
|
||||
|
||||
// Affiche liste des documents existant
|
||||
print_titre($langs->trans("AttachedFiles"));
|
||||
|
||||
@ -167,28 +167,9 @@ if ($facid > 0)
|
||||
if ($mesg) { print $mesg."<br>"; }
|
||||
|
||||
// Affiche formulaire upload
|
||||
if ($conf->global->MAIN_UPLOAD_DOC)
|
||||
{
|
||||
print_titre($langs->trans("AttachANewFile"));
|
||||
|
||||
print '<form name="userfile" action="document.php?facid='.$facture->id.'" enctype="multipart/form-data" method="POST">';
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input class="flat" type="file" name="userfile" size="80">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
|
||||
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('document.php?facid='.$facture->id);
|
||||
|
||||
// Affiche liste des documents existant
|
||||
print_titre($langs->trans("AttachedFiles"));
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@ class Conf
|
||||
/** \public */
|
||||
var $db; // Objet des caractéristiques de connexions
|
||||
// base db->host, db->name, db->user, db->pass, db->type
|
||||
var $maxfilesize = 2000000; // Taille max des fichiers uploadés
|
||||
|
||||
var $externalrss;
|
||||
var $commande;
|
||||
@ -134,8 +133,7 @@ class Conf
|
||||
* Autorisation globale d'uploader (necessaire pour desactiver dans la demo)
|
||||
* conf->upload peut etre écrasée dans main.inc.php (selon user)
|
||||
*/
|
||||
if ($this->global->MAIN_UPLOAD_DOC) $this->upload = 1;
|
||||
else $this->upload = 0;
|
||||
$this->upload = $this->global->MAIN_UPLOAD_DOC;
|
||||
|
||||
/*
|
||||
* Definition des parametres d'activation de module et dependants des modules
|
||||
|
||||
@ -69,7 +69,7 @@ $upload_dir = $conf->societe->dir_output . "/" . $socid ;
|
||||
|
||||
|
||||
// Envoie fichier
|
||||
if ( $_POST["sendit"] && $conf->upload)
|
||||
if ( $_POST["sendit"] && $conf->upload != 0)
|
||||
{
|
||||
if (! is_dir($upload_dir)) create_exdir($upload_dir);
|
||||
|
||||
@ -166,26 +166,9 @@ if ($socid > 0)
|
||||
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
|
||||
// Affiche formulaire upload
|
||||
if ($conf->global->MAIN_UPLOAD_DOC)
|
||||
{
|
||||
print_titre($langs->trans("AttachANewFile"));
|
||||
echo '<form name="userfile" action="docsoc.php?socid='.$socid.'" enctype="multipart/form-data" METHOD="POST">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input class="flat" type="file" name="userfile" size="80">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
|
||||
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
// Affiche formulaire upload
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),1);
|
||||
|
||||
// Affiche liste des documents existant
|
||||
print_titre($langs->trans("AttachedFiles"));
|
||||
|
||||
@ -162,21 +162,8 @@ if ($facid > 0)
|
||||
if ($mesg) { print $mesg.'<br>'; }
|
||||
|
||||
// Affiche formulaire upload
|
||||
if ($conf->global->MAIN_UPLOAD_DOC)
|
||||
{
|
||||
print_titre($langs->trans('AttachANewFile'));
|
||||
print '<form name="userfile" action="document.php?facid='.$facture->id.'" enctype="multipart/form-data" method="POST">';
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input class="flat" type="file" name="userfile" size="80">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Add').'" name="sendit">';
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('document.php?facid='.$facture->id);
|
||||
|
||||
// Affiche liste des documents existant
|
||||
print_titre($langs->trans('AttachedFiles'));
|
||||
|
||||
@ -1742,6 +1742,56 @@ class Form
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche formulaire ajout fichier
|
||||
* \param url Url
|
||||
* \param titre Titre zone
|
||||
* \param addcancel 1=Ajoute un bouton 'Annuler'
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function form_attach_new_file($url,$titre='',$addcancel=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
if ($conf->upload != 0)
|
||||
{
|
||||
print "\n\n<!-- Start form attach new file -->\n";
|
||||
|
||||
if (! $titre) $titre=$langs->trans("AttachANewFile");
|
||||
print_titre($titre);
|
||||
|
||||
print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
|
||||
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
if ($conf->upload > 0)
|
||||
{
|
||||
print '<input type="hidden" name="max_file_size" value="'.($conf->upload*1024).'">';
|
||||
}
|
||||
print '<input class="flat" type="file" name="userfile" size="70">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'">';
|
||||
|
||||
if ($addcancel)
|
||||
{
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
}
|
||||
|
||||
print ' ('.$langs->trans("MaxSize").': '.$conf->upload.' '.$langs->trans("Kb").')';
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
|
||||
print "\n<!-- End form attach new file -->\n\n";
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Affiche formulaire de selection de la remise fixe
|
||||
* \param page Page
|
||||
|
||||
@ -157,7 +157,6 @@ ChangeContactInProcess=Change status to 'Contact in process'
|
||||
ChangeContactDone=Change status to 'Contact done'
|
||||
ProspectsByStatus=Prospects by status
|
||||
BillingContact=Billing contact
|
||||
TotalSizeOfAttachedFiles=Total size of attached files
|
||||
NbOfAttachedFiles=Number of attached files
|
||||
AttachANewFile=Attach a new file
|
||||
FileWasRemoved=Files was removed
|
||||
|
||||
@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Validate intervention
|
||||
Notify_NOTIFY_VAL_FAC=Validate bill
|
||||
NbOfAttachedFiles=Number of attached files/documents
|
||||
TotalSizeOfAttachedFiles=Total size of attached files/documents
|
||||
MaxSize=Maximum size
|
||||
AttachANewFile=Attach a new file/document
|
||||
LinkedObject=Linked object
|
||||
NbOfActiveNotifications=Number of notifications
|
||||
|
||||
@ -157,7 +157,6 @@ ChangeContactInProcess=Changer le statut
|
||||
ChangeContactDone=Changer le statut à 'Contact effectué'
|
||||
ProspectsByStatus=Prospects par statut
|
||||
BillingContact=Contact de facturation
|
||||
TotalSizeOfAttachedFiles=Taille totale des fichiers attachés
|
||||
NbOfAttachedFiles=Nombre de fichiers attachés
|
||||
AttachANewFile=Attacher un nouveau fichier
|
||||
FileWasRemoved=Fichiers supprimés
|
||||
|
||||
@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Valider intervention
|
||||
Notify_NOTIFY_VAL_FAC=Valider facture
|
||||
NbOfAttachedFiles=Nombre de fichiers/documents attachés
|
||||
TotalSizeOfAttachedFiles=Taille totale des fichiers/documents attachés
|
||||
MaxSize=Taille maximum
|
||||
AttachANewFile=Attacher un nouveau fichier/document
|
||||
LinkedObject=Objets liés
|
||||
NbOfActiveNotifications=Nombre d'alertes
|
||||
|
||||
@ -157,7 +157,6 @@ ChangeContactInProcess=Changer l'
|
||||
ChangeContactDone=Changer l'état à 'Contact réalisé'
|
||||
ProspectsByStatus=Prospects par état
|
||||
BillingContact=Contact facturation
|
||||
TotalSizeOfAttachedFiles=Taille totale des fichiers joints
|
||||
NbOfAttachedFiles=Nombre de fichiers joints
|
||||
AttachANewFile=Joindre un nouveau fichier
|
||||
FileWasRemoved=Le fichier a été supprimé
|
||||
|
||||
@ -19,6 +19,7 @@ Notify_NOTIFY_VAL_FICHINTER=Validation fiche intervention
|
||||
Notify_NOTIFY_VAL_FAC=Validation facture
|
||||
NbOfAttachedFiles=Nombre de fichiers/documents liés
|
||||
TotalSizeOfAttachedFiles=Taille total des fichiers/documents liés
|
||||
MaxSize=Taille maximum
|
||||
AttachANewFile=Ajouter un nouveau fichier/document
|
||||
LinkedObject=Objet lié
|
||||
NbOfActiveNotifications=Nombre de notifications
|
||||
|
||||
@ -165,28 +165,11 @@ if ($product->id)
|
||||
print '</div>';
|
||||
|
||||
|
||||
// Affiche forumlaire upload
|
||||
if ($conf->upload && $user->rights->produit->creer)
|
||||
{
|
||||
print_titre($langs->trans('AttachANewFile'));
|
||||
// Affiche formulaire upload
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file('document.php?id='.$product->id);
|
||||
|
||||
print '<form name="userfile" action="document.php?id='.$product->id.'" enctype="multipart/form-data" method="POST">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input class="flat" type="file" name="userfile" size="80">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
|
||||
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
$errorlevel=error_reporting();
|
||||
error_reporting(0);
|
||||
$handle=opendir($upload_dir);
|
||||
|
||||
@ -53,7 +53,7 @@ $types[1] = $langs->trans("Service");
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_POST["sendit"] && $conf->global->MAIN_UPLOAD_DOC)
|
||||
if ($_POST["sendit"] && $conf->upload != 0)
|
||||
{
|
||||
if ($_GET["id"])
|
||||
{
|
||||
@ -64,7 +64,7 @@ if ($_POST["sendit"] && $conf->global->MAIN_UPLOAD_DOC)
|
||||
|
||||
// var_dump($_FILES);
|
||||
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['photofile']);
|
||||
$product->add_photo($conf->produit->dir_output, $_FILES['userfile']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,23 +153,9 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
*/
|
||||
if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer)
|
||||
{
|
||||
print_titre($langs->trans("AddPhoto"));
|
||||
|
||||
print '<form name="userfile" action="'.DOL_URL_ROOT.'/product/photos.php?id='.$product->id.'" enctype="multipart/form-data" METHOD="POST">';
|
||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||
|
||||
print '<table class="border" width="100%"><tr>';
|
||||
print '<td>'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')</td>';
|
||||
print '<td><input type="file" class="flat" name="photofile" size="80"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"> ';
|
||||
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
// Affiche formulaire upload
|
||||
$html=new Form($db);
|
||||
$html->form_attach_new_file(DOL_URL_ROOT.'/product/photos.php?id='.$product->id,$langs->trans("AddPhoto"),1);
|
||||
}
|
||||
|
||||
// Affiche photos
|
||||
|
||||
@ -34,7 +34,7 @@ if (! is_dir($upload_dir))
|
||||
}
|
||||
}
|
||||
|
||||
if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1)
|
||||
if ( $_POST["sendit"] && $conf->upload != 0)
|
||||
{
|
||||
if (is_dir($upload_dir))
|
||||
{
|
||||
|
||||
@ -48,7 +48,7 @@ insert into llx_action_def (rowid,code,titre,description,objet_type) values (2,'
|
||||
--
|
||||
insert into llx_const (name, value, type, note, visible) values ('MAIN_MONNAIE','euros','chaine','Monnaie',0);
|
||||
|
||||
insert into llx_const (name, value, type, note, visible) values ('MAIN_UPLOAD_DOC','1','chaine','Autorise l\'upload de document',1);
|
||||
insert into llx_const (name, value, type, note, visible) values ('MAIN_UPLOAD_DOC','2048','chaine','Max size for file upload (0 means no upload allowed)',0);
|
||||
insert into llx_const (name, value, type, note, visible) values ('MAIN_NOT_INSTALLED','1','chaine','Test d\'installation',1);
|
||||
|
||||
insert into llx_const (name, value, type, note, visible) values ('MAIN_TITLE','Dolibarr','chaine','Titre des pages',0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user