debug translate

This commit is contained in:
Alexis Algoud
2016-12-16 11:31:14 +01:00
parent e65ae08e5c
commit 4d375bcf95
6 changed files with 75 additions and 112 deletions

View File

@@ -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 = ' <a href="#" onclick="ListviewsubmitSearch(this);" class="list-search-link">'.$TParam['liste']['picto_search'].'</a>';
$search_button = ' <a href="#" onclick="Listview_submitSearch(this);" class="list-search-link">'.$TParam['liste']['picto_search'].'</a>';
if(!empty($TParam['liste']['head_search'])) {
$TParam['liste']['head_search'].='<div align="right">'.$langs->trans('Search').' '.$search_button.'</div>';
@@ -406,8 +366,8 @@ class Listview {
private function getJS(&$TParam) {
$javaScript = '<script language="javascript">
if(typeof(TListview_include)=="undefined") {
document.write("<script type=\"text/javascript\" src=\"'.DOL_URL_ROOT.'/core/js/list.view.js\"></scr");
if(typeof(Listview_include)=="undefined") {
document.write("<script type=\"text/javascript\" src=\"'.DOL_URL_ROOT.'/core/js/listview.js?version='.DOL_VERSION.'\"></scr");
document.write("ipt>");
}
</script>';
@@ -542,10 +502,13 @@ class Listview {
$out.='</tr>';
if(!empty($TParam['liste']['nbSearch'])) {
$out.='<tr class="liste_titre barre-recherche">
<td class="liste_titre">'.img_search().'</td>
</tr>';
if(count($TSearch)>0) {
$out.='<tr class="liste_titre barre-recherche">';
foreach($TSearch as $field=>$search) {
$out.='<td class="liste_titre">'.$search.'</td>';
}
$out.='</tr>';
}
$out.='</thead><tbody>';

View File

@@ -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 action="'+url+'" method="post" name="listTBSdAS_export_form" id="listTBSdAS_export_form"></form>');
$form = $('<form action="'+url+'" method="post" name="listviewdAS_export_form" id="listTBSdAS_export_form"></form>');
$form.append('<input type="hidden" name="mode" value="'+mode+'" />');
$form.append('<input type="hidden" name="token" value="'+token+'" />');
$form.append('<input type="hidden" name="session_name" value="'+session_name+'" />');
$('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('<input type="hidden" listviewtbs="hidden" name="session_name" value="'+session_name+'" />');
$div.append('<input type="hidden" listviewtbs="hidden" name="get-all-for-export" value="1" />');
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"]);
}
});

View File

@@ -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

View File

@@ -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'=>'<a href="'.DOL_URL_ROOT.'/product/stock/card.php?id=@val@">'.img_picto('','object_stock.png','',0).' @label@</a>'
)
,'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'
)
));

View File

@@ -49,4 +49,6 @@ ConfirmFlushInventory=Do you confirm this action ?
InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition
inventoryDeleteLine=Delete line
RegulateStock=Regulate Stock
RegulateStock=Regulate Stock
ListInventory=Inventories list
NewInventory=New inventory

View File

@@ -47,4 +47,6 @@ ConfirmFlushInventory=Do you confirm this action ?
InventoryFlushed=Inventory flushed
ExitEditMode=Exit edition
inventoryDeleteLine=Delete line
RegulateStock=Regulate Stock
RegulateStock=Regulate Stock
InventoryDate=Inventory date
DateUpdate=Last update