<?php
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
if('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] && true === isset($_GET['svt_id']) && true === is_numeric($_GET['svt_id'])) {  
  $ObjSvtMod = new SvtMod($MS_SP);
  $ArrSvt = $ObjSvtMod->GetFromDb('SqlRow', 'GetRow', "a.svt_id = '". $_GET['svt_id'] ."'");
  $smarty->assign('ArrSvt', $ArrSvt);
  //SiteLibs::GetVarDump($ArrSvt);

  $ObjIpMod = new IpMod($MS_SP);
  $ArrIp = $ObjIpMod->GetFromDb('SqlAll', 'GetAll', "s.svt_id = '". $_GET['svt_id'] ."'");
  $smarty->assign('ArrIp', $ArrIp);

  $ObjSvtStatusMod = new SvtStatusMod($MS_SP);
  $ArrSvtStatus = $ObjSvtStatusMod->GetFromDb('SqlAllLeft', 'GetAll', "b.svt_id = '". $_GET['svt_id'] ."'");
  $smarty->assign('ArrSvtStatus', $ArrSvtStatus);
  
  $VarSvtMove = $smarty->fetch('SvtMove/List.tpl');
  $smarty->assign('VarSvtMove', $VarSvtMove);

  if(true === isset($ArrSvt['svt_name']) && '' != $ArrSvt['svt_name'] && true === file_exists($_SERVER['DOCUMENT_ROOT'] . $MS_SP->Sp_Config['FolderReport'] . strtoupper($ArrSvt['svt_name']))){
    $ArrSvtAdditRow = file($_SERVER['DOCUMENT_ROOT'] . $MS_SP->Sp_Config['FolderReport'] . strtoupper($ArrSvt['svt_name']));
    foreach ($ArrSvtAdditRow as $value) {
  //    echo "b: ". substr($value, 0, 1) ."<br />";
  //    echo "e: ". substr($value, -3) ."<br />";
      if('[' == substr($value, 0, 1)){
        $VarKeyName = substr($value, 1, -3);
        //echo "VarKeyName: ". $VarKeyName ."<br />";
        $ArrSvtAddit[$VarKeyName] = array();
      }
      else{
        $VarEqPos = strpos($value, '=');
        $VarK = substr($value, 0, $VarEqPos);
        $VarV = substr($value, $VarEqPos+1);
        //echo "VarK: ". $VarK ."<>". "VarV: ". $VarV ."<br />";
        $ArrSvtAddit[$VarKeyName][iconv("windows-1251", $MS_SP->Sp_Config['charset'], $VarK)] = iconv("windows-1251", $MS_SP->Sp_Config['charset'], $VarV);
      }
    }
    //SiteLibs::GetVarDump($ArrSvtAddit);
    $smarty->assign('ArrSvtAddit', $ArrSvtAddit);
  }
  
  $VarReturn = $smarty->fetch('Svt/SvtInformationTabs-1.tpl');
}
else{
  $VarReturn = $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied'];
}
echo $VarReturn;
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>