Skip to content
Snippets Groups Projects
Commit 17f06e33 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

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

parent 6167e0c1
No related branches found
No related tags found
No related merge requests found
...@@ -42,13 +42,26 @@ $langs->load("bills"); ...@@ -42,13 +42,26 @@ $langs->load("bills");
if (isset($_GET["error"])) $error=$_GET["error"]; if (isset($_GET["error"])) $error=$_GET["error"];
$upload_dir = $conf->actions->dir_output.'/'.$_GET['id']; $upload_dir = $conf->actions->dir_output.'/'.$_GET['id'];
// Scurit accs client // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
unset($_GET["action"]);
$action=''; $action='';
$socid = $user->societe_id; $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 * Action envoie fichier
...@@ -170,7 +183,8 @@ if ($_GET["id"] > 0) ...@@ -170,7 +183,8 @@ if ($_GET["id"] > 0)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$act,'actions'); $param='&id='.$act->id;
$formfile->list_of_documents($filearray,$act,'actions',$param);
} }
else else
......
...@@ -40,9 +40,26 @@ $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action' ...@@ -40,9 +40,26 @@ $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action'
$propalid = isset($_GET["propalid"])?$_GET["propalid"]:''; $propalid = isset($_GET["propalid"])?$_GET["propalid"]:'';
// Security check // 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'); $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 * Actions
...@@ -80,6 +97,7 @@ if ($action=='delete') ...@@ -80,6 +97,7 @@ if ($action=='delete')
{ {
$propal = new Propal($db); $propal = new Propal($db);
$propalid=$_GET["id"];
if ($propal->fetch($propalid)) if ($propal->fetch($propalid))
{ {
$upload_dir = $conf->propal->dir_output . "/" . $propal->ref; $upload_dir = $conf->propal->dir_output . "/" . $propal->ref;
...@@ -145,7 +163,8 @@ if ($propalid > 0) ...@@ -145,7 +163,8 @@ if ($propalid > 0)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$propal,'propal'); $param='&propalid='.$propal->id;
$formfile->list_of_documents($filearray,$propal,'propal',$param);
} }
else else
......
...@@ -41,13 +41,27 @@ $langs->load('other'); ...@@ -41,13 +41,27 @@ $langs->load('other');
$id=empty($_GET['id']) ? 0 : intVal($_GET['id']); $id=empty($_GET['id']) ? 0 : intVal($_GET['id']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Securite acces // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
unset($_GET["action"]); unset($_GET["action"]);
$action='';
$socid = $user->societe_id; $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); $commande = new Commande($db);
if (!$commande->fetch($id)) { if (!$commande->fetch($id)) {
dolibarr_print_error($db); dolibarr_print_error($db);
...@@ -136,7 +150,8 @@ if ($id > 0) ...@@ -136,7 +150,8 @@ if ($id > 0)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$commande,'commande'); $param='&id='.$commande->id;
$formfile->list_of_documents($filearray,$commande,'commande',$param);
} }
else else
......
...@@ -42,6 +42,26 @@ if (!$user->rights->facture->lire) ...@@ -42,6 +42,26 @@ if (!$user->rights->facture->lire)
$facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']); $facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $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 * Actions
...@@ -144,7 +164,8 @@ if ($facid > 0) ...@@ -144,7 +164,8 @@ if ($facid > 0)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$facture,'facture'); $param='&facid='.$facture->id;
$formfile->list_of_documents($filearray,$facture,'facture',$param);
} }
else else
......
...@@ -39,6 +39,26 @@ $langs->load("products"); ...@@ -39,6 +39,26 @@ $langs->load("products");
if (!$user->rights->contrat->lire) if (!$user->rights->contrat->lire)
accessforbidden(); 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 = new Contrat($db);
$contrat->fetch($_GET["id"]); $contrat->fetch($_GET["id"]);
...@@ -137,7 +157,8 @@ if ($contrat->id) ...@@ -137,7 +157,8 @@ if ($contrat->id)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$contrat,'contract'); $param='&id='.$contrat->id;
$formfile->list_of_documents($filearray,$contrat,'contract',$param);
} }
else else
......
...@@ -41,11 +41,7 @@ $user->getrights('ecm'); ...@@ -41,11 +41,7 @@ $user->getrights('ecm');
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0) $socid = $user->societe_id;
{
$action = '';
$socid = $user->societe_id;
}
// Get parameters // Get parameters
$page=$_GET["page"]; $page=$_GET["page"];
...@@ -243,7 +239,7 @@ print '</div>'; ...@@ -243,7 +239,7 @@ print '</div>';
// Actions buttons // 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">'; print '<div class="tabsAction">';
...@@ -274,7 +270,7 @@ if ($mesg) { print $mesg.'<br>'; } ...@@ -274,7 +270,7 @@ if ($mesg) { print $mesg.'<br>'; }
// Confirm remove file // 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'); $form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print '<br>'; print '<br>';
...@@ -292,47 +288,11 @@ if ($_GET['action'] == 'delete_dir') ...@@ -292,47 +288,11 @@ if ($_GET['action'] == 'delete_dir')
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section); $formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section);
// Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles"));
/** // List of document
* 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">';
$param='&amp;section='.$section; $param='&amp;section='.$section;
print_liste_field_titre($langs->trans("Document"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder); $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath);
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']) && 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 // End of page
......
...@@ -43,6 +43,26 @@ if (!$user->rights->fournisseur->facture->lire) ...@@ -43,6 +43,26 @@ if (!$user->rights->fournisseur->facture->lire)
$facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']); $facid=empty($_GET['facid']) ? 0 : intVal($_GET['facid']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $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) ...@@ -152,7 +172,8 @@ if ($facid > 0)
// List of document // 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 else
......
...@@ -365,6 +365,73 @@ class FormFile ...@@ -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 * \brief Show list of documents in a directory
* \param upload_dir Dir to scan * \param upload_dir Dir to scan
...@@ -372,7 +439,7 @@ class FormFile ...@@ -372,7 +439,7 @@ class FormFile
* \param modulepart Value for modulepart used by download wrapper * \param modulepart Value for modulepart used by download wrapper
* \return int <0 if KO, nb of files shown if OK * \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 $user, $conf, $langs;
global $bc; global $bc;
......
...@@ -44,4 +44,3 @@ DeleteSection=Remove directory ...@@ -44,4 +44,3 @@ DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ? ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
ECMDirectoryForFiles=Relative directory for files ECMDirectoryForFiles=Relative directory for files
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
ECMNoFileFound=No documents saved in this directory
\ No newline at end of file
...@@ -423,6 +423,7 @@ MenuAWStats=AWStats ...@@ -423,6 +423,7 @@ MenuAWStats=AWStats
MenuMembers=Members MenuMembers=Members
MenuAgendaGoogle=Google agenda MenuAgendaGoogle=Google agenda
ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP limit: %s Kb ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP limit: %s Kb
NoFileFound=No documents saved in this directory
# Week day # Week day
Monday=Monday Monday=Monday
Tuesday=Tuesday Tuesday=Tuesday
......
...@@ -44,4 +44,3 @@ DeleteSection=Suppression rubrique ...@@ -44,4 +44,3 @@ DeleteSection=Suppression rubrique
ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ? ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ?
ECMDirectoryForFiles=Répertoire relatif pour les fichiers ECMDirectoryForFiles=Répertoire relatif pour les fichiers
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents
ECMNoFileFound=Pas de documents stockés dans cette rubrique
\ No newline at end of file
...@@ -425,6 +425,7 @@ MenuAWStats=AWStats ...@@ -425,6 +425,7 @@ MenuAWStats=AWStats
MenuMembers=Adhérents MenuMembers=Adhérents
MenuAgendaGoogle=Agenda Google MenuAgendaGoogle=Agenda Google
ThisLimitIsDefinedInSetup=Limite Dolibarr (Menu accueil-configuration-sécurité): %s Ko, Limite PHP: %s Ko 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 # Week day
Monday=Lundi Monday=Lundi
Tuesday=Mardi Tuesday=Mardi
......
...@@ -41,6 +41,27 @@ if (!$user->rights->produit->lire) ...@@ -41,6 +41,27 @@ if (!$user->rights->produit->lire)
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $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); $product = new Product($db);
if ($_GET['id'] || $_GET["ref"]) if ($_GET['id'] || $_GET["ref"])
{ {
...@@ -159,7 +180,8 @@ if ($product->id) ...@@ -159,7 +180,8 @@ if ($product->id)
// List of document // List of document
$formfile->list_of_documents($upload_dir,$product,'produit'); $param='&id='.$product->id;
$formfile->list_of_documents($filearray,$product,'produit',$param);
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment