<?php
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
//SiteLibs::GetVarDump($_SESSION);
if ((true === isset($_SESSION['SessionAuth']['SvtAdmin']['reg']) && 1 == $_SESSION['SessionAuth']['SvtAdmin']['reg']) ||
    (true === isset($_SESSION['SessionAuth']['SvtOperatorAdv']['reg']) && 1 == $_SESSION['SessionAuth']['SvtOperatorAdv']['reg']) ||
    (true === isset($_SESSION['SessionAuth']['SvtOperator']['reg']) && 1 == $_SESSION['SessionAuth']['SvtOperator']['reg'])
   ){

  if (true === isset($_GET['repair_id']) && true === is_numeric($_GET['repair_id'])){

    $ObjRepairMod = new RepairMod($MS_SP);
    $ArrRepair = $ObjRepairMod->GetFromDb('SqlAll', 'GetRow', "a.repair_id = '". $_GET['repair_id'] ."'");
    $smarty->assign('ArrRepair', $ArrRepair);
//    SiteLibs::GetVarDump($ArrRepair);
  //  $ObjUsersMod = new UsersMod($MS_SP);
  //  $VarWhereAdd = 'us.webservices_id = -1';
  //  if(true === isset($_SESSION['SessionAuth']['id']) && true === is_numeric($_SESSION['SessionAuth']['id'])){
  //    $VarWhereAdd = 'u.users_id = "'. $_SESSION['SessionAuth']['id'] .'"';
  //  }
  //  if(true === isset($_SESSION['SessionAuth']['SvtAdmin']['reg']) && 1 == $_SESSION['SessionAuth']['SvtAdmin']['reg']){
  //    $VarWhereAdd = 'us.webservices_id IN (1,2,3)';
  //  }
  //  $ArrUsersMaster = $ObjUsersMod->GetFromDb('SqlServices', 'GetAssoc', $VarWhereAdd);
  //  if (true === isset($ArrDemands['demands_masterid']) && true === isset($ArrDemands['master_fio']) && true !== array_key_exists($ArrDemands['demands_masterid'], $ArrUsersMaster)){
  //    $ArrUsersMaster[] = array("users_id" => $ArrDemands['demands_masterid'], "users_fio" => $ArrDemands['master_fio']);
  //  }
  //  $smarty->assign('ArrUsersMaster', $ArrUsersMaster);
  //  
  //  $ObjSprStatusMod = new SprStatusMod($MS_SP);
  //  $ArrSprStatus = $ObjSprStatusMod->GetFromDb('SqlAll', 'GetAll', '', 'a.sprstatus_order');
  //  $smarty->assign('ArrSprStatus', $ArrSprStatus);
  //  
  //  $ObjDemandsClassifMod = new DemandsClassifMod($MS_SP);
  //  $ArrDemandsClassif = $ObjDemandsClassifMod->GetFromDb('SqlAll', 'GetAll', '', 'a.demandsclassif_order');
  //  $smarty->assign('ArrDemandsClassif', $ArrDemandsClassif);



    $VarPagesTxt .= $smarty->fetch('Repair/OpRepairDetail.tpl');
  }
  else{
    $smarty->assign('VarError', $MS_SP->Sp_LangMessage['error']['ErrSettingWrong']);
    $VarPagesTxt .= $smarty->fetch('error.tpl');
  }
}
else{
  $smarty->assign('VarError', $MS_SP->Sp_LangMessage['error']['ErrAuthAccessDenied']);
  $VarPagesTxt .= $smarty->fetch('AccessDenied.tpl');
}
$smarty->assign('VarPagesTxt', @$VarPagesTxt);
if (true === isset($MS_SP->SP_CurrPage['template_file']) && '' != $MS_SP->SP_CurrPage['template_file']){
	$smarty->display($MS_SP->SP_CurrPage['template_file']);
}
else {
	$smarty->display('Page.tpl');
}
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>