Beispiel #1
0
 public function modifyRent()
 {
     global $config;
     // recupero dati
     $view = new VAdmin();
     $row = intval($view->getRow());
     // fila
     $number = intval($view->getNumber());
     // numero
     $sdate = $view->getStartDate();
     // data di inizio
     $edate = $view->getEndDate();
     // data di inizio
     $price = intval($view->getPriceRent());
     // prezzo
     $paid = $view->is_paid();
     // true o false
     $flag = true;
     $FRate = new FRate();
     try {
         $sdate = new DateTime($sdate);
     } catch (Exception $e) {
         $flag = false;
     }
     if ($flag) {
         $FUmbrella = new FUmbrella();
         $umb = $FUmbrella->loadUmbrella($row, $number);
         if (!$umb) {
             $flag = false;
         }
     }
     if ($flag) {
         //$seasonRates = $FRate->getSeasonRates(); // tariffa stagionale
         $seasonStart = new DateTime($config['season_start']);
         $seasonEnd = new DateTime($config['season_end']);
         if ($sdate < $seasonStart || $edate > $seasonEnd) {
             $flag = false;
         }
     }
     if ($flag) {
         $Frent = new FRent();
         if ($Frent->modifyRent($umb, $sdate, $price, $paid)) {
             echo '0';
         } else {
             echo 'error';
         }
     } else {
         echo 'error';
     }
 }