public function vlmisAction() { $salt = '159jboFHjeQK5mc1K0cdSz5'; $token = sha1(md5($salt . date('Y-m-d'))); if (!$this->_identity->login('userdashboard', base64_encode(123))) { $error = true; throw new Exception(); } if ($token != $_GET['token']) { $this->view->message = 'Invalid Token'; } $province = isset($_GET['combo1']) ? $_GET['combo1'] : 1; $level = isset($_GET['office']) ? $_GET['office'] : 1; $role_id = 4; $this->view->level = $level; $this->view->province = $province; $this->_helper->layout->setLayout('vlmis-dashboad'); $auth = App_Auth::getInstance(); //$role_id = $auth->getRoleId(); $campaign = new Model_Campaigns(); $location = new Model_Locations(); $location->form_values = array('geo_level_id' => 4, 'province_id' => $province); $res = $location->getLocationsByLevelByProvince(); $district = $res[0]['key']; $this->view->district = $district; switch ($level) { case 1: $this->view->campaigns = $campaign->getAllCampaigns(); break; case 2: $location->form_values = array("province_id" => $province); $dists = $location->districtLocations(); foreach ($dists as $dist) { $arr_dist[] = $dist['pk_id']; } $campaign->form_values = array("districts" => implode(",", $arr_dist)); $this->view->campaigns = $campaign->getCampaignsByDistrict(); break; case 6: $campaign->form_values = array("districts" => $district); $this->view->campaigns = $campaign->getCampaignsByDistrict(); break; default: $this->view->campaigns = $campaign->getAllCampaigns(); break; } $this->view->provinces = $location->getProvincesName(); $item = new Model_ItemPackSizes(); $this->view->items = $item->getAllItemsByCategoryAndActivity("1", "1"); // Default Filters for IM $this->view->item = 6; $this->view->date = Zend_Registry::get('report_month'); // Default Filters for Campaign $this->view->camp = 23; $this->view->user_role = $role_id; $this->view->prov = $province; $r = $this->_request->getParam("ri_btn", ''); if ($r == 'ri') { $this->view->r = $r; $this->view->item = $this->_request->getParam("items", ''); $this->view->date = $this->_request->getParam("date", ''); $this->view->period = $this->_request->getParam("period", ''); } $i = $this->_request->getParam("im_btn", ''); if ($i == 'im') { $this->view->i = $i; $this->view->item = $this->_request->getParam("items", ''); $this->view->date = $this->_request->getParam("date", ''); $this->view->period = $this->_request->getParam("period", ''); } $c = $this->_request->getParam("camp_btn", ''); if ($c == 'camp') { $this->view->c = $c; $this->view->camp = $this->_request->getParam("camp", ''); $this->view->prov = $this->_request->getParam("prov", ''); } $role_resource = new Model_RoleResources(); $role_resource->form_values = array('type_id' => 3, 'role_id' => $role_id); $dashboards = $role_resource->getRoleResourcesByTypeForVlmisDashboard(); $this->view->dashboards = $dashboards; $this->view->ri = 472; $this->view->im = 330; $this->view->campaign = 333; $period = new Model_Period(); $time_intervals = $period->getTimeIntervals(); $this->view->time_intervals = $time_intervals; $this->view->quarter = Model_Period::QUARTER; $this->view->halfyear = Model_Period::HALFYEAR; $this->view->annual = Model_Period::ANNUAL; $base_url = Zend_Registry::get('baseurl'); $this->view->inlineScript()->appendFile($base_url . '/js/all_level_area_combo.js'); $this->view->id = $this->_request->getParam("id", $dashboards[0]->getResource()->getPkId()); /* if ($role_id == 7) { $this->view->province = $this->_identity->getProvinceId(); $this->renderScript("dashboard/user-tehsil.phtml"); } */ }
public function getConsumptionMos() { /* Yearly Comparision - National */ $monthval = array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"); $post = $this->form_values; $products = $post['products']; $yearcomp = $post['yearcomp']; $all_provinces = $post['all_provinces']; $all_districts = $post['all_districts']; $optvals = $post['optvals']; $period = new Model_Period(); $period->form_values = array('id' => $post['period']); $months = $period->getPeriodById(); $location = new Model_Locations(); $location->form_values['pk_id'] = $all_provinces; $location_name = $location->getLocationName(); $title = "Vaccination vs Stock On Hand (" . $location_name . "-" . $yearcomp[0] . ")"; for ($k = 0; $k < sizeof($products); $k++) { $product_obj = new Model_ItemPackSizes(); $product_obj->form_values['pk_id'] = $products[$k]; $product_name = $product_obj->getProductName(); $xmlstore = "<chart exportEnabled='1' labelDisplay='rotate' slantLabels='1' yAxisMaxValue='100' exportAction='Download' caption='{$product_name} {$title}' exportFileName='" . $title . " - " . date('Y-m-d H:i:s') . " - " . $product_name . "' yAxisName='Doses' numberSuffix='' showValues='1' formatNumberScale='0' theme='fint'>"; $xmlstore .= "<categories>"; for ($i = $months->getBeginMonth(); $i <= $months->getEndMonth(); $i++) { $month_name = $monthval[$i - 1]; $xmlstore .= "<category label='{$month_name}' />"; } $xmlstore .= "</categories>"; $start_date = $yearcomp[0] . '-' . str_pad($months->getBeginMonth(), 2, "0", STR_PAD_LEFT) . "-01"; $end_date = $yearcomp[0] . '-' . str_pad($months->getEndMonth(), 2, "0", STR_PAD_LEFT) . "-01"; $sql = "SELECT\n summary_provincial.consumption,\n summary_provincial.soh_store\n FROM\n summary_provincial\n WHERE\n summary_provincial.item_id = '{$products[$k]}' AND\n summary_provincial.province_id = {$all_provinces} AND\n summary_provincial.stakeholder_id = 1 AND\n DATE_FORMAT(summary_provincial.reporting_date,'%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; $str_sql = $this->_em->getConnection()->prepare($sql); $str_sql->execute(); $rowData = $str_sql->fetchAll(); $xmlstore .= "<dataset seriesName='Consumption/Vaccination'>"; foreach ($rowData as $val2) { $xmlstore .= "<set value='" . round($val2['consumption']) . "' />"; } $xmlstore .= "</dataset>"; $xmlstore .= "<dataset seriesName='Stock On Hand(SOH)'>"; foreach ($rowData as $val2) { $xmlstore .= "<set value='" . round($val2['soh_store']) . "' />"; } $xmlstore .= "</dataset>"; $xmlstore .= "</chart>"; $xmlstore_array[] = $xmlstore; } return $xmlstore_array; }
public function simpleGraphsAction() { if ($this->_request->isPost()) { $post = $this->_request->getPost(); $graphs = new Model_Graphs(); $graphs->form_values = $post; $optvals = $post['optvals']; if (in_array($optvals, array(9, 10, 11))) { $xmlstore = $graphs->simpleGraphOptionYearNational(); } $this->view->xmlstore = $xmlstore; //print_r($post); $this->view->chart_type = $post['ctype']; $this->view->sel_indicator = $post['indicators']; $this->view->sel_product = $post['products']; $this->view->sel_optvals = $post['optvals']; $this->view->sel_period = $post['period']; $this->view->sel_year = $post['yearcomp']; $this->view->sel_province = $post['all_provinces']; $this->view->sel_district = $post['all_districts']; if (in_array($optvals, array(10, 11))) { $locations = new Model_Locations(); $locations->form_values = array('parent_id' => 10, 'geo_level_id' => 2); $this->view->combo_provinces = $locations->getLocationsByLevel(); } if ($optvals == 11) { $location = new Model_Locations(); $location->form_values = array('province_id' => $post['all_provinces'], 'geo_level_id' => 4); $this->view->combo_districts = $location->getLocationsByLevelByProvince(); } } else { $this->view->sel_optvals = 9; } $reports = new Model_Reports(); $indicators = $reports->getIndicators(); $this->view->indicators = $indicators; $products = new Model_ItemPackSizes(); $product = $products->getAllItemsNonDil(); $this->view->product = $product; $compare_option = array("Geographical" => array("9" => "National", "10" => "Provincial", "11" => "District")); $this->view->compare_option = $compare_option; $period = new Model_Period(); $time_intervals = $period->getTimeIntervals(); $this->view->time_intervals = $time_intervals; $this->view->quarter = Model_Period::QUARTER; $this->view->halfyear = Model_Period::HALFYEAR; $this->view->annual = Model_Period::ANNUAL; $years = array(); for ($i = 2013; $i <= date("Y"); $i++) { $years[] = $i; } $this->view->years = $years; $chart_type = array('Line' => "Line", 'Column3D' => "Bar"); $this->view->chart_types = $chart_type; $this->view->main_heading = "Simple Graphs"; }
public function compGraphOptionGeoDistrict() { /* District */ $monthval = array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"); $post = $this->form_values; $products = $post['products']; $year1 = $post['yearcomp']; $provinces = $post['all_provinces']; $districts = $post['all_districts']; $optvals = $post['optvals']; $period = new Model_Period(); $period->form_values = array('id' => $post['period']); $months = $period->getPeriodById(); $rep_option = new Model_ReportOptions(); $rep_option->form_values = array('stakeholder' => 1, 'report_id' => $post['indicators'], 'report_comp' => $optvals); $query = $rep_option->getReportDataSql(); $title = $query->getReportTitleSql(); $location = new Model_Locations(); $loc_name = array(); if (!empty($provinces)) { $location->form_values = array("pk_id" => $provinces); $province_name = $location->getLocationName(); } foreach ($districts as $dist_id) { $location->form_values = array("pk_id" => $dist_id); $loc_name[] = $location->getLocationName(); } $location_name = implode(",", $loc_name); for ($k = 0; $k < sizeof($products); $k++) { $product_obj = new Model_ItemPackSizes(); $product_obj->form_values['pk_id'] = $products[$k]; $product_name = $product_obj->getProductName(); list($indicator, $compare_options) = explode("-", str_replace("Report", "Graph", str_replace("Province", "Provincial", $title))); $graph_caption = $indicator . " of " . $product_name; if ($optvals == 1) { $graph_subcaption = $compare_options; } elseif ($optvals == 2) { $graph_subcaption = "Provincial " . $compare_options . " for " . $location_name; } elseif ($optvals == 3) { $graph_subcaption = "District " . $compare_options . " for " . $location_name; } elseif ($optvals == 7) { $graph_subcaption = "" . $compare_options . " for " . $location_name; } elseif ($optvals == 8) { $graph_subcaption = "" . $compare_options . " for " . $province_name . "(" . $location_name . ")"; } $xmlstore = "<chart exportEnabled='1' labelDisplay='rotate' slantLabels='1' yAxisMaxValue='100' exportAction='Download' caption='" . $graph_caption . "' subCaption='" . $graph_subcaption . "' exportFileName='" . $title . " - " . date('Y-m-d H:i:s') . " - " . $location_name . " - " . $product_name . "' yAxisName='Doses' numberSuffix='' showValues='1' formatNumberScale='0' theme='fint'>"; $xmlstore .= "<categories>"; for ($i = $months->getBeginMonth(); $i <= $months->getEndMonth(); $i++) { $month_name = $monthval[$i - 1]; $xmlstore .= "<category label='{$month_name}' />"; for ($j = 0; $j < sizeof($districts); $j++) { $location_obj = new Model_Locations(); $location_obj->form_values['product_id'] = $districts[$j]; $loc_name = $location_obj->getLocationById(); $sql = "select " . str_replace("\$i", $i, $query->getReportDataSql()) . " as xyz from dual "; $sql = str_replace("\$year1", $year1, $sql); $sql = str_replace("'\$products[\$k]'", "'" . $products[$j] . "'", $sql); $sql = str_replace("\$seluser", 1, $sql); $sql = str_replace("\$provinces[0]", $provinces, $sql); $sql = str_replace("\$dists[\$j]", $districts[$j], $sql); $dbg_sql .= $sql . '<br>'; //echo $sql."; "; $str_sql = $this->_em->getConnection()->prepare($sql); $str_sql->execute(); $row = $str_sql->fetchAll(); if (!empty($row)) { $res = explode('*', $row[0]['xyz']); $row_data = $res[$query->getReportDataPosition()] / 1; $filedata1[$loc_name][$monthval[$i - 1]] = $row_data; } } } //exit; //echo "<pre>"; //print_r($filedata1); //exit; $xmlstore .= "</categories>"; foreach ($filedata1 as $key1 => $value1) { $xmlstore .= "<dataset seriesName='{$key1}'>"; foreach ($value1 as $val2) { $xmlstore .= "<set value='" . $val2 . "' />"; } $xmlstore .= "</dataset>"; } $xmlstore .= "</chart>"; $xmlstore_array[] = $xmlstore; } //var_dump($xmlstore_array); //exit; return $xmlstore_array; }
public function provinceAction() { $auth = App_Auth::getInstance(); $role_id = $auth->getRoleId(); $this->view->level = 2; $this->view->province = $this->_identity->getProvinceId(); $province = $this->_request->getParam("combo1", 1); if (!empty($province) && $province != 'null') { $this->view->province = $province; } $campaign = new Model_Campaigns(); $location = new Model_Locations(); $location->form_values = array("province_id" => $province); $dists = $location->districtLocations(); foreach ($dists as $dist) { $arr_dist[] = $dist['pk_id']; } $campaign->form_values = array("districts" => implode(",", $arr_dist)); $this->view->campaigns = $campaign->getCampaignsByDistrict(); $this->view->provinces = $location->getProvincesName(); $item = new Model_ItemPackSizes(); $this->view->items = $item->getAllItems(); // Default Filters for IM $this->view->item = 6; $this->view->date = Zend_Registry::get('report_month'); // Default Filters for Campaign $this->view->camp = 23; $this->view->user_role = $role_id; $this->view->prov = $this->_identity->getProvinceId(); $r = $this->_request->getParam("ri_btn", ''); if ($r == 'ri') { $this->view->r = $r; $this->view->item = $this->_request->getParam("items", ''); $this->view->date = $this->_request->getParam("date", ''); $this->view->period = $this->_request->getParam("period", ''); } $i = $this->_request->getParam("im_btn", ''); if ($i == 'im') { $this->view->i = $i; $this->view->item = $this->_request->getParam("items", ''); $this->view->date = $this->_request->getParam("date", ''); $this->view->period = $this->_request->getParam("period", ''); } $c = $this->_request->getParam("camp_btn", ''); if ($c == 'camp') { $this->view->c = $c; $this->view->camp = $this->_request->getParam("camp", ''); $this->view->prov = $this->_request->getParam("prov", ''); } $role_resource = new Model_RoleResources(); $role_resource->form_values = array('type_id' => 3, 'role_id' => $role_id); $dashboards = $role_resource->getRoleResourcesByType(); $this->view->dashboards = $dashboards; $this->view->ri = 472; $this->view->im = 330; $this->view->campaign = 333; $period = new Model_Period(); $time_intervals = $period->getTimeIntervals(); $this->view->time_intervals = $time_intervals; $this->view->quarter = Model_Period::QUARTER; $this->view->halfyear = Model_Period::HALFYEAR; $this->view->annual = Model_Period::ANNUAL; $base_url = Zend_Registry::get('baseurl'); $this->view->inlineScript()->appendFile($base_url . '/js/all_level_area_combo.js'); }