public function editDataEntryAction()
 {
     $notify_text = "";
     $order = "";
     $sort = "";
     $campaign_data = array();
     $form = new Form_Campaigns_NewDataEntry();
     $campaigns = new Model_Campaigns();
     $campaign_user_type = Model_Roles::CAMPAIGN;
     $role_id = $this->_identity->getRoleId();
     $warehouse_id = $this->_identity->getWarehouseId();
     $wh_id = $this->_request->getParam('wh', '');
     $wh_id = !empty($wh_id) ? $wh_id : $warehouse_id;
     //$campaigns->form_values['province_id'] = ($this->_identity->getProvinceId() != 10) ? $this->_identity->getProvinceId() : '';
     $dist_id = $this->_identity->getDistrictId($this->_identity->getIdentity());
     $district_id = $this->_request->getParam('district_id', '');
     $district_id = !empty($district_id) ? $district_id : $dist_id;
     $campaigns->form_values['district_id'] = $district_id;
     $day = $this->_request->getParam('day', '');
     $campaign_id = $this->_request->getParam('campaign_id', '');
     $province_id = $this->_request->getParam('province_id', '');
     $itm = $this->_request->getParam('itm', '');
     $itm_id = $this->_request->getParam('item_id', '');
     $id = $this->_request->getParam('id');
     $type = $this->_request->getParam('type');
     $campaign_day = $this->_request->getParam('day');
     $action = 'add';
     $btn_txt = 'Save';
     $page_heading = 'Data Entry Control Room';
     // Edit Campaign
     if (isset($id) && !empty($id)) {
         $arr = explode('|', App_Controller_Functions::decrypt($id));
         $action = $arr[0];
         $id = $arr[1];
         $campaigns->form_values['campaign_id'] = $id;
         if ($action == 'view' || $action == 'edit') {
             if ($role_id == $campaign_user_type && empty($wh_id)) {
                 $page_heading = 'Data Entry Control Room';
             } elseif ($action == 'view') {
                 $page_heading = 'View Details Data Entry Control Room';
             } elseif ($action == 'edit') {
                 $page_heading = 'Update Data Entry Control Room';
             }
             $btn_txt = 'Update';
             if (isset($day)) {
                 //&& $day == 'all'
                 $campaigns->form_values['campaign_id'] = $campaign_id;
                 $campaigns->form_values['campaign_day'] = $day;
                 $campaigns->form_values['district_id'] = $district_id;
                 $campaigns->form_values['wh_id'] = $wh_id;
             }
             $campaignData = $campaigns->getCampaignDataEntry();
             $form->campaign_id->setValue($campaignData[0]['campaign_id']);
             $form->getElement('campaign_id')->setAttrib('disabled', 'disabled');
             $form->item_id->setValue($campaignData[0]['item_pack_size_id']);
             $form->getElement('item_id')->setAttrib('disabled', 'disabled');
             $form->wh_id->setValue($campaignData[0]['warehouse_id']);
             $form->getElement('wh_id')->setAttrib('readonly', 'readonly');
             $form->wh_name->setValue($campaignData[0]['warehouse_name']);
             $form->getElement('wh_name')->setAttrib('readonly', 'readonly');
             $form->campaign_day->setValue($campaignData[0]['campaign_day']);
             $form->getElement('campaign_day')->setAttrib('disabled', 'disabled');
             $form->daily_target->setValue($campaignData[0]['daily_target']);
             $form->household_visited->setValue($campaignData[0]['household_visited']);
             $form->multiple_family_household->setValue($campaignData[0]['multiple_family_household']);
             $form->target_age_six_months->setValue($campaignData[0]['target_age_six_months']);
             $form->target_age_sixty_months->setValue($campaignData[0]['target_age_sixty_months']);
             $form->total_coverage->setValue($campaignData[0]['total_coverage']);
             $form->refusal_covered->setValue($campaignData[0]['refusal_covered']);
             $form->coverage_mobile_children->setValue($campaignData[0]['coverage_mobile_children']);
             $form->coverage_not_accessible->setValue($campaignData[0]['coverage_not_accessible']);
             $form->record_not_accessible->setValue($campaignData[0]['record_not_accessible']);
             $form->record_refusal->setValue($campaignData[0]['record_refusal']);
             $form->reported_with_weakness->setValue($campaignData[0]['reported_with_weakness']);
             $form->zero_dose->setValue($campaignData[0]['zero_doses']);
             $form->teams_reported->setValue($campaignData[0]['teams_reported']);
             $form->inaccessible_coverage->setValue($campaignData[0]['inaccessible_coverage']);
             $form->vials_given->setValue($campaignData[0]['vials_given']);
             $form->vials_used->setValue($campaignData[0]['vials_used']);
             $form->vials_expired->setValue($campaignData[0]['vials_expired']);
             $form->vials_returned->setValue($campaignData[0]['vials_returned']);
             $form->recon_syr_wasted->setValue($campaignData[0]['recon_syr_wasted']);
             $form->ad_syr_wasted->setValue($campaignData[0]['ad_syr_wasted']);
             if ($action == 'view') {
                 $form->getElement('campaign_id')->setAttrib('disabled', 'disabled');
                 $form->getElement('item_id')->setAttrib('disabled', 'disabled');
                 $form->getElement('wh_id')->setAttrib('readonly', 'readonly');
                 $form->getElement('wh_name')->setAttrib('readonly', 'readonly');
                 $form->getElement('campaign_day')->setAttrib('disabled', 'disabled');
                 $form->getElement('daily_target')->setAttrib('readonly', 'readonly');
                 $form->getElement('household_visited')->setAttrib('readonly', 'readonly');
                 $form->getElement('multiple_family_household')->setAttrib('readonly', 'readonly');
                 $form->getElement('target_age_six_months')->setAttrib('readonly', 'readonly');
                 $form->getElement('target_age_sixty_months')->setAttrib('readonly', 'readonly');
                 $form->getElement('total_coverage')->setAttrib('readonly', 'readonly');
                 $form->getElement('refusal_covered')->setAttrib('readonly', 'readonly');
                 $form->getElement('coverage_mobile_children')->setAttrib('readonly', 'readonly');
                 $form->getElement('coverage_not_accessible')->setAttrib('readonly', 'readonly');
                 $form->getElement('record_not_accessible')->setAttrib('readonly', 'readonly');
                 $form->getElement('record_refusal')->setAttrib('readonly', 'readonly');
                 $form->getElement('reported_with_weakness')->setAttrib('readonly', 'readonly');
                 $form->getElement('zero_dose')->setAttrib('readonly', 'readonly');
                 $form->getElement('teams_reported')->setAttrib('readonly', 'readonly');
                 $form->getElement('inaccessible_coverage')->setAttrib('readonly', 'readonly');
                 $form->getElement('vials_given')->setAttrib('readonly', 'readonly');
                 $form->getElement('vials_used')->setAttrib('readonly', 'readonly');
                 $form->getElement('vials_expired')->setAttrib('readonly', 'readonly');
                 $form->getElement('vials_returned')->setAttrib('readonly', 'readonly');
                 $form->getElement('recon_syr_wasted')->setAttrib('readonly', 'readonly');
                 $form->getElement('ad_syr_wasted')->setAttrib('readonly', 'readonly');
             }
         } else {
             if ($action == 'del') {
                 $data = $campaigns->getCampaignDataWH();
                 $campaigns->deleteCampaignData();
                 $notify = 'delete_success';
             }
         }
     }
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $campaigns->form_values = $form->getValues();
             $date = App_Controller_Functions::dateToDbFormat($form->getValue('hdn_campaign_date'));
             $date = date_create($date);
             $year = date_format($date, 'Y');
             $month = date_format($date, 'm');
             if ($action == 'add') {
                 // If new campaign
                 $campaigns->form_values['district_id'] = $district_id;
                 $campaigns->addCampaignData();
                 $notify = 'add_success';
             } else {
                 if ($action == 'edit') {
                     // If campaign update
                     if (!empty($id)) {
                         $campaigns->form_values['campaign_pk_id'] = $id;
                     }
                     $campaigns->form_values['district_id'] = $district_id;
                     $campaigns->form_values['campaign_pk_id'] = $id;
                     $campaigns->form_values['modified_by'] = $this->_identity->getIdentity();
                     $campaigns->form_values['campaign_id'] = $campaign_id;
                     $campaigns->form_values['campaign_day'] = $day;
                     $campaigns->form_values['item_id'] = $itm_id;
                     $campaigns->form_values['modified_date'] = date('Y-m-d');
                     $campaigns->updateCampaignData();
                     $notify = 'update_success';
                 }
             }
             $this->_redirect("/campaign/manage-campaigns/new-data-entry?notify={$notify}&campaign_id={$campaign_id}&day={$campaign_day}");
             return;
         }
     }
     //Get Data for Listing Grid
     if (isset($day) && $day != 'all' && !empty($day)) {
         if (isset($campaign_id) && isset($day)) {
             $campaigns->form_values['district_id'] = isset($district_id) ? $district_id : $dist_id;
             $campaigns->form_values['campaign_id'] = $campaign_id;
             $campaigns->form_values['campaign_day'] = $day;
             $campaign_data = $campaigns->getCampaignEnteredData();
         }
     }
     //Paginate the contest results
     $paginator = Zend_Paginator::factory($campaign_data);
     $page = $this->_getParam("page", 1);
     $counter = $this->_getParam("counter", 10);
     $paginator->setCurrentPageNumber((int) $page);
     $paginator->setItemCountPerPage((int) $counter);
     $this->view->notify_text = $notify_text;
     $this->view->action = $action;
     $this->view->btn_txt = $btn_txt;
     $this->view->page_heading = $page_heading;
     $this->view->type = $type;
     $this->view->campaign_user_type = $campaign_user_type;
     $this->view->role_id = $role_id;
     $this->view->district_id = $district_id;
     $this->view->day = $day;
     $this->view->campaign_id = $campaign_id;
     $this->view->province_id = $province_id;
     $this->view->itm = $itm;
     $this->view->wh_id = $wh_id;
     $this->view->id = $id;
     $this->view->form = $form;
     $this->view->paginator = $paginator;
     $this->view->sort = $sort;
     $this->view->order = $order;
     $this->view->counter = $counter;
 }