Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.11.1 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

BUG when using OCS Last Contact (date field) and brazilian portuguese language on multi search page

Hi,

The line with expression "1242 m/d/y" in brazilian portuguese language and others cause incorrect timestamp conversion for a given date (e.g. 07/01/12 - MM/DD/AA), because the portuguese language file has the line with expression "1270 DDMMYYYY" used by input data.

In Brazil, the date representation is DD/MM/AAAA. Thus, the line should be replaced to "1242 d/m/y" to work correctly.

The below debug code is in brazilian language mode:

 

[DEBUG]RAW DATAS[DEBUG]
0 => HARDWARE
[DEBUG]table field=[DEBUG]
0 => LASTCOME
[DEBUG]Comparison field=[DEBUG]
0 => small
[DEBUG]value to search=[DEBUG]
0 => 01/07/2012
[DEBUG]Complementary field=[DEBUG]
[DEBUG]AND OR Field=[DEBUG]
[DEBUG]table =>[DEBUG]HARDWARE
[DEBUG]filed =>[DEBUG] unix_timestamp(LASTCOME) 
[DEBUG]comparison =>[DEBUG] <= 
[DEBUG]value to search =>[DEBUG]1325901600
[DEBUG]complementary field =>[DEBUG]
[DEBUG]AND_OR =>[DEBUG]
[DEBUG]NORMAL CONDITION REQUEST[DEBUG]


[DEBUG]REQUEST MADE => [DEBUG]
select distinct ID as HARDWARE_ID from hardware where ( ( unix_timestamp(LASTCOME) <= 1325901600)) and deviceid<>'_SYSTEMGROUP_' AND deviceid <> '_DOWNLOADGROUP_' 
[DEBUG] => weight: [DEBUG]1

 

The below code is in english language mode:

 

[DEBUG]RAW DATAS[DEBUG]
0 => HARDWARE
[DEBUG]table field=[DEBUG]
0 => LASTCOME
[DEBUG]Comparison field=[DEBUG]
0 => small
[DEBUG]value to search=[DEBUG]
0 => 07/01/2012
[DEBUG]Complementary field=[DEBUG]
[DEBUG]AND OR Field=[DEBUG]
[DEBUG]table =>[DEBUG]HARDWARE
[DEBUG]filed =>[DEBUG] unix_timestamp(LASTCOME) 
[DEBUG]comparison =>[DEBUG] <= 
[DEBUG]value to search =>[DEBUG]1341111600
[DEBUG]complementary field =>[DEBUG]
[DEBUG]AND_OR =>[DEBUG]
[DEBUG]NORMAL CONDITION REQUEST[DEBUG]


[DEBUG]REQUEST MADE => [DEBUG]
select distinct ID as HARDWARE_ID from hardware where ( ( unix_timestamp(LASTCOME) <= 1341111600)) and deviceid<>'_SYSTEMGROUP_' AND deviceid <> '_DOWNLOADGROUP_' 
[DEBUG] => weight: [DEBUG]1

 

in Administrative console by (320 points)
retagged by

2 Answers

0 votes
What timezone have you set in your php.ini ?
by (22k points)

Hi,

The default timezone of php configuration is America/Sao_Paulo.

 

Default timezone America/Sao_Paulo

 

The result for this filter is correctly shown in english, french and italian. Incorrect results are obtained in brazilian, spanish, polish, portuguese.

 

$ grep '1242' language/*/*.txt | cat -n
     1 language/brazilian_portuguese/brazilian_portuguese.txt:1242 m/d/y
     2 language/english/english.txt:1242 m/d/y
     3 language/french/french.txt:1242 d/m/y
     4 language/german/german.txt:1242 M/T/J
     5 language/hungarian/hungarian.txt:1242 m/d/y
     6 language/italian/italian.txt:1242 d/m/y
     7 language/polish/polish.txt:1242 m/d/y
     8 language/portuguese/portuguese.txt:1242 m/d/y
     9 language/russian/russian.txt:1242 m/d/y
    10 language/slovenian/slovenian.txt:1242 m/d/y
    11 language/spanish/spanish.txt:1242 m/d/y
    12 language/turkish/turkish.txt:1242 m/d/y
 
$ grep '1270' language/*/*.txt | cat -n
     1 language/brazilian_portuguese/brazilian_portuguese.txt:1270 DDMMYYYY
     2 language/english/english.txt:1270 MMDDYYYY
     3 language/french/french.txt:1270 DDMMYYYY
     4 language/german/german.txt:1270 TTMMJJJJ
     5 language/hungarian/hungarian.txt:1270 DDMMYYYY
     6 language/italian/italian.txt:1270 DDMMYYYY
     7 language/polish/polish.txt:1270 DDMMYYYY
     8 language/portuguese/portuguese.txt:1270 DDMMYYYY
     9 language/russian/russian.txt:1270 DDMMYYYY
    10 language/slovenian/slovenian.txt:1270 DDMMYYYY
    11 language/spanish/spanish.txt:1270 DDMMYYYY
    12 language/turkish/turkish.txt:1270 DDMMYYYY
 
$ head -300 require/function_search.php | tail -10
//modification d'un champ texte en date dans certains cas
  if ($field == "LASTDATE" or $field == "LASTCOME" or $field == "REGVALUE"){
  $tab_date = explode('/', $field_value);
  $ref_date = explode('/', $l->g(1242));
$day=array_search('d',$ref_date);
$months=array_search('m',$ref_date);
$year=array_search('y',$ref_date);
  //on applique le traitement que si la date est valide
  if (@checkdate ($tab_date[$months],$tab_date[$day],$tab_date[$year])){
  $field= " unix_timestamp(".$field.") ";
 
$ head -427 require/function_search.php | tail -8
$select2 .= "</select>";
echo "<td>".$select2;
if (array_key_exists($value,$opt2SelectField)){
if ($opt2SelectField[$value."-LBL"] == "calendar")
$opt2SelectField[$value."-LBL"]= calendars("InputValue-".$nameField,$l->g(1270));
echo $select."&nbsp;&nbsp;<input name='InputValue-".$nameField."' id='InputValue-".$nameField."' value=\"".stripslashes($protectedPost["InputValue-".$nameField])."\">&nbsp;".$opt2SelectField[$value."-LBL"];
}
 

 

0 votes
This directive is commented on php.ini.
by (320 points)
 
Powered by Question2Answer
...