Ejemplo n.º 1
0
 public function close_season()
 {
     global $config;
     if ($config['season_start'] != "closed" && $config['season_end'] != "closed") {
         $VAdmin = new VAdmin();
         $option = $VAdmin->getDownloadOption();
         $FRent = new FRent();
         $FUser = new FUser();
         $FUmbrella = new FUmbrella();
         $FRate = new FRate();
         $rents = $FRent->getAllRents();
         //$FRent ->deleteAllRents();
         //$FUmbrella->deleteUmbrellas();
         //$FUser->deleteNotUsers();
         //$FRate->deleteAllRates();
         $UFile = new UFile();
         $UFile->saveLine(10, "'closed';", "Includes/config.inc.php");
         $UFile->saveLine(12, "'closed';", "Includes/config.inc.php");
         if ($option) {
             $UFile = new UFile();
             $date = new DateTime($config['season_start']);
             $dir_name = "temp";
             $date = $date->format('Y');
             $name = $config['name'];
             $file_name = "Prenotazioni_" . $name . "_{$date}.txt";
             //$file = $UFile->openFile($dir_name, $file_name , 'w');
             $data = "";
             foreach ($rents as $rent) {
                 $rent_string = $rent->__toString();
                 $data = $data . PHP_EOL . " ----------------------------------------------------- " . PHP_EOL . $rent_string . PHP_EOL;
             }
             //$UFile->writeFile($data,$file);
             //$UFile->closeFile($file);
             //$UFile->downloadFile($dir_name."/".$file_name);
             $UFile->downloadString($data, $file_name);
         }
     }
 }