diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php
index e94a648ec27..d276853a362 100644
--- a/htdocs/core/class/listview.class.php
+++ b/htdocs/core/class/listview.class.php
@@ -68,7 +68,6 @@ class Listview {
$TParam['orderBy'] = $POSTList[$this->id]['orderBy'];
}
- // print_r($TParam);
}
private function getSearchNull($key, &$TParam) {
return !empty($TParam['search'][$key]['allow_is_null']);
@@ -80,7 +79,7 @@ class Listview {
if (!is_array($TParam['search'][$key]['table'])) $TParam['search'][$key]['table'] = array($TParam['search'][$key]['table']);
foreach ($TParam['search'][$key]['table'] as $prefix_table) {
- $TPrefixe[] = '`'.$prefix_table.'`.';
+ $TPrefixe[] = $prefix_table.'.';
}
}
@@ -90,27 +89,18 @@ class Listview {
foreach ($TParam['search'][$key]['field'] as $i => $field) {
$prefixe = !empty($TPrefixe[$i]) ? $TPrefixe[$i] : $TPrefixe[0];
- $TKey[] = $prefixe.'`'. $field .'`';
+ $TKey[] = $prefixe. $field ;
}
} else {
- $TKey[] =$TPrefixe[0].'`'. strtr($key,';','*').'`';
+ $TKey[] =$TPrefixe[0].$key;
}
return $TKey;
}
- private function getSearchValue($value) {
- $value = strtr(trim($value),';','*');
-
- return $value;
- }
private function dateToSQLDate($date) {
- list($dd,$mm,$aaaa) = explode('/', substr($date,0,10));
-
- $value = date('Y-m-d', mktime(0,0,0,$mm,$dd,$aaaa));
-
- return $value;
+ return $this->db->jdate($date);
}
private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey, $sBindKey)
@@ -118,19 +108,10 @@ class Listview {
if(is_array($value))
{
- unset($this->TBind[$sBindKey]);
- // Si le type de "recherche" est "calendars" on a 2 champs de transmis, [début et fin] ou [que début] ou [que fin] => un BETWEEN Sql serait utile que dans le 1er cas
- // donc l'utilisation des opérateur >= et <= permettent un fonctionnement générique
$TSQLDate=array();
if(!empty($value['start']))
{
$valueDeb = $this->dateToSQLDate($value['start']);
-
- if(isset($this->TBind[$sBindKey.'_start'])) // TODO can't use this in query case
- {
- $this->TBind[$sBindKey.'_start'] = $valueDeb;
- }
-
$TSQLDate[]=$sKey." >= '".$valueDeb." 00:00:00'" ;
}
@@ -138,10 +119,6 @@ class Listview {
if(!empty($value['end']))
{
$valueFin = $this->dateToSQLDate($value['end']);
- if(isset($this->TBind[$sBindKey.'_end'])) { // TODO can't use this in query case
- $this->TBind[$sBindKey.'_end'] = $valueFin;
- }
-
$TSQLDate[]=$sKey." <= '".$valueFin." 23:59:59'" ;
}
@@ -150,25 +127,15 @@ class Listview {
}
else
{
- // Sinon je communique une date directement au format d/m/Y et la méthode du dessous reformat en Y-m-d
$value = $this->dateToSQLDate($value);
- if(isset($this->TBind[$sBindKey]))
- {
- $this->TBind[$sBindKey] = $value;
- }
- else
- {
- // Le % en fin de chaine permet de trouver un resultat si le contenu est au format Y-m-d H:i:s et non en Y-m-d
- $TSQLMore[]=$sKey." LIKE '".$value."%'" ;
- }
+ $TSQLMore[]=$sKey." LIKE '".$value."%'" ;
+
}
}
private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $sBindKey, $key)
{
- $value = $this->getSearchValue($value);
-
if(isset($TParam['operator'][$key]))
{
if($TParam['operator'][$key] == '<' || $TParam['operator'][$key] == '>' || $TParam['operator'][$key]=='=')
@@ -207,7 +174,6 @@ class Listview {
foreach($_REQUEST['Listview'][$this->id]['search'] as $key=>$value)
{
$TsKey = $this->getSearchKey($key, $TParam);
- $TsBindKey = $this->getTsBindKey($TsKey);
//if (!empty($value)) var_dump($TsKey, $TsBindKey, '==================================');
$TSQLMore = array();
@@ -217,38 +183,32 @@ class Listview {
foreach ($TsKey as $i => &$sKey)
{
- //if (!empty($value)) var_dump($sKey);
- $sBindKey = $TsBindKey[$i];
-
if($allow_is_null && !empty($_REQUEST['Listview'][$this->id]['search_on_null'][$key]))
{
- $this->TBind[$sBindKey.'_null'] = $sKey.' IS NULL ';
$TSQLMore[] = $sKey.' IS NULL ';
$search_on_null = true;
- if(isset($this->TBind[$sBindKey])) $this->TBind[$sBindKey]= '';
$value = '';
}
elseif($allow_is_null)
{
- $this->TBind[$sBindKey.'_null'] =0; // $sKey.' IS NOT NULL ';
- //$TSQLMore[] = $sKey.' IS NOT NULL ';
+ null;
}
if($value!='') { // pas empty car biensûr le statut = 0 existe dans de nombreux cas
if(isset($TParam['type'][$key]) && ($TParam['type'][$key]==='date' || $TParam['type'][$key]==='datetime'))
{
- $this->addSqlFromTypeDate($TSQLMore, $value, $sKey, $sBindKey);
+ $this->addSqlFromTypeDate($TSQLMore, $value, $sKey);
}
else
{
- $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $sBindKey, $key);
+ $this->addSqlFromOther($TSQLMore, $value, $TParam, $sKey, $key);
}
}
}
- if(!isset($this->TBind[$sBindKey]) && !empty($TSQLMore))
+ if(!empty($TSQLMore))
{
$sql.=' AND ( '.implode(' OR ',$TSQLMore).' ) ';
}
@@ -282,13 +242,11 @@ class Listview {
}
private function setSearch(&$THeader, &$TParam) {
- global $langs;
+ global $langs, $form;
if(empty($TParam['search'])) return array();
$TSearch=array();
- $form=new TFormCore;
- $form->strict_string_compare = true;
$nb_search_in_bar = 0;
@@ -296,20 +254,22 @@ class Listview {
foreach($THeader as $key=>$libelle) { // init
if(empty($TSearch[$key]))$TSearch[$key]='';
}
- }
+ }
+
+ $ListPOST = GETPOST('Listview');
+
foreach($TParam['search'] as $key=>$param_search) {
-
- $value = isset($_REQUEST['Listview'][$this->id]['search'][$key]) ? $_REQUEST['Listview'][$this->id]['search'][$key] : '';
+ $value = isset($ListPOST[$this->id]['search'][$key]) ? $ListPOST[$this->id]['search'][$key] : '';
$typeRecherche = (is_array($param_search) && isset($param_search['recherche'])) ? $param_search['recherche'] : $param_search;
if(is_array($typeRecherche)) {
- $typeRecherche = array(''=>' ') + $typeRecherche;
- $fsearch=$form->combo('','Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,0,'',' listviewtbs="combo" init-value="'.$value.'" ');
+ $fsearch=$form->selectarray('Listview['.$this->id.'][search]['.$key.']', $typeRecherche,$value,1);
}
else if($typeRecherche==='calendar') {
- $fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" ');
+ $fsearch = $form->select_date($value, 'Listview['.$this->id.'][search]['.$key.']',0, 0, 1, "", 1, 0, 1);
+ //$fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.']',$value,10,10,' listviewtbs="calendar" ');
}
else if($typeRecherche==='calendars') {
$fsearch=$form->calendrier('','Listview['.$this->id.'][search]['.$key.'][start]',isset($value['start'])?$value['start']:'',10,10,' listviewtbs="calendars" ')
@@ -340,7 +300,7 @@ class Listview {
}
- $search_button = ' '.$TParam['liste']['picto_search'].'';
+ $search_button = ' '.$TParam['liste']['picto_search'].'';
if(!empty($TParam['liste']['head_search'])) {
$TParam['liste']['head_search'].='
'.$langs->trans('Search').' '.$search_button.'
';
@@ -406,8 +366,8 @@ class Listview {
private function getJS(&$TParam) {
$javaScript = '';
@@ -542,10 +502,13 @@ class Listview {
$out.='';
- if(!empty($TParam['liste']['nbSearch'])) {
- $out.='
- | '.img_search().' |
-
';
+ if(count($TSearch)>0) {
+ $out.='';
+ foreach($TSearch as $field=>$search) {
+ $out.='| '.$search.' | ';
+
+ }
+ $out.='
';
}
$out.='';
diff --git a/htdocs/core/js/listview.js b/htdocs/core/js/listview.js
index 1157c2ef4b8..03ca7f72508 100644
--- a/htdocs/core/js/listview.js
+++ b/htdocs/core/js/listview.js
@@ -1,27 +1,27 @@
-var TListTBS_include = true;
+var Listview_include = true;
-function TListTBS_OrderDown(idListe, column) {
+function Listview_OrderDown(idListe, column) {
var base_url = document.location.href;
- base_url = TListTBS_recup_form_param(idListe,base_url);
- base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]');
+ base_url = Listview_recup_form_param(idListe,base_url);
+ base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]');
- base_url = TListTBS_removeParam(base_url,'get-all-for-export');
+ base_url = Listview_removeParam(base_url,'get-all-for-export');
- document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC");
+ document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC");
}
-function TListTBS_OrderUp(idListe, column) {
+function Listview_OrderUp(idListe, column) {
var base_url = document.location.href;
- base_url = TListTBS_recup_form_param(idListe,base_url);
- base_url = TListTBS_removeParam(base_url,'TListTBS['+encodeURIComponent(idListe)+'][orderBy]');
+ base_url = Listview_recup_form_param(idListe,base_url);
+ base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]');
- base_url = TListTBS_removeParam(base_url,'get-all-for-export');
+ base_url = Listview_removeParam(base_url,'get-all-for-export');
- document.location.href=TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC");
+ document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC");
}
-function TListTBS_modifyUrl(strURL,paramName,paramNewValue){
+function Listview_modifyUrl(strURL,paramName,paramNewValue){
if (strURL.indexOf(paramName+'=')!=-1){
var strFirstPart=strURL.substring(0,strURL.indexOf(paramName+'=',0))+paramName+'=';
@@ -39,7 +39,7 @@ function TListTBS_modifyUrl(strURL,paramName,paramNewValue){
return strURL;
}
-function TListTBS_removeParam(strURL, paramMask) {
+function Listview_removeParam(strURL, paramMask) {
var cpt=0;
var url = '';
@@ -60,11 +60,11 @@ function TListTBS_removeParam(strURL, paramMask) {
return url;
}
-function TListTBS_recup_form_param(idListe,base_url) {
+function Listview_recup_form_param(idListe,base_url) {
$('#'+idListe+' tr.barre-recherche [listviewtbs],#'+idListe+' tr.barre-recherche-head input,#'+idListe+' tr.barre-recherche-head select,#'+idListe+' div.tabsAction input[listviewtbs]').each(function(i,item) {
if($(item).attr("name")) {
- base_url = TListTBS_modifyUrl(base_url, $(item).attr("name") , $(item).val());
+ base_url = Listview_modifyUrl(base_url, $(item).attr("name") , $(item).val());
}
});
@@ -72,37 +72,37 @@ function TListTBS_recup_form_param(idListe,base_url) {
return base_url;
}
-function TListTBS_GoToPage(idListe,pageNumber){
+function Listview_GoToPage(idListe,pageNumber){
var base_url = document.location.href;
- base_url = TListTBS_recup_form_param(idListe,base_url);
- base_url =TListTBS_modifyUrl(base_url,"TListTBS["+encodeURIComponent(idListe)+"][page]",pageNumber);
+ base_url = Listview_recup_form_param(idListe,base_url);
+ base_url =Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][page]",pageNumber);
- base_url = TListTBS_removeParam(base_url,'get-all-for-export');
+ base_url = Listview_removeParam(base_url,'get-all-for-export');
document.location.href=base_url;
}
-function TListTBS_submitSearch(obj) {
+function Listview_submitSearch(obj) {
$(obj).closest('form').submit();
- //console.log($(obj).closest('form'));
+
}
-function TListTBS_launch_downloadAs(mode,url,token,session_name) {
- $('#listTBSdAS_export_form').remove();
+function Listview_launch_downloadAs(mode,url,token,session_name) {
+ $('#listviewdAS_export_form').remove();
- $form = $('');
+ $form = $('');
$form.append('');
$form.append('');
$form.append('');
$('body').append($form);
- $('#listTBSdAS_export_form').submit();
+ $('#listviewdAS_export_form').submit();
}
-function TListTBS_downloadAs(obj, mode,url,token,session_name) {
+function Listview_downloadAs(obj, mode,url,token,session_name) {
$form = $(obj).closest('form');
$div = $form.find('div.tabsAction');
@@ -112,7 +112,7 @@ function TListTBS_downloadAs(obj, mode,url,token,session_name) {
$div.append('');
$div.append('');
- TListTBS_submitSearch(obj);
+ Listview_submitSearch(obj);
}
$(document).ready(function() {
@@ -137,7 +137,7 @@ $(document).ready(function() {
});
if(typeof $_GET["get-all-for-export"] != "undefined") {
- TListTBS_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]);
+ Listview_launch_downloadAs($_GET["mode"],$_GET["url"],$_GET["token"],$_GET["session_name"]);
}
});
diff --git a/htdocs/core/modules/modInventory.class.php b/htdocs/core/modules/modInventory.class.php
index 31170375752..abe65b65647 100644
--- a/htdocs/core/modules/modInventory.class.php
+++ b/htdocs/core/modules/modInventory.class.php
@@ -66,7 +66,7 @@ class modinventory extends DolibarrModules
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
- $this->picto='inventory@inventory';
+ $this->picto='inventory';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /inventory/core/xxxxx) (0=disable, 1=enable)
@@ -167,8 +167,6 @@ class modinventory extends DolibarrModules
// Example:
//$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>'')););
- $langs->load('inventory@inventory');
-
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
@@ -249,11 +247,11 @@ class modinventory extends DolibarrModules
// $r++;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
- 'titre'=>'Liste des inventaires',
+ 'titre'=>'ListInventory',
'mainmenu'=>'inventory',
'leftmenu'=>'inventory',
'url'=>'/inventory/inventory.php?action=list',
- 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'langs'=>'inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->inventory->read', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
@@ -263,11 +261,10 @@ class modinventory extends DolibarrModules
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=products,fk_leftmenu=stock', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
- 'titre'=>'Nouvel inventaire',
+ 'titre'=>'NewInventory',
'mainmenu'=>'inventory',
'leftmenu'=>'inventory',
'url'=>'/inventory/inventory.php?action=create',
- 'langs'=>'inventory@inventory', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->inventory->enabled', // Define condition to show or hide menu entry. Use '$conf->inventory->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->inventory->create', // Use 'perms'=>'$user->rights->inventory->level1->level2' if you want your menu with a permission rules
diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php
index d0ca303c239..f0a0d073a27 100644
--- a/htdocs/inventory/inventory.php
+++ b/htdocs/inventory/inventory.php
@@ -266,8 +266,8 @@ function _action()
header('Location: '.dol_buildpath('/inventory/inventory.php?action=list', 1));
exit;
- //_list();
+ break;
case 'exportCSV':
$id = GETPOST('id');
@@ -309,18 +309,14 @@ function _list()
$THide = array('label');
echo $l->render(Inventory::getSQL('All'), array(
- 'limit'=>array(
- 'nbLine'=>'30'
- )
- ,'subQuery'=>array()
- ,'link'=>array(
+ 'link'=>array(
'fk_warehouse'=>''.img_picto('','object_stock.png','',0).' @label@'
)
,'translate'=>array()
,'hide'=>$THide
,'type'=>array(
- 'date_cre'=>'date'
- ,'date_maj'=>'datetime'
+ 'datec'=>'date'
+ ,'tms'=>'datetime'
,'date_inventory'=>'date'
)
,'liste'=>array(
@@ -343,7 +339,10 @@ function _list()
,'eval'=>array(
'status' => '(@val@ ? img_picto("'.$langs->trans("inventoryValidate").'", "statut4") : img_picto("'.$langs->trans("inventoryDraft").'", "statut3"))'
,'rowid'=>'Inventory::getLink(@val@)'
-
+ )
+ ,'search'=>array(
+ 'date_inventory'=>'calendar'
+
)
));
diff --git a/htdocs/langs/en_US/inventory.lang b/htdocs/langs/en_US/inventory.lang
index ba947f09d77..152aceed862 100644
--- a/htdocs/langs/en_US/inventory.lang
+++ b/htdocs/langs/en_US/inventory.lang
@@ -49,4 +49,6 @@ ConfirmFlushInventory=Do you confirm this action ?
InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition
inventoryDeleteLine=Delete line
-RegulateStock=Regulate Stock
\ No newline at end of file
+RegulateStock=Regulate Stock
+ListInventory=Inventories list
+NewInventory=New inventory
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/inventory.lang b/htdocs/langs/fr_FR/inventory.lang
index 85fdf3112dc..546a5202976 100644
--- a/htdocs/langs/fr_FR/inventory.lang
+++ b/htdocs/langs/fr_FR/inventory.lang
@@ -47,4 +47,6 @@ ConfirmFlushInventory=Do you confirm this action ?
InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition
inventoryDeleteLine=Delete line
-RegulateStock=Regulate Stock
\ No newline at end of file
+RegulateStock=Regulate Stock
+InventoryDate=Inventory date
+DateUpdate=Last update
\ No newline at end of file