/**
  *
  * @param int $id
  * @return object
  */
 public function findModel($id)
 {
     if (!empty($id)) {
         $model = ClienteCrm::find($id);
         return $model;
     }
 }
 public function actionCreate()
 {
     $model = new RelatorioCrm();
     if (\Kanda::$post->post($model)) {
         $conditions = "date_format(cliente_crm.creation_date,'%d/%m/%Y') BETWEEN '{$_POST['start']}' AND '{$_POST['end']}'";
         if (!empty($_POST['servicos'])) {
             $conditions .= " AND servico_crm_id={$_POST['servicos']}";
         }
         if (!empty($_POST['status'])) {
             $conditions .= " AND status_crm_id={$_POST['status']}";
         }
         $joins = 'INNER JOIN status_crm as  st ON st.id=cliente_crm.status_crm_id ';
         $joins .= 'INNER JOIN servico_crm as sv ON sv.id=cliente_crm.servico_crm_id';
         $select = 'cliente_crm.*,st.name as status,sv.name as servico';
         $data = ClienteCrm::all(['select' => $select, 'conditions' => [$conditions], 'order' => 'creation_date', 'joins' => $joins]);
         $tr = '';
         foreach ($data as $res) {
             $tr .= "<tr>\n                     <td>{$res->name}</td>\n                     <td>{$res->email}</td>\n                     <td>Fixo: {$res->phone_fixed} | Celular: {$res->phone_cellula}</td>\n                     <td>" . date('d/m/Y -   H:i', strtotime($res->creation_date)) . "</td>\n                     <td>{$res->status}</td>\n                     <td>{$res->servico}</td>\n                     </tr>";
         }
         echo $tr;
     }
 }