<?php $__env->startSection('content'); ?>
<!-- row -->
<div class="container-fluid">
    <div class="page-titles">
        <ol class="breadcrumb">
            <li class="breadcrumb-item active"><a href="javascript:void(0)">My Profile</a></li>
        </ol>
    </div>
    <!-- row -->
    <div class="row">
        <div class="col-lg-12">
            <div class="profile card card-body px-3 pt-3 pb-0">
                <div class="profile-head">
                    <div class="profile-info">
						<div class="profile-photo">
							<?php if($users->photo): ?>
							<img  src="<?php echo e(asset('uploads/users/')); ?>/<?php echo e($users->photo); ?>" class="img-fluid rounded-circle" alt="">
							<?php else: ?>
							<img  src="<?php echo e(asset('images/profile/pic1.jpg')); ?>" class="img-fluid rounded-circle" alt=""> 
							<?php endif; ?>
						</div>
						<div class="profile-details">
							<div class="profile-name px-3 pt-2">
								<h4 class="text-primary mb-0"><?php echo e($users->name); ?></h4>
							</div>
							<div class="profile-email px-2 pt-2">
								<h4 class="text-muted mb-0"><?php echo e($users->email); ?></h4>
							</div>
						</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xl-12">
            <div class="card">
                <div class="card-body">
                    <div class="profile-tab">
                        <div class="custom-tab-1">
                            <ul class="nav nav-tabs">
                                <li class="nav-item"><a href="#profile-settings" data-toggle="tab" class="nav-link active show">Account Setting</a></li>
                                <li class="nav-item"><a href="#profile-password" data-toggle="tab" class="nav-link">Change Password</a></li>
                                <li class="nav-item"><a href="#profile-photo" data-toggle="tab" class="nav-link">Change Photo</a></li>
                            </ul>
                            <div class="tab-content">
                                <div id="profile-settings" class="tab-pane fade active show">
                                    <div class="pt-3">
                                        <div class="settings-form">
                                            <form id="userregform" class="form-horizontal" action="<?php echo e(URL::to('/myprofile_post')); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
                    							<?php echo e(csrf_field()); ?>

                                            	<div class="form-row">
				                                    <div class="form-group col-md-4">
				                                        <label>Name</label>
				                                        <input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required value="<?php echo e($users->name); ?>">
				                                        <input type="hidden" class="form-control" id="user_id" name="user_id" required value="<?php echo e($users->id); ?>">
				                                    </div>
				                                    <div class="form-group col-md-4">
				                                        <label>Email ID</label>
				                                        <input type="text" class="form-control" id="email" name="email" placeholder="Enter Email" required value="<?php echo e($users->email); ?>">
				                                    </div>
				                                    <div class="form-group col-md-4">
				                                        <label>Phone Number</label>
				                                        <input type="text" class="form-control" id="phone_number" name="phone_number" placeholder="Enter Phone Number" required value="<?php echo e($users->phone_number); ?>" maxlength="15">
				                                    </div>
				                                </div>
				                                <div class="form-row">
				                                  	<div class="form-group col-md-4">
				                                        <label>Organisation</label> <br>
				                                        <select name="organisation_id" id="organisation_id" class="form-control" required onchange="load_department(this.value)">
				                                          <option value="">Select Organisation</option>
				                                            <?php $__currentLoopData = $organisations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $organisation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
				                                              <option value="<?php echo e($organisation->id); ?>" <?php echo e($users->organisation_id == $organisation->id ? 'selected' : ''); ?>><?php echo e($organisation->organisation_name); ?></option>
				                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				                                        </select>
													</div>
													<div class="form-group col-md-4">
														<label>Department</label>
														<select name="department_id" id="department_id" class="form-control" required onchange="load_section(this.value)">
															<option value="">Select Department</option>
															<?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
																<option value="<?php echo e($department->id); ?>" <?php echo e($users->department_id == $department->id ? 'selected' : ''); ?>><?php echo e($department->department_name); ?></option>
															<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
														</select>
				                                  	</div>
				                                  	<div class="form-group col-md-4">
				                                      	<label>Section</label>
				                                      	<select name="section_id" id="section_id" class="form-control" required>
					                                        <option value="">Select Section</option>
					                                        <?php $__currentLoopData = $sections; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $section): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					                                            <option value="<?php echo e($section->id); ?>" <?php echo e($users->section_id == $section->id ? 'selected' : ''); ?>><?php echo e($section->section_name); ?></option>
					                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				                                      	</select>
				                                  	</div>
				                                </div>
												<div class="card-footer">
				                                  <button type="submit" class="btn btn-primary">Update Profile</button>
				                                </div>                                                    
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <div id="profile-password" class="tab-pane fade">
                                	<div class="pt-3">
                                        <div class="settings-form">
                                            <form id="userpwdform" class="form-horizontal" action="<?php echo e(URL::to('/myprofilepwd_post')); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
                    							<?php echo e(csrf_field()); ?>

                                            	<div class="form-row">
				                                    <div class="form-group col-md-4">
				                                        <label>Current Password</label>
				                                        <input type="password" class="form-control" id="current_password" name="current_password" placeholder="Enter Current Password" required>
				                                        <input type="hidden" class="form-control" id="user_id" name="user_id" required value="<?php echo e($users->id); ?>">
				                                    </div>
				                                    <div class="form-group col-md-4">
				                                        <label>New Password</label>
				                                        <input type="password" class="form-control" id="password" name="password" placeholder="Enter New Password" required>
				                                    </div>
				                                    <div class="form-group col-md-4">
				                                        <label>Confirm New Password</label>
				                                        <input type="password" class="form-control" id="confirm_password" name="confirm_password" placeholder="Enter Confirm New Password" required>
				                                    </div>
				                                </div>
				                                <div class="card-footer">
				                                  <button type="submit" class="btn btn-primary">Update Password</button>
				                                </div>
												                                                       
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <div id="profile-photo" class="tab-pane fade">
                                	<div class="pt-3">
                                        <div class="settings-form">
                                            <form id="userphotoform" class="form-horizontal" action="<?php echo e(URL::to('/myprofilephoto_post')); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
                    							<?php echo e(csrf_field()); ?>

                                            	<div class="form-row">
				                                    <div class="form-group col-md-4">
				                                          <label>Photo</label><br>
				                                          <input type="file" name="photo" id="photo" onchange="check_extension_photo(this);PreviewImage();">
				                                          <input type="hidden" class="form-control" id="user_id" name="user_id" required value="<?php echo e($users->id); ?>">
				                                    </div>
				                                    <div class="form-group col-md-2">
				                                          <!-- uploaded photo showing  -->
				                                          <img id="uploadPreview" style="width: 100px; height: 100px;" />                        
				                                    </div>
				                                    <div class="form-group col-md-2">
				                                          <!--already uploaded photo showing  -->
				                                          <?php if($users->photo!=""): ?>
				                                            <img class="img-fluid" src="<?php echo e(asset('uploads/users/')); ?>/<?php echo e($users->photo); ?>" alt="" style="width: 100px; height: 100px;" >
				                                          <?php else: ?> 
				                                            <label>No Photo Uploaded Yet</label>
				                                          <?php endif; ?>
				                                    </div>
				                                </div>
				                                <div class="card-footer">
				                                  <button type="submit" class="btn btn-primary">Update Photo</button>
				                                </div>
												                                                       
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>	
<script type="text/javascript">
	function load_department(organisation_id)
    {
        $.ajax({
           type:'GET',
           url: "<?php echo url('get_department/"+organisation_id+"'); ?>",
           success:function(data)
           {
              $('#department_id').empty();
              $('#department_id').append("<option value=''>Select Department</option>");
              $.each(data, function(key, element) {
                  $('#department_id').append("<option value='" + key +"'>" + element + "</option>");
              }); 
           }
        });
    }
    function load_section(department_id)
    {
        $.ajax({
           type:'GET',
           url: "<?php echo url('get_section/"+department_id+"'); ?>",
           success:function(data)
           {
              $('#section_id').empty();
              $('#section_id').append("<option value=''>Select Section</option>");
              $.each(data, function(key, element) {
                  $('#section_id').append("<option value='" + key +"'>" + element + "</option>");
              }); 
           }
        });
    }
    //////check the extension of photo upload////////////////////////
    function check_extension_photo(field)
    {
      var file= field.value;
      var reg = /(.*?)\.(jpeg|jpg|png|JPEG|JPG|PNG)$/;
      if(!file.match(reg))
      {
          alert("Invalid File format. Please upload jpeg/jpg/png format.");
          field.value="";
          field.focus();
          return false;
      }
    }
    //to show the uploaded photo immediately after uploading before insertion
    function PreviewImage()
    {
      var oFReader = new FileReader();
      oFReader.readAsDataURL(document.getElementById("photo").files[0]);
      oFReader.onload = function (oFREvent) {
          document.getElementById("uploadPreview").src = oFREvent.target.result;
      };
    }
</script>		
<?php $__env->stopSection(); ?>			
<?php echo $__env->make('layout.default', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmprod/resources/views/myprofile.blade.php ENDPATH**/ ?>