<script src="<?php echo base_url();?>ckeditor/ckeditor.js"></script>
      <section class="content-header">
      <h1>

        Members 

      </h1>

      <ol class="breadcrumb">

        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>

        <li><a href="<?php echo base_url('admin/users/alllist');?>">Members</a></li>

        <li class="active"> Edit</li>

      </ol>

    </section>

    

    <section class="content">

      <div class="row">

      <?php echo $this->utility->showMsg();?>

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

        <div class="loader" style="display:none;"><img src='<?php echo base_url();?>assets/images/loading.gif' alt='loading' /></div>

          <!-- Horizontal Form -->

          <div class="box box-info">

            <div class="box-header with-border">

              <h3 class="box-title">Edit </h3>

            </div>

            <!-- /.box-header -->

            <!-- form start -->

            <form id="add_frm" name="add_frm" class="form-horizontal" method="post" action="" enctype="multipart/form-data">

              <div class="box-body">

                <div class="form-group">

                  <label class="col-sm-2 control-label">Email</label>

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

                    <input type="text" class="form-control" id="email" name="email" value="<?php if(!empty($userDetails)){ echo $userDetails['email']; } ?>" placeholder="Please enter email" autocomplete="off">

                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Username</label>

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

                    <input type="text" class="form-control" id="username" name="username" value="<?php if(!empty($userDetails)){ echo $userDetails['username']; } ?>" placeholder="Please enter username" autocomplete="off">

                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Password</label>

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

                    <input type="text" class="form-control" id="password" name="password" value="" placeholder="Please enter password" autocomplete="off">
                    <span class="toggle" style="cursor:pointer;">Show</span>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Discount</label>

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

                    <select name="discount" class="form-control">
                    <?php for($i=1; $i<101; $i++){ ?>
                        <option value="<?php echo $i; ?>" <?php if(!empty($memberDiscount) && $memberDiscount['discount']==$i){ echo 'selected'; }?>><?php echo $i; ?></option>
                    <?php }?>
                    </select>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Membership</label>

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

                    <label class="" ><?php if(!empty($membershipDetails)){ echo $membershipDetails[0]['userstatus']; } else { echo 'No membership'; } ?><img src="<?php echo  base_url();?>assets/userfiles/img/logo-gold-mini.png" width=30></label>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Account Type</label>

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

                    <select name="acount_type" class="form-control">
                        <option value="lady" <?php if(!empty($userDetails) && $userDetails['accounttype']=='lady') { echo 'selected'; }?>> Lady </option>
                        <option value="gentleman" <?php if(!empty($userDetails) && $userDetails['accounttype']=='gentleman') { echo 'selected'; }?>> Gentleman </option>
                        <option value="couple" <?php if(!empty($userDetails) && $userDetails['accounttype']=='couple') { echo 'selected'; }?>> Couple </option>
                    </select>
                  </div>

                </div>
                <h4 style="text-align: center;background-color: #3c8dbc; color: #fff ;padding: 5px;font-weight: bold;">LADY</h4>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Date of birth</label>

                  <div class="col-sm-6">
                    <?php if($userDetails['accounttype']=='lady'){
                            if($userDetails['dob_lady']!='')
                            {
                              $date_lady = $userDetails['dob_lady'];
                            } 
                            elseif($userDetails['dob_gentleman']!='')
                            {
                              $date_lady = $userDetails['dob_gentleman'];
                            }
                            else
                            {
                              $date_lady = '';
                            }
                          }  

                          
                    ?>
                      <input type="text" class="form-control" name="lady_dob" id="lady_dob" value="<?php if(!empty($userDetails) && $date_lady!=''){ echo date('d-m-Y',$date_lady); }?>">
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Physis</label>

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

                    <select name="lady_physis" class="form-control">
                        <option value="normal" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='normal') { echo 'selected'; }?>> Normal </option>
                        <option value="athletic" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='athletic') { echo 'selected'; }?>> Athletisch </option>
                        <option value="muscular" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='muscular') { echo 'selected'; }?>> Muskulös </option>
                        <option value="slim" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='slim') { echo 'selected'; }?>> Schlank </option>
                        <option value="plump" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='plump') { echo 'selected'; }?>> Vollschalng </option>
                        <option value="obese" <?php if(!empty($userDetails) && $userDetails['physis_lady']=='obese') { echo 'selected'; }?>> Übergewichtig </option>
                    </select>
                  </div>

                </div>
                <h4 style="text-align: center;background-color: #3c8dbc; color: #fff ;padding: 5px;font-weight: bold;">GENTLEMAN</h4>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Date of birth</label>

                  <div class="col-sm-6">
                    <?php if($userDetails['accounttype']=='gentleman'){
                            if($userDetails['dob_lady']!='')
                            {
                              $date_gen = $userDetails['dob_lady'];
                            } 
                            elseif($userDetails['dob_gentleman']!='')
                            {
                              $date_gen = $userDetails['dob_gentleman'];
                            }
                            else
                            {
                              $date_gen = '';
                            }
                          }    
                    ?>
                      <input type="text" class="form-control" name="gen_dob" id="gen_dob" value="<?php if(!empty($userDetails) && $date_gen!=''){ echo date('d-m-Y',$date_gen); }?>">
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Physis</label>

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

                    <select name="gen_physis" class="form-control">
                        <option value="normal" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='normal') { echo 'selected'; }?>> Normal </option>
                        <option value="athletic" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='athletic') { echo 'selected'; }?>> Athletisch </option>
                        <option value="muscular" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='muscular') { echo 'selected'; }?>> Muskulös </option>
                        <option value="slim" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='slim') { echo 'selected'; }?>> Schlank </option>
                        <option value="plump" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='plump') { echo 'selected'; }?>> Vollschalng </option>
                        <option value="obese" <?php if(!empty($userDetails) && $userDetails['physis_gentleman']=='obese') { echo 'selected'; }?>> Übergewichtig </option>
                    </select>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">About Text</label>

                  <div class="col-sm-6">
                    <textarea name="about" class="form-control"><?php if(!empty($userDetails)) { echo $userDetails['about']; } ?></textarea>
                  <script>
                           CKEDITOR.replace( 'about',{
                                    filebrowserBrowseUrl : '/castle/fileman/index.html',
                                    filebrowserImageBrowseUrl : '/castle/fileman/index.html?type=image',
                                    removeDialogTabs: 'link:upload;image:upload'
                            });
                        </script> 
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Preferences</label>

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

                    <select name="preferences" class="form-control">
                        <option value="" <?php if(!empty($userDetails) && $userDetails['preferences']=='') { echo 'selected'; }?>>Keine</option>
                        <option value="soft_swap" <?php if(!empty($userDetails) && $userDetails['preferences']=='soft_swap') { echo 'selected'; }?>> Soft Swap </option>
                        <option value="full_swap" <?php if(!empty($userDetails) && $userDetails['preferences']=='full_swap') { echo 'selected'; }?>> Full Swap </option>
                    </select>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Interested In</label>

                  <div class="col-sm-6">
                    <input type="checkbox" name="interested_lady" value="1" <?php if(!empty($userDetails) && $userDetails['interested_in_ladies']==1) { echo 'checked'; }?>>Ladies
                    <input type="checkbox" name="interested_gen" value="1" <?php if(!empty($userDetails) && $userDetails['interested_in_gentlemen']==1) { echo 'checked'; }?>>Gentleman
                    <input type="checkbox" name="interested_couple" value="1" <?php if(!empty($userDetails) && $userDetails['interested_in_couples']==1) { echo 'checked'; }?>>Couples
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Country</label>

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

                    <select name="country" class="form-control">
                      <?php if(!empty($coutries)){
                            foreach($coutries as $row){?>
                              <option value="<?php echo $row['country_code']; ?>" <?php if(!empty($userDetails) && $userDetails['country']==$row['country_code']){ echo 'selected'; }?>><?php echo $row['country_name']; ?></option>
                          <?php } } ?>    
                    </select>
                  </div>

                </div>
                <div class="form-group">

                  <label class="col-sm-2 control-label">Language</label>

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

                    <select name="language" class="form-control">
                      <?php if(!empty($languages)){
                            foreach($languages as $row){?>
                              <option value="<?php echo $row['id']; ?>" <?php if(!empty($userDetails) && $userDetails['userlanguage']==$row['id']){ echo 'selected'; }?>><?php echo $row['name']; ?></option>
                          <?php } } ?>   
                    </select>
                  </div>

                </div>

                <div class="form-group">

                  <label class="col-sm-2 control-label">Images</label>

                  <div class="col-sm-6">
                    <?php if(!empty($avatarImage)){
                    ?>
                      <div class="col-md-6">
                        <img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $avatarImage['path']; ?>/<?php echo $avatarImage['filename']; ?>.<?php echo $avatarImage['extension']; ?>" class="img-responsive">
                        <a href="<?php echo  base_url();?>admin/dashboard/delete/<?php echo base64_encode($avatarImage['id']); ?>/<?php echo str_replace('/','-',uri_string()); ?>" class="" onclick="return confirm('Are you sure')">
                          <i class="fa fa-trash tooltipstered"></i>
                        </a>
                      </div>
                    <?php
                          }
                      ?>
                    <?php if(!empty($memberImages)){
                          foreach ($memberImages as $value) {
                    ?>
                      <div class="col-md-6">
                        <img src="<?php echo base_url(); ?>assets/userfiles/<?php echo $value['path']; ?>/<?php echo $value['filename']; ?>.<?php echo $value['extension']; ?>" class="img-responsive">
                        <a href="<?php echo  base_url();?>admin/dashboard/delete/<?php echo base64_encode($value['id']); ?>/<?php echo str_replace('/','-',uri_string()); ?>" class="" onclick="return confirm('Are you sure')">
                          <i class="fa fa-trash tooltipstered"></i>
                        </a>
                      </div>
                    <?php
                          }
                      }?>

                      <!--<input type="file" name="imagefile" value="Upload" class="form-control">
                      <input type="checkbox" name="is_private" value="1">Private Image-->
                  </div>

                </div>
                       

              </div>
             <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                  <th>#</th>
                  <th>Order date</th>
                  <th>Cart value(&euro;)</th>
                  <th>Total(&euro;)</th>
                  <th>Payment method</th>
                  <th>Type</th>
                  <th>Status</th>
                </thead>
                 <?php if(count($orders)>0)
                { ?>
                <tbody>
                <?php 
                  $i=1;
                  foreach ($orders as $data) 
                  {
                ?>
                <tr>
                    <td><?php echo $i;?></td>
                    <td><?php echo date('d-m-Y h:i:s',$data['created']); ?></td>
                    <td><?php echo number_format($data['total_base']/100, 2,',', '.');?></td>
                    <td><?php echo number_format($data['total_sum']/100, 2,',', '.'); ?></td>
                    <td><?php if($data['payment_method_id'] == 13) { echo 'SaferPay'; } elseif($data['payment_method_id'] ==14 ) { echo 'Stripe'; } else { echo 'Pay After Arrival'; }?></td>
                    <td><?php if($data['is_booking'] == 1) { echo 'Bookng'; } else{ echo 'Membership'; }?></td> 
                    <td><?php if($data['payed'] == 1) { echo 'Paid'; } else{ echo 'Not Paid'; }?></td> 
                </tr>

               <?php $i++; } ?>
                </tbody>
                <?php } ?>
              </table>
            </div>

              <!-- /.box-body -->

              <div class="box-footer">

                <button type="button" onclick="return_back()"class="btn btn-default  margin-left  " >Cancel</button>

                <input type="submit" class="btn btn-info " value="Update" id="add">

              </div>

              <input type="hidden" name="frmSecurity" value="<?php echo $this->utility->getSecurity();?>"/>

              <!-- /.box-footer -->

            </form>

          </div>

          <!-- /.box -->

         

          <!-- /.box -->

        </div>

        <!--/.col (right) -->

      </div>

      <!-- /.row -->

    </section>

    <style type="text/css">

    .loader{

      position: fixed;

      left: 0;

      top: 0;

      right: 0;

      bottom: 0;

      width: 100%;

      height: 100%;

      background-color: rgba(0, 0, 0, 0.60);

      z-index: 9999;

      text-align: center;

    }

    .loader img{

      z-index: 99999;

      margin-top: 10%;

    }
    input#password {
        -webkit-text-security: disc;
        -moz-text-security: disc;
    }
    </style>

   <script type='text/javascript'>
      $("#add_frm").validate({
        rules: {
          email: {
            required: true,
            email:true
          },
          username:{
            required: true,
          },
          interested:{
            required:true
          }
        }
      });
    </script>

   <script type="text/javascript">
    function return_back()
    {
      var back_url='<?php echo base_url()?>admin/users/alllist';
      window.location=back_url;
    }
    
    $(function(){
      $("#example1").DataTable();
      $("#gen_dob").datetimepicker();
      $("#lady_dob").datetimepicker();

      $('.toggle').click(function(){
        if($(this).prev().attr('type')=='password')
        {
          $(this).prev().attr('type','text');
          $(this).html('Hide');
        }
        else
        {
          $(this).prev().attr('type','password');
          $(this).html('Show');
        }
      })
    })

   </script>