예제 #1
0
 public function init()
 {
     $locations = new Model_Locations();
     $result = $locations->getAllProvinces();
     if ($result) {
         $this->_list["province"][''] = "Select";
         foreach ($result as $row) {
             $this->_list["province"][$row['pkId']] = $row['locationName'];
         }
     }
     //Generate
     $locations = new Model_Locations();
     $result = $locations->getSindhDistricts();
     $this->_list["district"][''] = "Select";
     if ($result) {
         foreach ($result as $row) {
             $this->_list["district"][$row['pkId']] = $row['locationName'];
         }
     }
     $date_from = date('01/m/Y');
     $date_to = date('d/m/Y');
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "name":
             case "father_name":
             case "age":
             case "contact":
             case "address":
             case "item_1":
             case "item_2":
             case "item_3":
             case "item_4":
             case "item_5":
             case "reffers_to":
             case "remarks":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "vaccination_date_from":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control", 'readonly' => 'true', 'style' => 'position: relative; z-index: 100000;'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => $date_from));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "vaccination_date_to":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control", 'readonly' => 'true', 'style' => 'position: relative; z-index: 100000;'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array(), "value" => $date_to));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option"))))));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_radio))) {
             $this->addElement("radio", $col, array("attribs" => array(), "allowEmpty" => true, 'separator' => '', "filters" => array("StringTrim", "StripTags"), "validators" => array(), "multiOptions" => $this->_radio[$col], 'value' => '1'));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag")->removeDecorator("<br>");
         }
     }
 }
 public function init()
 {
     //Generate month Combo
     $this->_list["month"][''] = 'Select';
     $this->_list["month"]['01'] = 'January';
     $this->_list["month"]['02'] = 'February';
     $this->_list["month"]['03'] = 'March';
     $this->_list["month"]['04'] = 'April';
     $this->_list["month"]['05'] = 'May';
     $this->_list["month"]['06'] = 'June';
     $this->_list["month"]['07'] = 'July';
     $this->_list["month"]['08'] = 'August';
     $this->_list["month"]['09'] = 'September';
     $this->_list["month"]['10'] = 'October';
     $this->_list["month"]['11'] = 'November';
     $this->_list["month"]['12'] = 'December';
     //Generate year Combo
     $this->_list["year"][''] = 'Select';
     //        for ($y = 2013; $y <= date("Y"); $y++) {
     //            $this->_list["year"][$y] = $y;
     //        }
     $this->_list["year"][date("Y")] = date("Y");
     //Generate Province/Region Combo
     $locations = new Model_Locations();
     $result = $locations->getAllProvinces();
     if ($result) {
         $this->_list["province_region"][''] = "Select";
         foreach ($result as $row) {
             $this->_list["province_region"][$row['pkId']] = $row['locationName'];
         }
     }
     //Generate Antigen(items) Combo
     $item_pack_sizes = new Model_ItemPackSizes();
     $result2 = $item_pack_sizes->getAllVaccines();
     foreach ($result2 as $item) {
         $this->_list["product"][''] = 'Select';
         $this->_list["product"][$item['pkId']] = $item['itemName'];
     }
     foreach ($this->_fields as $col => $name) {
         //            switch ($col) {
         //
         //                case "year":
         //                    $this->addElement("text", $col, array(
         //                        "attribs" => array("class" => "form-control", 'readonly' => 'true', 'style' => 'position: relative; z-index: 100000;'),
         //                        "allowEmpty" => false,
         //                        "filters" => array("StringTrim", "StripTags"),
         //                        "validators" => array(),
         //                        "value" => date("Y")
         //                    ));
         //                    $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         //                    break;
         //            }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option"))))));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }
예제 #3
0
 public function init()
 {
     //Generate Asset Type Combo
     $geo_level = new Model_Locations();
     $result1 = $geo_level->getStakeholderGeoLevel();
     $this->_list["geo_level"][''] = "Select";
     foreach ($result1 as $rs) {
         $this->_list["geo_level"][$rs['pkId']] = $rs['geoLevelName'];
     }
     $stakeholder_sectors = new Model_Stakeholders();
     $result2 = $stakeholder_sectors->getAllSectors();
     $this->_list["sector"][''] = "Select";
     foreach ($result2 as $rs) {
         $this->_list["sector"][$rs['pkId']] = $rs['stakeholderSectorName'];
     }
     $stakeholder_activities = new Model_Stakeholders();
     $result3 = $stakeholder_activities->getAllActivities();
     $this->_list["activity"][''] = "Select";
     foreach ($result3 as $rs) {
         $this->_list["activity"][$rs['pkId']] = $rs['activity'];
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "stakeholder_name":
             case "stakeholder_activity":
             case "stakeholder_type":
             case "stakeholder_sector":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "stakeholder_id":
             case "stakeholder_activity_id":
             case "stakeholder_type_id":
             case "stakeholder_sector_id":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
 }
 public function init()
 {
     $locations = new Model_Locations();
     $uc_warehouses = $locations->getAllUCByUserId();
     foreach ($uc_warehouses as $locations) {
         $this->_list["uc"][''] = 'Select';
         $this->_list["uc"][$locations['pk_id']] = $locations['location_name'];
     }
     foreach ($this->_fields as $col => $name) {
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }
예제 #5
0
 public function init()
 {
     $locations = new Model_Locations();
     $result2 = $locations->getAllProvinces();
     foreach ($result2 as $item) {
         $this->_list["province"][''] = 'Select';
         $this->_list["province"][$item['pkId']] = $item['locationName'];
     }
     $this->_list["district"][''] = 'Select';
     $this->_list["user"][''] = 'Select';
     foreach ($this->_fields as $col => $name) {
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         switch ($col) {
             case "starting_on":
             case "working_uptil":
             case "from_edit":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_radio))) {
             $this->addElement("radio", $col, array("attribs" => array(), "allowEmpty" => true, 'separator' => '', "filters" => array("StringTrim", "StripTags"), "validators" => array(), "multiOptions" => $this->_radio[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "user_hidden":
             case "district_hidden":
             case "province_hidden":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * save
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.1
  */
 public function save()
 {
     $this->core->logger->debug('massiveart->generic->data->GenericDataTypeLocation->save()');
     try {
         $this->getModelLocations()->setLanguageId($this->setup->getLanguageId());
         $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
         /**
          * add|edit|newVersion core and instance data
          */
         switch ($this->setup->getActionType()) {
             case $this->core->sysConfig->generic->actions->add:
                 $arrCoreData = array('idGenericForms' => $this->setup->getGenFormId(), 'idUnits' => $this->setup->getParentId(), 'idUsers' => $intUserId, 'creator' => $intUserId, 'created' => date('Y-m-d H:i:s'));
                 if (count($this->setup->CoreFields()) > 0) {
                     foreach ($this->setup->CoreFields() as $strField => $obField) {
                         $arrCoreData[$strField] = $obField->getValue();
                     }
                 }
                 /**
                  * add location 
                  */
                 $this->setup->setElementId($this->objModelLocations->addLocation($arrCoreData));
                 $this->insertFileData('location', array('Id' => $this->setup->getElementId()));
                 break;
             case $this->core->sysConfig->generic->actions->edit:
                 $arrCoreData = array('idUsers' => $intUserId);
                 if (count($this->setup->CoreFields()) > 0) {
                     foreach ($this->setup->CoreFields() as $strField => $obField) {
                         $arrCoreData[$strField] = $obField->getValue();
                     }
                 }
                 /**
                  * add location 
                  */
                 $this->objModelLocations->editLocation($this->setup->getElementId(), $arrCoreData);
                 $this->updateFileData('location', array('Id' => $this->setup->getElementId()));
                 break;
         }
         return $this->setup->getElementId();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * getModelLocations
  * @return Model_Locations
  * @author Cornelius Hansjakob <*****@*****.**>
  * @version 1.0
  */
 protected function getModelLocations()
 {
     if (null === $this->objModelLocations) {
         /**
          * autoload only handles "library" compoennts.
          * Since this is an application model, we need to require it 
          * from its modules path location.
          */
         require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Locations.php';
         $this->objModelLocations = new Model_Locations();
         $this->objModelLocations->setLanguageId($this->core->intZooluLanguageId);
     }
     return $this->objModelLocations;
 }
예제 #8
0
 public function init()
 {
     $this->addElement('captcha', 'captcha', array("attribs" => array("class" => "form-control"), 'required' => true, 'captcha' => array('captcha' => 'Image', 'font' => PUBLIC_DIR . '/fonts/arial.ttf', 'fontSize' => '24', 'wordLen' => 5, 'height' => '50', 'width' => '150', 'imgDir' => PUBLIC_DIR . '/captcha', 'imgUrl' => Zend_Controller_Front::getInstance()->getBaseUrl() . '/captcha', 'imgAlt' => "Captcha Image", 'messages' => array('badCaptcha' => 'Please enter the correct code'), 'dotNoiseLevel' => 50, 'lineNoiseLevel' => 5)));
     $this->getElement('captcha')->removeDecorator("Label")->removeDecorator("HtmlTag");
     // Generate Country List Combo
     $locations = new Model_Locations();
     $result = $locations->getCountryList();
     if ($result) {
         $this->_list["country"][''] = "Select";
         foreach ($result as $row) {
             $this->_list["country"][$row['country_id']] = $row['country_name'];
         }
         $this->_list["country"]['253'] = "other";
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "organization":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "e_mail":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "address":
                 $this->addElement("textarea", $col, array("attribs" => array("class" => "form-control", "rows" => "3"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option"))))));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }
예제 #9
0
 public function getNonCcmLocationsStatusAction()
 {
     $wh_id = $this->_request->getParam('wh_id');
     $locations = new Model_Locations();
     $result = $locations->getNonCcmLocationsStatus($wh_id);
     echo Zend_Json::encode($result);
 }
예제 #10
0
 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 inventoryManagementReportingAction()
 {
     $this->_helper->layout->setLayout('reports');
     $this->view->report_id = 'SNONREPDIST';
     $this->view->report_title = 'Inventory Management Reporting Report';
     $this->view->actionpage = 'inventory-management-reporting';
     $this->view->parameters = 'TS01IP';
     $this->view->parameter_width = '100%';
     $item_pack_sizes = new Model_ItemPackSizes();
     $locations = new Model_Locations();
     //FOR BCG ITEM
     $item_pack_sizes->form_values = 6;
     $items = $item_pack_sizes->getItemForConsumptionReport();
     $this->view->items = $items;
     //For locations Combo
     $lct = $locations->conusmptionReportLocations();
     $this->view->location = $lct;
     if (!empty($this->_request->from_year_sel) && !empty($this->_request->from_month_sel)) {
         $this->view->from_year_sel = $from_year = $this->_request->from_year_sel;
         $this->view->from_month_sel = $from_month = $this->_request->from_month_sel;
     } else {
         $from_year = date("Y");
         $this->view->from_year_sel = $from_year;
         $this->view->from_month_sel = $from_month = date("m", strtotime("-4 month"));
     }
     if (!empty($this->_request->year_sel) && !empty($this->_request->month_sel)) {
         $this->view->year_sel = $year = $this->_request->year_sel;
         $this->view->month_sel = $month = $this->_request->month_sel;
     } else {
         $year = date("Y");
         if (date('d') > 10) {
             $month = date("m", strtotime("-2 month"));
         } else {
             $month = date("m", strtotime("-2 month"));
         }
         $this->view->year_sel = $year;
         $this->view->month_sel = $month;
     }
     if (isset($this->_request->province) && !empty($this->_request->province)) {
         $this->view->prov_sel = $province = $this->_request->province;
     } else {
         $this->view->prov_sel = $province = 2;
     }
     if (isset($this->_request->district) && !empty($this->_request->district)) {
         $this->view->district_id = $district_id = $this->_request->district;
     } else {
         $this->view->district_id = $district_id = 30;
     }
     if (isset($this->_request->tehsil) && !empty($this->_request->tehsil)) {
         $this->view->tehsil = $this->_request->tehsil;
     } else {
         $this->view->tehsil = 1;
     }
     if (isset($this->_request->wh_type) && !empty($this->_request->wh_type)) {
         $this->view->wh_type = $wh_type = $this->_request->wh_type;
     } else {
         $this->view->wh_type = $wh_type = 4;
     }
     if ($this->_request->wh_type == 4) {
         $locations->form_values['pk_id'] = $this->_request->district;
         $this->view->loc_name = "District:" . ' ' . $locations->getLocationName();
     } elseif ($this->_request->wh_type == 5) {
         $locations->form_values['pk_id'] = $this->_request->tehsil;
         $this->view->loc_name = "Tehsil:" . ' ' . $locations->getLocationName();
     } else {
         $this->view->loc_name = "District:" . ' ' . 'Badin';
     }
     $locations->form_values['geo_level_id'] = '4';
     $locations->form_values['province_id'] = $province;
     $district = $locations->getLocationsByLevelByProvinceConsumption();
     $this->view->district = $district;
     $this->view->prov_sel = $province;
     $locations->form_values['dist_id'] = $district_id;
     $locations->form_values['year'] = $year;
     $distrctName = $locations->getLocationForReport();
     $res = $locations->getLocationsForConsumptionReport();
     $this->view->result = $res;
     //FOR Excel File Name
     $reportingDate = $year . '-' . $month . '-01';
     $fileName = 'BCG-Vaccine-Coverage' . $distrctName . '_for_' . date('M-Y', strtotime($reportingDate));
     $this->view->file_name = $fileName;
 }
예제 #12
0
 public function vvmManagementAction()
 {
     $form = new Form_VvmManagement();
     if ($this->_request->isPost()) {
         $product_id = $this->_request->getPost('product');
         $batch_id = $this->_request->getPost('batch');
         $msg = '';
         $em = Zend_Registry::get('doctrine');
         $em->getConnection()->beginTransaction();
         try {
             $quantity = $this->_request->quantity;
             $newvvm = $this->_request->newvvm;
             foreach ($quantity as $key => $value) {
                 if (!empty($value) && $value > 0) {
                     $updatedqty = $value;
                     list($batchid, $vvmid, $locationid) = explode("_", $key);
                     $batch_detail = $this->_em->getRepository("StockBatch")->find($batchid);
                     $placement = new Model_Placements();
                     $placement->form_values = array('quantity' => "-" . $updatedqty, 'placement_loc_id' => $locationid, 'batch_id' => $batchid, 'placement_loc_type_id' => 116, 'user_id' => $this->_userid, 'created_date' => date("Y-m-d"), 'vvmstage' => $vvmid, 'is_placed' => 0);
                     $placement->add();
                     $placement->form_values = array('quantity' => $updatedqty, 'placement_loc_id' => $locationid, 'batch_id' => $batchid, 'placement_loc_type_id' => 116, 'user_id' => $this->_userid, 'created_date' => date("Y-m-d"), 'vvmstage' => $newvvm[$key], 'is_placed' => 1);
                     $placement->add();
                     //Log Entry START
                     $history = new VvmTransferHistory();
                     $from_to_batch = $this->_em->getRepository("StockBatch")->find($batchid);
                     $history->setBatch($from_to_batch);
                     $from_vvmstages = $this->_em->getRepository("VvmStages")->find($vvmid);
                     $history->setFromVvmStage($from_vvmstages);
                     $to_vvmstages = $this->_em->getRepository("VvmStages")->find($newvvm[$key]);
                     $history->setToVvmStage($to_vvmstages);
                     $created_by = $this->_em->getRepository("Users")->find($this->_userid);
                     $history->setCreatedBy($created_by);
                     $history->setCreatedDate(new DateTime(date("Y-m-d")));
                     $history->setQuantity(ABS($updatedqty));
                     $this->_em->persist($history);
                     $this->_em->flush();
                     //Log Entry END
                     $msg = 'VVM has been changed successfully!';
                     $product_id = $batch_detail->getItemPackSize()->getPkId();
                     $batch_id = $batchid;
                 }
             }
             $location = new Model_Locations();
             $this->view->result = $location->getBatchVvmLocations($batch_id);
             $form->product->setValue($product_id);
             $this->view->batch = $batch_id;
             $em->getConnection()->commit();
         } catch (Exception $e) {
             $em->getConnection()->rollback();
             $em->close();
             App_FileLogger::info($e);
         }
         $stock_detail = new Model_StockDetail();
         $this->view->h_result = $stock_detail->getVvmTransferHistory($product_id);
     }
     $this->view->form = $form;
     $this->view->msg = $msg;
 }
 public function ajaxGetUcsAction()
 {
     $this->_helper->layout->disableLayout();
     $form_values = $this->_request->getPost();
     $location = new Model_Locations();
     $location->form_values = $form_values;
     $result = $location->getAllUcsByCampaignId();
     $this->view->data = $result;
 }
예제 #14
0
 public function init()
 {
     $items = new Model_Item();
     $result = $items->getProductList();
     $productItem = $items->getProductByCategory();
     for ($j = date('Y'); $j >= 2010; $j--) {
         $this->_year["year"][$j] = $j;
     }
     foreach ($result as $item) {
         $this->_list["product"][$item['pkId']] = $item['itemName'];
     }
     foreach ($productItem as $item) {
         $this->_product_item["product_item"][$item['pkId']] = $item['itemName'];
     }
     $locations = new Model_Locations();
     $res = $locations->getProvinceName();
     $this->_province_list["province"]['all'] = "Select";
     foreach ($res as $loc) {
         $this->_province_list["province"][$loc['pk_id']] = $loc['location_name'];
         $this->_province["prov"][$loc['pk_id']] = $loc['location_name'];
     }
     $this->_reporting_list["reporting_product"]['%'] = "All Product";
     foreach ($result as $item) {
         $this->_reporting_list["reporting_product"][$item['pkId']] = $item['itemName'];
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "month":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "dist":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags")));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "batch_no":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "year":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('2014' => '2014', '2013' => '2013', '2012' => '2012', '2011' => '2011', '2010' => '2010')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "coldchain_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'ILR/Refrigerators at District + Field Level', '3' => 'Cold Rooms at District Level')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "cc_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'ILR/Refrigerators at Tehsil + Field Level')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "level":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('all' => 'District + Field', '4' => 'District', '6' => 'Field')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "map_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('2' => 'Provincial', '4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "district_level":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "amc_type":
                 $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('C' => 'Consumption', 'A' => 'Avg.Consumption')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "status":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('1' => 'Functional', '2' => 'Non-Functional')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "vvm_level":
                 $this->addElement("select", $col, array("allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "multiOptions" => array('3' => 'Provincial', '4' => 'District')));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_reporting_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_reporting_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_province_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_province_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_province))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_province[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_year))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_year[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_product_item))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => false, "required" => true, "registerInArrayValidator" => false, "multiOptions" => $this->_product_item[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }
예제 #15
0
 public function locationsCombosFourAction()
 {
     $this->_helper->layout->disableLayout();
     if (isset($this->_request->combo3) && !empty($this->_request->combo3)) {
         $tehsil_id = $this->_request->combo3;
         $location = new Model_Locations();
         $location->form_values = array('parent_id' => $tehsil_id, 'geo_level_id' => 6);
         $this->view->result = $location->getLocationsByLevelByTehsil();
         if (!empty($this->_request->uc_id)) {
             $this->view->uc_id = $this->_request->uc_id;
         }
     }
 }
 public function ajaxGetDistrictAction()
 {
     $this->_helper->layout->disableLayout();
     if (isset($this->_request->province_id) && !empty($this->_request->province_id)) {
         $locations = new Model_Locations();
         $locations->form_values['province_id'] = $this->_request->province_id;
         $array = $locations->districtLocations();
         $this->view->data = $array;
     }
 }
예제 #17
0
 public function getConsumptionByUc($dist_id)
 {
     $date = $this->form_values['date'];
     list($yy, $mm) = explode("-", $date);
     if (empty($dist_id)) {
         $dist_id = $this->_identity->getDistrictId();
     }
     $rows = $this->_em->getRepository('Warehouses')->findBy(array('district' => $dist_id));
     $role_id = $rows[0]->getProvince()->getPkId();
     $teh_id = $this->form_values['teh_id'];
     $cache = Zend_Registry::get('cacheManager')->getCache('file');
     $mosucdashlet = "CONSD_{$yy}{$mm}{$dist_id}{$teh_id}" . $this->form_values['item'];
     if (!($result = $cache->load($mosucdashlet))) {
         $em = Zend_Registry::get('doctrine');
         $str_sql_con = "CALL REPgetConsumptionHF('D','" . $yy . "-" . $mm . "-01', {$teh_id}, '" . $this->form_values['item'] . "', 1);";
         $row_consumption = $em->getConnection()->prepare($str_sql_con);
         $row_consumption->execute();
         $result_consumption = $row_consumption->fetchAll();
         $em->getConnection()->close();
         $result = array();
         foreach ($result_consumption as $row) {
             $result[$row['location_name']]['ucName'] = $row['location_name'];
             $result[$row['location_name']]['CONS'] = $row['consumption'];
             $result[$row['location_name']]['target'] = $row['target'];
         }
         $cache->save($result, $mosucdashlet);
     }
     $item_pack_sizes = new Model_ItemPackSizes();
     $item_pack_sizes->form_values['pk_id'] = $this->form_values['item'];
     $item = $item_pack_sizes->getProductName();
     $locations = new Model_Locations();
     $locations->form_values['pk_id'] = $teh_id;
     $tehsil_name = $this->view->location_name = $locations->getLocationName();
     $xmlstore = "<chart labelDisplay='rotate' exportEnabled='1' exportAction='Download' bgColor='white' caption='Vaccination status of {$item}(Doses) in {$tehsil_name} Stores  and EPI centers  during " . ("(" . date('M Y', strtotime($this->form_values['date'])) . ")") . "'\n        exportFileName='Districts Consumption " . date('Y-m-d H:i:s') . "' yAxisName='Doses' showValues='1' formatNumberScale='0' theme='fint'>";
     $xmlstore .= '<categories>';
     foreach ($result as $data) {
         $coverage = ROUND($data['CONS'] / $data['target'] * 100, 1);
         $xmlstore .= '<category label="' . $data[ucName] . ' (' . $coverage . '%)" />';
     }
     $xmlstore .= '</categories>';
     $xmlstore .= "<dataset seriesname='Consumption' color='0075C2'>";
     foreach ($result as $data) {
         $xmlstore .= "<set value='{$data['CONS']}' />";
     }
     $xmlstore .= "</dataset>";
     $xmlstore .= "<dataset seriesname='Target' parentyaxis='S' renderas='Line' color='f8bd19'>";
     foreach ($result as $data) {
         $xmlstore .= "<set value='{$data['target']}' />";
     }
     $xmlstore .= "</dataset>";
     $xmlstore .= "</chart>";
     return $xmlstore;
 }
    public function allLevelComboAllColdChainEquipment($office_term = "", $postfix = null, $data_array)
    {
        $identity = App_Auth::getInstance();
        $translate = Zend_Registry::get('Zend_Translate');
        $base_url = Zend_Registry::get('baseurl');
        $user_lvl = $identity->getUserLevel($identity->getIdentity());
        $stakeholder_id = $identity->getStakeholderId();
        $warehouse = new Model_Warehouses();
        $office = $data_array["level"];
        $province = $data_array["province"];
        $district = $data_array["district"];
        $warehouse_id = $data_array["warehouse"];
        if ($office == 1) {
            $warehouse->form_values = array('stakeholder_id' => $stakeholder_id);
            switch ($office) {
                case 1:
                    $warehouse_array = $warehouse->getFederalWarehouses();
                    break;
            }
        }
        if (!empty($province)) {
            $locations = new Model_Locations();
            $locations->form_values = array('parent_id' => 10, 'geo_level_id' => 2);
            $provinces_array = $locations->getLocationsByLevel();
            if (empty($district)) {
                $warehouse->form_values = array('province_id' => $province, 'stakeholder_id' => $stakeholder_id);
                switch ($office) {
                    case 1:
                        $warehouse_array = $warehouse->getFederalWarehouses();
                        break;
                    case 2:
                        $warehouse_array = $warehouse->getProvincialWarehouses();
                        break;
                    case 4:
                        $warehouse_array = $warehouse->getDistrictWarehousesofProvince();
                        break;
                }
            }
        }
        if (!empty($district)) {
            $location = new Model_Locations();
            $location->form_values = array('province_id' => $province, 'geo_level_id' => 4);
            $districts_array = $location->getLocationsByLevelByProvince();
            $warehouse->form_values = array('district_id' => $district, 'stakeholder_id' => $stakeholder_id);
            switch ($office) {
                case 5:
                    $warehouse_array = $warehouse->getTehsilWarehousesofDistrict();
                    break;
                case 6:
                    $warehouse_array = $warehouse->getUCWarehousesofDistrict();
                    break;
                case 8:
                    $warehouse_array = $warehouse->getTehsilWarehousesofDistrict();
                    break;
                case 9:
                    $warehouse_array = $warehouse->getUCWarehousesofDistrict();
                    break;
            }
        }
        switch ($user_lvl) {
            case 1:
            case 2:
            case 3:
                $arr_levels = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '4' => $translate->translate('District'), '8' => $translate->translate('Tehsil-Taluka'), '9' => $translate->translate('UC'));
                break;
            case 4:
                $arr_levels = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '4' => $translate->translate('District'), '8' => $translate->translate('Tehsil-Taluka'), '9' => $translate->translate('UC'));
                break;
            case 5:
                $arr_levels = array('2' => $translate->translate('National'), '4' => $translate->translate('District'));
                break;
            case 6:
                $arr_levels = array('2' => $translate->translate('Province'), '5' => $translate->translate('Tehsil-Taluka'), '6' => $translate->translate('Union Council'));
                break;
            case 7:
                $arr_levels = array('7' => $translate->translate('District'), '6' => $translate->translate('Union Council'));
            case 8:
                $arr_levels = array('7' => $translate->translate('District'), '5' => $translate->translate('Tehsil-Taluka'), '6' => $translate->translate('Union Council'));
                break;
            default:
                $arr_levels = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '4' => $translate->translate('District'), '5' => $translate->translate('Tehsil-Taluka'), '6' => $translate->translate('Union Council'));
                break;
        }
        ?>
        <div class="row">
            <div class="col-md-12" id="all_level_combo">
                <div class="col-md-3">
                    <div class="control-group">
                        <label class="control-label" for="office" class="col-md-7"><?php 
        echo $translate->translate("Level");
        ?>
</label>
                        <div class="controls">
                            <select name="office" id="office<?php 
        echo $postfix;
        ?>
" class="form-control">
                                <option value=""><?php 
        echo $translate->translate("Select");
        ?>
</option>
                                <?php 
        foreach ($arr_levels as $key => $value) {
            ?>
                                    <option value="<?php 
            echo $key;
            ?>
" <?php 
            if (!empty($office) && $key == $office) {
                echo 'selected';
            }
            ?>
><?php 
            echo $value;
            ?>
</option>
                                <?php 
        }
        ?>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-md-3" id="div_combo1<?php 
        echo $postfix;
        ?>
" <?php 
        if ($office == 2 || !empty($province)) {
            ?>
 style="display:block;" <?php 
        } else {
            ?>
 style="display:none;"<?php 
        }
        ?>
>
                    <label class="control-label" id="lblcombo1"><?php 
        echo $translate->translate("Province");
        ?>
 </label>
                    <div class="controls">
                        <select name="combo1" id="combo1<?php 
        echo $postfix;
        ?>
" class="form-control">
                            <?php 
        if ($provinces_array != false) {
            ?>
                                <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                                <?php 
            foreach ($provinces_array as $row) {
                ?>
                                    <option value="<?php 
                echo $row['key'];
                ?>
" <?php 
                if (!empty($province) && $row['key'] == $province) {
                    echo 'selected';
                }
                ?>
>
                                        <?php 
                echo $row['value'];
                ?>
</option>
                                    <?php 
            }
        }
        ?>
                        </select>
                    </div>
                </div>	
                <div class="col-md-3" id="div_combo2<?php 
        echo $postfix;
        ?>
" <?php 
        if ($office == 5 || !empty($district)) {
            ?>
 style="display:block;" <?php 
        } else {
            ?>
 style="display:none;"<?php 
        }
        ?>
>
                    <label class="control-label" id="lblcombo2"><?php 
        echo $translate->translate("District");
        ?>
 </label>
                    <div class="controls">
                        <select name="combo2" id="combo2<?php 
        echo $postfix;
        ?>
" class="form-control">
                            <?php 
        if ($districts_array != false) {
            ?>
                                <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                                <?php 
            foreach ($districts_array as $row) {
                ?>
                                    <option value="<?php 
                echo $row['key'];
                ?>
" <?php 
                if (!empty($district) && $row['key'] == $district) {
                    echo 'selected';
                }
                ?>
>
                                        <?php 
                echo $row['value'];
                ?>
</option>
                                    <?php 
            }
        }
        ?>
                        </select>
                    </div>
                </div>
                <div class="col-md-3" id="wh_combo<?php 
        echo $postfix;
        ?>
" <?php 
        /*if (!empty($warehouse_id)) { ?> style="display:block;" <?php } else { ?> style="display:none;"<?php } */
        ?>
>
                    <label class="control-label" id="wh_l"><?php 
        echo $translate->translate("Warehouse");
        ?>
 <span class="red">*</span></label>
                    <div class="controls">
                        <select name="warehouse<?php 
        echo $postfix;
        ?>
" id="warehouse<?php 
        echo $postfix;
        ?>
" class="form-control">
                            <?php 
        if ($warehouse_array != false) {
            ?>
                                <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                                <?php 
            foreach ($warehouse_array as $row) {
                ?>
                                    <option value="<?php 
                echo $row['key'];
                ?>
" <?php 
                if (!empty($warehouse_id) && $row['key'] == $warehouse_id) {
                    echo 'selected';
                }
                ?>
>
                                        <?php 
                echo $row['value'];
                ?>
</option>
                                    <?php 
            }
        }
        ?>

                        </select>
                    </div>
                </div>
                <div class="col-md-1" id="loader<?php 
        echo $postfix;
        ?>
" style="display:none;"><img src="<?php 
        echo $base_url;
        ?>
/images/loader.gif" style="margin-top:8px; float:left" alt="" /></div>
            </div>
        </div>
        <?php 
        return true;
    }
예제 #19
0
 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 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');
 }
 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");
        } */
 }
예제 #22
0
 public function getConsumptionByUc($dist_id)
 {
     $date = $this->form_values['date'];
     list($yy, $mm) = explode("-", $date);
     if (empty($dist_id)) {
         $dist_id = $this->_identity->getDistrictId();
     }
     $role_id = $this->form_values['province'];
     $teh_id = $this->form_values['teh_id'];
     $cache = Zend_Registry::get('cacheManager')->getCache('file');
     $mosucdashlet = "CONSD_{$yy}{$mm}{$teh_id}" . $this->form_values['item'];
     if (!($result = $cache->load($mosucdashlet))) {
         $em = Zend_Registry::get('doctrine');
         if ($role_id == 2) {
             $str_sql_con = "CALL REPgetConsumptionHF('D','" . $yy . "-" . $mm . "-01', {$teh_id}, '" . $this->form_values['item'] . "', 1);";
         } else {
             $str_sql_con = "CALL REPgetConsumption('D','" . $yy . "-" . $mm . "-01', {$teh_id}, '" . $this->form_values['item'] . "', 1);";
         }
         $row_consumption = $em->getConnection()->prepare($str_sql_con);
         $row_consumption->execute();
         $result_consumption = $row_consumption->fetchAll();
         $em->getConnection()->close();
         $result = array();
         foreach ($result_consumption as $row) {
             $result[$row['location_name']]['ucName'] = $row['location_name'];
             $result[$row['location_name']]['CONS'] = $row['consumption'];
             $result[$row['location_name']]['target'] = $row['target'];
         }
         $cache->save($result, $mosucdashlet);
     }
     //        $str_sql = "SELECT IFNULL(A.CONS,0) as CONS,
     //                    A.ucName,
     //                    ROUND(((((A.population / 100) * B.population_percent_increase_per_year) / 100 * B.child_surviving_percent_per_year)* B.doses_per_year) / 12) AS target
     //            FROM (
     //            SELECT DISTINCT
     //                    IFNULL(REPgetConsumption (" . $mm . "," . $yy . "," . $this->form_values['item'] . ",1,'U',locations.pk_id),0) AS CONS,
     //                    locations.location_name AS ucName,
     //                    (SELECT
     //					IFNULL(location_populations.population,0)
     //				FROM
     //					location_populations
     //				WHERE
     //					location_populations.location_id = locations.pk_id
     //
     //				AND DATE_FORMAT(
     //					location_populations.estimation_date,
     //					'%Y'
     //				) = '$yy'
     //			) AS population
     //            FROM
     //                    pilot_districts
     //            INNER JOIN locations ON pilot_districts.district_id = locations.district_id
     //
     //            WHERE
     //            locations.geo_level_id = 6
     //            AND locations.parent_id = $teh_id ) A,
     //            (
     //                            SELECT
     //                                    item_pack_sizes.item_name,
     //                                    items.population_percent_increase_per_year,
     //                                    items.child_surviving_percent_per_year,
     //                                    items.doses_per_year
     //                            FROM
     //                                    item_pack_sizes
     //                            INNER JOIN items ON item_pack_sizes.item_id = items.pk_id
     //                            WHERE
     //                                    item_pack_sizes.pk_id = 6
     //                    ) B";
     //$row = $this->_em->getConnection()->prepare($str_sql);
     //$row->execute();
     //$result = $row->fetchAll();
     $item_pack_sizes = new Model_ItemPackSizes();
     $item_pack_sizes->form_values['pk_id'] = $this->form_values['item'];
     $item = $item_pack_sizes->getProductName();
     $locations = new Model_Locations();
     $locations->form_values['pk_id'] = $teh_id;
     $tehsil_name = $this->view->location_name = $locations->getLocationName();
     $xmlstore = "<chart labelDisplay='rotate' exportEnabled='1' exportAction='Download' bgColor='white' caption='Consumption status of {$item}(Doses) in {$tehsil_name} Stores  and EPI centers  during " . ("(" . date('M Y', strtotime($this->form_values['date'])) . ")") . "'\n        exportFileName='Districts Consumption " . date('Y-m-d H:i:s') . "' yAxisName='Doses' showValues='1' formatNumberScale='0' theme='fint'>";
     $xmlstore .= '<categories>';
     foreach ($result as $data) {
         $coverage = ROUND($data['CONS'] / $data['target'] * 100, 1);
         $xmlstore .= '<category label="' . $data[ucName] . ' (' . $coverage . '%)" />';
     }
     $xmlstore .= '</categories>';
     $xmlstore .= "<dataset seriesname='Consumption' color='0075C2'>";
     foreach ($result as $data) {
         $xmlstore .= "<set value='{$data['CONS']}' />";
     }
     $xmlstore .= "</dataset>";
     $xmlstore .= "<dataset seriesname='Target' parentyaxis='S' renderas='Line' color='f8bd19'>";
     foreach ($result as $data) {
         $xmlstore .= "<set value='{$data['target']}' />";
     }
     $xmlstore .= "</dataset>";
     $xmlstore .= "</chart>";
     return $xmlstore;
 }
예제 #23
0
    public function allLevelCampaign($data_array)
    {
        $identity = App_Auth::getInstance();
        $translate = Zend_Registry::get('Zend_Translate');
        $base_url = Zend_Registry::get('baseurl');
        $user_lvl = $identity->getRoleId();
        $districts_array = false;
        $office = $data_array["level"];
        $province = $data_array["province"];
        $district = $data_array["district"];
        $facility_type = $data_array["facility_type"];
        if (!empty($province)) {
            $locations = new Model_Locations();
            $locations->form_values = array('parent_id' => 10, 'geo_level_id' => 2);
            $provinces_array = $locations->getLocationsByLevel();
        }
        if (!empty($district)) {
            $location = new Model_Locations();
            $location->form_values = array('province_id' => $province, 'geo_level_id' => 4);
            $districts_array = $location->getLocationsByLevelByProvince();
        }
        switch ($user_lvl) {
            case 1:
            case 2:
            case 3:
                $arr_province = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '6' => $translate->translate('District'));
                break;
            case 4:
                $arr_province = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '6' => $translate->translate('District'));
                break;
            case 5:
                $arr_province = array('2' => $translate->translate('Province'));
                break;
            case 6:
                $arr_province = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '6' => $translate->translate('District'));
                break;
            case 7:
                $arr_province = array();
            case 8:
                $arr_province = array('6' => $translate->translate('District'));
                break;
            default:
                $arr_province = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'));
                break;
        }
        if ($facility_type == 3) {
            $arr_province = array('1' => $translate->translate('National'), '2' => $translate->translate('Province'), '6' => $translate->translate('District'));
        }
        ?>

        <?php 
        if ($facility_type != 1 && $facility_type != 2) {
            ?>
            <div class="col-md-2" id="div_office_combo">
                <label class="control-label" for="office"><?php 
            if (empty($office_term)) {
                echo $translate->translate("Office");
            } else {
                echo $office_term;
            }
            ?>
 </label>
                <div class="controls">
                    <select name="office" id="office" class="form-control input-small">
                        <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                        <?php 
            foreach ($arr_province as $key => $value) {
                ?>
                            <option value="<?php 
                echo $key;
                ?>
" <?php 
                if ($key == $office) {
                    ?>
selected=""<?php 
                }
                ?>
 ><?php 
                echo $value;
                ?>
</option>
                        <?php 
            }
            ?>
                    </select>
                </div>
            </div>
        <?php 
        }
        ?>
        <div class="col-md-2" id="div_combo1" <?php 
        if (empty($province)) {
            ?>
 style="display:none;" <?php 
        }
        ?>
>
            <label class="control-label" id="lblcombo1">
                <?php 
        echo $translate->translate("Province");
        ?>
 
                <span class="red">*</span>
            </label>
            <div class="controls">
                <select name="combo1" id="combo1" class="form-control input-small">
                    <?php 
        if ($provinces_array != false) {
            ?>
                        <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                        <?php 
            foreach ($provinces_array as $row) {
                ?>
                            <option value="<?php 
                echo $row['key'];
                ?>
" <?php 
                if (!empty($province) && $row['key'] == $province) {
                    echo 'selected';
                }
                ?>
>
                                <?php 
                echo $row['value'];
                ?>
</option>
                            <?php 
            }
        }
        ?>
                </select>
            </div>
        </div>	
        <div class="col-md-2" id="div_combo2" <?php 
        if ($district == '') {
            ?>
 style="display:none;" <?php 
        }
        ?>
>		
            <label class="control-label" id="lblcombo2">
                <?php 
        echo $translate->translate("District");
        ?>
 
                <span class="red">*</span>
            </label>
            <div class="controls">
                <select name="combo2" id="combo2" class="form-control input-small">
                    <?php 
        if ($districts_array != false) {
            ?>
                        <option value=""><?php 
            echo $translate->translate("Select");
            ?>
</option>
                        <?php 
            foreach ($districts_array as $row) {
                ?>
                            <option value="<?php 
                echo $row['key'];
                ?>
" <?php 
                if (!empty($district) && $row['key'] == $district) {
                    echo 'selected';
                }
                ?>
>
                                <?php 
                echo $row['value'];
                ?>
</option>
                            <?php 
            }
        }
        ?>
                </select>
            </div>
        </div>
        <div class="col-md-1" id="loader" style="display:none;">
            <img src="<?php 
        echo $base_url;
        ?>
/images/loader.gif" style="margin-top:8px; float:left" alt="" />
        </div>
        <?php 
        return true;
    }
예제 #24
0
 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";
 }
예제 #25
0
 public function init()
 {
     //Generate Provinces Combo
     $locations = new Model_Locations();
     $provinces = $locations->getAllProvinces();
     $this->_list["combo1"][''] = "Select";
     $this->_list["combo1_add"][''] = "Select";
     if ($provinces) {
         foreach ($provinces as $row) {
             $this->_list["combo1"][$row['pkId']] = $row['locationName'];
             $this->_list["combo1_add"][$row['pkId']] = $row['locationName'];
         }
     }
     $this->_list["combo2_add"][''] = "Select Province";
     $this->_list["combo2"][''] = "Select Province";
     //Generate Facility Type Combo
     $warehouse = new Model_Warehouses();
     $warehouse->form_values['stakeholder_id'] = 1;
     $wh_types = $warehouse->getAllHealthFacilityTypesByStakeholder();
     $this->_list["facility_type"][''] = "Select";
     if ($wh_types) {
         foreach ($wh_types as $row) {
             $this->_list["facility_type"][$row['pkId']] = $row['warehouseTypeName'];
         }
     }
     $this->_list["year"][''] = "Select";
     $yy = date('Y');
     $end_year = 2014;
     for ($i = $yy; $i >= $end_year; $i = $i - 1) {
         $this->_list["year"][$i] = $i;
     }
     $campaign = new Model_Campaigns();
     $result1 = $campaign->allCampaigns();
     $this->_list["campaign_id"][''] = 'Select';
     foreach ($result1 as $row) {
         $this->_list["campaign_id"][$row['pkId']] = $row['campaignName'];
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             /* case "abc":
                $this->addElement("text", $col, array(
                "attribs" => array("class" => "form-control"),
                "allowEmpty" => true,
                "filters" => array("StringTrim", "StripTags"),
                "validators" => array()
                ));
                $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                break; */
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option"))))));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "district_id_hidden":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
 }
 /**
  * Campaign Management Dashlet
  */
 public function dayWiseCoverageAction()
 {
     $campaign = new Model_Campaigns();
     $this->view->campaigns = $campaign->getAllCampaigns();
     $location = new Model_Locations();
     $this->view->provinces = $location->getProvincesName();
     $wh_data = new Model_WarehousesData();
     $params["level"] = $this->_request->getParam("level");
     $params["loc_id"] = $this->_request->getParam("district");
     $params["prov_id"] = $this->_request->getParam("province");
     $params["camp"] = $this->_request->getParam('camp');
     $wh_data->form_values = $params;
     $xmlstore = $wh_data->dayWiseCoverage();
     $this->view->xmlstore = $xmlstore;
     $this->view->camp = $params["camp"];
     $this->view->prov = $params["prov"];
 }
 public function checkCcmLocationUpdateAction()
 {
     $this->_helper->layout->disableLayout();
     $form_values = $this->_request->getPost();
     $location = new Model_Locations();
     $location->form_values = $form_values;
     $result = $location->checkCcmLocationIdUpdate();
     $this->view->result = $result;
 }
 public function init()
 {
     $auth = App_Auth::getInstance();
     $role_id = $auth->getRoleId();
     if ($auth->getStakeholderId() != 10) {
         $warehouse_id = $auth->getWarehouseId();
     } else {
         $warehouse_id = "";
     }
     $district_id = $auth->getDistrictId($auth->getIdentity());
     $locations = new Model_Locations();
     $locations->form_values['district_id'] = $district_id;
     $result13 = $locations->getAllUcsByCampaignId();
     $this->_list["uc_id"][''] = 'All';
     // $this->_list["uc_add_id"][''] = 'Select';
     //  $this->_list["uc_edit_id"][''] = 'Select';
     foreach ($result13 as $row) {
         //  $this->_list["uc_id"][$row['pkId']] = $row['warehouseName'];
         // $this->_list["uc_add_id"][$row['pkId']] = $row['warehouseName'];
         //  $this->_list["uc_edit_id"][$row['pkId']] = $row['warehouseName'];
     }
     $campaign = new Model_Campaigns();
     if ($role_id == Model_Roles::CAMPAIGN && empty($warehouse_id)) {
         $result1 = $campaign->allCampaigns();
         $this->_list["campaign_id"][''] = 'Select';
         //   $this->_list["campaign_add_id"][''] = 'Select';
         $this->_list["campaign_edit_id"][''] = 'Select';
         foreach ($result1 as $row) {
             $this->_list["campaign_id"][$row['pkId']] = $row['campaignName'];
             //   $this->_list["campaign_add_id"][$row['pkId']] = $row['campaignName'];
             $this->_list["campaign_edit_id"][$row['pkId']] = $row['campaignName'];
         }
     } else {
         $campaign->form_values['district_id'] = $district_id;
         $result1 = $campaign->districtCampaigns();
         $this->_list["campaign_id"][''] = 'Select';
         //  $this->_list["campaign_add_id"][''] = 'Select';
         $this->_list["campaign_edit_id"][''] = 'Select';
         foreach ($result1 as $row) {
             $this->_list["campaign_id"][$row['pkId']] = $row['campaignName'];
             //  $this->_list["campaign_add_id"][$row['pkId']] = $row['campaignName'];
             $this->_list["campaign_edit_id"][$row['pkId']] = $row['campaignName'];
         }
     }
     /* $campaign->form_values['province_id'] = $auth->getProvinceId();
        $result2 = $campaign->getProvinces();
        $this->_list["province_id"][''] = 'Select';
        foreach ($result2 as $row) {
        $this->_list["province_id"][$row['pkId']] = $row['locationName'];
        } */
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "inaccessible_children":
             case "no_of_mobile_teams":
             case "inaccessible_area":
             case "no_of_fixed_teams":
             case "area_in_charge":
             case "no_of_transist_points":
             case "aics_trained":
             case "no_of_teams_trained":
             case "area_mobile_population":
             case "uc_add_id":
             case "campaign_add_id":
             case "target":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             case "date_upec_meeting":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control", 'readonly' => 'true'), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if ($col == "campaign_id") {
             $attribute_class = "form-control";
         } else {
             $attribute_class = "form-control";
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => $attribute_class), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "readiness_uc_id":
             case "uc_edit_id_hidden":
             case "campaign_add_id_hidden":
             case "warehouse_add_id_hidden":
             case "uc_id_hidden":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
 }