<?php
  ///////////////////////////////////////////////////
  //Домашняя библиотека,
  //обновление
  //2019 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  require_once "utils/chlang_osn.php";

  $title = $TEXT['update-title'];

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

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

  $button = $TEXT['btn-vip'];
  $action = "update1121frm.php";

  if($_GET['cycl'] == "on") {$_POST['cycl'] = "on";}
   else {
          if($_POST['cycl'] == "on") {$visible_cylc = "checked";}
            else {$visible_cylc = "";}
        }

  if($_POST['use_bibl'] == "on") 
    {
    if(strlen($_POST['bibl_id'])>5) {puterror(base,$TEXT['error-libr6']); require_once "utils/bottom.php"; exit();}
    $_POST['bibl_id'] = rep($_POST['bibl_id']);
    
    $query = "UPDATE `db_library`.`tbl_book` SET `remote_copy` = 'yes', `paper_copy` = 'no' WHERE `bibl_id` = '".$_POST['bibl_id']."'";
     if(!mysqli_query($dbcnx,$query)) {puterror(base,$TEXT['error-tbl3']); require_once "utils/bottom.php"; exit();}
    }
    else {$action = "update1121frm.php";}

  if($_POST['cycl'] == "on") {$action = "update1121frm.php";}
    else {$button = $TEXT['menu-btn1'];
          $action = "main.php";}

//  echo "cycl = ".$_POST['cycl']."<br/>";
//  echo "use_bibl = ".$_POST['use_bibl']."<br/>";
//  echo "bibl_id = ".$_POST['bibl_id']."<br/>";
?>
<table align="center" width="65%" border="0" cellspacing="0" cellpadding="0">
 <tr>
  <td width="16">&nbsp;</td>
  <td></td>
  <td width="16">&nbsp;</td>
 </tr>
 <tr>
  <td class="osn_top_r"></td>
  <td class="osn_top"></td>
  <td class="osn_top_l"></td>
 </tr>
 <tr>
  <td class="osn_left">&nbsp;</td>
  <td class="osn_center">
   <table width="100%" border="0" cellspacing="0" cellpadding="30">
   <tr>
    <td class="osn_center">
    <form enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
    <table align="center">
     <tr><td align="center" class="zagolovok"><?php echo $TEXT['update-title']; ?></td></tr>
     <tr><td class="upd"><?php echo $TEXT['update-help1121']; ?></td></tr>
    </table>
    <br />
    <table align="center" border="0">
    <tr><td  class="add_field_op"><?php echo $TEXT['book-bibl']; ?>:</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(base,$TEXT['error-tbl2']); require_once "utils/bottom.php"; exit();}
              while($result_libr = mysqli_fetch_array($result13))
                {
                if($result_iskh2['bibl_id'] == $result_libr['bibl_id']) {$chk_libr = "<option selected value=".$result_libr['bibl_id'].">".$result_libr['name']."";}
                 else {$chk_libr = "<option value=".$result_libr['bibl_id'].">".$result_libr['name']."";}
                 echo $chk_libr;
                }
    ?>
    </select></td><td class="upd_var" ><input type="checkbox" name=use_bibl /></td></tr>     
    <tr><td align="right" class="add_field_op"><?php echo $TEXT['cicle-update']; ?></td><td class="upd_var" ><input type="checkbox" name=cycl <?php echo $visible_cylc; ?> /></td><td></td></tr>
     <tr><td>&nbsp;</td><td><br /><input class=button type=submit value='<?php echo $button; ?>'></td><td></td></tr>
    </table>
   </form>
  </td>
 </tr>
</table>
   </td>
     <td class="osn_right">&nbsp;</td>
   </tr>
   <tr>
    <td class="osn_bottom_r"></td>
    <td class="osn_bottom"></td>
    <td class="osn_bottom_l"></td>
   </tr>
 </table>
 <br />
<?php
  require_once "utils/bottom.php";
?>