Search code examples
phpsugarcrmdashlet

sugarcrm 6.5 custom where for dashlet not working based on a guide


I am following this guide: here

I followed every step but my problem is that this part of the code is not working as expected:

MyTasksUntilNowDashlet.php

function process($lvsParams = array()) {
  global $timedate, $current_user;
  $format = $timedate->get_date_time_format($current_user);
  $dbformat = date('Y-m-d H:i:s', strtotime(date($format)));
   $lvsParams['custom_where'] = 'AND DATE_FORMAT(tasks.date_start, "%Y-%m-%d %H:%i:%s") <= "'.$dbformat.'"';
  parent::process($lvsParams);
  }

If I do a direct query in my workbench there is a result, but if run trough this function it returns nothing. Is there something wrong with how this was implemented?


Solution

  • Apparently you need to keep a space after the single quote or else your query will be an error.

    $lvsParams['custom_where'] = ' AND DATE_FORMAT(tasks.date_start, "%Y-%m-%d %H:%i:%s") <= "'.$dbformat.'"';