Example #1
0
 public function actionGetIndexData()
 {
     $userId = $_SESSION['userInfo']['user_id'];
     $dataList = $this->_dataModel->getDataList($userId, array('data_id,data_name,user_id'));
     $resultModel = new Model_Result();
     $resultList = $resultModel->getResultList($userId, array('data_id', 'type', 'ret_id'));
     $graphsModel = new Model_Graphs();
     $graphsList = $graphsModel->getGraphsList($userId, array('data_id', 'type', 'g_id'));
     $return = array('files' => array(), 'results' => array(), 'graphs' => array());
     $dataMap = array();
     //处理filelist
     if ($dataList) {
         foreach ($dataList as $data) {
             $return['files'][] = array('dataId' => $data['data_id'], 'dataName' => $data['data_name']);
             $dataMap[$data['data_id']] = $data['data_name'];
         }
     }
     //处理result
     if ($resultList) {
         foreach ($resultList as $result) {
             $dataId = $result['data_id'];
             $dataName = $dataMap[$dataId];
             $key = 'result_' . $dataId;
             if (!isset($return['results'][$key])) {
                 $return['results'][$key]['dataId'] = $dataId;
                 $return['results'][$key]['dataName'] = $dataName;
             }
             $return['results'][$key]['resultList'][] = array('resultId' => $result['ret_id'], 'resultName' => $dataName . $result['type'] . "的分析结果", 'resultType' => $result['type']);
         }
     }
     //处理graphs
     if ($graphsList) {
         foreach ($graphsList as $graphs) {
             $dataId = $graphs['data_id'];
             $dataName = $dataMap[$dataId];
             $key = 'graphs_' . $dataId;
             if (!isset($return['graphs'][$key])) {
                 $return['graphs'][$key]['dataId'] = $dataId;
                 $return['graphs'][$key]['dataName'] = $dataName;
             }
             $return['graphs'][$key]['graphsList'][] = array('graphsId' => $graphs['g_id'], 'graphsName' => $dataName . $graphs['type'] . "的分析结果", 'graphsType' => $graphs['type']);
         }
     }
     echo json_encode(array('status' => 0, 'data' => $return));
 }
 public function coldChainCapacityVvmAction()
 {
     $this->_helper->layout->setLayout("layout");
     $graphs = new Model_Graphs();
     $to_date = $this->_request->getPost('to_date');
     if (empty($to_date)) {
         $to_date = $this->_request->getParam('to_date', date("d/m/Y"));
     }
     $graphs->form_values['to_date'] = $to_date;
     $this->view->to_date = $to_date;
     $xmlstore1 = $graphs->coldChainCapacityVvm(1);
     $this->view->xmlstore1 = $xmlstore1;
     $xmlstore2 = $graphs->coldChainCapacityVvm(3);
     $this->view->xmlstore2 = $xmlstore2;
     $this->view->warehousename = $this->_identity->getWarehouseName();
     $this->view->data = $graphs->coldChainCapacityVvm(2);
     $base_url = Zend_Registry::get("baseurl");
     $this->view->inlineScript()->appendFile($base_url . '/js/reports/dashlet/cold-chain-capacity.js');
 }
 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";
 }