<?php

include('libraryPHP/site_config.php');

include('libraryPHP/session_check_url.php');

?>

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">

    <title><?php echo $appName ?> | <?php echo $pageTitle ?></title>



    <!-- App favicon -->



    <?php echo $appFaviconHtml ?>



    <?php include('commoncss.php') ?>



    <!--[if lt IE 9]>

            <script src="assets/js/html5shiv.min.js"></script>

            <script src="assets/js/respond.min.js"></script>

        <![endif]-->

</head>

<body>



    <!-- Main Wrapper -->

    <div class="main-wrapper">



        <!-- Header -->

        <!-- Header -->

        <?php include('header.php') ?>

        <!-- /Header -->



        <!-- Sidebar -->

        <?php include('sidebar.php') ?>

        <!-- /Sidebar -->

        <!-- /Sidebar -->



        <!-- Page Wrapper -->

        <div class="page-wrapper">

            <div class="content container-fluid">



                <!-- Page Header -->

                <div class="page-header">

                    <div class="row">

                        <div class="col-sm-7">

                            <h3 class="page-title">Edit User</h3>

                            <ul class="breadcrumb">

                                <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
                                <li class="breadcrumb-item"><a href="manage_user.php">Manage User</a></li>


                                <li class="breadcrumb-item active">Edit User</li>

                            </ul>

                        </div>

                        <div class="col-sm-5 col">

                          
                        </div>

                    </div>

                </div>

                <!-- /Page Header -->



                <div class="row">

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

                        <div class="card">

                            <div class="card-body">

                                <h5>Edit User


                                </h5>



                                <form method="POST" id="edit_manage_service_form" enctype="multipart/form-data">
                                    <input required="required" type="hidden" id="action" name="action" value="edit_user">

                                    <input type="hidden" name="user_id" id="user_id" value="<?php echo $_GET['id'] ?>">
                                   

                                    <input type="hidden" name="type" value="1">
                                   


                                    

                                                 <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Name</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                    <input type="text" class="form-control" name="name" id="name" placeholder="Enter  Name" value="<?php echo $getUsersData['name'] ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Mobile Number</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                    <input type="text" class="form-control" name="mobile" id="mobile" placeholder="Enter Mobile Number" value="<?php echo $getUsersData['mobile'] ?>">
                                                </div>
                                            </div>
                                        </div>

                                         <div class="form-group">
                                                    <label class="col-sm-12 col-md-12 ">Country</label>
                                                    <select class="form-control required " id="sel2" name="country" data-palceholder="Choose Country">

                                                        <option value="" selected disabled hidden>Choose Country</option>


                                                        <?php
                                                        $user_id    =   0;
                                                        $name           =   '';
                                                        if (!empty($getCountryData)) {
                                                            foreach ($getCountryData as $key => $value) {
                                                                $country_id    =   $value['country_id'];
                                                                $name           =   $value['name'];

                                                        ?>
                                                                <option value="<?php echo $country_id; ?>" <?php if ($country_id == $getUsersData['country_id']) {
                                                                                                            echo 'selected';
                                                                                                        } else {
                                                                                                            '';
                                                                                                        } ?>><?php echo $name; ?></option>
                                                        <?php
                                                            }
                                                        }
                                                        ?>


                                                    </select>

                                                </div>

                                                <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">DOB</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                    <input type="date" class="form-control" name="dob" id="dob" placeholder="Enter dob" value="<?php echo date('Y-m-d',strtotime($getUsersData["dob"])) ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Gender</label>
                                            <div class="col-sm-12 col-md-12">
                                               
                                                   <div class="form-check-inline">
                                                      <label class="form-check-label">
                                                     <input type="radio" class="form-check-input" name="gender" <?php if($getUsersData['gender1'] == 1){echo "checked";}?> value="1">Male
  </label>
</div>
<div class="form-check-inline">
  <label class="form-check-label">
    <input type="radio" class="form-check-input" name="gender" <?php if($getUsersData['gender1'] == 2){echo "checked";}?> value="2">Female
  </label>
</div>
<div class="form-check-inline">
  <label class="form-check-label">
    <input type="radio" class="form-check-input" name="gender" <?php if($getUsersData['gender1'] == 3){echo "checked";}?> value="3">Other
  </label>
</div>
                                            </div>
                                        </div>


                                                <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Height</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                    <input type="number" class="form-control" name="height" id="height" placeholder="Enter height" value="<?php echo $getUsersData['height_fit'] ?>">
                                                </div>
                                            </div>
                                        </div>

                                         <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Weight</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                    <input type="number" class="form-control" name="weight" id="weight" placeholder="Enter weight" value="<?php echo $getUsersData['weight'] ?>">
                                                </div>
                                            </div>
                                        </div>
                                        



                                                <div class="form-group">
                                                      <label class="col-sm-12 col-md-12 ">Education</label>
                                                    <select class="form-control required " id="sel2" name="education" data-palceholder="Choose Education">

                                                        <option value="" selected disabled hidden>Choose Education </option>


                                                        <?php
                                                        $user_id    =   0;
                                                        $name           =   '';
                                                        if (!empty($getEductionData)) {
                                                            foreach ($getEductionData as $key => $value) {
                                                                $education_id    =   $value['education_id'];
                                                                $name           =   $value['name'];

                                                        ?>
                                                                <option value="<?php echo $education_id; ?>" <?php if ($education_id == $getUsersData['education_id1']) {
                                                                                                            echo 'selected';
                                                                                                        } else {
                                                                                                            '';
                                                                                                        } ?>><?php echo $name; ?></option>
                                                        <?php
                                                            }
                                                        }
                                                        ?>


                                                    </select>

                                                </div>

                                                 <div class="form-group">
                                                     <label class="col-sm-12 col-md-12 ">Profession</label>
                                                    <select class="form-control required " id="sel2" name="profession" data-palceholder="Choose Profession">

                                                        <option value="" selected disabled hidden>Choose Profession </option>


                                                        <?php
                                                        $user_id    =   0;
                                                        $name           =   '';
                                                        if (!empty($getProfessionData)) {
                                                            foreach ($getProfessionData as $key => $value) {
                                                                $profession_id    =   $value['profession_id'];
                                                                $name           =   $value['name'];

                                                        ?>
                                                                <option value="<?php echo $profession_id; ?>" <?php if ($profession_id == $getUsersData['profession_id1']) {
                                                                                                            echo 'selected';
                                                                                                        } else {
                                                                                                            '';
                                                                                                        } ?>><?php echo $name; ?></option>
                                                        <?php
                                                            }
                                                        }
                                                        ?>


                                                    </select>

                                                </div>


                                         <div class="form-group ">
                                            <label class="col-sm-12 col-md-12 ">Biography</label>
                                            <div class="col-sm-12 col-md-12">
                                                <div class="form-group">
                                                  <textarea rows="10" cols="15" class="form-control" placeholder="Enter biography" name="bio"><?php echo $getUsersData['biography'] ?></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        



                                            
                                        <div class="form-group row">

                                            <label class="col-form-label col-md-2"></label>

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

                                                <div href="#img_view">

                                                    <img src="<?php echo $img_url_user_main . $getUsersData['image']; ?>" class="img-responsive rounded-circle" name="event_image" id="image-holder11" style="width:80px; height: 80px;" onerror="this.src='assets/images/placeholder.png'" alt="">



                                                    <a href="" class="close_my_popup"><img src=""></a>

                                                </div>

                                            </div>

                                        </div>

                                        <div class="form-group row">

                                            <label class="col-form-label col-md-2">User Image</label>

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

                                                <input class="form-control" type="file" id="fileUpload1" name="image">

                                                <label style="color:red;">(Note : please choose image resolution with 500X500 pixels)</label>

                                            </div>

                                        </div>




                                    







                                       

                                        
                                        

                                       








                                        

                                  



                            <!--  <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>-->


                            <button type="submit" class="btn btn-primary">Update</button>



                      


                        </form>



                    </div>

                </div>

            </div>

        </div>



    </div>

    </div>


    <?php include('commonjs.php') ?>

    <?php include_once('extrajs.php') ?>

    <script type="text/javascript">
        

$('#edit_manage_service_form').validate({
      rules:{
             
                
              name: {
                        required: true,
                       
                        maxlength: 50,
                        //noSpace: true,
                       

                    },

                     mobile: {
                        required: true,
                        minlength: 10,
                        maxlength: 10,
                        
                       

                    },
                    country:{
                        required:true,
                    },
                    dob:
                    {
                        required:true,
                    },
                    gender:
                    {
                        required:true,
                    },
                     height:
                    {
                        required:true,
                        min:1,
                    },
                    weight:
                    {
                        required:true,
                        min:1,
                    },
                    education:{
                        required:true,
                    },

                     profession:{
                        required:true,
                    },

                     bio:
                    {
                        required:true,
                    }, 


                
            },
             messages:{
                 
                 name: {
                        required:"Please enter name",
                      
                        maxlength:"Maximum 50 character allowed for name",
                        
                       

                    },

                     mobile: {
                        required:"Please enter mobile number",
                        minlength:"Minimum 10 digit allowed for mobile number",
                        maxlength:"Maximum 10 digit allowed for mobile number",
                        
                       

                    },
                    country:{
                        required:'Please choose country',
                    },
                    dob:
                    {
                        required:"Please enter dob",
                    },
                    gender:
                    {
                        required:"Please choose gender",
                    },
                     height:
                    {
                        required:"Please enter height",
                    },
                      
                    weight:
                    {
                        required:"Please enter wight",
                       
                    },
                    education:{
                        required:'Please choose eductaion',
                    },

                     profession:{
                        required:'Please choose profession',
                    },

                     bio:
                    {
                        required:"Please enter biography",
                    },
                 
               
                 

            },
        
         submitHandler:function(form){
          // e.preventDefault();
          var link=URLAPI+'manage_all_controller.php';
          var data = new FormData($(form)[0]);
          var message = msgLoading.blankMessage[language];
          console.log('message',message);
          apiRequest.postFile(link,data,message).then(function(obj){
          if(obj.success === true){
            // var title = msgTitleOperation.StatusSend[language];
            var message = obj.msg[language];
            swal_alert(title,message,"#","success");
             //$('#add_category_modal').modal('hide');
            // var message = obj.msg[language];
          
           //getUserTable('first', 'all');
       
          }else{
            var title = msgTitleOperation.BannerNotAdded[language];
            var message = obj.msg[language];
            swal_alert(title,message,'#','error');
             return false;
          }
        },function(err){
          consoleProvider.log('err',err);
          var title    = msgTitleOperation.errorOnServer[language];
          var messsage = msgOperations.errorOnServer[language];
          swal_alert(title,message,"#","warning");
          return false;
        });
      }//end of submit handler
    });
           

          

          
            // $('#edit_manage_service_form').validate({
            //     rules: {
            //         name: {
            //             required: true,
                       
            //             maxlength: 50,
            //             //noSpace: true,
                       

            //         },

            //          mobile: {
            //             required: true,
            //             minlength: 10,
            //             maxlength: 10,
                        
                       

            //         },
            //         country:{
            //             required:true,
            //         },
            //         dob:
            //         {
            //             rrequired:true,
            //         },
            //         gender:
            //         {
            //             required:true,
            //         },
            //          height:
            //         {
            //             required:true,
            //             min:1,
            //         },
            //         weight:
            //         {
            //             required:true,
            //             min:1,
            //         },
            //         education:{
            //             required:true,
            //         },

            //          profession:{
            //             required:true,
            //         },

            //          bio:
            //         {
            //             required:true,
            //         },
          
                    



                   

            //     },
            //     messages: {
                   
          
                    



            //     },

            //     submitHandler: function(form,e){

                   
            //          e.preventDefault();
            //         var link = URLAPI + 'manage_all_controller.php';
            //         var data = new FormData($(form)[0]);
            //         var message = msgLoading.blankMessage[language];
            //         console.log('message', message);

            //         apiRequest.postFile(link, data, message).then(function(obj) {
            //             if (obj.success === true){
            //                 var title = '';
            //                 var message = obj.msg[language];
            //                 swal_alert(title, message, "manage_user.php", "success");
                       


                            

            //             } else {
            //                 var title = '';
            //                 var message = obj.msg[language];
            //                 swal_alert(title, message, '#', 'error');
            //                 return false;
            //             }
            //         }, function(err) {

            //             consoleProvider.log('err', err);
            //             var title = msgTitleOperation.errorOnServer[language];
            //             var messsage = msgOperations.errorOnServer[language];
            //             swal_alert(title, message, "#", "warning");
            //             return false;

            //         });

            //     } //end of submit handler
            // });

    </script>

    
    
   
   <script type="text/javascript">
        $('#fileUpload1').change(function(event){
    var x = URL.createObjectURL(event.target.files[0]);
     $('#image-holder11').attr('src',x);
  });

  
   </script>




</body>

</html>