<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  require_once "../utils/chlang.php";

  $title = $TEXT['menu-btn22-film'];
  $button = $TEXT['btn_filter'];
  $action = "add_izd.php";
  $button2 = $TEXT['btn_add'];
  $action2 = "add_izd_run.php";

require_once "../config_a.php";
require_once "../utils/functions.php";
require_once "../utils/top_adm_film.php";

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

if(strlen($_POST['izdatelstvo'])>255) {puterror($result2['skin'],$TEXT['error-izd1']); require_once "../utils/bottom_adm_film.php"; exit();}
$_POST['izdatelstvo'] = rep($_POST['izdatelstvo']);
$izdatelstvo =$_POST['izdatelstvo'];

if(empty($_POST['film_id']))
{
    if(empty($_GET['film_id'])) {puterror($result2['skin'],$TEXT['error-film5']); require_once "../utils/bottom_adm_film.php"; exit();}
    if(strlen($_GET['film_id'])>255) {puterror($result2['skin'],$TEXT['error-film6']); require_once "../utils/bottom_adm_film.php"; exit();}
    $_GET['film_id'] = rep($_GET['film_id']);
    $film_id = $_GET['film_id'];
}
else
{
if(strlen($_POST['film_id'])>255) {puterror($result2['skin'],$TEXT['error-film6']); require_once "../utils/bottom_adm_film.php"; exit();}
$_POST['film_id'] = rep($_POST['film_id']);
$film_id = $_POST['film_id'];
}

?>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="30%">
<form enctype='multipart/form-data' action=<?php echo $action; ?> method=post >
<tr>
<td width="10%" align="left"><input size="20" maxlength="255" type=text name=izdatelstvo title='<?php echo $TEXT['film-izd']; ?>' value='<?php echo $izdatelstvo; ?>'></td>
<td align="left"><input class="button2" type="submit" value='<?php echo $button; ?>' /></td>
<input type=hidden name=film_id value='<?php echo $film_id; ?>' />
</form>
<form enctype='multipart/form-data' action=<?php echo $action2; ?> method=post >
<td align="right"><input class="button2" type="submit" value='<?php echo $button2; ?>' />
<input type=hidden name=film_id value='<?php echo $film_id; ?>' />
</td>
</tr>
</table>
<table align="center" border="1" cellpadding="3" cellspacing="0" width="30%" >
<?php
 if(!empty($_POST['izdatelstvo']))
 {
 $izdatelstvo = " AND LOWER(izdatelstvo) LIKE LOWER('".$_POST['izdatelstvo']."%') ORDER BY izdatelstvo";
 }
    else 
    {
     $izdatelstvo = "ORDER BY izdatelstvo";
    }

     $query_body = "SELECT izd_id, izdatelstvo FROM `tbl_izdatelstvo` WHERE use_prog='2' $izdatelstvo ";
     $result_body = mysqli_query($dbcnx,$query_body);
     if(!$result_body) {puterror($result2['skin'],$TEXT['error-tbl6']); require_once "../utils/bottom_adm_film.php"; exit();}
       $result_rows = mysqli_num_rows($result_body);
       if($result_rows > 0)
         {
           echo "<thead ><tr class='tableheadercat'>
            <td>".$TEXT['film-izd']."</td>
            <td>".$TEXT['global-action']."</td>
                 </tr></thead><tbody id='tab'>";
             while($result_body_izdatelstvo = mysqli_fetch_array($result_body))
               {
               if(empty($_POST['izdatelstvo'])) {$fam = "";}
                else {$fam = "&izdatelstvo=".$_POST['izdatelstvo']."";}

              $izd_id = $result_body_izdatelstvo['izd_id'];
           ?>
           <tr>
              <td><?php echo $result_body_izdatelstvo['izdatelstvo']; ?></td>
              <td><input type="checkbox" name=izdatelstvo[<?php echo $izd_id; ?>] /></td>
                 </tr>
           <?php
               }
           ?>
               </tbody>
               <tfoot>
                <tr class="tableheadercat">
                <td colspan=3 align="right"><?php echo $TEXT['size-count2']; ?> = <?php echo $result_rows; ?></td>
                </tr>
                </tfoot>
              <?php
         }
?>
</table>
</form>
<?php
  require_once "../utils/bottom_adm_film.php";
?>