Пример #1
0
 public function monthlyConsumption2Action()
 {
     if ($this->_identity->getProvinceId() != 2) {
         $this->redirect("/stock/monthly-consumption");
     }
     $form = new Form_MonthlyConsumption();
     $warehouse = new Model_Warehouses();
     $warehouses = $warehouse->getWarehouseNames();
     $this->view->warehouses = $warehouses;
     if (isset($this->_request->do) && !empty($this->_request->do)) {
         $temp = $this->_request->do;
         //App_Controller_Functions::pr(base64_decode(substr($temp, 1, strlen($temp) - 1)));
         $warehouse_data = new Model_WarehousesData();
         $warehouse_data->temp = $temp;
         $arr_temp = $warehouse_data->monthlyConsumtionTemp();
         // App_Controller_Functions::pr($arr_temp);
         $this->view->month = $arr_temp['month'];
         $this->view->mm = $arr_temp['mm'];
         $this->view->year = $arr_temp['yy'];
         $this->view->is_new_report = $arr_temp['is_new_rpt'];
         $this->view->prev_month_date = $arr_temp['prev_month_date'];
         $this->view->check_date = $arr_temp['check_date'];
         $this->view->first_month = Zend_Registry::get('first_month');
         $item_pack_sizes = new Model_ItemPackSizes();
         $item_pack_sizes->form_values = array('month' => $arr_temp['mm'], 'year' => $arr_temp['yy'], 'wh_id' => $arr_temp['wh_id']);
         $items = $item_pack_sizes->monthlyConsumtion2();
         $items_non_vaccines = $item_pack_sizes->monthlyConsumtion2_non_vaccinces();
         $items_tt = $item_pack_sizes->monthlyConsumtion2_tt();
         $warehouse_data->form_values = array('warehouse_id' => $arr_temp['wh_id']);
         $result = $warehouse_data->getMonthYearByWarehouseId2();
         if ($result != false) {
             $arr_combo = array();
             $arr_combo[] = array("key" => "", "value" => "Select");
             foreach ($result as $row) {
                 $loc_id = $row['location_id'];
                 $do = 'Z' . base64_encode($arr_temp['wh_id'] . '|' . $row['report_year'] . '-' . str_pad($row['report_month'], 2, "0", STR_PAD_LEFT) . '-01' . '|2');
                 $arr_combo[] = array("key" => $do, "value" => $row['report_month'] . '-' . $row['report_year']);
             }
         } else {
             $arr_combo = array();
             $arr_combo[] = array("key" => "", "value" => "Select");
         }
         $warehouse = $this->_em->getRepository("Warehouses")->find($arr_temp['wh_id']);
         $warehouse_name = $warehouse->getWarehouseName();
         $form->monthly_report->setMultiOptions($arr_combo);
         $form->monthly_report->setValue($temp);
         $this->view->rpt_date = $arr_temp['rpt_date'];
         $this->view->wh_id = $arr_temp['wh_id'];
         $this->view->warehouse_name = $warehouse_name;
         $this->view->district_name = $warehouse->getDistrict()->getLocationName();
         $tehsil = $this->_em->getRepository("Locations")->find($warehouse->getLocation()->getPkId());
         $tehsil_name = $tehsil->getParent()->getLocationName();
         $this->view->tehsil_name = $tehsil_name;
         $this->view->uc_name = $warehouse->getLocation()->getLocationName();
         $this->view->locid = $loc_id;
         $this->view->items = $items;
         $this->view->items_non_vaccinces = $items_non_vaccines;
         $this->view->items_tt = $items_tt;
         //$form->uc->setValue($arr_temp['loc_id']);
     }
     if ($this->_request->isPost()) {
         $data = $this->_request->getPost();
         $warehouse_data = new Model_WarehousesData();
         $warehouse_data->form_values = $data;
         $result = $warehouse_data->addMonthlyConsumption2Validation();
         // App_Controller_Functions::pr($result);
         if (empty($result)) {
             $l3m_dt = new DateTime($data['rpt_date']);
             $string = "Z" . base64_encode($data['wh_id'] . '|' . $l3m_dt->format('Y-m-') . '01|2');
             $this->redirect("/stock/monthly-consumption2?do=" . $string);
         } else {
             // Open report in edit form after save
             //  App_Controller_Functions::pr($result);
             $this->view->error = "P";
             $this->view->msg = $result;
         }
     }
     //var_dump($this->_request->do);
     //exit;
     $this->view->form = $form;
     $this->view->do = $this->_request->do;
 }