public function rentList() { $session = new USession(); $ssn = $session->getValue('ssn'); $FRent = new FRent(); $rate_array = $FRent->getRentBySSN($ssn); return $this->show("rent_list", $rate_array); }
public function dataManagement() { global $config; $FUser = new FUser(); $FRent = new FRent(); $siteName = $config['name']; $max = $config['max']; $clientList = $FUser->loadUsersAndClients(); $gain = $FRent->getGain(); $egain = $FRent->getEstimatedGain(); $ngain = $FRent->getUnpaidGain(); $VAdmin = new VAdmin(); if ($config['season_end'] == "closed" && $config['season_start'] == "closed") { $season_data = ""; $seasonStart = "Chiusa"; $seasonEnd = "Chiusa"; } else { $season_data = $VAdmin->fetch("close_season_mod.tpl"); $seasonStart = $config['season_start']; $seasonEnd = $config['season_end']; } $VAdmin->setData('max', $max); $VAdmin->setData('ngain', $ngain); $VAdmin->setData('egain', $egain); $VAdmin->setData('gain', $gain); $VAdmin->setData('siteName', $siteName); $VAdmin->setData('sdate', $seasonStart); $VAdmin->setData('edate', $seasonEnd); $VAdmin->setData('season_mod', $season_data); $VAdmin->setData('client_list', $clientList); return $VAdmin->fetch('data_manage.tpl'); }
private function getRateArray($rates, $period, $start, $owner, $umbrella) { $pe = $period - 1; $FRent = new FRent(); $ratesForClient = array(); foreach ($rates as $r) { $ok = false; $ratePeriod = $r->getPeriod(); while (!$ok) { if ($period - $ratePeriod >= 0) { $ratesForClient[] = $r; $period = $period - $ratePeriod; } else { $ok = true; } } } // fine foreach $price = 0; foreach ($ratesForClient as $c) { $price = $price + $c->getPrice(); } $startDate = $start; $t = clone $startDate; $p = new DateInterval('P' . $pe . 'D'); // periodo della tariffa $endDate = $t->add($p); $rent = new DRent($owner, $umbrella, false, $price, $startDate, $endDate); $FRent->saveRent($rent); }
public function deleteRent() { global $config; // lettura valori $view = new VAdmin(); $row = intval($view->getRow()); // fila $number = intval($view->getNumber()); // numero $sdate = $view->getStartDate(); // data di inizio $edate = $view->getEndDate(); // data di fine $periodsdate = $view->getPeriodSdate(); $periodedate = $view->getPeriodEdate(); $flag = true; $FRate = new FRate(); $FRent = new FRent(); $season = false; if ($periodsdate == 'STAGIONE' && $periodedate == 'STAGIONE') { //$seasonRates = $FRate->getSeasonRates(); // tariffa stagionale $periodsdate = new DateTime($config['season_start']); $periodedate = new DateTime($config['season_end']); $season = true; } else { try { $periodsdate = new DateTime($periodsdate); $periodedate = new DateTime($periodedate); } catch (Exception $e) { $flag = false; } } if ($flag) { try { $sdate = new DateTime($sdate); $edate = new DateTime($edate); } catch (Exception $e) { $flag = false; } } if ($flag) { $Fumb = new FUmbrella(); $umb = $Fumb->loadUmbrella($row, $number); if (!$umb) { $flag = false; } } if ($flag) { if ($FRent->is_Rent($umb, $sdate) == 0) { $flag = false; } } if ($flag) { $bool = $FRent->deleteRent($umb, $sdate); // cancello if (!$bool) { echo 'error'; } else { $numRent = count($FRent->getRentByPeriod($periodsdate, $periodedate, $umb)); if ($numRent > 0) { echo '0'; } else { /*$season = false; if($sdate == $seasonStart && $edate== $seasonEnd) // se la tariffa è stagionale $season = true;*/ $price = $this->getPrice($umb, $periodsdate, $periodedate, $season); // calcolo il prezzo dell'ombrellone $lenght = strlen("{$price}"); echo "1{$lenght}" . "{$price}"; } } } else { echo 'error'; } // da modificare la risposta }