Example #1
0
 public function setEntityLoadParams(&$load_params)
 {
     $table = $this->entity->getTableName();
     $client_id = (int) $this->getValue('client_id');
     if ($client_id) {
         $load_params['where'][] = "{$table}.ocs_client_id={$client_id}";
     }
     $type = trim($this->getValue('type'));
     if ($type) {
         $type = addslashes($type);
         $load_params['where'][] = "{$table}.type='{$type}'";
     }
     $status_raw = $this->getValue('status');
     $status = array();
     foreach ($status_raw as $s) {
         $status[] = "'" . addslashes($s) . "'";
     }
     if ($status) {
         $flow_item = Application::getEntityInstance('ocs_order_flow');
         $flow_table = $flow_item->getTableName();
         $child_flow_table = $flow_table . '_child';
         $status_str = implode(',', $status);
         $load_params['from'][] = "\r\n\t\t\t\t\tLEFT JOIN {$flow_table} ON {$flow_table}.ocs_order_id={$table}.id\r\n\t\t\t\t";
         $load_params['from'][] = "\r\n\t\t\t\t\tLEFT JOIN {$flow_table} {$child_flow_table} ON {$child_flow_table}.parent_id={$flow_table}.id\r\n\t\t\t\t";
         $load_params['group_by'][] = "{$table}.id";
         $load_params['where'][] = "{$child_flow_table}.id IS NULL";
         $load_params['where'][] = "{$flow_table}.status IN({$status_str})";
     }
     $date_range = $this->getValue('date_range');
     if ($date_range['from']) {
         $date_from = addslashes($date_range['from']);
         $load_params['where'][] = "{$table}.created>='{$date_from}'";
     }
     if ($date_range['to']) {
         $date_to = addslashes($date_range['to']);
         $load_params['where'][] = "{$table}.created<='{$date_to}'";
     }
     //$load_params['show_sql'] = 1;
 }
Example #2
0
 function set_params(&$params)
 {
     parent::set_params($params);
     $db = Application::getDb();
     $user = Application::getEntityInstance('user');
     $table = $user->getTableName();
     $keyword = trim($this->getValue('search_keyword'));
     if ($keyword) {
         $skeyword = addslashes($keyword);
         $params['where'][] = "({$table}.name LIKE '%{$keyword}%' OR {$table}.email LIKE '%{$keyword}%' OR {$table}.login LIKE '%{$keyword}%')";
     }
     $role_id = $this->getValue('search_role_id');
     if ($role_id) {
         foreach ($role_id as &$r) {
             $r = (int) $r;
         }
         $coupling_table = $user->getRolesCouplingTableName();
         $role_id = implode(',', $role_id);
         $params['from'][] = "\r\n            \t\tINNER JOIN {$coupling_table} ON {$coupling_table}.user_id={$table}.id AND {$coupling_table}.role_id IN({$role_id})\r\n            \t";
         $params['group_by'][] = "{$table}.id";
     }
 }
Example #3
0
 protected function createFlowItem($new_status, $comment = '')
 {
     $flow_item = Application::getEntityInstance('ocs_order_flow');
     $user_session = Application::getUserSession();
     $flow_item->user_id = $user_session->getUserId();
     $flow_item->status = $new_status;
     $flow_item->comment = $comment;
     $this->addFlowItem($flow_item);
 }