New: We can sort file list for all document pages like in ECM module

This commit is contained in:
Laurent Destailleur 2008-05-04 14:24:29 +00:00
parent 6167e0c181
commit 17f06e3318
13 changed files with 224 additions and 64 deletions

View File

@ -42,13 +42,26 @@ $langs->load("bills");
if (isset($_GET["error"])) $error=$_GET["error"];
$upload_dir = $conf->actions->dir_output.'/'.$_GET['id'];
// Sécurité accés client
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Action envoie fichier
@ -170,7 +183,8 @@ if ($_GET["id"] > 0)
// List of document
$formfile->list_of_documents($upload_dir,$act,'actions');
$param='&id='.$act->id;
$formfile->list_of_documents($filearray,$act,'actions',$param);
}
else

View File

@ -40,9 +40,26 @@ $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action'
$propalid = isset($_GET["propalid"])?$_GET["propalid"]:'';
// Security check
if ($user->societe_id) $socid=$user->societe_id;
if ($user->societe_id)
{
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'propale', $propalid, 'propal');
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Actions
@ -80,6 +97,7 @@ if ($action=='delete')
{
$propal = new Propal($db);
$propalid=$_GET["id"];
if ($propal->fetch($propalid))
{
$upload_dir = $conf->propal->dir_output . "/" . $propal->ref;
@ -145,7 +163,8 @@ if ($propalid > 0)
// List of document
$formfile->list_of_documents($upload_dir,$propal,'propal');
$param='&propalid='.$propal->id;
$formfile->list_of_documents($filearray,$propal,'propal',$param);
}
else

View File

@ -41,13 +41,27 @@ $langs->load('other');
$id=empty($_GET['id']) ? 0 : intVal($_GET['id']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Securite acces
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$socid = $user->societe_id;
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$commande = new Commande($db);
if (!$commande->fetch($id)) {
dolibarr_print_error($db);
@ -136,7 +150,8 @@ if ($id > 0)
// List of document
$formfile->list_of_documents($upload_dir,$commande,'commande');
$param='&id='.$commande->id;
$formfile->list_of_documents($filearray,$commande,'commande',$param);
}
else

View File

@ -42,6 +42,26 @@ if (!$user->rights->facture->lire)
$facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Actions
@ -144,7 +164,8 @@ if ($facid > 0)
// List of document
$formfile->list_of_documents($upload_dir,$facture,'facture');
$param='&facid='.$facture->id;
$formfile->list_of_documents($filearray,$facture,'facture',$param);
}
else

View File

@ -39,6 +39,26 @@ $langs->load("products");
if (!$user->rights->contrat->lire)
accessforbidden();
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$contrat = new Contrat($db);
$contrat->fetch($_GET["id"]);
@ -137,7 +157,8 @@ if ($contrat->id)
// List of document
$formfile->list_of_documents($upload_dir,$contrat,'contract');
$param='&id='.$contrat->id;
$formfile->list_of_documents($filearray,$contrat,'contract',$param);
}
else

View File

@ -41,11 +41,7 @@ $user->getrights('ecm');
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($user->societe_id > 0) $socid = $user->societe_id;
// Get parameters
$page=$_GET["page"];
@ -243,7 +239,7 @@ print '</div>';
// Actions buttons
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete_dir' && $_GET['action'] != 'delete_file')
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete_dir' && $_GET['action'] != 'delete')
{
print '<div class="tabsAction">';
@ -274,7 +270,7 @@ if ($mesg) { print $mesg.'<br>'; }
// Confirm remove file
if ($_GET['action'] == 'delete_file')
if ($_GET['action'] == 'delete')
{
$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print '<br>';
@ -292,47 +288,11 @@ if ($_GET['action'] == 'delete_dir')
$formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
/**
* TODO Mettre cette section dans une zone AJAX
*/
$modulepart='ecm';
$url=$_SERVER["PHP_SELF"];
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
// List of document
$param='&amp;section='.$section;
print_liste_field_titre($langs->trans("Document"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
print '</tr>';
$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath);
$var=true;
foreach($filearray as $key => $file)
{
if (!is_dir($dir.$file['name']) && substr($file['name'], 0, 1) <> '.' && substr($file['name'], 0, 3) <> 'CVS')
{
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&type=application/binary&file='.urlencode($relativepath.$file['name']).'">';
print img_mime($file['name']).' ';
print $file['name'];
print '</a>';
print "</td>\n";
print '<td align="right">'.dol_print_size($file['size']).'</td>';
print '<td align="center">'.dolibarr_print_date($file['date'],"dayhour").'</td>';
print '<td align="right">';
//print '&nbsp;';
print '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
print "</td></tr>\n";
}
}
if (sizeof($filearray) == 0) print '<tr '.$bc[$var].'><td colspan="4">'.$langs->trans("ECMNoFileFound").'</td></tr>';
print "</table>";
// Fin de zone Ajax
// End of page

View File

@ -43,6 +43,26 @@ if (!$user->rights->fournisseur->facture->lire)
$facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
@ -152,7 +172,8 @@ if ($facid > 0)
// List of document
$formfile->list_of_documents($upload_dir,$facture,'facture_fournisseur');
$param='&facid='.$facture->id;
$formfile->list_of_documents($filearray,$facture,'facture_fournisseur',$param);
}
else

View File

@ -365,6 +365,73 @@ class FormFile
}
/**
* \brief Show list of documents in a directory
* \param filearray Array of files loaded by dol_dir_list function
* \param object Object on which document is linked to
* \param modulepart Value for modulepart used by download wrapper
* \param param Parameters on sort links
* \param forcedownload Mime type is forced to 'application/binary' to have a download
* \param relativepath Relative path of docs (autodefined if not provided)
* \return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='')
{
global $user, $conf, $langs;
global $bc;
global $sortfield, $sortorder;
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
$url=$_SERVER["PHP_SELF"];
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Document"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
print '</tr>';
$var=true;
foreach($filearray as $key => $file)
{
if (!is_dir($dir.$file['name'])
&& $file['name'] != '.'
&& $file['name'] != '..'
&& $file['name'] != 'CVS'
&& ! eregi('\.meta$',$file['name']))
{
// Define relative path used to store the file
if (! $relativepath)
{
$relativepath=$object->ref.'/';
if ($modulepart == 'facture_fournisseur') $relativepath=get_exdir($object->id,2).$relativepath;
}
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
if ($forcedownload) print '&type=application/binary';
print '&file='.urlencode($relativepath.$file['name']).'">';
print img_mime($file['name']).' ';
print $file['name'];
print '</a>';
print "</td>\n";
print '<td align="right">'.dol_print_size($file['size']).'</td>';
print '<td align="center">'.dolibarr_print_date($file['date'],"dayhour").'</td>';
print '<td align="right">';
//print '&nbsp;';
print '<a href="'.$url.'?id='.$object->id.'&amp;section='.$_REQUEST["section"].'&amp;action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
print "</td></tr>\n";
}
}
if (sizeof($filearray) == 0) print '<tr '.$bc[$var].'><td colspan="4">'.$langs->trans("NoFileFound").'</td></tr>';
print "</table>";
// Fin de zone
}
/**
* \brief Show list of documents in a directory
* \param upload_dir Dir to scan
@ -372,7 +439,7 @@ class FormFile
* \param modulepart Value for modulepart used by download wrapper
* \return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($upload_dir,$object,$modulepart)
function list_of_documents2($upload_dir,$object,$modulepart)
{
global $user, $conf, $langs;
global $bc;

View File

@ -43,5 +43,4 @@ ShowECMSection=Show directory
DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
ECMDirectoryForFiles=Relative directory for files
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
ECMNoFileFound=No documents saved in this directory
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files

View File

@ -423,6 +423,7 @@ MenuAWStats=AWStats
MenuMembers=Members
MenuAgendaGoogle=Google agenda
ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP limit: %s Kb
NoFileFound=No documents saved in this directory
# Week day
Monday=Monday
Tuesday=Tuesday

View File

@ -43,5 +43,4 @@ ShowECMSection=Afficher rubrique
DeleteSection=Suppression rubrique
ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ?
ECMDirectoryForFiles=Répertoire relatif pour les fichiers
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents
ECMNoFileFound=Pas de documents stockés dans cette rubrique
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents

View File

@ -425,6 +425,7 @@ MenuAWStats=AWStats
MenuMembers=Adhérents
MenuAgendaGoogle=Agenda Google
ThisLimitIsDefinedInSetup=Limite Dolibarr (Menu accueil-configuration-sécurité): %s Ko, Limite PHP: %s Ko
NoFileFound=Pas de documents stockés dans cette rubrique
# Week day
Monday=Lundi
Tuesday=Mardi

View File

@ -41,6 +41,27 @@ if (!$user->rights->produit->lire)
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
if ($user->societe_id > 0)
{
unset($_GET["action"]);
$action='';
$socid = $user->societe_id;
}
// Get parameters
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$product = new Product($db);
if ($_GET['id'] || $_GET["ref"])
{
@ -159,7 +180,8 @@ if ($product->id)
// List of document
$formfile->list_of_documents($upload_dir,$product,'produit');
$param='&id='.$product->id;
$formfile->list_of_documents($filearray,$product,'produit',$param);
}
else