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

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang.".php")) include "../lang/".$lang.".php";
     else include "../lang/ru.php";

  $title=$titlepage=$TEXT['support33'];

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

  ?>
  <title><?php echo $title; ?></title>
  <link rel="StyleSheet" type="text/css" href="../utils/reader.css" />
  </head>
  <body leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0" topmargin="0" >
  <?php

  if($result2['user'] == 1) puterror2($TEXT['error-supp11']);
  if($result2['master'] == 1) puterror2($TEXT['error-supp11']);

  if(empty($_POST['zay_id'])) puterror2($TEXT['error-supp6']);
  if(strlen($_POST['zay_id'])>11) puterror2($TEXT['error-supp7']);
  $_POST['zay_id'] = rep($_POST['zay_id']);

  $query_man2 = "SELECT * FROM `tbl_logins` WHERE `login`='".$_COOKIE['login']."'";
   $man_tmp = mysql_query($query_man2);
    if(!$man_tmp) puterror2($TEXT['error-tbl20']);
     $man = mysql_fetch_array($man_tmp,MYSQL_ASSOC);
     $manager = $man['fullname'];

  $query5 = "SELECT `pic_tr` FROM `tbl_supp_zayavka` WHERE `zay_id`='".$_POST['zay_id']."' ";
   $zay_tmp = mysql_query($query5);
    if(!$zay_tmp) puterror($TEXT['error-tbl26']);
     $zay = mysql_fetch_array($zay_tmp,MYSQL_ASSOC);
     $pic_tr = $zay['pic_tr'];

  $query = "DELETE FROM `tbl_supp_zayavka` WHERE `zay_id`='".$_POST['zay_id']."' LIMIT 1";
  if(mysql_query($query))
  {
    if(file_exists("../".$zay['pic_tr'])) unlink("../".$zay['pic_tr']);
    //*************************************
    $ip = $_SERVER['REMOTE_ADDR'];
    $doing = $TEXT['zay-pardel2'];
    $what = $TEXT['zay-pardel3'].$_POST['zay_id'];
    $who = $manager;
    //*************************************
    $query2 = "INSERT INTO tbl_logs ( `log_id` , `data` , `ip` , `who` , `doing` , `what` ) VALUES ( NULL , NOW() , '$ip' , '$who' , '$doing' , '$what')";
        if(mysql_query($query2))
           {
             echo "<html><head>
                   <meta HTTP-EQUIV='Refresh' CONTENT='0; URL=manager.php' />
                   </head></html>";
           } else puterror2($TEXT['error-log']);
  } else puterror2($TEXT['error-tbl26']);
?>
</body>
</html>