Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
 function write_xml()
 {
     // Load XML writer library
     $this->load->library('MY_Xml_writer');
     // Initiate class
     $xml = new MY_Xml_writer();
     $xml->setRootName('my_store');
     $xml->setXmlVersion('1.0');
     $xml->setCharSet('UTF-8');
     $xml->setIndentStr(' ');
     $xml->initiate();
     // Start branch 1
     $xml->startBranch('cars');
     // Set branch 1-1 and its nodes
     $xml->startBranch('car', array('country' => 'usa'));
     // start branch 1-1
     $xml->addNode('make', 'Ford');
     $xml->addNode('model', 'T-Ford', array(), true);
     $xml->endBranch();
     // Set branch 1-2 and its nodes
     $xml->startBranch('car', array('country' => 'Japan'));
     // start branch
     $xml->addNode('make', 'Toyota');
     $xml->addNode('model', 'Corolla', array(), true);
     $xml->endBranch();
     // End branch 1
     $xml->endBranch();
     // Start branch 2
     $xml->startBranch('bikes');
     // start branch
     // Set branch 2-1  and its nodes
     $xml->startBranch('bike', array('country' => 'usa'));
     // start branch
     $xml->addNode('make', 'Harley-Davidson');
     $xml->addNode('model', 'Soft tail', array(), true);
     $xml->endBranch();
     // End branch 2
     $xml->endBranch();
     // Print the XML to screen
     $xml->getXml(true);
 }