<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////
  require_once "utils/chlang_osn.php";

  $title = $TEXT['book-otziv-add2'];
  $button = $TEXT['btn_add'];
  $action = "add_otz.php";

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

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

  if(empty($_GET['book_id'])) {puterror2($result2['skin'],$TEXT['error-book5']); require_once "utils/bottom.php"; exit();}
  if(strlen($_GET['book_id'])>255) {puterror2($result2['skin'],$TEXT['error-book6']); require_once "utils/bottom.php"; exit();}
  $_GET['book_id'] = rep($_GET['book_id']);
?>
<form name="book" enctype="multipart/form-data" action="<?php echo $action; ?>" method="post">
<?php
$query_iskh = "SELECT book_name, photo_book FROM tbl_book WHERE book_id = '".$_GET['book_id']."' ";
 $result_iskh = mysqli_query($dbcnx,$query_iskh);
  if(!$result_iskh) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
      $result_iskh2 = mysqli_fetch_array($result_iskh);

     $query_autor = "SELECT
     tbl_s_book_aut.*,
     tbl_autor.autor_id,
     tbl_autor.name,
     tbl_autor.familiya,
     tbl_autor.otchestvo
     FROM tbl_s_book_aut
     JOIN tbl_autor ON tbl_s_book_aut.autor_id=tbl_autor.autor_id
    WHERE book_id = '".$_GET['book_id']."' ";
    $result_autor = mysqli_query($dbcnx,$query_autor);
     if(!$result_autor) {puterror2($result2['skin'],$TEXT['error-tbl16']); require_once "utils/bottom.php"; exit();}
      while($result_autor2 = mysqli_fetch_array($result_autor))
       {
           $autor .="<a href='info_autor.php?autor_id=".$result_autor2['autor_id']."' target=_blank title='".$TEXT['search-all-aut']."'>".$result_autor2['name']." ".$result_autor2['otchestvo']." ".$result_autor2['familiya']."</a>, ";
       }
       $autors =substr($autor, 0,-2);

      $sm = preg_replace("/\.\.+./","",$result_iskh2['photo_book']);
      if(!empty($result_iskh2['photo_book']) && file_exists($sm)) {$result_image = "<div id='author-container'><img alt='".$TEXT['global-alt']."' src='".$sm."' /></div>";}
        else {$result_image =  "<img alt='".$TEXT['global-alt']."' align='top' src='skins/".$result2['skin']."/nophoto.png' />";}

?>
<table align="center" width="98%" border="0">
    <tr><td class="zagolovok">&nbsp;<?php echo rep_back($result_iskh2['book_name']); ?>&nbsp;<span class="opis">&#040;<?php echo $autors; ?>&#041;</span></td></tr>
</table>
<hr width="98%" />
<table align="center" width="98%" border="0">
<tr>
<td width="5%" valign="top">
 <table align="left" border="0" width="100%">
  <tr><td><?php echo $result_image; ?></td></tr>
 </table>
</td>
<td width="65%" valign="top" align="right">
<fieldset>
 <legend align="left" title="<?php echo $TEXT['book-otziv-add2']; ?>"><?php echo $TEXT['book-otziv']; ?></legend>
<table align="left" width="100%" border="0">
<tr><td class="inform"><?php echo $TEXT['book-otziv']; ?>:</td><td><textarea class="input" cols="85" rows="3" name="otziv" ></textarea></td></tr>
<tr><td class="inform"><?php echo $TEXT['book-ocenka']; ?>:</td><td>
 <select name="book_ocenka">
  <option value=1 ><?php echo $TEXT['book-ocenka1']; ?>
  <option value=2 ><?php echo $TEXT['book-ocenka2']; ?>
  <option value=3 selected><?php echo $TEXT['book-ocenka3']; ?>
  <option value=4 ><?php echo $TEXT['book-ocenka4']; ?>
  <option value=5 ><?php echo $TEXT['book-ocenka5']; ?>
 </select>
</td></tr>
</table>
</fieldset>
<table align="left" width="100%" border="0">
<tr><td>
<input class="button2" type="submit" value="<?php echo $button; ?>" />
<input type="hidden" name="book_id" value="<?php echo $_GET['book_id']; ?>" />
</td></tr>
</table>
</td></tr>
</table>
</form>
<?php
  require_once "utils/bottom.php";
?>