<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

$pageName = basename($_SERVER['PHP_SELF']);

 $m->where("page_name", $pageName);
 $pageNameAccess=$m->get("eduportal_modules_pages_detail");


$m->where("user_id", $_SESSION['user_id']);
$m->where ("branch_id", $_SESSION['branch']);
$m->where("page_id", $pageNameAccess[0]['page_id']);
$access = $m->get("users_privilege_detail");



 $date;
if($_REQUEST['diaryDate']!=" " && $_REQUEST['diaryDate']!=NULL ) {
        $date=date("Y-m-d",strtotime($_REQUEST['diaryDate']));  

      }else {
        $date=date("Y-m-d");  
      }
     ?>


<!DOCTYPE html>
<html lang="en">
  <head>
    
    <title>Add Ticket/Query | EduPortal</title>
    <?php include('RootMe/css_links.php');?>
  
<script type="text/javascript">

function getSubCat(id){
  //alert(id);

    if (window.XMLHttpRequest) {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4 && xmlhttp.status==200) {

        document.getElementById("subcatgory").innerHTML=xmlhttp.responseText;
       //alert(xmlhttp.responseText);

      }

    }
    xmlhttp.open("GET","get_exp_subcategory.php?id="+id,true);
    xmlhttp.send();
  }
</script> 
  </head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- <script>
$(document).ready(function(){
  
    $("#div1").fadeOut();
    $("#div2").fadeOut("slow");
    $("#div3").fadeOut(3000);
 
});
</script> -->
  <style>
#snackbar {
  visibility: hidden;
  min-width: 250px;
  margin-left: -125px;
  background-color: #1E90FF;
  color: #fff;
  text-align: right;
  border-radius: 2px;
  padding: 16px;
  position: fixed;
  z-index: 1;
  left: 80%;
  bottom: 30px;
  font-size: 17px;
}

#snackbar.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

@-webkit-keyframes fadein {
  from {bottom: 0; opacity: 0;} 
  to {bottom: 30px; opacity: 1;}
}

@keyframes fadein {
  from {bottom: 0; opacity: 0;}
  to {bottom: 30px; opacity: 1;}
}

@-webkit-keyframes fadeout {
  from {bottom: 30px; opacity: 1;} 
  to {bottom: 0; opacity: 0;}
}

@keyframes fadeout {
  from {bottom: 30px; opacity: 1;}
  to {bottom: 0; opacity: 0;}
}
</style>
  <body class="nav-md">
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
     
            <?php include('RootMe/sidebar.php');?>

              <?php include('RootMe/header.php');?>
     
        <!-- page content -->
          <div class="right_col" role="main">

            <a href="<?php echo $_SESSION['dashboard'];?>">Dashboard </a> &nbsp; <i style="" class="fa fa-angle-double-right"></i>  &nbsp; 
          Manage Ticket
                  <br><br>

          <div class="row" style="background-color: white;">
           
  <section class="add_sub_agent" id="table_sub_agent">
  <div class="container">

 <div class="" style="margin-top:10px;">
   
      

                                    <!-- page content -->
        
          <div class="">
            <div class="page-title">
              <div class="title_left">
                
              </div>

             
            </div>
            <div class="clearfix"></div>
      <h3 style="margin-left: 15px;">Add New Ticket/Query</h3>
            <div class="row">
          
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
            
                  <div class="x_content">
          
     
                    <form action="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php" method="post" enctype="multipart/form-data" class="form-horizontal form-label-left" >
  <?php
  
  $month;
   if(!isset($_GET['tikup'])){?>
        <input type="hidden" name="action" value="addTicket" />

  <?php $month=date("m");}else {

          $query="select * from eduportal_customer_support where customer_support_id =".$_GET['tikup'];
          $ticketdata = $m->query($query);

          $month=$ticketdata[0]['month_id'];
?>
              <input type="hidden" name="action" value="updateTicket" />
              <input type="hidden" name="customer_support_id"  value="<?php echo $_GET['tikup'];?>">

  <?php } ?>        

            <div class="col-md-12">

           <div class="col-md-2 col-sm-3 col-xs-12" style="margin-top:8px;" >
             
           <div class="form-group" >

           <label  class="control-label" >  Module <span class="required">*</span></label>
             

        
              <div class="form-group" >
                    
                   
                <select name="modules_id" required class="chosen-multi-select form-control"  >
                  <option value="">Select Module</option>

                  <?php
                  $query="select * From eduportal_modules_detail";
                  $modules = $m->query($query);
                  foreach($modules as $module)
                  { ?>

                         <option <?php if($_GET['bid']==$module['modules_id']){echo "selected";} ?>   value="<?php echo $module['modules_id']; ?>"><?php echo $module['modules_name']; ?></option>


                  <?php } ?>

                </select>
              </div>

                </div>
          </div> 



          <div class="col-md-2 col-sm-12 col-xs-12" style="padding:8px; float:left; margin-top:3px;"  id="col1">
           <div class="form-group ">
           <label class="required"> Complain</label>
            <select id="complain" required name="complain" class="chosen-multi-select form-control">

                    <option value="">Select Complain   </option>
                    <option <?php if($ticketdata[0]['priority']=="High"){echo "Selected";} ?> value="AmountError">Amount Error</option>
                    <option <?php if($ticketdata[0]['priority']=="Medium"){echo "Selected";} ?> value="ResultCardIssue">Result Card Issue</option> 
                    <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="StudentCardIssue">Student Card Issue</option>    
                    <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="DiaryIssue">Diary Issue </option>
                    <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="ReportingIssue">Reporting Issue </option>  

                    <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="DateSheetIssue">Date Sheet Issue </option>   

                    <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="RollNumberIssue">Roll Number Issue </option>          
                                                          
              </select>
                 
            </div>
            </div> 


            <div class="col-md-2 col-sm-12 col-xs-12" style="padding:11px; float:left;"  id="col1">
                 <div class="form-group ">
                 <label class="required"> Priority</label>
                  <select id="medium" name="priority" class="form-control">

                          <option value="">Select Priority   </option>
                          <option <?php if($ticketdata[0]['priority']=="High"){echo "Selected";} ?> value="High">High</option>
                          <option <?php if($ticketdata[0]['priority']=="Medium"){echo "Selected";} ?> value="Medium">Medium</option> 
                          <option <?php if($ticketdata[0]['priority']=="Low"){echo "Selected";} ?> value="Low">Low</option>                   
                                                                
                        </select>
                       
                  </div>
                  </div>

                  <div class="col-md-2 col-sm-12 col-xs-12" style="margin-top:11px;">
             <div class="form-group ">
             <label class="required"> Date</label>
              
              <input type="date" name="ticketDate" value="<?php echo date('Y-m-d');?>" class="form-control">
                   
              </div>
              </div>
          
                 <div class="col-md-4 col-sm-12 col-xs-12" style="padding:11px; float:left;"  id="col1">
                 <div class="form-group ">

                 <label class="required"> Ticket/Query Title</label>
                 <input class="form-control col-md-7 col-xs-12"  name="customer_support_title" placeholder="eg Fee Submit Due Date.... " value="<?php echo $ticketdata[0]['customer_support_title']; ?>">
                       
                  </div>
                  </div>

                  

             

              </div>

                  <div class="item form-group">
                    <h2 style="margin-left: 18px;">Discription</h2> 
                        <div class="col-md-12 col-sm-12 col-xs-12">
                          <textarea id="textarea" required="required" name="description" class="ckeditor"> <?php echo $ticketdata[0]['description']; ?></textarea>
                        </div>
                  </div>

                 <div class="col-md-3 col-sm-12 col-xs-12" style="padding:8px; float:left;" >
                 <div class="form-group ">

                 <label> Upload Image</label>
                 <input type="file" class="form-control has-feedback-left" name="img_file" value="<?php echo $ticketdata[0]['images']; ?>" id="img_file" />
                       
                  </div>
                 </div>

                  <div class="ln_solid" style="border-top:none;"></div>
                  <div class="form-group">
                    <div class="col-md-6 col-md-offset-3">
                      
                      <button id="send" type="submit" class="btn btn-primary" >Submit</button>
                      <button type="submit" class="btn btn-primary" >Cancel</button>

                    </div>
                  </div>

                </form>
              
          </div>
                </div>
              </div>
            </div>
          </div>
       
        

        <!-- /page content -->



  </div>
  <div class="clearfix"></div>
</section>           

<?php

$branch=$_SESSION['branch'];
$sql = "SELECT * FROM eduportal_customer_support where branch_id='$branch' order by customer_support_id desc";

// echo $sql;

$tickets = $m->query($sql);
 //print_r($categories);
 
     ?>




     <div class="t col-md-12 col-sm-12 col-xs-12">
                <h3>Ticket/Queries List<small> (<?php echo count($tickets);?> records)</small></h3>
              </div>

              
          
          
    

<?php  if(isset($_SESSION['addsuccessexp'])){?>

<div id="snackbar"><script> toastFunction();</script> Your Recored is Sucessfully Added</div>

<?php  unset($_SESSION['addsuccessexp']); }
          ?>


          
          <?php  if(isset($_SESSION['upsuccessexp'])){?>


            <div class="alert alert-success" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Success!</strong> Record is updated successfully...
            </div>


          <?php  unset($_SESSION['upsuccessexp']); }
          ?>

          <?php  if(isset($_SESSION['deleteexp'])){?>


            <div class="alert alert-danger" id="msg">
             <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
              <strong>Danger!</strong> Record is deleted successfully...
            </div>


          <?php  unset($_SESSION['deleteexp']); }
          ?>

<table id="datatable" class="table table-striped table-bordered"style="background-color: white;">
                      <thead>
                        <tr>
                          <th width="1%">S.No</th>
                          <th width="20%">Title</th>
                          <th width="10%">Module</th>
                          <th width="10%">Priority </th>
                          <th width="10%">Review</th>
                          <th width="10%">Images</th>
                          <th width="10%">Status</th>
                          <th width="8%">Action</th>
                         

                        </tr>
                      </thead>
                      <tbody>

                        
<?php  $count=1;

foreach($tickets as $ticket){

  $m->where("Month_Id", $ticket['month_id']);
  $months=$m->get("eduportal_month_config");


?>
                        <tr>
                          <td style="text-align:center;"><?php echo $count; $count++;?></td>
                         
                          <td><?php echo $ticket['customer_support_title'];?></td>
                          <td>
                            <a class="btn btn-success" style="padding: 0px 5px; font-size:14px;color:white;" data-toggle="modal" data-target="#ticketDetails<?php echo $ticket['customer_support_id'];?>" > View Ticket </a>
                          </td>

                             <!-- Student Lecture popup start -->


      <div id="ticketDetails<?php echo $ticket['customer_support_id'];?>" class="modal fade" role="dialog">
        <div class="modal-dialog" style="width: 80%;">

          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header" style="border-bottom:none;">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title" style="text-align:center"> Ticket Details </h4>
            </div>

            <div class="modal-body">

              
                   
                  <div class="col-md-12 col-sm-12 col-xs-12" style="padding:8px;"  id="">

                          <?php echo $ticket['description'];?>
                  </div>

                                
      
            <div class="modal-footer">

                      


            </div>



                 

          </div>

          </div>

        </div>
      </div>

      <!-- Student Lecture popup ending -->

                          <td><?php echo $ticket['priority'];?></td>
                          <td>
                            <?php if($ticket['status']==1 || $ticket['status']=="1"){    

                            echo  $ticket['approval_date']; ?>
                            <a  href="commentPopUp.php?TicketId=<?php echo $ticket['customer_support_id'];?>" class="btn btn-warning iframePupop">Comment</a>
                          <?php } ?>
                             
  
                          </td>
                          <td><?php
                   $extention=substr($ticket['images'],-4);        
                    if($extention==".jpg" || $extention==".JPEG") { ?>

                      <img style="height:100px;width:100%;" src="<?php echo DOMAIN.AgentDirectory; ?>/Ticketimages/<?php echo $ticket['images'];?>"  />
                      
                    <?php }  else if($extention==".png" || $extention==".PNG") {?>

                  <img style="height:100px;width:100%;" src="https://www.emiratesnights.com/Project/EduPortal/Production/Ticketimages/<?php echo $ticket['images'];?>"  />

                    <?php  } else if($extention==".pdf" || $extention==".PDF") { ?> 
                    

                    <a class="btn btn-success" target="_blank" href="https://www.emiratesnights.com/Project/EduPortal/Production/Ticketimages/<?php echo $ticket['images'];?>">Download file</a>
                    <?php } else {echo "No Attachment..."; }?>
                </td>

                <td> 

      <?php if($ticket['status']==0 || $ticket['status']=="0"){ ?>    

          <a  class="btn btn-danger">Under Review</a> 
        
         <?php } else { ?>    


          <a  class="btn btn-success">Completed </a> 


         <?php } ?>   


                  </td>
                      
                                                  

          <td>
             <?php if ($access[0]['edit_access']!=NULL) { ?>

          <a style="padding: 0px 5px; font-size:14px;"  href="add_ticket.php?<?php echo session_id().session_id().session_id().session_id().session_id();?>&tikup=<?php echo $ticket['customer_support_id'];?>" style="cursor:pointer;"  class="btn btn-success"> <i class="fa fa-pencil" aria-hidden="true"></i></a> 
           <?php } ?>


           <?php if ($access[0]['delete_access']!=NULL) { ?>

        <a href="<?php echo DOMAIN.AgentDirectory;?>parent/InsertMe.php?id=<?php echo $ticket['customer_support_id'];?>&action=DeleteTicket" style="padding: 0px 5px; font-size:14px;" onClick="return confirm('Are you sure you want to delete this record');"  class="btn btn-danger"><i class="fa fa-remove"></i> </a>

         <?php } ?>
                          </td>

                        </tr>
<?php } ?>
                      

                      </tbody>
                    </table>
           
          </div>
        </div>

            </div>
          </div>
        </div>
        <!-- /page content -->
  

    
  <?php include('RootMe/js_linksscript.php');?>
  <script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
  </body>
</html>
<script>
function toastFunction() {
  var x = document.getElementById("snackbar");
  x.className = "show";
  setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>

<link rel="stylesheet" href="colorbox.css" />

<script src="jquery.colorbox.js"></script>

 <script>

$(document).ready(function(){

$(".iframePupop").colorbox({iframe:true, width:"80%", height:"85%"});

});

</script>