예제 #1
0
 public static function getIdRegionByName($nameRegion)
 {
     $idRegion = 0;
     $region = self::model()->findByAttributes(array('name' => $nameRegion), array('select' => 'idRegion'));
     if (!isset($region->idRegion)) {
         $Region = new Regions();
         $Region->name = $nameRegion;
         $Region->save();
         $idRegion = $Region->idRegion;
     } else {
         $idRegion = $region->idRegion;
     }
     return $idRegion;
 }
	public function index() {
		ini_set("max_execution_time", "500000");

		$user_groups = Emails::getStateprovincial();
		
	
		foreach ($user_groups as $user_group) {

			$provincial = $user_group["provincial"];
		 $district_or_region = $provincial;
			//if provincial is selected
			if ($district_or_region > 0) 
			{
				
				$region = Regions::getRegionName($district_or_region);
			 $region_name = urlencode($region);
				$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
				$from = $today;


				$this -> getBalances($region_name, $from, $district_or_region);
			}
		}
	
			}//end of index function
예제 #3
0
	public function getBalances($from, $district_or_region, $region_name) #
	{
		$this -> load -> database();
		$start_date = "";
		$number = "";
		@$end_date = date('m/d/y');
		$closing_balance = 0;
		//calls the following function from the vaccines model.
		//the function c=selects data from the vaccines table then stores them in an array
		//the array is stored in the $vaccines variable
		$vaccines = Vaccines::getAll_Minified();

		//gets consumption as per every vaccine
		@$message = "";
		
		foreach ($vaccines as $vaccine) 
		{
			//$district_or_region is the regions id number
			$region_object = Regions::getRegion($district_or_region);
			$name = urlencode($vaccine['Name']);
			$store = urlencode($region_object -> name);
			$closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine -> id, strtotime($end_date));
			$closing_balance_formatted = number_format($closing_balance);

			if ($closing_balance_formatted == 0) 
			{
				//	echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*";
				$this -> get_phones($name,$district_or_region,$store);

			}

		}

	}
예제 #4
0
 public function getDelete($id)
 {
     $regions = Regions::find($id);
     $regions->delete();
     Session::flash('message', 'The records are deleted successfully');
     return Redirect::to('regions');
 }
예제 #5
0
파일: Mapgrid.php 프로젝트: kokkez/shineisp
 public function mapgrid($data)
 {
     $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     if (isset($data['records'])) {
         // Name of the table, useful for the jQuery pager
         $this->view->name = !empty($data['name']) ? $data['name'] : "table_" . rand(1, 50);
         // Index of the table
         $this->view->id = !empty($this->view->fields[0]) && is_numeric($data['records'][0][$this->view->fields[0]]) ? $data['records'][0][$this->view->fields[0]] : "0";
         foreach ($data['records'] as &$record) {
             $name = "";
             $regionid = intval($record['region_id']);
             if ($regionid != 0) {
                 $objregion = Regions::find($regionid);
                 $name = $objregion->name;
             }
             $record['region'] = $name;
         }
         unset($record);
         // All the records
         $this->view->records = $data['records'];
         // If these options are true a link appear for each row in a table
         $this->view->edit = !empty($data['edit']) ? $data['edit'] : false;
         $this->view->delete = !empty($data['delete']) ? $data['delete'] : false;
         // If you need more action use this parameter Array{'url'=>'name'}
         $this->view->actions = !empty($data['actions']) ? $data['actions'] : false;
     } else {
         $this->view->records = "";
     }
     // Path of the template
     return $this->view->render('partials/mapgrid.phtml');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id = NULL)
 {
     $currUser = Auth::user();
     $oCategories = Category::all();
     $oCity = Cities::all();
     $oVacancy = null;
     if ($id > 0) {
         $oVacancy = Vacancy::find($id);
     }
     foreach ($oCategories as $item) {
         $aCategories[$item->id] = $item->name;
     }
     if (Auth::user()->is_admin == 0) {
         $aCompanies = Companies::where('user_id', '=', $currUser->id)->get();
     } else {
         $aCompanies = Companies::all();
     }
     foreach ($aCompanies as $item) {
         $aCompany[$item->id] = $item->name;
     }
     $oQuery = Regions::join('country', 'country.id', '=', 'country_id')->select('regions.id as id', 'regions.name', 'country.name as country_name', 'country.id as country_id');
     if ($oRegions = $oQuery->get()) {
     }
     foreach ($oRegions as $item) {
         $aRegions[$item->country_name] = array();
         $aCity = Cities::where('region_id', '=', $item->id)->get();
         foreach ($aCity as $city) {
             $aRegions[$item->name][$city->id] = $city->name;
         }
     }
     if ($currUser->is_admin == 0 && (empty($oVacancy) === false && $oVacancy->user_id != $currUser->id)) {
         return Redirect::route('vacancy-list', array('user_id' => $currUser->id));
     }
     return View::make('/vacancy/edit', array('currUser' => $currUser, 'aCategories' => $aCategories, 'aCompany' => $aCompany, 'aRegions' => $aRegions, 'oVacancy' => $oVacancy, 'id' => $id));
 }
예제 #7
0
 public function run()
 {
     $country = Country::model()->findAll(['order' => 'country_order']);
     $region = Regions::model()->findAllByAttributes(['id_country' => $this->model['countries']]);
     $city = City::model()->findAllByAttributes(['id_region' => $this->model['region']]);
     $this->render('main', ['model' => $this->model, 'title' => $this->title, 'prefix_name' => $this->prefixName, 'country' => $country, 'region' => $region, 'city' => $city]);
 }
예제 #8
0
 public function index()
 {
     $final_html = "";
     $css = "<style type='text/css'>\n\t\ttd{\n\t\t\tborder:1px solid black; \n\t\t}\n\t\t.no_border{\n\t\t\tborder: none;\n\t\t} \n\t\t.regionals td{\n\t\t\tmin-width:110px;\n\t\t}\n\t\tth, .title{\n\t\t\tbackground:#DDD;\n\t\t\tborder:none;\n\t\t\tpadding:0;\n\t\t\tmargin:0;\n\t\t}\n\t\t\n\t\t</style>";
     $final_html .= $css;
     $html_title = "<img src='Images/coat_of_arms.png' style='position:absolute;  width:160px; top:0px; right:0px; margin-bottom:-100px;margin-right:-100px;'></img>";
     $html_title .= "<h2 style='text-align:center; text-decoration:underline;'>Republic of Kenya</h2>";
     $html_title .= "<h3 style='text-align:center; text-decoration:underline;'>Ministry of Public Health and Sanitation</h3>";
     $html_title .= "<h1 style='text-align:center; text-decoration:underline;'>MONTHLY VACCINE STOCK MANAGEMENT REPORT</h1>";
     //echo "$html_title";
     $final_html .= $html_title;
     $final_html .= $this->create_national_report();
     $this->load->library('mpdf');
     $mpdf = new mPDF('', 'A4-L', 0, '', 15, 15, 16, 16, 9, 9, '');
     $mpdf->SetTitle('MONTHLY VACCINE STOCK MANAGEMENT REPORT');
     $mpdf->WriteHTML($final_html);
     $regions = Regions::getAllRegions();
     foreach ($regions as $region) {
         $regional_report = $this->create_regional_reports($region);
         $mpdf->AddPage();
         $mpdf->WriteHTML($regional_report);
         //
     }
     //echo $final_html
     $mpdf->Output('Summaries/Monthly_Summary.pdf', 'F');
     $this->email_reports();
 }
예제 #9
0
 public function plot($vaccine)
 {
     // Initiate class
     $xml = new MY_Xml_writer();
     $xml->setRootName('markers');
     $xml->initiate();
     $year = date('U');
     $mapped_districts = Districts::getMappedDistricts();
     $mapped_regions = Regions::getAllRegions();
     foreach ($mapped_districts as $mapped_district) {
         //$stock = Disbursements::getDistrictStockAtHand($mapped_district->id,$vaccine);
         $stock = Disbursements::getDistrictPeriodBalance($mapped_district->id, $vaccine, $year);
         $xml->startBranch('marker', array('name' => $mapped_district->name . " District Store", 'lat' => $mapped_district->latitude, 'lng' => $mapped_district->longitude, 'facility_id' => $mapped_district->id, 'stock' => $stock));
         // start branch 1-1
         $xml->endBranch();
     }
     foreach ($mapped_regions as $mapped_region) {
         // $stock = Disbursements::getRegionalStockAtHand($mapped_region->id,$vaccine);
         $stock = Disbursements::getRegionalPeriodBalance($mapped_region->id, $vaccine, $year);
         $xml->startBranch('marker', array('name' => $mapped_region->name, 'lat' => $mapped_region->latitude, 'lng' => $mapped_region->longitude, 'facility_id' => $mapped_region->id, 'stock' => $stock));
         // start branch 1-1
         $xml->endBranch();
     }
     //$stock = Disbursements::getNationalStockAtHand($vaccine);
     $stock = Disbursements::getNationalPeriodBalance($vaccine, $year);
     $xml->startBranch('marker', array('name' => "Central Vaccine Store", 'lat' => "-1.304507", 'lng' => "36.806191", 'facility_id' => 0, 'stock' => $stock));
     // start branch 1-1
     $xml->endBranch();
     // Print the XML to screen
     $xml->getXml(true);
 }
예제 #10
0
 public function dashboard($dashboard = "country_stock_view")
 {
     $year = date('Y');
     $data['title'] = "Home Page::Dashboards";
     $data['content_view'] = "home_view";
     $data['vaccines'] = Vaccines::getAll();
     $data['styles'] = array("jquery-ui.css", "tab.css");
     $data['script_urls'] = array("http://maps.google.com/maps/api/js?sensor=false");
     $data['scripts'] = array("FusionCharts/FusionCharts.js", "markerclusterer/src/markerclusterer.js", "markerclusterer/src/jsapi.js", "jquery-ui.js", "tab.js");
     $data['dashboard'] = $dashboard;
     $from = date('U');
     $national_balances = array();
     $regional_balances = array();
     $regional_stores = Regions::getAllRegions();
     //Get Statistics for each of the vaccines.
     foreach ($data['vaccines'] as $vaccine) {
         $national_balances[$vaccine->id] = array(Disbursements::getNationalPeriodBalance($vaccine->id, $from), Regional_Populations::getNationalPopulation(date('Y')));
         foreach ($regional_stores as $regional_store) {
             $regional_balances[$vaccine->id][$regional_store->id] = array(Disbursements::getRegionalPeriodBalance($regional_store->id, $vaccine->id, $from), Regional_Populations::getRegionalPopulation($regional_store->id, date('Y')));
         }
     }
     $data['national_stocks'] = $national_balances;
     $data['regional_stocks'] = $regional_balances;
     $data['regional_stores'] = $regional_stores;
     $data['link'] = "home";
     $this->load->view('template', $data);
 }
예제 #11
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Regions the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Regions::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #12
0
 public function getEdit($id)
 {
     $data = provinces::find($id);
     $regions = Regions::all();
     $country = Countries::where('region_id', '=', $data->country->region->id)->get();
     $options = array('data' => $data, 'regions' => $regions, 'country' => $country);
     return View::make('home/dashboard', array())->nest('content', 'provinces/edit', $options);
 }
예제 #13
0
 public static function updateRegion($regionID, $regionData)
 {
     global $db;
     // check if exists
     if (Regions::getRegion($regionID)) {
         return $db->update('regions', $regionData, ['id' => $regionID]);
     }
     return -1;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('regions')->delete();
     Regions::create(array('id' => 1, 'name' => 'Kiev', 'description' => 'Kiev is the capital and largest city of Ukraine, located in the north central part of the country on the Dnieper River.', 'country_id' => 1));
     Regions::create(array('id' => 2, 'name' => 'Kharkov', 'description' => 'Kharkov, is the second-largest city of Ukraine. Located in the north-east of the country, it is the largest city of the Slobozhanshchyna historical region.', 'country_id' => 1));
     Regions::create(array('id' => 3, 'name' => 'Odessa', 'description' => 'Odessa is the fourth largest city in Ukraine. The city is a major seaport and transportation hub located on the northwestern shore of the Black Sea.', 'country_id' => 1));
     $this->command->info('Regions table seeded!');
 }
예제 #15
0
 public function download()
 {
     $this->load->database();
     $valid = $this->validate_form();
     if ($valid) {
         $data_buffer = "\n\t\t\t<style>\n\t\t\ttable.data-table {\n\t\t\ttable-layout: fixed;\n\t\t\twidth: 700px;\n\t\t\tborder-collapse:collapse;\n\t\t\tborder:1px solid black;\n\t\t\t}\n\t\t\ttable.data-table td, th {\n\t\t\twidth: 100px;\n\t\t\tborder: 1px solid black;\n\t\t\t}\n\t\t\t.leftie{\n\t\t\t\ttext-align: left !important;\n\t\t\t}\n\t\t\t.right{\n\t\t\t\ttext-align: right !important;\n\t\t\t}\n\t\t\t.center{\n\t\t\t\ttext-align: center !important;\n\t\t\t}\n\t\t\t</style> \n\t\t\t";
         $start_date = $this->input->post("start_date");
         $end_date = $this->input->post("end_date");
         $data_buffer .= "<table class='data-table'>";
         $data_buffer .= $this->echoTitles();
         $district_or_region = $this->session->userdata('district_province_id');
         $identifier = $this->session->userdata('user_identifier');
         $population = 0;
         $opening_balance = 0;
         $closing_balance = 0;
         $sql_consumption = "";
         $store = "";
         $vaccines = Vaccines::getAll_Minified();
         foreach ($vaccines as $vaccine) {
             if ($identifier == 'provincial_officer') {
                 $region_object = Regions::getRegion($district_or_region);
                 $store = $region_object->name;
                 $population = Regional_Populations::getRegionalPopulation($district_or_region, date('Y'));
                 $opening_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date));
                 $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
                 $owner = "R" . $district_or_region;
                 $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_Region = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
             } else {
                 if ($identifier == 'district_officer') {
                     $district_object = Districts::getDistrict($district_or_region);
                     $store = $district_object->name;
                     $population = District_Populations::getDistrictPopulation($district_or_region, date('Y'));
                     $opening_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($start_date));
                     $closing_balance = Disbursements::getDistrictPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
                     $owner = "D" . $district_or_region;
                     $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_District = '" . $district_or_region . "' and Owner = '" . $owner . "' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
                 } else {
                     if ($identifier == 'national_officer') {
                         $store = "Central Vaccines Store";
                         $population = Regional_Populations::getNationalPopulation(date('Y'));
                         $opening_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($start_date));
                         $closing_balance = Disbursements::getNationalPeriodBalance($vaccine->id, strtotime($end_date));
                         $sql_consumption = "select (SELECT date_format(max(str_to_date(Date_Issued,'%m/%d/%Y')),'%d-%b-%Y')  FROM `disbursements` where Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and str_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "' and total_stock_balance>0)as last_stock_count,(SELECT sum(Quantity)FROM `disbursements` where Issued_By_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_issued,(SELECT sum(Quantity) FROM `disbursements` where Issued_To_National = '0' and Owner = 'N0' and str_to_date(Date_Issued,'%m/%d/%Y') between str_to_date('" . $start_date . "','%m/%d/%Y') and\nstr_to_date('" . $end_date . "','%m/%d/%Y') and Vaccine_Id = '" . $vaccine->id . "')as total_received";
                     }
                 }
             }
             $query = $this->db->query($sql_consumption);
             $vaccine_data = $query->row();
             $monthly_requirement = ceil($vaccine->Doses_Required * $population * $vaccine->Wastage_Factor / 12);
             $data_buffer .= "<tr><td style='text-align:left;'>" . $vaccine->Name . "</td><td class='right'>" . number_format($opening_balance + 0) . "</td><td  class='right'>" . number_format($vaccine_data->total_received + 0) . "</td><td class='right'>" . number_format($vaccine_data->total_issued + 0) . "</td><td class='right'>" . number_format($closing_balance - ($opening_balance + $vaccine_data->total_received - $vaccine_data->total_issued) + 0) . "</td><td class='right'>" . number_format($closing_balance + 0) . "</td><td class='center'>" . number_format($closing_balance / $monthly_requirement, 1) . "</td><td class='center'>" . $vaccine_data->last_stock_count . "</td></tr>";
         }
         $data_buffer .= "</table>";
         $this->generatePDF($data_buffer, $start_date, $end_date, $store);
     } else {
         $this->view_transactions_interface();
     }
 }
예제 #16
0
	public function edit_region($code) {
		$region = Regions::getRegion($code);
		$data['region_populations'] = Regional_Populations::getAllForRegion($code);
		$data['region'] = $region;
		$data['title'] = "Region Management::Edit ".$region->name;
		$data['module_view'] = "add_region_view";
		//$data['quick_link'] = "new_region"; 
		$this -> base_params($data);
	}
예제 #17
0
 public function getEdit($id)
 {
     $data = guest::find($id);
     $regions = Regions::all();
     $country = Countries::where('region_id', '=', $data->city->province->country->region->id)->get();
     $province = Provinces::where('country_id', '=', $data->city->province->country->id)->get();
     $city = Cities::where('province_id', '=', $data->city->province->id)->get();
     $options = array('data' => $data, 'regions' => $regions, 'country' => $country, 'province' => $province, 'city' => $city, 'identity' => Identity::all(), 'job' => Jobs::all());
     return View::make('home/dashboard', array())->nest('content', 'guest/edit', $options);
 }
예제 #18
0
 public function getIndex()
 {
     $hotel = Hotel::find(1);
     $regions = Regions::all();
     $country = Countries::where('region_id', '=', $hotel->city->province->country->region->id)->get();
     $province = Provinces::where('country_id', '=', $hotel->city->province->country->id)->get();
     $city = Cities::where('province_id', '=', $hotel->city->province->id)->get();
     $options = array('hotel' => $hotel, 'regions' => $regions, 'country' => $country, 'province' => $province, 'city' => $city);
     return View::make('home/dashboard', array())->nest('content', 'hotel/profile', $options);
 }
예제 #19
0
 public function getEdit($id)
 {
     $data = employee::find($id);
     $regions = Regions::all();
     $country = Countries::where('region_id', '=', $data->city->province->country->region->id)->get();
     $province = Provinces::where('country_id', '=', $data->city->province->country->id)->get();
     $city = Cities::where('province_id', '=', $data->city->province->id)->get();
     $options = array('data' => $data, 'regions' => $regions, 'country' => $country, 'province' => $province, 'city' => $city, 'position' => $this->Position());
     return View::make('home/dashboard', array())->nest('content', 'employee/edit', $options);
 }
예제 #20
0
	public function edit_user($id) {
		$user = User::getUser($id);
		$data['user'] = $user;
		$data['title'] = "User Management::Edit " . $user -> Full_Name . "'s Details";
		$data['title'] = "User Management::Add New User";
		$data['module_view'] = "add_user_view";
		$data['groups'] = User_Groups::getAllGroups();
		$data['districts'] = Districts::getAllDistricts();
		$data['regions'] = Regions::getAllRegions();
		$this -> base_params($data);
	}
예제 #21
0
파일: Regions.php 프로젝트: kokkez/shineisp
 public function getAll($countrycode)
 {
     $this->authenticate();
     if (empty($countrycode)) {
         throw new Shineisp_Api_Exceptions(400002, ":: 'countrycode' field");
         exit;
     }
     $states = Regions::fildAllFromCountryCode($countrycode);
     if (empty($states)) {
         return false;
     }
     return $states;
 }
 public function fill_timetable($regions = array(), $couriers = array())
 {
     // Получаем массив регионов
     $reg = new Regions();
     $regions = $reg->find_regions();
     // Массив курьеров
     $cour = new Couriers();
     $couriers = $cour->find_all_couriers();
     // С какого времени хотим заполнить
     $start_data = mktime(0, 0, 0, 6, 1, 2015);
     // По сегодняшний день
     $today = time() + 86400;
     //Пробегаем по всем дням интервала
     for ($i = $start_data; $i < $today; $i = $i + 86400) {
         //Формируем поездки для каждого курьера
         for ($j = 0; $j < count($couriers); $j++) {
             //Получаем данные о прибытии с последней поездки
             $last = $this->last_trip($couriers[$j]['id']);
             $last = $last[0]['date_back'];
             $current = date('Y-m-d', $i);
             //Если курьер прибыл из поездки отправляем его снова в случайный регион
             if ($last < $current) {
                 $count_reg = count($regions) - 1;
                 $numb = rand(0, $count_reg);
                 $id_region = $regions[$numb]['id'];
                 $id_courier = $couriers[$j]['id'];
                 $date_out = $i;
                 $date_in = $i + $regions[$numb]['days_there'] * 86400;
                 $date_back = $date_in + $regions[$numb]['days_back'] * 86400;
                 $date_out = date('Y-m-d', $date_out);
                 $date_in = date('Y-m-d', $date_in);
                 $date_back = date('Y-m-d', $date_back);
                 $this->add_trip($id_region, $id_courier, $date_out, $date_in, $date_back);
             }
         }
     }
 }
예제 #23
0
	public function send_reports() {
		//Create the National report and save it!
		$national_data = $this -> create_national_report();
		$name = 'Country_Vaccine_Status_Summary.xls';
		$this -> write_file($name, $national_data);
		//Create the Regional Reports and Save them
		$regions = Regions::getAllRegions();
		foreach ($regions as $region) {
			$region_data = $this -> create_regional_reports($region);
			$name = $region -> name . "_Vaccine_Status_Summary.xls";
			$this -> write_file($name, $region_data);
		}
		//Email all the reports
		$this -> email_reports();
	}
예제 #24
0
파일: Regions.php 프로젝트: kokkez/shineisp
 public function isValid($value, $context = null)
 {
     $value = intval($value);
     if ($value != 0) {
         $countryid = intval($context['country_id']);
         if ($countryid == 0) {
             $this->_error(self::COUNTRYIDEMPTY);
             return false;
         }
         $region = Regions::find($value);
         if ($region->country_id != $countryid) {
             $this->_error(self::REGIONIDNOTVALID);
             return false;
         }
     }
     return true;
 }
예제 #25
0
 /**
  * indexAction
  * Create the User object and get all the records.
  * @return unknown_type
  */
 public function getallAction()
 {
     $result = array();
     $result['success'] = false;
     $id = $this->getRequest()->getParam('country_id');
     $id = intval($id);
     if ($id == 0) {
         $result['message'] = 'CoutryId not found';
         echo json_encode($result);
         exit;
     }
     $result['success'] = true;
     $regions = Regions::findAll($id);
     $result['total'] = count($regions);
     if ($result['total'] > 0) {
         array_unshift($regions, array('region_id' => 0, 'name' => '-- Select Regions --'));
     }
     $result['rows'] = $regions;
     echo json_encode($result);
     exit;
 }
예제 #26
0
 /**
  * Show the GET form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id = NULL)
 {
     $currUser = Auth::user();
     $oCountries = Countries::all();
     $oRegions = Regions::all();
     $aCity = NULL;
     foreach ($oCountries as $item) {
         $aCountries[$item->name] = array();
         $aRegions = Regions::where('country_id', '=', $item->id)->get();
         foreach ($aRegions as $region) {
             $aCountries[$item->name][$region->id] = $region->name;
         }
     }
     if ($id > 0) {
         $aCity = Cities::find($id);
     }
     if ($currUser->is_admin == 0) {
         return Redirect::route('user-dashboard', array());
     }
     return View::make('/city/edit', array('aCity' => $aCity, 'aCountries' => $aCountries, 'oRegions' => $oRegions, 'currUser' => $currUser, 'id' => $id));
 }
예제 #27
0
	public static function getNationalPopulation($year) {
		$regions = Regions::getAllRegions();
		$total_population = 0;
		foreach ($regions as $region) {
			$region_id = $region->id;
			$query = Doctrine_Query::create() -> select("population") -> from("regional_populations") -> where("region_id = '$region_id' and year='$year'");
			$population_object = $query -> execute(array(), Doctrine::HYDRATE_ARRAY);
			if (isset($population_object[0])) {
				$total_population += str_replace(',', '', $population_object[0]['population']);
			} else {
				$query = Doctrine_Query::create() -> select("population") -> from("regional_populations") -> where("region_id = '$region_id'") -> OrderBy("id desc") -> limit(0);
				$population_object = $query -> execute(array(), Doctrine::HYDRATE_ARRAY); 
				if (isset($population_object[0])) {
					$total_population += str_replace(',', '', $population_object[0]['population']);
				} else {
					$total_population += 0;
				}
			}
		}
		return $total_population;
	}
 public function actionResidence()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         throw new CHttpException('403');
     }
     if ($_POST) {
         $id = (int) $_POST['id'];
         $this_model = $_POST["who_this"];
         $who_model = $_POST['who_model'];
         $prefix = $_POST['prefix'];
         $model = !empty($_POST['model']) && class_exists($_POST['model']) ? new $_POST['model']() : '';
         $data = [];
         $empty = '';
         $js_param_two = 'region';
         if ($who_model == 'region') {
             $js_param_two = 'city';
             $regions = Regions::model()->findAllByAttributes(['id_' . $this_model => $id]);
             $data = CHtml::listData($regions, 'id_region', 'region_name_ru');
             $empty = 'Select region';
         } elseif ($who_model == 'city') {
             $js_param_two = '';
             $cities = City::model()->findAllByAttributes(['id_' . $this_model => $id]);
             $data = CHtml::listData($cities, 'id_city', 'city_name_ru');
             $empty = 'Select city';
         }
         $url = $this->createUrl('/residence/residence/residence');
         $name = $who_model;
         if ($model && $model instanceof CActiveRecord && isset($model->{$who_model})) {
             $name = CHtml::activeName($model, $who_model);
         } elseif ($prefix) {
             $name = $prefix . "[{$who_model}]";
         }
         if ($model && $model instanceof CActiveRecord && isset($model->{$who_model})) {
             $label = $model->getAttributeLabel($who_model);
         } else {
             $label = Yii::t('choose-city', $who_model);
         }
         $this->renderPartial('residence.views.widget._select_block', ['attribute' => $who_model, 'label' => $label, 'name' => $name, 'data' => $data, 'onChange' => "showCities{$prefix}(\$(this),'{$js_param_two}','{$who_model}','{$url}')", 'empty' => $empty]);
     }
 }
예제 #29
0
 public function getBalances($from, $district_or_region, $region_name)
 {
     $this->load->database();
     $start_date = "";
     $number = "";
     @($end_date = date('m/d/y'));
     $closing_balance = 0;
     $vaccines = Vaccines::getAll_Minified();
     //gets consumption as per every vaccine
     @($message = "");
     foreach ($vaccines as $vaccine) {
         $region_object = Regions::getRegion($district_or_region);
         $name = urlencode($vaccine['Name']);
         $store = urlencode($region_object->name);
         $closing_balance = Disbursements::getRegionalPeriodBalance($district_or_region, $vaccine->id, strtotime($end_date));
         $closing_balance_formatted = number_format($closing_balance);
         if ($closing_balance_formatted == 0) {
             //	echo @$message.= "VACCINES+STOCK+OUTS++AT++%0A+*+DVI+-+SMT*";
             $this->get_phones($name, $district_or_region, $store);
         }
     }
 }
예제 #30
0
<?if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){
	$Cart = new Cart();
	$Region = new Regions();
	$City = new Citys();
	$DeliveryService = new DeliveryService();
	$Delivery = new Delivery();
	$Orders = new Orders();
	$Address = new Address();
	/*$Orders->Add($_POST['user_number']);*/
	if(isset($_POST['action'])){
		switch($_POST['action']){
			case "GetRegionsList":
				$Region->SetList();
				foreach($Region->list as $region){
					if($region['region'] != ''){?>
						<li class="mdl-menu__item" data-value="<?php 
echo $region['id_city'];
?>
"><?php 
echo $region['region'];
?>
</li>
					<?}
				}
				break;
			case "GetCitiesList":
				$res = $City->SetFieldsByInput($_POST['input']);
				foreach($res as $city){
					if($city['name'] != ''){?>
						<li class="mdl-menu__item" data-value="<?php 
echo $city['id_city'];