YetiForceCompany / YetiForceCRM

Our team created for you one of the most innovative CRM systems that supports mainly business processes and allows for customization according to your needs. Be ahead of your competition and implement YetiForce!
https://yetiforce.com
Other
1.74k stars 749 forks source link

Filters' conditions when user's preference for data format is different than yyyy-mm-dd[bug] #10968

Closed nerimic closed 4 years ago

nerimic commented 5 years ago

🔥 How to trigger the error

Steps to reproduce the behavior:

  1. Go to https://gitdeveloper.yetiforce.com/index.php?module=Users&view=PreferenceDetail&record=5
  2. Click on Calendar hour format, set it to dd-mm-yyyy
  3. Create a new filter in https://gitdeveloper.yetiforce.com/index.php?module=Campaigns&view=List&mid=54&parent=52 for expected data before 31-12-2019
  4. See error

👎 Actual Behavior

No data to display.

👍 Expected Behavior

Elements in list.

davide-alghi commented 5 years ago

I have investigated about this issue and probably it is the same of #10090 I will not give the fix because it is not clear to me.

step by step

  1. Vtiger_ListView_Model::getListViewEntries() calls $this->getQueryGenerator()->createQuery()
  2. createQuery() calls $this->loadWhere()
  3. loadWhere() calls $this->parseConditions($this->conditions)
  4. parseConditions() calls $this->getCondition($fieldName, $rule['value'], $rule['operator'])
  5. getConditions() calls $queryField->getCondition() [$queryField = $this->getQueryField($fieldName)]
  6. [App\QueryField\DateField] getCondition() calls relative operator function: operatorE, operatorC ans so on.
  7. each operator function calls App\QueryField\DateField getValue()
    public function getValue()
    {
    return \DateTimeField::convertToDBFormat($this->value);
    }

    at this point

  8. convertToDBFormat() calls __convertToDBFormat($date, $format) where $format is user preferred date format
  9. __convertToDBFormat() calls list($y, $m, $d) = App\Fields\Date::explode($date, $format)
  10. explode($date, $format) receives date in db format [yyyy-mm-dd] and $format is user preferred date format: explode() returns a mystified date. eg: if user preferred date format is dd-mm-yyyy and the date into database (condition value) is 2019-07-14, the returned value will be 14-07-2019. Query returns empty record set. The condition value is already into querying correct format: it has not to be formatted.

PS: if the problem is into App\QueryField\DateField getValue(), maybe (maybe) there could be similar problems for App\QueryField\DatetimeField, App\QueryField\TimeField, App\QueryField\CurrencyField

konadrian commented 4 years ago

Error was fixed SortingNotice