public function getMap() { global $config; $VAdmin = new VAdmin(); if ($config['season_end'] != "closed" && $config['season_start'] != "closed") { $FUmbrella = new FUmbrella(); $data1 = new DateTime('now'); $dt = $data1->format('y-m-d'); $rentUmb = $FUmbrella->loadRentUmbrellaByperiod($dt, $dt); // ho gli ombrelloni occupati $allUmb = $FUmbrella->loadUmbrellas(); // ho tutti gli ombrelloni $map = array(); foreach ($allUmb as $u) { $b = false; $c1 = array_search($u, $allUmb); $umbrella['place'] = $u; foreach ($rentUmb as $r) { $c2 = $r[0] . ',' . $r[1]; if ($c1 == $c2) { $b = true; $umbrella['status'] = 1; } } if (!$b) { $umbrella['status'] = 2; } $map[] = $umbrella; } // calcolo tariffa complessiva $FRate = new FRate(); $rates = $FRate->getRate($dt, $dt); // array di tariffe da considerare $period = date_diff($data1, $data1); $period = $period->format('%d') + 1; // periodo in giorni richiesto dal cliente $map = $this->getPriceUmbrellas($rates, $map, $period); // calcola prezzo $VAdmin->setData('map', $map); $html = $VAdmin->fetch('plant.tpl'); $VAdmin->setData('plant', $html); return $VAdmin->fetch('map_manage.tpl'); } else { return $VAdmin->fetch("admin_season_closed.tpl"); } }
public function rent() { $VRent = new VRent(); global $config; if ($config['season_end'] != "closed" && $config['season_start'] != "closed") { $USession = new USession(); $FUmbrella = new FUmbrella(); $data1 = new DateTime('now'); $dt = $data1->format('y-m-d'); $owner = $USession->getValue('ssn'); $rentUmb = $FUmbrella->loadRentUmbrellaByperiod($dt, $dt); // ho gli ombrelloni occupati $allUmb = $FUmbrella->loadUmbrellas(); // ho tutti gli ombrelloni $map = array(); foreach ($allUmb as $u) { $b = false; $c1 = array_search($u, $allUmb); $umbrella['place'] = $u; foreach ($rentUmb as $r) { $c2 = $r[0] . ',' . $r[1]; if ($c1 == $c2) { $b = true; if ($r[3] == $owner) { $sdate = new DateTime($r[4]); $edate = new DateTime($r[5]); $umbrella['sdate'] = $sdate->format('d-m-y'); $umbrella['edate'] = $edate->format('d-m-y'); $umbrella['price'] = $r[6]; $umbrella['status'] = 0; if ($r[0] == 1) { // se è pagato $umbrella['paid'] = true; } else { $umbrella['paid'] = NULL; } } else { $umbrella['status'] = 1; $umbrella['paid'] = NULL; } } } if (!$b) { $umbrella['status'] = 2; $umbrella['paid'] = NULL; } $map[] = $umbrella; } // calcolo tariffa complessiva $FRate = new FRate(); $rates = $FRate->getRate($dt, $dt); // array di tariffe da considerare $period = date_diff($data1, $data1); $period = $period->format('%a') + 1; // periodo in giorni richiesto dal cliente $map = $this->getPriceUmbrellas($rates, $map, $period); // calcolo il prezzo $VRent->setData('map', $map); $VRent->setData('maxUmb', $config['max']); $html = $VRent->fetch('plant.tpl'); $VRent->setData('plant', $html); return $VRent->fetch('rent.tpl'); } else { return $VRent->fetch('user_season_closed.tpl'); } }