<?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'];
$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir']."core.php");

//$res = $dba->getSCCTicketDetailById($_REQUEST['item']) ;
$ticketlist = $_REQUEST['ticketlist'] ;



?>

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

  
 

  <div class="form-row">
  
  <div class="form-group col-md-12">
      <label for="assigneeProfile"><h3 style="color: red">Voulez-vous clôturer automatiquement les éléments selectionnés?</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="ticketlist" id="ticketlist" value="<?php echo $ticketlist; ?>" />
       </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>
</form>
                


<script type="text/javascript">

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 ) {
			   
			   //alert( obj.errorMessage );
			 
			 //    $.alert( obj.errorMessage );
			 
			 $.alert({
				 icon: 'glyphicon glyphicon-ok',
				 title: 'RESULTAT',
                 content: obj.errorMessage,
                 type: 'green',
                 typeAnimated: true

				});
			    //  alert(data);
          
            $('#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'
		  
		});
		 $("#content-wrapper").load("<?php echo $rpage; ?>");
		$modal.modal('hide');
           $('#loader').loading('stop'); 
		
});
</script>
 
<link rel="stylesheet" href="css/jquery-confirm.min.css">
<script src="js/jquery-confirm.min.js"></script>

