<style>
.form-group.form-md-line-input {
    margin: 0 0 25px !important;
    padding-top: 17px !important;
}

.form .form-body,
.portlet-form .form-body {
    padding: 12px !important;
}

label {
    font-weight: 400;
    word-break: break-word;
}

#spr {
    padding: 5px;
}

/* Optional styling for checkboxes */
#spr option {
    padding-left: 20px;
    /* Indent checkboxes */
}
.select2-dropdown--below{
    width:33em !important;
}
.select2-dropdown--above{
    width:33em !important;
}

.select2-selection__rendered{
    width: 33em;
    border-bottom: 2px solid #c2cad8;
}

.select2-results {
    display: block;
    overflow-y: auto;
    max-height: 150px;
}

</style>
<?php include("header.php");

	    $user_id = $this->session->userdata('USER_ID');
        $role = $this->session->userdata('USER_ROLE');
?>


<body class="page-container-bg-solid">
    <div class="page-wrapper">
        <div class="page-wrapper-row">
            <div class="page-wrapper-top">
                <!-- BEGIN HEADER -->
                <div class="page-header">
                    <!-- BEGIN HEADER TOP -->
                    <div class="page-header-top">
                        <div class="container">
                            <!-- BEGIN LOGO -->
                         <div class="page-logo">
                                        <img src="../assets/layouts/layout3/img/Healthwatch_logo.png" alt="logo" class="logo-default">
                                    </a>
                            </div>
                            <!-- END LOGO -->
                            <!-- BEGIN RESPONSIVE MENU TOGGLER -->
                            <a href="javascript:;" class="menu-toggler"></a>
                            <!-- END RESPONSIVE MENU TOGGLER -->
                            <!-- BEGIN TOP NAVIGATION MENU -->
                            <div class="top-menu">
                                <ul class="nav navbar-nav pull-right">

                                    <!-- END INBOX DROPDOWN -->
                                    <!-- BEGIN USER LOGIN DROPDOWN -->
                                    <li class="dropdown dropdown-user dropdown-dark">
                                        <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown"
                                            data-hover="dropdown" data-close-others="true">
                                            <img alt="" class="img-circle" id="profile_image"
                                                src="../assets/layouts/layout3/img/avatar3_small.png">
                                            <span><?php echo $name; ?></span>
                                        </a>
                                        <ul class="dropdown-menu dropdown-menu-default">


                                            <li>
                                                <a href="../login/logout">
                                                    <i class="icon-key"></i> Log Out </a>
                                                <a href="#"
                                                        data-target="#edit_users_details"
                                                        data-toggle="modal"
                                                        data-id='<?php echo $user_id; ?>'
                                                        class="edit_users_details"
                                                        title="profile"><i class="icon-user"></i> Profile</a>    
                                            </li>
                                        </ul>
                                    </li>
                                    <!-- END USER LOGIN DROPDOWN -->
                                    <!-- BEGIN QUICK SIDEBAR TOGGLER 
                                        <li class="dropdown dropdown-extended quick-sidebar-toggler">
                                            <span class="sr-only">Toggle Quick Sidebar</span>
                                            <i class="icon-logout"></i>
                                        </li>
                                         END QUICK SIDEBAR TOGGLER -->
                                </ul>
                            </div>
                            <!-- END TOP NAVIGATION MENU -->
                        </div>
                    </div>
                    <!-- END HEADER TOP -->
                    <!-- BEGIN HEADER MENU -->
                    <?php 
                                $this->load->view('navigation');
                          ?>
                    <!-- END HEADER MENU -->
                </div>
                <!-- END HEADER -->
            </div>
        </div>
        <div class="page-wrapper-row full-height">
            <div class="page-wrapper-middle">
                <!-- BEGIN CONTAINER -->
                <div class="page-container">
                    <!-- BEGIN CONTENT -->
                    <div class="page-content-wrapper">
                        <!-- BEGIN CONTENT BODY -->
                        <!-- BEGIN PAGE HEAD-->
                        <div class="page-head">
                            <div class="container">
                                <!-- BEGIN PAGE TITLE -->
                                <div class="page-title">
                                    <h1>Tickets
                                        <small></small>
                                    </h1>
                                </div>
                                <!-- END PAGE TITLE -->

                            </div>
                        </div>
                        <!-- END PAGE HEAD-->
                        <!-- BEGIN PAGE CONTENT BODY -->
                        <div class="page-content">
                            <div class="container">
                                <!-- BEGIN PAGE BREADCRUMBS -->
                                <!-- <ul class="page-breadcrumb breadcrumb">
                                        <li>
                                            <a href="../super_admin/super_admin_homepage">Home</a>
											<i class="fa fa-circle"></i>
                                        </li>
                                        <li>
                                            <span>Dashboard</span>
                                        </li>
                                    </ul>-->
                                <!-- <input type='text' id='date' /> -->
                                <!-- <div class="form-group form-md-line-input">
                                       <div class="form-group">
                                              <input class="input-group form-control input-medium date att_date"  id="surya_check_date" name="ticket_date" placeholder="Pick date"  data-date-start-date="+0d"/>
                                              <label for="form_control_1">Preferred Dateslot
                                              <span class="required">*</span></label>
                                              <span class="help-block">Select date...</span>
                                       </div>
                                    </div> -->
                                <!-- END PAGE BREADCRUMBS -->
                                <!-- BEGIN PAGE CONTENT INNER -->
                                <div class="page-content-inner">
                                    <div class="mt-content-body">
                                        <div class="se-pre-con"></div>
                                        <div class="row">
                                            <div class="portlet box green">
                                                <div class="portlet-title">
                                                    <div class="caption">
                                                        <?php if($role !== "3" && $role !== "6" && $role !== "7") { ?><i
                                                            class="fa fa-gift"></i>Create New Ticket
                                                    </div>
                                                    <?php } else {?> <i class="fa fa-gift"></i>View Assigned Tickets
                                                </div><?php } ?>
                                                <div class="tools">
                                                    <a href="javascript:;" class="collapse"> </a>
                                                </div>
                                            </div>
                                            <div class="portlet-body">
                                                <div class="tabbable-line">
                                                    <ul class="nav nav-tabs ">
                                                        <li class="active">
                                                            <a href="#tab_15_1" data-toggle="tab">Ticket </a>
                                                        </li>
                                                    </ul>
                                                    <div class="tab-content">
                                                        <div class="tab-pane active" id="tab_15_1">
                                                            <div class="row">
                                                                <div class="col-md-12">
                                                                    <!-- BEGIN EXAMPLE TABLE PORTLET-->
                                                                    <div class="portlet light bordered">
                                                                        <div class="portlet-title">
                                                                            <div class="caption font-dark">
                                                                                <i class="icon-settings font-dark"></i>
                                                                                <?php if($role !== "3" && $role !== "6" && $role !== "7") { ?>
                                                                                <span class="caption-subject"> Create /
                                                                                    Edit Tickets </span><?php } else {?>
                                                                                <span class="caption-subject"> Use the
                                                                                    below form to edit tickets.
                                                                                </span><?php } ?>
                                                                            </div>
                                                                            <div class="actions">
                                                                            </div>
                                                                        </div>
                                                                        <div class="portlet-body">
                                                                            <div class="table-toolbar">
                                                                                <div class="row">
                                                                                    <div class="col-md-6">
                                                                                        <?php if (in_array($role, array("3", "6", "7"))) : ?>
                                                                                        <!-- Display button for roles 3, 6, and 7 -->
                                                                                        <button
                                                                                            data-target="#create_new_ticket"
                                                                                            data-toggle="modal"
                                                                                            class="btn sbold green create_new_ticket">
                                                                                            Create New IT Ticket <i
                                                                                                class="fa fa-plus"></i>
                                                                                        </button>


                                                                                        <?php //elseif (in_array($role, array("2", "1"))) : ?>
                                                                                        <!--<button style="display: none;"-->
                                                                                        <!--    data-target="#create_new_ticket"-->
                                                                                        <!--    data-toggle="modal"-->
                                                                                        <!--    class="btn sbold green create_new_ticket">-->
                                                                                        <!--    Create New Ticket <i-->
                                                                                        <!--        class="fa fa-plus"></i>-->
                                                                                        <!--</button>-->



                                                                                        <?php else : ?>
                                                                                        <!-- Display default button (without "IT") for other roles -->
                                                                                        <button
                                                                                            data-target="#create_new_it_ticket"
                                                                                            data-toggle="modal"
                                                                                            class="btn sbold green create_new_ticket">
                                                                                            Create New IT Ticket <i
                                                                                                class="fa fa-plus"></i>
                                                                                        </button>

                                                                                        <button
                                                                                            data-target="#create_new_ticket"
                                                                                            data-toggle="modal"
                                                                                            class="btn sbold green create_new_ticket">
                                                                                            Create New Quality Ticket <i
                                                                                                class="fa fa-plus"></i>
                                                                                        </button>

                                                                                        <?php endif; ?>
                                                                                    </div>
                                                                                    <!-- <?php  { ?>
                                                                                        <div class="btn-group">
                                                                                            <button
                                                                                                data-target="#create_new_ticket"
                                                                                                data-toggle="modal"
                                                                                                class="btn sbold green create_new_ticket">Create
                                                                                                New Ticket
                                                                                                <i
                                                                                                    class="fa fa-plus"></i>
                                                                                            </button>
                                                                                            <?php } ?> -->
                                                                                </div>
                                                                                <div class="btn-group">

                                                                                </div>
                                                                                <div class="pull-right">
                                                                                    <div class="actions">
                                                                                    </div>
                                                                                </div>

                                                                            </div>

                                                                            <table
                                                                                class="table-scrollable table table-striped table-bordered table-checkable order-column"
                                                                                id="sample_1">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <!--<th> S.No </th>-->
                                                                                        <th> Ticket No </th>
                                                                                        <!--<th> Request Date </th>-->
                                                                                        <th> Assigned to</th>
                                                                                        <!-- <th> Company Name </th> -->
                                                                                        <!--<th> Contact Person </th>-->
                                                                                        <th> Contact No </th>
                                                                                        <th>Created Date</th>
                                                                                        <th> Modified Date</th>
                                                                                        <th> Turn arround time </th>
                                                                                        <th> Modified User</th>
                                                                                        <!--<th> Preferred Date </th>
																										<th> Preferred Time</th>-->

                                                                                        <th> Status </th>
                                                                                        <th> Actions </th>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    <?php
                                                                                    	for ($i = 0; $i < count($ticket_details); $i++) {
                                                                                            if ($role == 4 || $role == 5) {
                                                                                                if ($user_id != $ticket_details[$i]['user_id']) {
                                                                                                    continue; // Skip to the next iteration if user is not the ticket owner
                                                                                                }
                                                                                            }
                                                                                            elseif ($role == 3 || $role == 6 || $role == 7) {
                                                                                                $assigned_staff_ids = explode(',', $ticket_details[$i]['assigned_staff_id']);
                                                                                                $user_assigned = false;
                                                                                                foreach ($assigned_staff_ids as $assigned_staff_id) {
                                                                                                    if ($user_id == trim($assigned_staff_id)) {
                                                                                                        $user_assigned = true;
                                                                                                        break;
                                                                                                    }
                                                                                                }
                                                                                                if (!$user_assigned) {
                                                                                                    continue;
                                                                                                }
                                                                                            }
                                                                                            if (isset($_REQUEST['status']) && !empty($_REQUEST['status']) ) {
                                                                                                if ($ticket_details[$i]['issue_status'] != $_REQUEST['status'] && $ticket_details[$i]['issue_status'] != '4' && $ticket_details[$i]['issue_status'] == 'null' ) {
                                                                                                    echo 1;
                                                                                                    continue; 
                                                                                                }
                                                                                            }
                                                                                           
                                                                                        
                                                                                        
                                    
                                                                                    	?>
                                                                                    <tr class="odd gradeX">
                                                                                        <!-- <td>
                                                                                    				<label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
                                                                                    					<input type="checkbox" class="checkboxes" value="1" />
                                                                                    					<span></span>
                                                                                    				</label>
                                                                                    			</td> -->
                                                                                        <!--<td><?php echo $id = $ticket_details[$i]['ticket_id']; ?> </td> -->
                                                                                        <!--<td><?php echo $i+1; ?> </td>-->
                                                                                        <td><?php echo  $ticket_details[$i]['ticket_number']; ?>
                                                                                        </td>
                                                                                        <?php
                                                                                    				$req_date = date("Y-m-d",strtotime($ticket_details[$i]['request_date']));

                                                                                    			?>
                                                                                        <!--<td><?php echo $req_date; ?></td>-->
                                                                                        <td>
                                                                                            
                                                                                             <?php                                        
                                                                                                            if ($role == 1 || $role == 2 ) {
                                                                                                                $technician = $ticket_details[$i]['technician'];
                                                                                                            
                                                                                                            
                                                                                                                $users = $this->db->query("SELECT * FROM users WHERE (role = '3' OR role = '6' OR role = '7') AND user_id = $technician")->result_array();

                                                                                                                    foreach ($users as $user) {
                                                                                                                        echo $user['user_name']; // Output user name
                                                                                                                    }
                                                                                                            }
                                                                                                            
                                                                                            ?>
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            

                                                                                            <?php 
                                                                                                     if($role == 4 || $role == 3 || $role == 6 || $role == 5){
                                                                                                        $technician = $ticket_details[$i]['technician'];

                                                                                                            $users = $this->db->query("SELECT * FROM users WHERE role = '3'  AND user_id = $technician")->result_array();

                                                                                                                foreach ($users as $user) {
                                                                                                                      echo $user['user_name']; // Output user name
                                                                                                                }
                                                                                                       
                                                                                                       
                                                                                                       
                                                                                                        }
                                                                                                    ?>

                                                                                            <?php                                        
                                                                                                        if ($role == 5 || $role == 6 || $role == 7) {
                                                                                                            $technician = $ticket_details[$i]['technician'];
                                                                                                           
                                                                                                           
                                                                                                            $users = $this->db->query("SELECT * FROM users WHERE (role = '6' OR role = '7') AND user_id = $technician")->result_array();

                                                                                                                foreach ($users as $user) {
                                                                                                                      echo $user['user_name']; // Output user name
                                                                                                                }
                                                                                                        }
                                                                                                        ?>














                                                                                            <?php //echo $name = $ticket_details[$i]['technician']; ?>
                                                                                        </td>
                                                                                        <!-- <td><?php echo $company_name = $ticket_details[$i]['company_name']; ?>
                                                                                            </td> -->
                                                                                        <!--<td ><?php echo $contact_person = $ticket_details[$i]['contact_person']; ?></td> -->
                                                                                        <td><?php echo $contact_number = $ticket_details[$i]['contact_number']; ?>
                                                                                        </td>
                                                                                        <td><?php echo $ticket_details[$i]['created_at']; ?>
                                                                                        </td>
                                                                                        <td><?php echo $updated_at = date('Y-m-d H:i:s',strtotime($ticket_details[$i]['updated_at'])); ?>
                                                                                        </td>
                                                                                        <td>
                                                                                            <?php

                                                                                                    $startDateString=$ticket_details[$i]['created_at'];
                                                                                                    $endDateString=$ticket_details[$i]['updated_at'];

                                                                                                    $startDate = new DateTime($startDateString);
                                                                                                    $endDate = new DateTime($endDateString);

                                                                                                    $dateInterval = $startDate->diff($endDate);
                                                                                                    $totalDays = $dateInterval->days;


                                                                                                    $totalSeconds = $dateInterval->s + ($dateInterval->i * 60) + ($dateInterval->h * 3600) + ($dateInterval->days * 86400);

                                                                                                    // Calculate total hours, minutes, and seconds
                                                                                                    $totalHours = floor($totalSeconds / 3600);
                                                                                                    $totalMinutes = floor(($totalSeconds % 3600) / 60);
                                                                                                    $totalSeconds = $totalSeconds % 60;
                                                                                                    
                                                                                                    echo  $totalDays ."days -". $totalHours .":". $totalMinutes .":". $totalSeconds;
                                                                                                    // echo "Total Time: " . $totalHours . " hours, " . $totalMinutes . " minutes, " . $totalSeconds . " seconds\n";
                                                                                                ?>
                                                                                        </td>
                                                                                        </td>
                                                                                        <td><?php echo $ticket_details[$i]['updated_by']; ?>
                                                                                        </td>


                                                                                        <?php  
                                                                                    					$ticket_status = $ticket_details[$i]['issue_status'];
                                                                                    				if( $ticket_status == '1')
                                                                                    					{
                                                                                    				?>
                                                                                        <td><span class="label"
                                                                                                style="background: blue;font-weight: 500;">
                                                                                                Acknowledged </span>
                                                                                        </td>

                                                                                        <?php 
                                                                                    					} else if( $ticket_status == '2'){?>

                                                                                        <td><span class="label"
                                                                                                style="background: yellow;font-weight: 500;color:unset">
                                                                                                Return with query
                                                                                            </span>
                                                                                        </td>

                                                                                        <?php	} else if( $ticket_status == '3'){?>

                                                                                        <td><span class="label"
                                                                                                style="background: green;font-weight: 500;">Mark Resolved
                                                                                            </span></td>

                                                                                        <?php	} else if( $ticket_status == '4'){?>

                                                                                        <td><span class="label"
                                                                                                style="background: magenta;font-weight: 500;">Return</span>
                                                                                        </td>

                                                                                        <?php	}  else if( $ticket_status == '5'){?>

                                                                                        <td><span class="label"
                                                                                                style="background: orange;font-weight: 500;">cancel</span>
                                                                                        </td>

                                                                                        <?php	} ?>

                                                                                        <!--//else if( $ticket_status == '6'){?>-->
                                                                                        <!--<td><span class="label"-->
                                                                                        <!--        style="background: gray;font-weight: 500;">Cancelled</span>-->
                                                                                        <!--</td>-->

                                                                                        <!--<?php//	} ?>-->





                                                                                        <td><a href="#"
                                                                                                data-target="#view_ticket_details"
                                                                                                data-toggle="modal"
                                                                                                class="view_ticket_details btn btn-sm btn-outline grey-salsa"
                                                                                                data-id='<?php echo $ticket_details[$i]['ticket_id']; ?>'
                                                                                                title="view completed ticket"><i
                                                                                                    class="fa fa-eye"></i></a>
                                                                                            <!--3-->
                                                                                            <?php if( $ticket_status != '5'){ ?>
                                                                                            <a href="#"
                                                                                                data-target="#edit_ticket_details"
                                                                                                data-toggle="modal"
                                                                                                class="edit_ticket_details btn btn-sm btn-outline grey-salsa"
                                                                                                data-id='<?php echo $ticket_details[$i]['ticket_id']; ?>'
                                                                                                title="edit"><i
                                                                                                    class="fa fa-edit"></i></a>
                                                                                              
                                                                                              <?php if( $role == 2){ ?>       
                                                                                            <a href="#"
                                                                                               data-id='<?php echo $ticket_details[$i]['ticket_id']; ?>'
                                                                                               class="view_ticket_details btn btn-sm btn-outline grey-salsa delete_button"
                                                                                                title="delete" id='delete_button'><i
                                                                                                    class="fa fa-trash"></i></a>
                                                                                                    
                                                                                                    <?php } ?>
                                                                                                    
                                                                                                    
                                                                                        </td>

                                                                                        <?php 
                                                                                        } } ?>
                                                                                </tbody>
                                                                            </table>
                                                                        </div>
                                                                    </div>
                                                                    <!-- END EXAMPLE TABLE PORTLET-->
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="clearfix"></div>
                                    <!-- END DASHBOARD STATS 1-->

                                </div>

                            </div>
                        </div>
                        <!-- END PAGE CONTENT INNER -->
                    </div>
                </div>
                <!-- END PAGE CONTENT BODY -->
                <!-- END CONTENT BODY -->
            </div>
            <!-- END CONTENT -->

        </div>
        <!-- END CONTAINER -->
    </div>
    </div>

    <?php include('footer.php'); ?>


    <!-- BEGIN QUICK NAV -->
    <div class="quick-nav-overlay"></div>
    <!-- Modals starts here!-->
    <!-- static -->
    <div id="create_new_ticket" class="modal fade" data-backdrop="static" data-keyboard="false" data-width="1000">
        <div class="modal-body">
            <div class="portlet box" style="background-color: #168d90 !important;">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i>Create Ticket Here
                    </div>
                    <div class="tools">
                        <a href="" class="collapse"> </a>
                        <!-- <a href="" class="reload"> </a> -->
                    </div>
                </div>
                <div class="portlet-body form" style="background-color: #e0f8ff !important;">
                    <!-- BEGIN FORM-->
                    <form action="create_ticket" method="post" id="form_img" enctype="multipart/form-data"
                        accept-charset="utf-8">
                        <div class="form-body">
                            <div class="row">
                                <?php 
												$username=$contact_number=$email=$address=$company="";
												
												
												if($role == "4" || $role == "5" || $role == "7" || $role == "6"|| $role == "3" || $role == "1" || $role == "2"){
												$result = $this->User1_model->user_info($user_id);
			                                          if (count($result) > 0){ 
			                                            $user_id =  $result[0]['user_id'];
	                                                    $username =  $result[0]['user_name'];
														$contact_number =  $result[0]['mobile'];
				             										$email =  $result[0]['email'];
                                                        $department_id= $result[0]['dept_id'];
                                                        $location_id= $result[0]['location_id'];
														// $address =  $result[0]['address'];
														// $company =  $result[0]['company'];
															} 	?>
                                <!--hidden element-->
                                <!-- customer_id-->
                                <input type="text" class="form-control hide" name="customer_id" id="form_control_1"
                                    placeholder="Enter name" value="<?php echo $user_id; ?>">
                                <!-- customer_id-->

                                <!-- customer_name-->
                                <input type="text" class="form-control hide" name="name"
                                    value="<?php echo $username; ?>">
                                <!-- customer_name-->


                                <!-- contact_number-->
                                <input type="text" class="form-control hide" name="contact_number"
                                    value="<?php echo $contact_number; ?>">
                                <!-- contact_number-->

                                <!-- <input type="text" class="form-control hide" name="company_name" value="<?php echo $company; ?>"> -->
                                <!-- <input type="text" class="form-control hide" name="address" value="<?php echo $address; ?>"> -->
                                <!-- email -->
                                <input type="text" class="form-control hide" name="email" value="<?php echo $email; ?>">

                                <!-- email -->
                                <!---------------------------------->
                                <!-- user_name -->
                                <div class="col-md-6">
                                    <div class="form-group form-md-line-input">
                                        <input type="text" class="form-control" name="name" id="form_control_1"
                                            placeholder="Enter Name" value="<?php echo $username; ?>" disabled>
                                        <label for="form_control_1">Name
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Enter Name...</span>
                                    </div>
                                    <!-- user_name -->
                                    <div class="form-group form-md-line-input has-success">
                                        <input type="number" class="form-control" name="contact_number"
                                            placeholder="0"
                                            onchange="contact_validate()" minlength="8" id="form_control_1"
                                            value="<?php echo $contact_number; ?>" disabled>
                                        <label for="form_control_1">Contact Number
                                        </label>
                                        <span class="help-block">Type Contact Number between 8 or 10 Digits Only
                                            (ex.+651234567)</span>
                                    </div>
                                    <!-- <div class="form-group form-md-line-input">
															<input type="text" class="form-control" name="company_name" id="form_control_1" placeholder="Enter company Name" value="<?php echo 	$company ?>" disabled>
															<label for="form_control_1">Company Name
															</label>
															<span class="help-block">Enter Company Name...</span>
														  </div> -->

                                    <!-- <div class="form-group form-md-line-input">
																<textarea class="form-control" name="address" rows="1" placeholder="Enter Address" disabled><?php echo $address; ?></textarea>
																<label for="form_control_1">Address
                                                                <span class="required">*</span></label>
																<span class="help-block">Enter Address Here...</span>
														  </div> -->
                                    <div class="form-group form-md-line-input">
                                        <div class="input-group">
                                            <input type="text" class="form-control" name="email" id=""
                                                placeholder="Enter your email" value="<?php echo $email; ?>" disabled>
                                            <label for="form_control_1">Email
                                                <span class="required"></span></label>
                                            <span class="help-block">Enter Email Here...</span>
                                            <span class="input-group-addon">
                                                <i class="fa fa-envelope"></i>
                                            </span>
                                        </div>
                                    </div>


                                    <!-- Location -->
                                    <div class="form-group form-md-line-input">
                                        <select class="form-control" id="location" name="location">

                                            <?php  
                                                   if($role == "5" || $role == "1" || $role == "2"){                                      
                                                    echo '<option value="">Select</option>';
                                                }
                                                ?>

                                            <?php $locations = $this->db->query("select * from location ORDER BY location_id ASC;")->result_array();
																	foreach($locations as $location){
																	?>



                                            <?php  
                                            if($role == "5" || $role == "1" || $role == "2"){
                                            echo '<option value="' . $location['location_id'] . '">' . $location['location_id'] . '</option>';
                                            // echo '<option value="' . $location_id . '">' . $location_id . '</option>';

                                            }
                                            if($role == "4" || $role == "7" || $role == "6"|| $role == "3"){
                                            // echo '<option value="' . $location['location_id'] . '">' . $location_id . '</option>';
                                            echo '<option value="' . $location_id . '">' . $location_id . '</option>';

                                            }
                                            
                                            ?>

                                            <?php	}
																?>
                                        </select>
                                        <label for="form_control_1">Location
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select Location Here...</span>
                                    </div>
                                    <!-- Location -->

                                    <?php if($role == "4"|| $role == "7" || $role == "6"|| $role == "3"){  ?>
                                    <!-- Technician -->
                                    <div class="form-group form-md-line-input">
                                        <select class="form-control technician" id="technician" name="technician">
                                            <?php $techs = $this->db->query("select * from users where role=3 && location_id='$location_id' ORDER BY user_name ASC")->result_array();
                                                foreach($techs as $tech){
                                                ?>
                                            <option value="<?php echo $tech['user_id']; ?>">
                                                <?php  echo $tech['user_name']; ?>
                                            </option>
                                            <?php } ?>
                                        </select>
                                        <label for="form_control_1">Technician
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select Technician Here...</span>
                                    </div>

                                    <!-- Technician -->
                                    <?php } ?>



                                    <?php if($role == "5" || $role == "1" || $role == "2"){ ?>
                                    <!-- Sub Employee -->
                                    <div class="form-group form-md-line-input">
                                        <select class="form-control technician" id="technician" name="technician">
                                            <option value="">Select</option>
                                        </select>
                                        <label for="form_control_1">Frontliner
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Assigned to Employee Name...</span>
                                    </div>
                                    <input type="hidden" name="update_id" id="subemployee_role" value="<?= $role ?>" />


                                    <!-- Sub Employee -->
                                    <?php } ?>




                                </div>
                                <div class="col-md-6">
                                    <div class="col-md-12">
                                        <!-- <div class="form-group form-md-line-input">
																<input type="text" class="form-control" name="device_location" placeholder="Enter Device Location">
																<label for="form_control_1">Device Location
																  <span class="required">*</span></label>
																<span class="help-block">Enter Device Location Here...</span>
														 </div> -->
                                    </div>
                                    <!-- <div class="col-md-12">-->
                                    <!--    <div class="form-group form-md-line-input">-->
                                    <!--        <input class="form-control" name="system" rows="1"-->
                                    <!--            placeholder="Device/System" />-->
                                    <!--        <label for="form_control_1">Device/System-->
                                    <!--            <span class="required">*</span></label>-->
                                    <!--        <span class="help-block">Enter Device/System Here...</span>-->
                                    <!--    </div>-->
                                    <!--</div> -->



                                    <!-- device -->
                                    <?php if($role !== "5" && $role !== "1" && $role !== "2"){  ?>

                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <select class="form-control" id="system" name="system">
                                                <option value="">Select</option>
                                                <?php $devices = $this->db->query("select * from device ORDER BY device_name ASC")->result_array();
																	foreach($devices as $device){
																	?>
                                                <option value="<?php echo $device['device_name']; ?>">
                                                    <?php echo $device['device_name']; ?></option>
                                                <?php	}
																?>
                                                <option value="other">Others</option>

                                            </select>
                                            <label for="form_control_1">Device/System
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Device/System Here...</span>
                                        </div>
                                    </div>



                                    <div id="deviceTextBox" class="hidden col-md-12">
                                        <!-- <label for="otherOption">Enter Other Option:</label> -->
                                        <input type="text" name="otherOption" id="deviceOption"
                                            placeholder="Enter Other Option">
                                    </div>


                                    <?php } ?>



                                    <!-- /device -->


                                    <?php if($role == "5" || $role == "1" || $role == "2"){  ?>

                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <select class="form-control" id="dept" name="dept">
                                                <option value="">Select</option>
                                                <?php $depts = $this->db->query("select * from department ORDER BY dept_name ASC")->result_array();
																	foreach($depts as $dept){
																	?>
                                                <option value="<?php echo $dept['dept_id']; ?>">
                                                    <?php echo $dept['dept_id']; ?></option>

                                                <?php	}
																?>
                                            </select>
                                            <label for="form_control_1">Department
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Location Here...</span>
                                        </div>
                                    </div>


                                    <!-- employee Subject -->
                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <select class="form-control" id="subject" name="subject">
                                                <option value="">Select</option>
                                                <?php $subjects = $this->db->query("select * from subject ORDER BY subject_issue ASC")->result_array();
																	foreach($subjects as $subject){
																	?>
                                                <option value="<?php echo $subject['subject_issue']; ?>">
                                                    <?php echo $subject['subject_issue']; ?></option>

                                                <?php	}
																?>
                                            </select>
                                            <label for="form_control_1">Subject
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Subject Here...</span>
                                        </div>
                                    </div>
                                    <!-- /employee Subject -->



                                    <!-- Employee Issue Description -->
                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <!--<select class="form-control" id="issue_desc" name="issue_desc">-->
                                            <!--    <option value="">Select</option>-->
                                                <?php 
                                                //$descriptions = $this->db->query("select * from description")->result_array();
																//	foreach($descriptions as $description){
																	?>
                                                <!--<option value="-->
                                                <?php 
                                                //echo $description['issue_name'];
                                                ?>
                                                <!--">-->
                                                    <?php 
                                                    //echo $description['issue_name']; 
                                                    ?>
                                                    <!--</option>-->

                                                <?php
                                                // }
																?>
                                            <!--</select>-->
                                            
                                            
                                            
                                            <input type="text" class="form-control" name="issue_desc" id="issue_desc"
                                            placeholder="Enter your Issue" value="">
                                            
                                            
                                            <label for="form_control_1">Issue Description
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Issue Description Here...</span>
                                        </div>
                                    </div>
                                    <!-- / Employee Issue Description -->
                                    <?php } ?>


                                    <?php if($role != "1" && $role !== "2" && $role !== "5"){ ?>
                                   
                                    <!-- Subject -->

                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <input type="text" class="form-control" name="subject" id="subject"
                                                placeholder="Enter your Subject" value="">

                                            <label for="form_control_1">Subject
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Subject Here...</span>
                                        </div>
                                    </div>
                                    <!-- Subject -->





                                    <!-- Issue Description -->
                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">

                                            <input type="text" class="form-control" name="issue_desc" id="issue_desc"
                                                placeholder="Enter your Issue Description" value="">

                                            <label for="form_control_1">Issue Description
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select Issue Description Here...</span>
                                        </div>
                                    </div>
                                    <!-- Issue Description -->

                                    <?php } ?>

                                    <div class="col-md-12">
                                        <!-- <div class="form-group form-md-line-input">
															<select class="form-control" name="status" tabindex="6">
																<option value="">Select</option>
																<?php $status = $this->db->query("select * from status")->result_array();
																	foreach($status as $stat){
																	?>
																	<option value="<?php echo $stat['status_id']; ?>"><?php echo $stat['status_name']; ?></option>
																		
																<?php	}
																?>
															</select>
															<label for="form_control_1">Status
																<span class="required">*</span>
															</label>
															<span class="help-block">Select status here...</span>
														</div>-->
                                    </div>

                                    <?php if($role == "5" || $role == "1" || $role == "2"){  ?>
                                    <!-- SLA -->
                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <!-- <select class="form-control spr" id="spr" name="spr[]" multiple> -->
                                            <select class="form-control sla" id="sla" name="sla">
                                                <option value="">Select</option>
                                                <option value="1">1 Hrs</option>
                                                <option value="6">6 Hrs</option>
                                                <option value="9">9 Hrs</option>
                                                <option value="12">12 Hrs</option>
                                                <option value="24">24 Hrs</option>

                                            </select>
                                            <label for="form_control_1">SLA
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Select SLA Here...</span>
                                        </div>
                                    </div>
                                    <!-- /SLA -->


                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <label for="form_control_1">Supervisor
                                                <span class="required">*</span>
                                            </label>



                                            <div class="checkbox-container" id="spr">
                                            </div>
                                            <!-- <select class="form-control spr checkbox-container" id="spr" name="spr[]" multiple> 
                                         <select class="form-cont  rol spr" id="spr" name="spr">  
                                                <option value="">Select</option>
                                            </select> -->







                                            <span class="help-block">Select Supervisor Here...</span>

                                        </div>
                                    </div>

                                    <!-- 
                                    <div class="col-md-12">
    <div class="form-group form-md-line-input">
        <label>Supervisor <span class="required">*</span></label>
        <div>
            <div class="checkbox">
                <label>
                    <input type="checkbox" class="spr" name="spr[]" value="$user_id"> Supervisor 1
                </label>
            </div>
            <div class="checkbox">
                <label>
                    <input type="checkbox" class="spr" name="spr[]" value="$user_id"> Supervisor 2
                </label>
            </div>
        </div>
        <span class="help-block">Select Supervisor(s) Here...</span>
    </div>
</div> -->







                                    <?php } ?>

                                    <!-- <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <input type="file" class="form-control" name="attachment[]" multiple />
                                            <label for="form_control_1">Attachment
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Choose Attachement Here</span>
                                        </div>
                                    </div>  -->

                                    <div class="col-md-12">
                                        <div class="form-group form-md-line-input">
                                            <label for="attachment">Attachment</label>
                                            <input type="file" name="attachment[]" id="attachment" multiple />
                                            <span class="help-block">Choose Attachment Here</span>
                                        </div>
                                    </div>
                                    <p id="files-area">
                                        <span id="filesList">
                                            <span id="files-names"></span>
                                        </span>
                                    </p>
                                    <style>
                                    #files-area {
                                        width: 30%;
                                        margin: 0 auto;
                                    }

                                    .file-block {
                                        border-radius: 10px;
                                        background-color: rgba(144, 163, 203, 0.2);
                                        margin: 5px;
                                        color: initial;
                                        display: inline-flex;

                                        &>span.name {
                                            padding-right: 10px;
                                            width: max-content;
                                            display: inline-flex;
                                        }
                                    }

                                    .file-delete {
                                        display: flex;
                                        width: 24px;
                                        color: initial;
                                        background-color: #6eb4ff00;
                                        font-size: large;
                                        justify-content: center;
                                        margin-right: 3px;
                                        cursor: pointer;

                                        &:hover {
                                            background-color: rgba(144, 163, 203, 0.2);
                                            border-radius: 10px;
                                        }

                                        &>span {
                                            transform: rotate(45deg);
                                        }

                                    }
                                    </style>


















































                                    <?php } else { ?>











































                                    <!-- Admin create ticket   -->
                                    <div class="col-md-6">
                                        <div class="form-group form-md-line-input">
                                            <input type="text" class="form-control" name="name" id="form_control_1"
                                                placeholder="Enter Name">
                                            <input type="text" class="form-control hide" name="customer_id"
                                                id="form_control_1" placeholder="Enter name">
                                            <label for="form_control_1">Name
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Enter Name...</span>
                                        </div>
                                        <div class="form-group form-md-line-input has-success">
                                            <input type="text" class="form-control" name="contact_number" maxlength="10"
                                                id="form_control_1" placeholder="Enter Contact Number">
                                            <label for="form_control_1">Contact Number
                                                <span class="required">*</span>
                                            </label>
                                            <span class="help-block">Type Contact Number</span>
                                        </div>
                                        <div class="form-group form-md-line-input">
                                            <input type="text" class="form-control" name="company_name"
                                                id="form_control_1" placeholder="Enter Company Name">
                                            <label for="form_control_1">Company Name
                                            </label>
                                            <span class="help-block">Enter Company Name...</span>
                                        </div>

                                        <div class="form-group form-md-line-input">
                                            <textarea class="form-control" name="address" rows="1"
                                                placeholder="Enter Address"></textarea>
                                            <label for="form_control_1">Address
                                                <span class="required">*</span></label>
                                            <span class="help-block">Enter Address Here...</span>
                                        </div>
                                        <div class="form-group form-md-line-input">
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="email" id=""
                                                    placeholder="Enter Your Email">
                                                <label for="form_control_1">Email
                                                    <span class="required"></span></label>
                                                <span class="help-block">Enter Email Here...</span>
                                                <span class="input-group-addon">
                                                    <i class="fa fa-envelope"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="form-group form-md-line-input">
                                            <div class="form-group">
                                                <input type="text" class="form-control" name="contact_person"
                                                    id="form_control_1" placeholder="Enter Contact Person">
                                                <label for="form_control_1">Contact Person
                                                    <span class="required">*</span>
                                                </label>
                                                <span class="help-block">Enter Contact Person...</span>
                                            </div>
                                        </div>


                                    </div>
                                    <div class="col-md-6">
                                        <div class="col-md-12">
                                            <div class="form-group form-md-line-input">
                                                <input type="text" class="form-control" name="device_location"
                                                    placeholder="Enter your device location">
                                                <label for="form_control_1">Device Location
                                                    <span class="required">*</span></label>
                                                <span class="help-block">Enter Device Location Here...</span>
                                            </div>
                                        </div>

                                        <div class="col-md-12">
                                            <div class="form-group form-md-line-input">
                                                <input class="form-control" name="system" rows="1"
                                                    placeholder="Device/System" />
                                                <label for="form_control_1">Device/System
                                                    <span class="required">*</span></label>
                                                <span class="help-block">Enter Device/System Here...</span>
                                            </div>
                                        </div>

                                        <div class="col-md-12">
                                            <div class="form-group form-md-line-input">
                                                <select class="form-control" name="branch">
                                                    <option value="">Select</option>
                                                    <?php $branches = $this->db->query("select * from branch")->result_array();
																	foreach($branches as $branch){
																	?>
                                                    <option value="<?php echo $branch['branch_id']; ?>">
                                                        <?php echo $branch['branch_name']; ?></option>

                                                    <?php	}
																?>
                                                </select>
                                                <label for="form_control_1">Branch
                                                    <span class="required">*</span>
                                                </label>
                                                <span class="help-block">Select Branch Here...</span>
                                            </div>
                                        </div>

                                        <div class="col-md-12">
                                            <div class="form-group form-md-line-input">
                                                <input type="text" class="form-control" name="subject"
                                                    placeholder="Subject" />
                                                <label for="form_control_1">Subject
                                                    <span class="required">*</span></label>
                                                <span class="help-block">Enter Subject Here...</span>
                                            </div>
                                        </div>

                                        <div class="col-md-12">
                                            <div class="form-group form-md-line-input">
                                                <textarea class="form-control" name="issue_desc" rows="1"
                                                    placeholder="Issue Description"></textarea>
                                                <label for="form_control_1">Issue Description
                                                    <span class="required">*</span></label>
                                                <span class="help-block">Enter Issue Description Here...</span>
                                            </div>
                                        </div>
                                        <!--<div class="col-md-12">
														 <div class="form-group form-md-line-input">
															<select class="form-control" name="service_engineer" tabindex="6">
																<option value="">Select</option>
																<?php $users = $this->db->query("select * from users where role='3'")->result_array();
																	foreach($users as $user){
																	?>
																	<option value="<?php echo $user['user_id']; ?>"><?php echo $user['name']; ?></option>
																		
																<?php	}
																?>
															</select>
															<label for="form_control_1">Service Engineer
																<span class="required">*</span>
															</label>
															<span class="help-block">Select Service Engineer here...</span>
														</div>
															</div>
															
															<div class="col-md-12">
														 <div class="form-group form-md-line-input">
															<select class="form-control" name="status" tabindex="6">
																<option value="">Select</option>
																<?php $status = $this->db->query("select * from status")->result_array();
																	foreach($status as $stat){
																	?>
																	<option value="<?php echo $stat['status_id']; ?>"><?php echo $stat['status_name']; ?></option>
																		
																<?php	}
																?>
															</select>
															<label for="form_control_1">Status
																<span class="required">*</span>
															</label>
															<span class="help-block">Select status here...</span>
														</div>
															</div>-->
                                        <div class="col-md-12">

                                            <div class="form-group form-md-line-input">
                                                <input type="file" class="form-control" name="attachment[]" multiple />
                                                <label for="form_control_1">Attachment
                                                    <!-- <span class="required">*</span>-->
                                                </label>
                                                <span class="help-block">Choose Attachement Here</span>
                                            </div>
                                        </div>






                                        <?php } ?>
                                    </div>

                                    <!-- /Admin create ticket   -->

                                </div>

                                <div class="form-actions" style="background-color: #e0f8ff !important;">
                                    <div class="row">
                                        <div class="col-md-offset-3 col-md-9">
                                            <button type="submit" id="new_ticket" class="btn green">Create
                                                ticket</button>
                                            <button type="reset" class="btn default">Reset</button>
                                            <button type="button" data-dismiss="modal"
                                                class="btn btn-outline dark">Close</button>
                                        </div>
                                    </div>
                                </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    </div>
    </div>











    <?php if($role == "5" || $role == "1" || $role == "2"){ ?>
                                <div id="create_new_it_ticket" class="modal fade" data-backdrop="static"
                                    data-keyboard="false" data-width="1000">
                                    <div class="modal-body">
                                        <div class="portlet box" style="background-color: #168d90 !important;">
                                            <div class="portlet-title">
                                                <div class="caption">
                                                    <i class="fa fa-gift"></i>Create Ticket Here
                                                </div>
                                                <div class="tools">
                                                    <a href="" class="collapse"> </a>
                                                </div>
                                            </div>
                                            <div class="portlet-body form"
                                                style="background-color: #e0f8ff !important;">
                                                <!-- BEGIN FORM-->
                                                <form action="create_ticket" method="post" id="form_imges"
                                                    enctype="multipart/form-data" accept-charset="utf-8">
                                                    <div class="form-body">
                                                        <div class="row">
                                                            <?php 
												$username=$contact_number=$email=$address=$company="";
												$result = $this->User1_model->user_info($user_id);
			                                          if (count($result) > 0){ 
			                                            $user_id =  $result[0]['user_id'];
	                                                    $username =  $result[0]['user_name'];
														$contact_number =  $result[0]['mobile'];
				             										$email =  $result[0]['email'];
                                                        $department_id= $result[0]['dept_id'];
                                                        $location_id= $result[0]['location_id'];
														// $address =  $result[0]['address'];
														// $company =  $result[0]['company'];
															} 	?>
                                                            <!--hidden element-->
                                                            <!-- customer_id-->
                                                            <input type="text" class="form-control hide"
                                                                name="customer_id" id="form_control_1"
                                                                placeholder="Enter name"
                                                                value="<?php echo $user_id; ?>">
                                                            <!-- customer_id-->

                                                            <!-- customer_name-->
                                                            <input type="text" class="form-control hide" name="name"
                                                                value="<?php echo $username; ?>">
                                                            <!-- customer_name-->


                                                            <!-- contact_number-->
                                                            <input type="text" class="form-control hide"
                                                                name="contact_number"
                                                                value="<?php echo $contact_number; ?>">
                                                            <!-- email -->
                                                            <input type="text" class="form-control hide" name="email"
                                                                value="<?php echo $email; ?>">

                                                            <!-- email -->
                                                            <!---------------------------------->
                                                            <!-- user_name -->

                                                            <div class="col-md-12">
                                                                <div class="col-md-6">
                                                                    <div class="form-group form-md-line-input">
                                                                        <input type="text" class="form-control"
                                                                            name="name" id="form_control_1"
                                                                            placeholder="Enter Name"
                                                                            value="<?php echo $username; ?>" disabled>
                                                                        <label for="form_control_1">Name
                                                                            <span class="required">*</span>
                                                                        </label>
                                                                        <span class="help-block">Enter
                                                                            Name...</span>
                                                                    </div>
                                                                    <!-- user_name -->
                                                                    <div
                                                                        class="form-group form-md-line-input has-success">
                                                                        <input type="number" class="form-control"
                                                                            name="contact_number"
                                                                            onchange="contact_validate()" minlength="8"
                                                                            id="form_control_1"
                                                                            placeholder="0"
                                                                            value="<?php echo $contact_number; ?>"
                                                                            disabled>
                                                                        <label for="form_control_1">Contact Number
                                                                            
                                                                        </label>
                                                                        <span class="help-block">Type Contact Number
                                                                            between 8 or 10 Digits Only
                                                                            (ex.+651234567)</span>
                                                                    </div>

                                                                    <div class="form-group form-md-line-input">
                                                                        <div class="input-group">
                                                                            <input type="text" class="form-control"
                                                                                name="email" id=""
                                                                                placeholder="Enter your email"
                                                                                value="<?php echo $email; ?>" disabled>
                                                                            <label for="form_control_1">Email
                                                                                <span class="required"></span></label>
                                                                            <span class="help-block">Enter Email
                                                                                Here...</span>
                                                                            <span class="input-group-addon">
                                                                                <i class="fa fa-envelope"></i>
                                                                            </span>
                                                                        </div>
                                                                    </div>


                                                                    <!-- Location -->
                                                                    <div class="form-group form-md-line-input">
                                                                        <select class="form-control" id="location" name="location">


                                                                            <?php $locations = $this->db->query("select * from location ORDER BY location_id ASC")->result_array();
                                                                                            
                                                                                            echo '<option value="' . $location_id . '">' . $location_id . '</option>';   
                                                                                        
                                                                                       	?>


                                                                        </select>
                                                                        <label for="form_control_1">Location
                                                                            <span class="required">*</span>
                                                                        </label>
                                                                        <span class="help-block">Select Location
                                                                            Here...</span>
                                                                    </div>
                                                                    <!-- Location -->

                                                                    <!-- Technician -->
                                                                    <div class="form-group form-md-line-input">
                                                                        <select class="form-control"
                                                                            id="technician" name="technician">
                                                                            <?php $techs = $this->db->query("select * from users where role=3 && location_id='$location_id' ORDER BY user_name ASC")->result_array();
                                                                                    foreach($techs as $tech){
                                                                                    ?>
                                                                            <option
                                                                                value="<?php echo $tech['user_id']; ?>">
                                                                                <?php echo $tech['user_name']; ?>
                                                                            </option>
                                                                            <?php } ?>
                                                                        </select>
                                                                        <label for="form_control_1">Technician
                                                                            <span class="required">*</span>
                                                                        </label>
                                                                        <span class="help-block">Select Technician
                                                                            Here...</span>
                                                                    </div>
                                                                    <!-- /Technician -->

                                                                </div>

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

                                                                    <!--Device-->
                                                                    <div class="col-md-12">
                                                                        <div class="form-group form-md-line-input">
                                                                            <select class="form-control" id="system"
                                                                                name="system">
                                                                                <option value="">Select</option>
                                                                                <?php $devices = $this->db->query("select * from device ORDER BY device_name ASC")->result_array();
																	foreach($devices as $device){
																	?>
                                                                                <option
                                                                                    value="<?php echo $device['device_name']; ?>">
                                                                                    <?php echo $device['device_name']; ?>
                                                                                </option>
                                                                                <?php	}
																?>
                                                                                <option value="other">Others
                                                                                </option>

                                                                            </select>
                                                                            <label for="form_control_1">Device/System
                                                                                <span class="required">*</span>
                                                                            </label>
                                                                            <span class="help-block">Select
                                                                                Device/System Here...</span>
                                                                        </div>
                                                                    </div>



                                                                    <div id="deviceTextBox" class="hidden col-md-12">
                                                                        <!-- <label for="otherOption">Enter Other Option:</label> -->
                                                                        <input type="text" name="otherOption"
                                                                            id="deviceOption"
                                                                            placeholder="Enter Other Option">
                                                                    </div>

                                                                    <!--/Device-->


                                                                    <!-- Subject -->

                                                                    <div class="col-md-12">
                                                                        <div class="form-group form-md-line-input">
                                                                            <input type="text" class="form-control"
                                                                                name="subject" id="subject"
                                                                                placeholder="Enter your Subject"
                                                                                value="">

                                                                            <label for="form_control_1">Subject
                                                                                <span class="required">*</span>
                                                                            </label>
                                                                            <span class="help-block">Select Subject
                                                                                Here...</span>
                                                                        </div>
                                                                    </div>
                                                                    <!-- Subject -->

                                                                    <!-- Issue Description -->
                                                                    <div class="col-md-12">
                                                                        <div class="form-group form-md-line-input">

                                                                            <input type="text" class="form-control"
                                                                                name="issue_desc" id="issue_desc"
                                                                                placeholder="Enter your Issue Description"
                                                                                value="">

                                                                            <label for="form_control_1">Issue
                                                                                Description
                                                                                <span class="required">*</span>
                                                                            </label>
                                                                            <span class="help-block">Select Issue
                                                                                Description Here...</span>
                                                                        </div>
                                                                    </div>
                                                                    <!-- Issue Description -->


                                                                    <!--Attachment-->

                                                                    <div class="col-md-12">
                                                                        <div class="form-group form-md-line-input">
                                                                            <label for="attachment">Attachment</label>
                                                                            <input type="file" name="attachment[]"
                                                                                id="attachment" multiple />
                                                                            <span class="help-block">Choose
                                                                                Attachment Here</span>
                                                                        </div>
                                                                    </div>
                                                                    <p id="files-area">
                                                                        <span id="filesList">
                                                                            <span id="files-names"></span>
                                                                        </span>
                                                                    </p>

                                                                    <!--/Attachment-->








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




                                                    <div class="form-actions"
                                                        style="background-color: #e0f8ff !important;">
                                                        <div class="row">
                                                            <div class="col-md-offset-3 col-md-9">
                                                                <button type="submit" id="new_tickets"
                                                                    class="btn green">Create
                                                                    ticket</button>
                                                                <button type="reset" class="btn default">Reset</button>
                                                                <button type="button" data-dismiss="modal"
                                                                    class="btn btn-outline dark">Close</button>
                                                            </div>
                                                        </div>
                                                    </div>

                                                </form>
                                            </div>


                                        </div>
                                    </div>
                                </div>
                                <?php  } ?>



























































    <!-- Pending edit tickets -->
    <div id="edit_ticket_details" class="modal fade" tabindex="-1" data-backdrop="static" data-keyboard="false"
        data-width="1000">
        <div class="modal-body">
            <div class="portlet box purple">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i>Edit Ticket Here
                    </div>
                    <div class="tools">
                        <a href="" class="collapse"> </a>
                        <!-- <a href="#portlet-config" data-toggle="modal" class="config"> </a> -->
                        <!-- <a href="" class="reload"> </a> -->
                    </div>
                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form action="#" id="edit_ticket_form" style="background-color: #e0f8ff !important;"
                        enctype="multipart/form-data" accept-charset="utf-8">
                        <div class="form-body">
                            <div class="row">
                                <div class="col-md-2">
                                    <label for=""><strong>Name :</strong> </label>
                                </div>
                                <div class="col-md-4">
                                    <label for="name"> </label>
                                </div>

                                <div class="col-md-2">
                                    <label for=""><strong>Contact Number :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="contact_number"></label>
                                </div>








                            </div>

                            <!-- <div class="row">
                                <div class="col-md-2">
                                    <label for=""><strong>Company Name :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="company"></label>
                                </div>
                                <div class="col-md-2">
                                    <label for=""><strong>Address :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="address"></label>
                                </div>
                            </div> -->

                            <div class="row">
                                <div class="col-md-2">
                                    <label for=""><strong>E-mail :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="email"></label>
                                </div>

                                <div class="col-md-2">
                                    <label for=""><strong>Supervisor :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="supervisor"></label>
                                </div>

                                <!-- <div class="col-md-2">-->
                                <!--    <label for=""><strong>Service Engineer :</strong></label>-->
                                <!--</div>-->
                                <!--<div class="col-md-4">-->
                                <!--    <label for="Technician"></label>-->
                                <!--</div>-->
                            </div>

                            <div class="row">
                                <!-- <div class="col-md-2">
                                    <label for=""><strong>Device Location:</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="device_location"></label>
                                </div> -->

                                <div class="col-md-2">
                                    <label for=""><strong>Device :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="system"></label>
                                </div>
                            </div>
                            <div class="row">
                                <!-- <div class="col-md-2">
                                    <label for=""><strong>Branch :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="branch">-</label>
                                </div> -->
                                <div class="col-md-2">
                                    <label for=""><strong>Subject :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="subject"></label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-2">
                                    <label for=""><strong>Issue Description :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="issue_desc"></label>
                                </div>
                                <div class="col-md-2">
                                    <label for=""><strong>Attachment :</strong></label>
                                </div>
                                <div class="col-md-4">
                                    <label for="attachment"></label>
                                </div>
                            </div>
                            <div class="row">
                                <div id="line">
                                    <hr style="">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <label for="">
                                        <h4><strong>View Comments:</strong></h4>
                                    </label>
                                    <div id="comments">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div id="line">
                                    <hr style="">
                                </div>
                            </div>
                            <div class="row">
                                <input type="hidden" name="update_id" />

                                <!-- service_engineer -->





                                <div class="col-md-6" id="service_engineer_edit">
                                    <div class="form-group form-md-line-input">
                                        <div class="scroll-container">

                                        <select class="form-control service_engineer" name="service_engineer" tabindex="6" style="overflow-y: auto !important;">
                                            <?php if($role == 3 || $role == 6){ echo "readonly"; } ?>>

                                            <option value="">Select</option>

                                            <?php 
            if($role == 4 || $role == 3){
                $users = $this->db->query("SELECT * FROM users WHERE role = '3'")->result_array();
                foreach ($users as $user) {
               
            ?>
                                            <option value="<?php echo $user['user_id']; ?>">
                                                <?php echo $user['user_name']; ?></option>
                                            <?php
                    
                } 
            }

            if($role == "1" || $role == "2" || $role == 5 || $role == 6 || $role == 7){
               
             $users = $this->db->query("SELECT * FROM users WHERE role = '6' OR role = '7'")->result_array();
                foreach ($users as $user) {
                    
            ?>
                                            <option value="<?php echo $user['user_id']; ?>">
                                                <?php echo $user['user_name']; ?></option>
                                            <?php
                } 
            }
            ?>

                                        </select>
                                        </div>
                                        <label for="form_control_1">Frontliner
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select Frontliner here...</span>
                                    </div>
                                </div>





                                <!-- Supervisor -->
                                <?php if( $role == 6 ){  ?>

                                <input type="hidden" name="supervisor">
                                <?php }?>

                                <?php if($role == 5 || $role == 7){  ?>
                                <div class="col-md-6" id="supervisor_edit">
                                    <div class="form-group form-md-line-input">

                                        <select class="form-control supervisor" name="supervisor" tabindex="6"
                                            <?php if($role == 6){ echo "readonly"; } ?>>
                                            <option value="">Select</option>
                                            <?php    $users = $this->db->query("select * from users where role='7'")->result_array();
													 foreach($users as $user){ ?>
                                                     <option value="<?php echo $user['user_id']; ?>"><?php echo $user['user_name']; ?></option>
                                            <?php   }   ?>
                                        </select>
                                        
                                        
                                        <label for="form_control_1">Supervisor
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select Supervisor here...</span>
                                    </div>
                                </div>
                                <?php } ?>
                                <div class="col-md-6">
                                    <div class="form-group form-md-line-input">
                                        <select class="form-control" name="status" tabindex="6"
                                            <?php if($role == 4){ echo "disabled"; } ?>>
                                            <!--<option value="">Select</option>-->
                                           
                                           <?php
                                           
                                             if($role ==5 || $role ==1 || $role ==2){

                                                $status = $this->db->query("select * from status")->result_array();
                                            
                                            }	else {
                                           
                                                $status = $this->db->query("SELECT * FROM status WHERE status_id != 3 AND status_id != 5")->result_array();;
                                            }																
																
																
																
																
																
																	foreach($status as $stat){
																	?>
                                            <option value="<?php echo $stat['status_id']; ?>">
                                                <?php echo $stat['status_name']; ?></option>

                                            <?php	}
																?>
                                        </select>
                                        <label for="form_control_1">Status
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select status here...</span>
                                    </div>
                                </div>
                                
                                
                                
                                
                                <div class="col-md-6" id="service_engineer_hidden">
                                    <div class="form-group form-md-line-input">
                                        <select class="form-control" name="service_engineer_hidden" tabindex="6">
                                          
                                          
                                           <option value="">
                                               
                                         <?php   $users = $this->db->query("SELECT * FROM users WHERE role = '3'")->result_array();
                                                foreach ($users as $user) {
                                               
                                            ?>
                                            <option value="<?php echo $user['user_id']; ?>">
                                                <?php echo $user['user_name']; ?></option>
                                            <?php
                    
                                              } ?>
                                           
                                           
                                           
                                           
                                           
                                           </option>
                                        </select>
                                        <label for="form_control_1">Frontliner
                                            <span class="required">*</span>
                                        </label>
                                        <span class="help-block">Select Frontliner here...</span>
                                    </div>
                                </div>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <div class="col-md-6">
                                    <div class="form-group form-md-line-input">
                                        <textarea id="comment-field" name="description" cols="10" rows="1"
                                            class="form-control" spellcheck="false"></textarea>
                                        <label for="form_control_1">Comments</label>
                                        <span class="help-block">Enter Comments Here...</span>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group form-md-line-input">
                                        <input type="file" class="form-control" name="attachment[]" multiple />
                                        <label for="form_control_1">Attachment
                                            <!-- <span class="required">*</span>-->
                                        </label>
                                        <span class="help-block">Choose Attachement Here</span>
                                    </div>
                                </div>
                                <input type="hidden" name="user_role" value="<?php echo $role; ?>">
                            </div>
                        </div>

                        <?php if($role == 7){?>

                        <div class="form-actions" style="background-color: #e0f8ff !important;">
                            <div class="row">
                                <div class="col-md-offset-4 col-md-12" style="display:flex">

                                    <div id="ticket-container">
                                        <button type="submit" id="pending_edit_ticket_update" class="btn green"> Update
                                            Ticket</button>
                                        <button id="pending_edit_ticket_hide" type="reset" class="btn default"> Reset</button>

                                    </div>

                                    <button type="button" data-dismiss="modal"
                                        class="button_closed btn btn-outline dark">Close</button>


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

                        <?php   } ?>
                        <!-- <option value="<?php echo $location['location_id']; ?>"> -->


                        <div class="form-actions" style="background-color: #e0f8ff !important;">
                            <div class="row">
                                <div class="col-md-offset-6 col-md-12" style="display:flex">

                                    <button type="submit" id="" class="btn green"
                                        style="display: <?= $role == 7 ? 'none' : 'block'; ?>">Update Ticket</button>

                                    <button type="reset" class="btn default"
                                        style="display: <?= $role == 7 ? 'none' : 'block'; ?>">Reset</button>


                                    <button type="button" data-dismiss="modal"
                                        style="display: <?= $role == 7 ? 'none' : 'block'; ?>"
                                        class="button_closed btn btn-outline dark">Close</button>


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

                </div>
                </form>

            </div>
        </div>
    </div>
    
    
    
    
    
    
    
    <!-- Edit User Details -->
<div id="edit_users_details" class="modal fade" tabindex="-1" data-backdrop="" data-keyboard="false"
        data-width="800">
        <div class="modal-body">
            <div class="portlet box purple">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i>Edit Selected User details And Update It Here!
                    </div>
                    <div class="tools">
                        <a href="" class="collapse"> </a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form action="javascript:;" id="update_user">
                        <div class="form-body">
                            <div class="row">
                            <div class="col-md-3">
                            </div>
                                <div class="col-md-9">
                                    <input type="text" class="form-control hide edit_id_value_user" name="edit_id_value_user"
                                        id="form_control_1">
                                   
                                   
                                    <div class="form-group form-md-line-input">
                                        <input type="text" class="form-control ename_user" name="ename_user" maxlength="50"
                                            id="form_control_1"  tabindex="2">
                                        <label for="form_control_1" disable>Name
                                        </label>
                                        <span class="help-block">Enter Full Name ...</span>
                                    </div>


                                <!-- <div class="col-md-6">
                                    <label for=""><strong>Name :</strong> </label>
                                </div>
                                <div class="col-md-6">
                                    <label for="ename"> </label>
                                </div> -->




                                    <div class="form-group form-md-line-input">
                                        <input type="text" class="form-control epass_user" id="form_control_1" name="epass_user"
                                            maxlength="10"  tabindex="5">
                                        <label for="form_control_1">Password
                                        </label>
                                        <span class="help-block">Enter Password ...</span>
                                    </div>
                                </div>
                                    
                                </div>
                            </div>
                        </div>

                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-offset-4 col-md-9">
                                    <button type="submit" id="" class="btn green">Update User
                                        details</button>
                                    <button type="button" data-dismiss="modal"
                                        class="btn btn-outline dark">Close</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    
    
    
    
    

    <div id="view_ticket_details" class="modal fade" data-backdrop="static" data-keyboard="false" data-width="800">
        <div class="modal-body">
            <div class="portlet box purple">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="fa fa-gift"></i>View Ticket Status Details
                    </div>
                    <div class="tools">
                        <a href="" class="collapse"> </a>
                        <!-- <a href="" class="reload"> </a> -->
                    </div>
                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form action="#" id="form_sample_2">
                        <div class="form-body">
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Name :</strong> </label>
                                </div>
                                <div class="col-md-8">
                                    <label for="name"> </label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Contact Number :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="contact_number"></label>
                                </div>
                            </div>

                            <!-- <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Company Name :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="company"></label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Address :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="address"></label>
                                </div>
                            </div> -->
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>E-mail :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="email"></label>
                                </div>
                            </div>

                            <!-- <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Contact Person :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="contact_person">-</label>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Device Location</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="device_location"></label>
                                </div>
                            </div> -->

                            <?php  if($role == 1 || $role == 2 || $role == 3 || $role == 4){  ?>

                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Device/System :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="system"></label>
                                </div>
                            </div>
                            <?php } ?>





                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Supervisor :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="supervisor"></label>
                                </div>
                            </div>





                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Subject :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="subject"></label>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Issue Description :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="issue_desc"></label>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Attachment :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="attachment"></label>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-md-3">
                                    <label for=""><strong>Status :</strong></label>
                                </div>
                                <div class="col-md-8">
                                    <label for="status"></label>
                                </div>

                            </div>
                        </div>

                </div>
                <div class="form-actions">
                    <div class="row">
                        <div class="col-md-3 col-md-9">
                            <button type="button" data-dismiss="modal" class="btn btn-outline dark">Close</button>
                        </div>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>

    <?php if($role == "4" || $role == "2" || $role == "3"){  ?>

    <input type="hidden" name="update_ids" id="technician_role" value="<?= $role ?>" />

    <?php }?>




    <script src="../assets/pages/scripts/cityairjs/ticket.js" type="text/javascript"></script>
            <script src="../assets/pages/scripts/cityairjs/change_password.js" type="text/javascript"></script>

<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>


<script>
//   $(document).ready(function() {
//     $('#technician').select2({
//       placeholder: 'Select a state', 
//       allowClear: true,
//     });
//   });
  
  
  
  $(document).ready(function() {
    $('#technician').select2();
});
</script>

    <!-- End loader pages here -->
    <script>
    
    

    
    
    $("#startdDate").datepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        todayHighlight: true
    });
    $("#enddDate").datepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        todayHighlight: true
    });
    $(document).ready(function() {

        var now = new Date();

        var day = ("0" + now.getDate()).slice(-2);
        var month = ("0" + (now.getMonth() + 1)).slice(-2);

        var today = now.getFullYear() + "-" + (month) + "-" + (day);


        $('#startdDate').val(today);
        $('#enddDate').val(today);

    });


    //paste this code under head tag or in a seperate js file.
    // Wait for window load
    $(window).load(function() {
        // Animate loader off screen
        $(".se-pre-con").fadeOut("slow");
    });



    // // Location to contact pesrion
    // $(document).ready(function() {
    //     $('#location').change(function() {
    //         var location_id = $(this).val();
    //         var role= $("#subemployee_role").val();
    //         var technician_role= $("#technician_role").val();
    //         // var branch = $(this).val();
    //         $.ajax({
    //             url: "<?php echo base_url()?>Ticket/get_technicians",
    //             method: 'POST',
    //             data: {
    //                 location_id: location_id
    //             },
    //             dataType: 'json',
    //             success: function(response) {
    //                 $('.technician').empty();
    //                 // Add new options based on the response
    //                 $.each(response, function(index, technicians) {
    //                             if (technicians.length > 0) { 

    //                                 $.each(technicians, function(index, technician) { 

    //                                     if (technician.role == 3 && technician_role != null) {
    //                                         $('.technician').append('<option value="' + technician.user_id + '">' + technician.user_name + '</option>');
    //                                     } 

    //                                     else if (technician.role == 6 && role != null) {
    //                                         $('.technician').append('<option value="' + technician.user_id + '">' + technician.user_name + '</option>');

    //                                     }

    //                                     else if (technician.role == 7 && role != null) {
    //                                         $('.spr').append('<option value="' + technician.user_id + '">' + technician.user_name + '</option>');
    //                                     }


    //                                 });
    //                             } else {
    //                                 $('.technician').append('<option value="' + technicians.user_id + '">' + technicians.user_name + '</option>');
    //                             }
    //                         });
    //                         }
    //                     });
    //                 });




    // IT ticket Location based technician
    $(document).ready(function() {
        $('#location').change(function() {
            var location_id = $(this).val();
            var role = $("#subemployee_role").val();
            var technician_role = $("#technician_role").val();
            $('.checkbox-container').empty();
            
            
            $.ajax({
                url: "<?php echo base_url()?>Ticket/get_technicians",
                method: 'POST',
                data: {
                    location_id: location_id
                },
                dataType: 'json',
                success: function(response) {
                    
                    console.log(response);
                    
                    $('.technician').empty();
                    // Add new options based on the response
                    $.each(response, function(index, technicians) {
                        if (technicians.length > 0) {
                            $.each(technicians, function(index, technician) {
                                console.log(technician);
                                
                                

                                if (technician.role == 3 && technician_role != null) {
                                   $('.technician').append('<option value="' + technician.user_id + '">' + technician.user_name + '(' + technician.employee_id + ')' + '</option>');

                                } else if (technician.role == 6 && role != null) {
                                    $('.technician').append('<option value="' + technician.user_id + '">' + technician .user_name + '(' + technician.employee_id + ')' + '</option>');
                                } else if (technician.role == 7 && role != null) {
                                    //  $('.checkbox-container').empty();

                                    
                                    $('.technician').append('<option value="' + technician.user_id + '">' + technician.user_name + '(' + technician.employee_id + ')' + '</option>');

                                    var isChecked = technician
                                        .isChecked; // true or false

                                    var checkbox = $('<input>')
                                        .attr({
                                            type: 'checkbox',
                                            name: 'technician_ids[]', // Use [] to send multiple values as an array
                                            value: technician.user_id,
                                            id: 'checkbox_' + technician
                                                .user_id
                                        })
                                        .prop('checked', isChecked)
                                        .css({
                                            'margin-right': '10px',
                                            'vertical-align': 'middle'
                                        });

                                        

                                    // Create label for the checkbox
                                    var label = $('<label>')
                                        .attr('for', 'checkbox_' +
                                            technician.user_id)
                                        .text(technician.user_name);
                                        

                                    // Append checkbox and label to the checkbox container
                                    $('.checkbox-container').append(
                                        checkbox, label).append('<br>');

                                }
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            });
                        } else {
                            if(technicians.user_name !== undefined){
                            
                            $('.technician').append('<option value="' + technicians
                                .user_id + '">' + technicians.user_name +
                                '</option>');
                            
                                
                            }
                                
                                
                        }
                    });
                }
            });
        });
    });



    // //Supervisor
    // $('#technician').change(function() {
    //         var user_id = $(this).val();
    //         var location_id = $("#location").val();
    //         var role = $("#subemployee_role").val();

    //         $.ajax({
    //             url: "<?php echo base_url()?>Ticket/get_supervisor",
    //             method: 'POST',
    //             data: {
    //                 location_id: location_id,
    //                 user_id: user_id
    //             },
    //             dataType: 'json',
    //             success: function(response) {
    //                 $('.spr').empty();

    //                 $.each(response, function(index, supervisor) {
    //                     console.log(supervisor);
    //                     if (supervisor.role == 7 && role != null) {
    //                         $('.spr').append('<option value="' + supervisor.user_id + '">' + supervisor.user_name + '</option>');
    //                     }
    //                 });
    //             }
    //         });
    //     });

    //})













    document.getElementById("system").addEventListener("change", function() {

        var selectedOption = this.value;


        var deviceTextBox = document.getElementById("deviceTextBox");
        var deviceOptionInput = document.getElementById("deviceOption");

        if (selectedOption === "other") {
            deviceTextBox.classList.remove("hidden");
            deviceOptionInput.setAttribute("required", "required"); // Add required attribute if needed
        } else {
            deviceTextBox.classList.add("hidden");
            deviceOptionInput.removeAttribute("required"); // Remove required attribute if not needed
        }
    });

    // $(document).ready(function() {
    // var role = 7;

    //     var button = document.getElementById("pending_edit_ticket_update");

    //     if (role == 7) {
    //         button.style.display = "none";
    //     }
    // });
    </script>




    <script>
    const dt = new DataTransfer(); // Permet de manipuler les fichiers de l'input file

    $("#attachment").on('change', function(e) {
        for (var i = 0; i < this.files.length; i++) {
            let fileBloc = $('<span/>', {
                    class: 'file-block'
                }),
                fileName = $('<span/>', {
                    class: 'name',
                    text: this.files.item(i).name
                });
            fileBloc.append('<span class="file-delete"><span>+</span></span>')
                .append(fileName);
            $("#filesList > #files-names").append(fileBloc);
        };
        // Ajout des fichiers dans l'objet DataTransfer
        for (let file of this.files) {
            dt.items.add(file);
        }
        // Mise à jour des fichiers de l'input file après ajout
        this.files = dt.files;

        // EventListener pour le bouton de suppression créé
        $('span.file-delete').click(function() {
            let name = $(this).next('span.name').text();
            // Supprimer l'affichage du nom de fichier
            $(this).parent().remove();
            for (let i = 0; i < dt.items.length; i++) {
                // Correspondance du fichier et du nom
                if (name === dt.items[i].getAsFile().name) {
                    // Suppression du fichier dans l'objet DataTransfer
                    dt.items.remove(i);
                    continue;
                }
            }
            // Mise à jour des fichiers de l'input file après suppression
            document.getElementById('attachment').files = dt.files;
        });
    });
    
    
    
        document.getElementById("service_engineer_hidden").hidden = true;
        
        
        
        
        
        
        
        
        
        
                     var user_id = "<?php echo $this->session->userdata('USER_ID'); ?>"; 

        
$(document).on('click', '.delete_button', function() {
            var delete_id = $(this).data('id');

        
            //   var userConfirmation = confirm("Are you sure you want to proceed with this action?");
              
              let ticket = prompt("Could you share the reason for deleting the ticket?", "The ticket was created in error");
                
              
              
              
           
              if (ticket) {
                $.ajax({
                  url: 'update_ticket_status',  
                  type: 'POST',     
                  data: {
                      delete_id:delete_id,
                      ticket:ticket,
                      user_id: user_id
                  },
                  dataType: 'json',
                  success: function(response) {
                    if(response.status == 'success') {
                    alert(response.message);
                    window.location.reload();
                    } else {
                        alert(response.message);
                    }
                    
                  },
                  error: function(error) {
                    console.error('Request failed:', error);
                  }
                });
              } else {
                console.log('Request canceled by the user.');
              }
            });
 
        
        
        
        
        
        
        
        
        
        
        
        
        
        

    </script>
</body>

</html>