<?php
  ///////////////////////////////////////////////////
  //Отключить резервирование
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////
  require_once "utils/chlang_osn.php";

  $title = $TEXT['aut-title-info'];

  require_once "config.php";
  require_once "utils/functions.php";
  require_once "utils/top_film.php";

  if($result2['administrator'] == 0) {puterror2($result2['skin'],$TEXT['error-loginform2']); require_once "utils/bottom_film.php"; exit();}

  $query_body = "SELECT film_id FROM tbl_film WHERE zakazano = '1'";
     $result_body = mysqli_query($dbcnx,$query_body);
     if(!$result_body) {puterror2($result2['skin'],$TEXT['error-tbl26']); require_once "utils/bottom_film.php"; exit();}
       $result_rows = mysqli_num_rows($result_body);
       if($result_rows > 0)
         {
         while($result_body_film= mysqli_fetch_array($result_body))
           {
           $query_zad = mysqli_query($dbcnx,"SELECT DATEDIFF(CURRENT_DATE(),data_zakaza) AS zad_date FROM tbl_film WHERE film_id = ".$result_body_film['film_id']."");
            $res_zad = mysqli_fetch_array($query_zad);

           if($res_zad['zad_date'] > 0)
            {
             $query_upd = mysqli_query($dbcnx,"UPDATE `tbl_film` SET `zakazano`='0', `data_zakaza`='1970-01-01', `user_id_zak`='0' WHERE `film_id`='".$result_body_film['film_id']."' ");
             if(!$query_upd) {puterror2($result2['skin'],$TEXT['error-tbl26']); require_once "utils/bottom_film.php"; exit();}
            }
           }
         }

    echo "<html><head>
          <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=film-reserv-search.php' />
          </head></html>";
require_once "utils/bottom_film.php";
?>