<?php
  include("conn.php");
  
  if (!isset($_POST['xAtajo'])) {
    $jsondata['success'] = false;
    $jsondata['message'] = 'Información de entrada mal definida.';
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($jsondata);
    die();
  }

  $xAtajo   = $_POST['xAtajo'];

  $DBSegu->startTrans();

  $sql = 'delete from ATJ_ATAJOS_DETALLE where ID_ATAJO = ? ';
  $RsIns = $DBSegu->Execute($sql, array($xAtajo));
  if ($DBSegu->hasFailedTrans()) {
    $DBSegu->completeTrans();
    $jsondata['success'] = false;
    $jsondata['message'] = 'Ha ocurrido un error al eliminar el atajo. Ref. #V01.01';
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($jsondata);
    die();  
  }

  $sql = 'delete from ATJ_ATAJOS where ID_ATAJO = ? ';
  $RsIns = $DBSegu->Execute($sql, array($xAtajo));
  if ($DBSegu->hasFailedTrans()) {
    $DBSegu->completeTrans();
    $jsondata['success'] = false;
    $jsondata['message'] = 'Ha ocurrido un error al eliminar el atajo. Ref. #V01.02';
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($jsondata);
    die();  
  }

  $DBSegu->completeTrans();

  $jsondata['success'] = true;
  $jsondata['message'] = 'Atajo eliminado.';
  header('Content-type: application/json; charset=utf-8');
  echo json_encode($jsondata);
?>