public function logBookAction()
 {
     //ini_set('max_input_vars', '10000');
     $form = new Form_MonthlyConsumption();
     $start = 0;
     $end = $this->_request->getParam('counter', 10);
     $temp = $this->_request->do;
     $temp = base64_decode(substr($temp, 1, strlen($temp) - 1));
     $temp = explode("|", $temp);
     $warehouse_id = $temp[0];
     $is_new_rpt = $temp[2];
     $rpt_date = $temp[1];
     $tt = explode("-", $rpt_date);
     $yy = $tt[0];
     $mm = $tt[1];
     $dd = $tt[2];
     if (isset($this->_request->do) && !empty($this->_request->do)) {
         $temp1 = $this->_request->do;
         $warehouse_data = new Model_WarehousesData();
         $warehouse_data->form_values = array('warehouse_id' => $warehouse_id);
         $result = $warehouse_data->getMonthYearByWarehouseIdLogBook();
         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($warehouse_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");
         }
         $form->monthly_report->setMultiOptions($arr_combo);
         $form->monthly_report->setValue($temp1);
     }
     if ($this->_request->isPost()) {
         $em = Zend_Registry::get('doctrine');
         $em->getConnection()->beginTransaction();
         try {
             if ($this->_request->getPost()) {
                 $temp = $this->_request->do;
                 $log_book = new Model_WarehousesData();
                 $log_book->form_values = $this->_request->getPost();
                 // App_Controller_Functions::pr($_REQUEST);
                 $log_book->form_values['temp'] = $temp;
                 $result = $log_book->addLog();
                 $em->getConnection()->commit();
                 if ($result) {
                     // Open report in edit form after save
                     $l3m_dt = new DateTime($rpt_date);
                     $string = "Z" . base64_encode($warehouse_id . '|' . $l3m_dt->format('Y-m-') . '01|2');
                     $this->redirect("/stock/log-book?do=" . $string);
                 }
             }
         } catch (Exception $e) {
             $em->getConnection()->rollback();
             $em->close();
         }
     }
     $item_pack_sizes = new Model_ItemPackSizes();
     $items = $item_pack_sizes->logBookItemPackSize();
     $this->view->is_new_report = $is_new_rpt;
     $this->view->wh_id = $warehouse_id;
     $this->view->prev_month_date = $rpt_date;
     $this->view->items = $items;
     $this->view->mm = $mm;
     $this->view->yy = $yy;
     $this->view->params = $params;
     $this->view->form = $form;
     $this->view->start = $start;
     $this->view->end = $end;
     $this->view->do = $this->_request->do;
     $this->view->locid = $loc_id;
     $this->view->rpt_date = $rpt_date;
     $locations = new Model_Locations();
     $result = $locations->getSindhDistricts();
     $this->view->locations = $result;
 }