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

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

  $title = $TEXT['book-title'];
  $button = $TEXT['btn_add'];
  $action = "add.php";
  $visible = "checked";

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

if($result2['administrator'] == 0) {puterror($result2['skin'],$TEXT['error-loginform2']); require_once "../utils/bottom_adm.php"; exit();}
if(empty($_GET['book_name']) && !empty($_POST['book_name']))
 {
 if(strlen($_POST['book_name'])>255) {puterror($result2['skin'],$TEXT['error-book2']); require_once "../utils/bottom_adm.php"; exit();}
 $book_name = $_POST['book_name'];
 }
  elseif(empty($_POST['book_name']) && !empty($_GET['book_name']))
  {
   if(strlen($_GET['book_name'])>255) {puterror($result2['skin'],$TEXT['error-book2']); require_once "../utils/bottom_adm.php"; exit();}
   $book_name = $_GET['book_name'];
  }
  else {$book_name = "";}
?>
<script type="text/javascript" language="JavaScript" src="../lang/<?php echo $lang; ?>/calendar.js"></script>
<form name='book' enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table align="center" width="98%" border="0">
<tr>
<td width="42%" valign="top">
<fieldset>
    <legend align="left" title="<?php echo $TEXT['book-fldset1-tit']; ?>"><?php echo $TEXT['book-fldset1']; ?></legend>
<table align="left" width="100%" border="0">
<tr><td class="inform"><?php echo $TEXT['book-name']; ?>:</td><td><input size=40 maxlength=127 type=text name=book_name value="<?php echo $book_name; ?>"/></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-isbn']; ?>:</td><td><input size=40 maxlength=127 type=text name=isbn /></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-num']; ?>:</td><td><input size=3 maxlength=3 type=text name=book_num /></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-opis']; ?>:</td><td><textarea cols="38" rows="5" name=opisanie ></textarea></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-oglavl']; ?>:</td><td><textarea cols="38" rows="5" name=oglavlenie ></textarea></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-show5']; ?>:</td><td><input type=checkbox name=zakupka /></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-show']; ?>:</td><td><input type=checkbox name=visible <?php echo $visible; ?> /></td></tr>
</table>
</fieldset>
</td>
<td width="42%" valign="top">
<fieldset>
    <legend align="left" title="<?php echo $TEXT['book-fldset2-tit']; ?>"><?php echo $TEXT['book-fldset2']; ?></legend>
<table align="right" width="100%" border="0">
<tr><td class="inform"><?php echo $TEXT['book-data']; ?>:</td><td><input size=4 maxlength=4 type=text name=data_izdaniya /></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-data2']; ?>:</td><td><input size=10 maxlength=10 type=text name=data_postupleniya />
<script type="text/javascript" language="JavaScript">
	var o_cal = new tcal ({
		// form name
		'formname': 'book',
		// input name
		'controlname': 'data_postupleniya'
	});
	</script></td></tr>
<tr><td  class="inform"><a class="inform" href='../zhanr/addform.php' target="_blank"><?php echo $TEXT['book-zhanr']; ?>:</a></td><td>
    <select name="zhanr_id">
    <?php
        $query10 = "SELECT * FROM `tbl_zhanr`ORDER BY `zhanr` ";
          $result10 = mysqli_query($dbcnx,$query10);
            if (!$result10) {puterror($result2['skin'],$TEXT['error-tbl14']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_zhanr = mysqli_fetch_array($result10))
                {
                 $chk_zhanr = "<option value=".$result_zhanr['zhanr_id'].">".$result_zhanr['zhanr']."";
                 echo $chk_zhanr;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../seriya/addform.php' target="_blank"><?php echo $TEXT['ser-title']; ?>:</a></td><td>
    <select name="ser_id">
    <?php
        $queryser = "SELECT * FROM `tbl_seriya` ORDER BY `seriya` ";
          $resultser = mysqli_query($dbcnx,$queryser);
            if (!$resultser) {puterror($result2['skin'],$TEXT['error-tbl21']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_seriya = mysqli_fetch_array($resultser))
                {
                 $chk_seriya = "<option value=".$result_seriya['ser_id'].">".$result_seriya['seriya']."";
                 echo $chk_seriya;
                }
    ?>
    </select></td></tr>

<tr><td  class="inform"><a class="inform" href='../cicl/addform.php' target="_blank"><?php echo $TEXT['book-cicle']; ?>:</a></td><td>
    <select name="cicle_id">
    <?php
        $query11 = "SELECT * FROM `tbl_cicle` ORDER BY `cicle` ";
          $result11 = mysqli_query($dbcnx,$query11);
            if (!$result11) {puterror($result2['skin'],$TEXT['error-tbl5']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_cicle = mysqli_fetch_array($result11))
                {
                 $chk_cicle = "<option value=".$result_cicle['cicle_id'].">".$result_cicle['cicle']."";
                 echo $chk_cicle;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../typeizd/addform.php' target="_blank"><?php echo $TEXT['book-tip-izd']; ?>:</a></td><td>
    <select name="tip_izd_id">
    <?php
        $query12 = "SELECT * FROM `tbl_tip_izd` ORDER BY `position`, `tip_izd` ";
          $result12 = mysqli_query($dbcnx,$query12);
            if (!$result12) {puterror($result2['skin'],$TEXT['error-tbl15']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_izd = mysqli_fetch_array($result12))
                {
                 $chk_izd = "<option value=".$result_izd['tip_izd_id'].">".$result_izd['tip_izd']."";
                 echo $chk_izd;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><?php echo $TEXT['user-photo']; ?>:</td><td><input size=20 type=file name=photo  /></td></tr>
<tr><td  class="inform"><?php echo $TEXT['photo_obr']; ?>:</td><td>
 <select name=photo_obr>
  <option value='1' selected><?php echo $TEXT['photo_no']; ?>
  <option value='2' ><?php echo $TEXT['photo_rec_l']; ?>
  <option value='4' ><?php echo $TEXT['photo_rec_l_t']; ?>
  <option value='6' ><?php echo $TEXT['photo_rec_l_r']; ?>
 </select>
</td></tr>
<tr><td  class="inform"><?php echo $TEXT['book-ebook']; ?>:</td><td><input size=20 type=file name=ebook  /></td></tr>
<tr><td  class="inform"><a class="inform" href='../libr/addform.php' target="_blank"><?php echo $TEXT['book-bibl']; ?>:</a></td><td>
    <select name="bibl_id">
    <?php
        $query13 = "SELECT name, bibl_id FROM `tbl_biblioteka` ORDER BY `name` ";
          $result13 = mysqli_query($dbcnx,$query13);
            if (!$result13) {puterror($result2['skin'],$TEXT['error-tbl2']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_libr = mysqli_fetch_array($result13))
                {
                 $chk_libr = "<option value=".$result_libr['bibl_id'].">".$result_libr['name']."";
                 echo $chk_libr;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../zal/addform.php' target="_blank"><?php echo $TEXT['book-zal']; ?>:</a></td><td>
    <select name="zal_id">
    <?php
        $query14 = "SELECT * FROM `tbl_zal` ORDER BY `zal` ";
          $result14 = mysqli_query($dbcnx,$query14);
            if (!$result14) {puterror($result2['skin'],$TEXT['error-tbl11']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_zal = mysqli_fetch_array($result14))
                {
                 $chk_zal = "<option value=".$result_zal['zal_id'].">".$result_zal['zal']."";
                 echo $chk_zal;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../shkaf/addform.php' target="_blank"><?php echo $TEXT['book-shkaf']; ?>:</a></td><td>
    <select name="shkaf_id">
    <?php
        $query15 = "SELECT * FROM `tbl_shkaf` ORDER BY `shkaf` ";
          $result15 = mysqli_query($dbcnx,$query15);
            if (!$result15) {puterror($result2['skin'],$TEXT['error-tbl9']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_shkaf = mysqli_fetch_array($result15))
                {
                 $chk_shkaf = "<option value=".$result_shkaf['shkaf_id'].">".$result_shkaf['shkaf']."";
                 echo $chk_shkaf;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../polki/addform.php' target="_blank"><?php echo $TEXT['book-polka']; ?>:</a></td><td>
    <select name="polka_id">
    <?php
        $query16 = "SELECT * FROM `tbl_polka` ORDER BY `polka` ";
          $result16 = mysqli_query($dbcnx,$query16);
            if (!$result16) {puterror($result2['skin'],$TEXT['error-tbl8']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_polka = mysqli_fetch_array($result16))
                {
                 $chk_polka = "<option value=".$result_polka['polka_id'].">".$result_polka['polka']."";
                 echo $chk_polka;
                }
    ?>
    </select></td></tr>
<tr><td  class="inform"><a class="inform" href='../book_lang/addform.php' target="_blank"><?php echo $TEXT['menu-btn35']; ?>:</a></td><td>
    <select name="bl_id">
    <?php
        $query17 = "SELECT `bl_id`,`booklang` FROM `tbl_booklang` ORDER BY `position`, `booklang` ";
          $result17 = mysqli_query($dbcnx,$query17);
            if (!$result17) {puterror($result2['skin'],$TEXT['error-tbl23']); require_once "../utils/bottom_adm.php"; exit();}
              while($result_bl = mysqli_fetch_array($result17))
                {
                 $chk_bl = "<option value=".$result_bl['bl_id'].">".$result_bl['booklang']."";
                 echo $chk_bl;
                }
    ?>
    </select></td></tr>
</table>
</fieldset>
</td></tr>
<tr><td><input class="button2" type=submit value='<?php echo $button; ?>' /></td><td></td></tr>
</table>
</form>
<?php
  require_once "../utils/bottom_adm.php";
?>