<?php
include($_SERVER['DOCUMENT_ROOT'] .'/script/HeaderInc.php');
if('XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] && true === isset($_SESSION['SessionAuth']['id']) && 0 < $_SESSION['SessionAuth']['id']) {
  if((true === isset($_SESSION['SessionAuth']['SvtAdmin']['reg']) && 1 == $_SESSION['SessionAuth']['SvtAdmin']['reg']) OR
     (true === isset($_SESSION['SessionAuth']['SvtOperatorAdv']['reg']) && 1 == $_SESSION['SessionAuth']['SvtOperatorAdv']['reg'])){
    $VarWhere = "(us.webservices_id = 1 || us.webservices_id = 2)";
  }
  else{
    if (true === is_numeric($ArrRepair['users_id']) && 0 < $ArrRepair['users_id']){
      $VarWhereAdd = ', '. $ArrRepair['users_id'];
    }
    $VarWhere = 'u.users_id IN ('. $_SESSION['SessionAuth']['id'] . $VarWhereAdd .')';
  }
  $ObjUsersMod = new UsersMod($MS_SP);
  $ArrUsers = $ObjUsersMod->GetFromDb('SqlServices', 'GetAll', $VarWhere);
  $smarty->assign('ArrUsers', $ArrUsers);
  
  
  if(true === isset($_GET['repair_id']) && '' != $_GET['repair_id']){
    $ObjRepairMod = new RepairMod($MS_SP);
    $ArrRepair = $ObjRepairMod->GetFromDb('SqlAll', 'GetRow', "a.repair_id = '". $_GET['repair_id'] ."'");
    //SiteLibs::GetVarDump($ArrRepair);

    $smarty->assign('ArrRepair', $ArrRepair);
  }
  $VarReturn = $smarty->fetch('Repair/Form.tpl');
}
else{
  $VarReturn = $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied'];
}
echo $VarReturn;
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>