function monthsalesbydateAction() { $report_data = reportModel::getCurrentMonthSalesByDate(); $date_array = array(); $sales_array = array(); foreach ($report_data as $report) { array_push($date_array, $report['date']); array_push($sales_array, (int) $report['TotalSales']); } echo json_encode(array("dates" => $date_array, "sales" => $sales_array)); }
public function cau15($dethi_id, $user_id) { if (empty(self::$conn)) { self::$conn = $this->connect_pdo(); } $sql = "SELECT u.id,CONCAT_WS(' ',first_name,last_name) AS name,count(t.answer) AS tong_so_cau_lam,\n\t\t\t\t\t\t\tsum(t.score) AS score\n\t\t\t\t\tFROM test AS t\n\t\t\t\t\tLEFT JOIN question AS q\n\t\t\t\t\t\tON q.id=t.question_id\n\t\t\t\t\tLEFT JOIN users AS u\n\t\t\t\t\t\tON u.id=t.user_id\n\t\t\t\t\tWHERE dethi_id=? AND user_id=?"; $stmt = self::$conn->prepare($sql); $stmt->bindParam(1, $dethi_id); $stmt->bindParam(2, $user_id); $stmt->execute(); $score = $stmt->fetch(); return $score; }
public function inactive($year = null, $month = null) { if ($year == null) { $date = new DateTime(); if ($date->format('d') >= 26) { $date->modify('+1 month'); } $year = $date->format('Y'); } if ($month == null) { $date = new DateTime(); if ($date->format('d') >= 26) { $date->modify('+1 month'); } $month = $date->format('m'); } $date = new DateTime(); $date->setDate($year, $month, 26); $date->setTime(0, 0, 0); $this->view->year = $date->format('Y'); $this->view->date = $date->format("F Y"); $date->modify('+1 year'); $this->view->nextYear = $date->format('Y'); $date->modify('-2 year'); $this->view->previousYear = $date->format('Y'); $date->modify('+1 year'); $month = $date->format('m'); $this->view->month = $month; $date->modify('-1 month'); $this->view->previousMonth = $date->format('m'); $date->modify('+2 month'); $this->view->nextMonth = $date->format('m'); $report = new reportModel($year, $month, 1); $this->view->report = $report->getTimesheets(); $this->view->accountLevel = $this->authLevel; $date = new DateTime(); if ($date->format('d') >= 26) { $date->modify('+1 month'); } $date->setDate($year, $month, 1); $this->view->monthName = $date->format('F'); $printInactiveTimeSheetForm = new printInactiveTimeSheetForm(); $printInactiveTimeSheetForm->setAction($this->_link(array("reports", "inactive", $year, $month))); if ($printInactiveTimeSheetForm->wasSubmitted()) { $printInactiveTimeSheetForm->addData($_POST); if ($printInactiveTimeSheetForm->validate()) { $data = $printInactiveTimeSheetForm->exportFormData(); $this->layout->addScriptBlock("\n window.open('" . $this->_link(array("reports", "inactive", "printpreview", $year, $month, $data['account'])) . "');\n "); $this->view->printTimeSheetForm = $printInactiveTimeSheetForm; } else { $this->view->printTimeSheetForm = $printInactiveTimeSheetForm; } } else { $this->view->printTimeSheetForm = $printInactiveTimeSheetForm; } }