<?php
session_start();
$pageSequence = $_SESSION['sequence'];
$toDiv = "contentZone" . $pageSequence;
$resultZoneDiv = "resultZone" . $pageSequence;
$_SESSION['sequence']++;
//echo  dirname(__FILE__);  
//echo $_SERVER['DOCUMENT_ROOT'] . "   ".dirname(__FILE__)."  ".str_replace($_SERVER['DOCUMENT_ROOT'],"",dirname(__FILE__)) . " SELF :" .$_SERVER['PHP_SELF']  ;
$toDiv = $_REQUEST['toDiv'];
$rpage = $_REQUEST['rpage'];
$cancelPage = $_REQUEST['cancelPage']; 
$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir'] . "core.php");

//$res = $dba->getSCCTicketDetailById($_REQUEST['item']) ;
$ticketId = $_REQUEST['ticketId'];
$item = $_REQUEST['item'];
$rPage = $_REQUEST['rPage'];
$rDiv = $_REQUEST['rDiv'];
$res = $dba->getAssigneeProfileById($_SESSION['right'])
?>

<style>
    /*  LOADER_SKF CSS  */
    .loader_skf {
    visibility:hidden;
    width: 33px;
    height: 33px;
    border: 5px solid black;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-left: 400px;
    margin-top:15px;
    }

    @keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
    } 
    

</style>

<form action="<?php echo $currentBaseDir; ?>/exec_close_ticket_reclamation.php" method="post" enctype="multipart/form-data"  id="campaignFrm"  toDiv="<?php echo $toDiv; ?>" returnPage="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return false;">




    <div class="form-row">

        <div class="form-group col-md-12">
            <label for="assigneeProfile"><h3>Clôturer le ticket <strong><?php echo $ticketId; ?></strong></h3></label>

        </div>

        <div class="form-group col-md-12">
            <label for="comment"><h3>Commentaire <strong></h3></label>
            <textarea id="comment" name="comment" class="form-control" cols="5" rows="3"></textarea>
            <input type="hidden" name="ticketId" id="ticketId" value="<?php echo $ticketId; ?>" />
        </div>

    </div>


    <button type="submit" class="btn btn-primary" id="assign">Clôturer</button>  <button type="button" class="btn close-btn" data-dismiss="modal">Fermer</button><span class="loader_skf" id="loader_skf"></span>
</form>



<script type="text/javascript">
    var classLOADER = document.getElementById('loader_skf');
    var $modal = $('#myModal');

    $('form').on("submit", function (event) {

        var toDiv = $("form").attr('toDiv');
        var rpage = $("form").attr('returnPage');

        $.post($(this).attr("action"), $(this).serialize(), function (data) {

            var obj = jQuery.parseJSON(data);

            if (obj.errorCode == 0) {
                classLOADER.style.visibility = 'visible';
                setTimeout(function() {
                 classLOADER.style.visibility = 'hidden';
                 }, 2000); // 2 secondes 
                $('#assign').hide();
                //alert( obj.errorMessage );
                //    $.alert( obj.errorMessage );

                $.alert({
                    icon: 'glyphicon glyphicon-ok',
                    title: 'RESULTAT',
                    content: obj.errorMessage,
                    type: 'green',
                    typeAnimated: true

                });
                //  alert(data);
                //  $("#" + toDiv).load(rpage);
                $('#loader').hide();

            } else {

                $.alert({
                    icon: 'glyphicon glyphicon-warning-sign',
                    title: 'RESULTAT',
                    content: obj.errorMessage,
                    type: 'red',
                    typeAnimated: true
                });

                // $.alert( obj.errorMessage );
            }

        });
        // return false; // prevent normal submit


        event.preventDefault();

        /*
         var postData = $(this).serializeArray();
         var formURL = $(this).attr("action");
         
         $.ajax({
         url: formURL,
         type: "POST",
         data: postData,
         success: function(data, textStatus, jqXHR) {
         
         alert("Processing the form...");
         
         },
         error: function(jqXHR, status, error) {
         console.log(status + ": " + error);
         }
         });
         event.preventDefault(); */
    });

    $(".close-btn").on('click', function () {
        // create the backdrop and wait for next modal to be triggered
        // $('body').modalmanager('loading');
        $('#loader').loading({
            message: "Chargement...",
            theme: 'dark'

        });

        $modal.modal('hide');
        $("#content-wrapper").load("/manager/products/scc/scc_my_calls.php");
        $('#loader').loading('stop');

    });
</script>

<link rel="stylesheet" href="css/jquery-confirm.min.css">
<script src="js/jquery-confirm.min.js"></script>

