<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/x-json");
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($_GET['purchase_id']) && true === is_array($_GET['purchase_id']) && 1 <= count($_GET['purchase_id'])){
    $i = 0;
    $ObjPurchaseMod = new PurchaseMod($MS_SP);
    foreach ($_GET['purchase_id'] as $value) {
      $VarResult = $ObjPurchaseMod->Del($value);
      if(true === $VarResult){
        $i++;
      }
    }
    $ArrReturn = array('message' => $i . $MS_SP->Sp_LangMessage['message']['MessRecordDeleteSuccessPart1'] . count($_GET['purchase_id']) . $MS_SP->Sp_LangMessage['message']['MessRecordDeleteSuccessPart2']);
  }
  else{
    $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrSettingWrong']);
  }
}
else{
  $ArrReturn = array('error' => $MS_SP->Sp_LangMessage['error']['ErrFuncAccessDenied']);
}
echo json_encode($ArrReturn);
include($_SERVER['DOCUMENT_ROOT'] .'/script/FooterInc.php');
?>