diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index 4cb56ea7f..96e5dff0b 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -257,7 +257,7 @@ class PlayouthistoryController extends Zend_Controller_Action { $templateType = $this->_getParam('type', null); - $request = $this->getRequest(); + $request = $this->getRequest(); $params = $request->getPost(); try { diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 7a18ba77e..8f2dedb7e 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -292,22 +292,22 @@ class Application_Service_HistoryService $start = $startDT->format("Y-m-d H:i:s"); $end = $endDT->format("Y-m-d H:i:s"); - $paramMap["starts"] = $start; + $paramMap["starts"] = $start; $paramMap["ends"] = $end; - $template = $this->getConfiguredFileTemplate(); - $fields = $template["fields"]; + $template = $this->getConfiguredFileTemplate(); + $fields = $template["fields"]; $required = $this->mandatoryFileFields(); - foreach ($fields as $index=>$field) { + foreach ($fields as $index=>$field) { $key = $field["name"]; - - if (in_array($field["name"], $required)) { - continue; + + if (in_array($field["name"], $required)) { + continue; } - $select[] = "summary.{$key}"; + $select[] = "summary.{$key}"; } $fileSummaryTable = "(( @@ -324,69 +324,69 @@ class Application_Service_HistoryService " FROM {$fileSummaryTable}"; //------------------------------------------------------------------------- - //need to count the total rows to tell Datatables. - $stmt = $this->con->prepare($mainSqlQuery); - foreach ($paramMap as $param => $v) { - $stmt->bindValue($param, $v); - } - - if ($stmt->execute()) { - $totalRows = $stmt->rowCount(); - Logging::info("Total Rows {$totalRows}"); - } - else { - $msg = implode(',', $stmt->errorInfo()); - Logging::info($msg); - throw new Exception("Error: $msg"); + //need to count the total rows to tell Datatables. + $stmt = $this->con->prepare($mainSqlQuery); + foreach ($paramMap as $param => $v) { + $stmt->bindValue($param, $v); } - //------------------------------------------------------------------------ - //Using Datatables parameters to sort the data. - - $numOrderColumns = $opts["iSortingCols"]; - $orderBys = array(); - - for ($i = 0; $i < $numOrderColumns; $i++) { - - $colNum = $opts["iSortCol_".$i]; - $key = $opts["mDataProp_".$colNum]; - $sortDir = $opts["sSortDir_".$i]; - - $orderBys[] = "summary.{$key} {$sortDir}"; - } - - if ($numOrderColumns > 0) { - - $orders = join(", ", $orderBys); - - $mainSqlQuery.= - " ORDER BY {$orders}"; + if ($stmt->execute()) { + $totalRows = $stmt->rowCount(); + Logging::info("Total Rows {$totalRows}"); + } + else { + $msg = implode(',', $stmt->errorInfo()); + Logging::info($msg); + throw new Exception("Error: $msg"); + } + + //------------------------------------------------------------------------ + //Using Datatables parameters to sort the data. + + $numOrderColumns = $opts["iSortingCols"]; + $orderBys = array(); + + for ($i = 0; $i < $numOrderColumns; $i++) { + + $colNum = $opts["iSortCol_".$i]; + $key = $opts["mDataProp_".$colNum]; + $sortDir = $opts["sSortDir_".$i]; + + $orderBys[] = "summary.{$key} {$sortDir}"; + } + + if ($numOrderColumns > 0) { + + $orders = join(", ", $orderBys); + + $mainSqlQuery.= + " ORDER BY {$orders}"; } //------------------------------------------------------------ //using datatables params to add limits/offsets - $displayLength = intval($opts["iDisplayLength"]); - if ($displayLength !== -1) { - $mainSqlQuery.= - " OFFSET :offset LIMIT :limit"; - - $paramMap["offset"] = $opts["iDisplayStart"]; - $paramMap["limit"] = $displayLength; - } - - $stmt = $this->con->prepare($mainSqlQuery); - foreach ($paramMap as $param => $v) { - $stmt->bindValue($param, $v); - } - - $rows = array(); - if ($stmt->execute()) { - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - } - else { - $msg = implode(',', $stmt->errorInfo()); - Logging::info($msg); - throw new Exception("Error: $msg"); + $displayLength = intval($opts["iDisplayLength"]); + if ($displayLength !== -1) { + $mainSqlQuery.= + " OFFSET :offset LIMIT :limit"; + + $paramMap["offset"] = $opts["iDisplayStart"]; + $paramMap["limit"] = $displayLength; + } + + $stmt = $this->con->prepare($mainSqlQuery); + foreach ($paramMap as $param => $v) { + $stmt->bindValue($param, $v); + } + + $rows = array(); + if ($stmt->execute()) { + $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); + } + else { + $msg = implode(',', $stmt->errorInfo()); + Logging::info($msg); + throw new Exception("Error: $msg"); } //-----------------------------------------------------------------