dolibarr/htdocs/ecm/search.php

214 lines
8.2 KiB
PHP
Raw Normal View History

2008-04-29 00:27:49 +02:00
<?php
2010-06-26 00:35:54 +02:00
/* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2008-2009 Regis Houssin <regis.houssin@capnetworks.com>
2009-03-09 00:57:28 +01:00
*
* 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 3 of the License, or
2009-03-09 00:57:28 +01:00
* (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
2011-08-01 01:45:11 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2008-04-29 00:27:49 +02:00
*/
/**
2009-03-09 00:57:28 +01:00
* \file htdocs/ecm/index.php
* \ingroup ecm
* \brief Main page for ECM section area
* \author Laurent Destailleur
2008-11-09 13:33:13 +01:00
*/
2008-04-29 00:27:49 +02:00
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
2008-04-29 00:27:49 +02:00
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
2009-03-09 00:57:28 +01:00
$langs->load("users");
$langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("contracts");
2008-04-29 00:27:49 +02:00
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ecm','');
2008-04-29 00:27:49 +02:00
// Load permissions
$user->getrights('ecm');
// Get parameters
2012-08-09 07:47:41 +02:00
$socid = GETPOST('socid','int');
$action = GETPOST('action','alpha');
$section=GETPOST('section');
2009-03-09 00:57:28 +01:00
if (! $section) $section=0;
2008-04-29 00:27:49 +02:00
$upload_dir = $conf->ecm->dir_output.'/'.$section;
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
2009-03-09 00:57:28 +01:00
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="label";
2011-11-23 15:19:44 +01:00
$ecmdir = new EcmDirectory($db);
2012-08-09 07:47:41 +02:00
if (! empty($section))
2009-03-09 00:57:28 +01:00
{
2012-08-09 07:47:41 +02:00
$result=$ecmdir->fetch($section);
2009-03-09 00:57:28 +01:00
if (! $result > 0)
{
dol_print_error($db,$ecmdir->error);
exit;
}
}
2008-04-29 00:27:49 +02:00
/*******************************************************************
2009-03-09 00:57:28 +01:00
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
2008-04-29 00:27:49 +02:00
/*******************************************************************
2009-03-09 00:57:28 +01:00
* PAGE
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
2008-04-29 00:27:49 +02:00
llxHeader();
$form=new Form($db);
2011-11-23 15:19:44 +01:00
$ecmdirstatic = new EcmDirectory($db);
2009-03-09 00:57:28 +01:00
$userstatic = new User($db);
2008-04-29 00:27:49 +02:00
2009-03-09 00:57:28 +01:00
// Ajout rubriques automatiques
$rowspan=0;
$sectionauto=array();
2012-09-15 11:21:22 +02:00
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
2012-09-15 10:01:35 +02:00
if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
2008-04-29 00:27:49 +02:00
2009-03-09 00:57:28 +01:00
//***********************
// List
//***********************
2010-08-26 01:27:44 +02:00
print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
2008-04-29 00:27:49 +02:00
2010-08-26 01:27:44 +02:00
//print $langs->trans("ECMAreaDesc")."<br>";
//print $langs->trans("ECMAreaDesc2")."<br>";
//print "<br>\n";
print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
2008-04-29 00:27:49 +02:00
2009-03-09 00:57:28 +01:00
// Tool bar
2012-08-09 07:47:41 +02:00
$head = ecm_prepare_head_fm($ecmdir);
2010-08-26 01:27:44 +02:00
//dol_fiche_head($head, 'search_form', '', 1);
2009-03-09 00:57:28 +01:00
print '<table class="border" width="100%"><tr><td width="40%" valign="top">';
// Left area
//print_fiche_titre($langs->trans("ECMSectionsManual"));
print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2009-03-09 00:57:28 +01:00
print '<table class="nobordernopadding" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
print "<tr ".$bc[false]."><td>".$langs->trans("Ref").':</td><td align="right"><input type="text" name="search_ref" class="flat" size="14"></td></tr>';
print "<tr ".$bc[false]."><td>".$langs->trans("Title").':</td><td align="right"><input type="text" name="search_title" class="flat" size="14"></td></tr>';
print "<tr ".$bc[false]."><td>".$langs->trans("Keyword").':</td><td align="right"><input type="text" name="search_keyword" class="flat" size="14"></td></tr>';
print "<tr ".$bc[false].'><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
print "</table></form>";
//print $langs->trans("ECMSectionManualDesc");
//print_fiche_titre($langs->trans("ECMSectionAuto"));
print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
2010-06-26 00:35:54 +02:00
print '<table class="nobordernopadding" width="100%">';
2009-03-09 00:57:28 +01:00
print "<tr class=\"liste_titre\">";
print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
$buthtml='<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
$butshown=0;
foreach($sectionauto as $sectioncur)
{
if (! $sectioncur['test']) continue;
//if ($butshown % 2 == 0)
print '<tr '. $bc[false].'>';
print "<td>".$sectioncur['label'].':</td>';
print '<td';
//if ($butshown % 2 == 1)
print ' align="right"';
print '>';
print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
print '</td>';
//if ($butshown % 2 == 1)
print '</tr>';
$butshown++;
}
//if ($butshown % 2 == 1)
// print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
print "</table></form>";
//print $langs->trans("ECMSectionAutoDesc");
print '</td><td valign="top">';
// Right area
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
2011-07-06 22:56:48 +02:00
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
2009-03-09 00:57:28 +01:00
$formfile=new FormFile($db);
$param='&amp;section='.$section;
$textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection"));
$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty);
// print '<table width="100%" class="border">';
// print '<tr><td> </td></tr></table>';
print '</td></tr>';
print '</table>';
2008-04-29 00:27:49 +02:00
2009-03-09 00:57:28 +01:00
print '<br>';
2008-04-29 00:27:49 +02:00
// End of page
llxFooter();
2012-08-09 07:47:41 +02:00
$db->close();
2008-04-29 00:27:49 +02:00
?>