Esempio n. 1
0
 /**
  * Info modal for regular stats showing task info (time, product)
  */
 public function infoAction()
 {
     $request = $this->request;
     if ($request->isAjax()) {
         $data = $request->get('data');
         $data = explode('_', $data);
         // [0] - role, [1] - user, [2] - day
         $next_day = $data[2] + 86400;
         // Get unix timestamp of the next day
         $tasks = new PTasks();
         $sql = "SELECT trole, tassignee, tlang, tprodid, MAX(tstart) AS tstart FROM p_tasks\n                    WHERE (tstart BETWEEN {$data['2']} AND {$next_day})\n                        AND trole = '{$data['0']}'\n                        AND tassignee = '{$data['1']}'\n                        AND (tstatus = 3 OR tstatus = 5)\n                    GROUP BY trole, tassignee, tprodid\n                    ORDER BY tstart DESC";
         $stats = new Resultset(null, $tasks, $tasks->getReadConnection()->query($sql));
         foreach ($stats as $stat) {
             $tlang = $stat->tlang != 'ru' ? "<span class=\"text-muted\">язык: {$stat->tlang} </span>" : '';
             $prod_title = !empty($stat->getPProdInfo("lang='ru'")->title) ? $stat->getPProdInfo("lang='ru'")->title : $stat->PProductMain->title;
             $info[] = ['user' => $stat->Accounts->name, 'date' => date('d.m.Y', $stat->tstart), 'time' => date('H:i:s', $stat->tstart), 'product_title' => $prod_title, 'product_id' => $stat->tprodid, 'lang' => $tlang];
         }
         $info = json_encode($info);
         $this->view->disable();
         echo json_encode($info);
     }
 }