<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <?php
    $this->load->view('user/common_style');
 ?>
<link rel="stylesheet" href="<?php echo base_url();?>styles/fonts/Socialico/stylesheet.css">
<link rel="stylesheet" href="<?php echo base_url();?>styles/css/set1.css">
  <script src="<?php echo base_url();?>styles/js/modernizr.js"></script>
 <style>
  .contact_one .contact_left_content form input[type="text"]{border:0px;}
  .prfledit textarea, .prfledit textarea {
  width:100%;
  border: 1px solid #ededed;
  height:100px;
  padding:20px 20px;
}

.prfledit .select2-container, .prfledit .select2-container {
   -moz-appearance: none;
    background: url("styles/img/arw.png") no-repeat scroll right center #fff;
    border: 1px solid #e6e6e6;
  width:100%;
  border: 1px solid #ededed;
  height:50px;
  padding:13px 20px;
  margin: 0px;
  color:#444;
}
span.select2-chosen{
  color: #444;
}
#select2-drop{
    border: none;
}
.help-block {
    color: #eb5055;
    margin: 0em 0em 0em !important;
}
.profilesub ul li label{
  display: inline;
  color: #eb5055;
}
.profilesub ul li span{
  font-weight: bold;
  font-size: 14px;
}
p.frgtpwd {
text-transform: none;
  }
  </style>
        
</head>
<body>
<?php
$this->load->view('user/header');
$this->load->view('user/login_header');
?>           
   <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
      <div class="table-list clearfix">
          <?php if(isset($action)) { ?>
            <form class="steps-validation update-user" method="post" action="<?php echo $action;?>">
            <?php } else { ?>
            <form class="steps-validation update-user" name="fprofile" id="fprofile" enctype="multipart/form-data" method="post" action="<?php echo base_url();?>editprofile">
            <?php } ?>
              <div class="row">
              <?php $fullname = explode(' ', $username->fullname);
              $phoneno = explode(' ', $username->phone); 
           ?>  
                <div class="profilesub clearfix profilesub2">
                    	<h4 class="other-title theme-color"><?php echo $this->lang->line('edit_profile_title'); ?> <span><?php echo $this->lang->line('edit_profile_name');?></span></h4>
                        <?php if($this->session->flashdata('success_message')) {?>
                             <div class="col-lg-12 ">     <p class="frgtpwd frgtpwd1"><i class="fa fa-thumbs-up"></i><?php echo $this->session->flashdata('success_message');?></p></div>
                              <?php } elseif ($this->session->flashdata('error_message')) { ?>
                                <div class="col-lg-12">  <p class="frgtpwd frgtpwd1 frgtpwdred"><i class="fa fa-thumbs-down"></i><?php echo $this->session->flashdata('error_message');?></p></div>
                              <?php } else { }?>

                              <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_first_name'); ?> * </label>
                                  <div class="col-lg-9">
                                      <input name="firstname" class="" type="text" value="<?php echo (isset($fullname[0])) ? $fullname[0] :'';?>"/>
                                  </div>
                              </div>

                              <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_last_name'); ?> * </label>
                                  <div class="col-lg-9">
                                    <input name="lastname" class="" type="text" id="" value="<?php echo (isset($fullname[1])) ? $fullname[1] : '';?>"/>
                                  </div>
                              </div>

                           <?php if($user_change_email=='on') {?>

                              <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('lbl_user_email'); ?> * </label>
                                  <div class="col-lg-9">
                                    <input name="email" class="" type="text" id="" value="<?php echo $username->email;?>"/>
                                  </div>
                              </div>  
                               <?php } ?>

                               <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_address'); ?> * </label>
                                  <div class="col-lg-9">
                                    <textarea class="form-control" name="address"><?php echo $username->address; ?></textarea>
                                  </div>
                              </div> 

                               <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('country_lbl'); ?> * </label>
                                  <div class="col-lg-9">
                                      <select name="country" id="simg" class="select form-control">
                                         <?php
                                          foreach ($countries as $country)
                                          {?>
                                              <option <?php if(isset($username->country)) { if($username->country==$country->iso_2) { echo 'selected'; } } ?> value="<?php echo $country->iso_2;?>"><?php echo $country->Country;?></option>
                                          <?php 
                                          }?>
                                      </select>
                                  </div>
                              </div> 

                               <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_city'); ?> * </label>
                                  <div class="col-lg-9">
                                    <input name="city" class="" type="text" id="" value="<?php echo $username->city; ?>" />
                                  </div>
                              </div>                               

                               <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_state'); ?> * </label>
                                  <div class="col-lg-9">
                                      <input name="state" class="" type="text" id="" value="<?php echo $username->state; ?>" />
                                  </div>
                              </div>                                                        

                               <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_zip'); ?> * </label>
                                  <div class="col-lg-9">
                                      <input name="zipcode" class="" type="text" id="" value="<?php echo $username->zip;?>" />
                                  </div>
                               </div> 
                                
                                <div class="col-lg-12 mt-10">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_phone'); ?> * </label>
                                  <div class="col-lg-2">
                                        <input name="code" id="code" type="text"  value="<?php if(isset($phoneno[0])) { echo $phoneno[0];} ?>" readonly>
                                  </div>
                                    <div class="col-lg-7">
                                         <input name="phone" class="" type="text"  value="<?php if(isset($phoneno[1])) { echo $phoneno[1]; } ?>" />
                                    </div>   
                               </div>                                                                                       

                              <div class="col-lg-12 mt-10" style="display:none;">
                                  <label class="col-lg-3 other-title theme-color mt-15"><?php echo $this->lang->line('place_user_account'); ?> * </label>
                                  <div class="col-lg-9">
                                      <input name="eth_address" class="" type="text" id="" value="<?php echo $username->eth_address; ?>" />
                                  </div>
                             </div>  
                         
                               <?php if($payment_list) { foreach ($payment_list as $list) { ?> 
                             <div class="col-lg-12 mt-10" style="display:none;">
                                <label class="col-lg-3 other-title theme-color mt-15"><?php echo ucfirst($list->payment_name); ?> </label>
                                <div class="col-lg-9">
                                    <input name="gateway[]" class="" type="text" value="<?php if(isset($payment_data[$list->payment_id])) { echo $payment_data[$list->payment_id]; } else { echo ""; } ?>" id="" <?php if($user_change_payment=='0'){ echo "readonly"; }else{ echo ""; } ?> />
                                    <input name="gate[]" class="" value="<?php echo $list->payment_id; ?>" type="hidden" id="" />
                                </div>
                             </div>

                             <?php } } ?>
                            <div class="clearfix" style="clear:both;"><br></div>
                            <div class="cmmn col-lg-12"> 
                              <div class="contact_page_btn">
                                  <button type="submit" class="yellow-btn" ><?php echo $this->lang->line('update_btn'); ?></button>
                              </div>
                            </div>
                      </div>      
                </div>
                </div>
            </form>
        </div>
    </div>
  </div>
 </div>
   </div>
 
  <?php
                $this->load->view('user/footer');
            ?>


<script type="text/javascript">
  

/*  function upload_chk(str,str1)
{
  var error="";
  var fileExtension =str.substr((str.lastIndexOf('.') + 1));

  var fileExtension=fileExtension.toLowerCase(); 
  if(str=="")
  {
    error="* Select Proof";
    document.getElementById(str1).innerHTML="* Select proof";
  }
  else if(fileExtension!="jpg" && fileExtension!="jpeg" && fileExtension!="png" && fileExtension!="gif" && fileExtension!="pdf")
  {

    error="* please only upload jpg,jpeg,png,gif,pdf Images or pdf file only";
    document.getElementById(str1).innerHTML="* please only upload jpg,jpeg,png,gif Images or pdf file only";
  }
  else
  {


    error="";
    document.getElementById(str1).innerHTML="";
  }
  return error;

}

  function check_pro()
  {
    var msg="";
    var proof_id=document.getElementById("proof_id").value;
    var proof_doc=document.getElementById("proof_doc").value;
    
    msg+=upload_chk(proof_id,'proof_err');
    msg+=upload_chk(proof_doc,'prodoc_err');

    if(msg=="")
    {
            document.getElementById('fprofile').submit();
    }

    

  }*/
</script>

<script src="<?php echo base_url();?>styles/js/jquery-1.12.2.min.js"></script>

<script src="<?php echo base_url();?>styles/js/jquery.meanmenu.js"></script>
<script src="<?php echo base_url();?>styles/js/owl.carousel.min.js"></script>
<script src="<?php echo base_url();?>styles/js/waypoints.min.js"></script>
<script src="<?php echo base_url();?>styles/js/jquery.counterup.min.js"></script>
<script src="<?php echo base_url();?>styles/js/jquery.mixitup.min.js"></script>
<script src="<?php echo base_url();?>styles/js/waypoints.min.js"></script>
<script src="<?php echo base_url();?>styles/js/instafeed.min.js"></script>
<!-- <script src="<?php echo base_url();?>styles/js/bootstrap.min.js"></script> -->
<!-- Bootsrap form validation JS files -->
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/formValidation.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/bootstrap.js"></script>
        
         <script src="<?php echo base_url();?>/assets/boots/js/select_min.js"></script>
    
       <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>/assets/boots/css/select2.css">


<script>
			(function() {

        if ($("#simg").length > 0) {
                    function formatFlags(state) {
                        if (!state.id) return state.text;
                        return "<img style='padding-right:10px;' src='<?php echo base_url();?>assets/images/flags/" + state.id.toLowerCase() + ".png'/>" + state.text;
                    }
                    $("#simg").select2({
                        formatResult: formatFlags,
                        formatSelection: formatFlags,
                        escapeMarkup: function(m) {
                            return m;
                        }
                    });
                }
                $('#simg').change(function(){
                  var id = $(this).val();
                  if(id) {
                    $.ajax({
                              type: 'post',
                              url : '<?php echo base_url();?>user/profile/changecountry',
                              data : {'id':id},
                              success : function(msg)
                              {
                                if(msg!=0) {
                                  $('#phone').html('+'+msg);
                                  $('#code').val('+'+msg);
                                }
                              }
                          });
                  }
                });


                  $('.update-user').formValidation({
                    framework: 'bootstrap',
                    excluded: [':disabled'],
                    
                    fields: {
                        firstname: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_firstname_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[a-z]+$/i,
                                    message: '<?php echo $this->lang->line("user_firstname_alpha");?>'
                                }
                            }
                        },
                         lastname: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_lastname_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[a-z]+$/i,
                                    message: '<?php echo $this->lang->line("user_lastname_alpha");?>'
                                }
                            }
                        },
                        <?php if($user_change_email=='on') {?>

                          email:{
                            validators: {
                               notEmpty: {
                                    message: '<?php echo $this->lang->line("user_emailid_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/,
                                    message: '<?php echo $this->lang->line("user_emailid_invalid"); ?>'
                                },
                                remote: {
                                    url: function(validator, $field, value) {
                                        
                                        return '<?php echo base_url();?>user/profile/validemail';
                                    },
                                    type: 'POST',
                                    delay: 1000,
                                    message: '<?php echo $this->lang->line("mailaddress_invalid"); ?>'
                                }
                              }
                          },
                          <?php } ?>
                        address: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_address_empty");?>'
                                }

                            }
                        },
                        state: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_state_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[a-z ]+$/i,
                                    message: '<?php echo $this->lang->line("user_state_alpha");?>'
                                }

                            }
                        },
                        <?php if($user_dat=='1' && $das[0]->site_value=='on') 
                        {
                          ?>
                        proof_id: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_proof_empty");?>'
                                },
                                file: {
                                    extension: 'jpg,jpeg,png,gif,pdf',
                                    message: '<?php echo $this->lang->line("user_proof_must");?>'
                                }
                            }
                        },
                        proof_doc: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_doc_empty");?>'
                                },
                                file: {
                                    extension: 'jpg,jpeg,png,gif,pdf',
                                    message: '<?php echo $this->lang->line("user_doc_must");?>'
                                }
                            }
                        },
                        <?php
                      }
                      ?>
                        zipcode: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_zip_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[a-zA-Z0-9]*$/,
                                    message: '<?php echo $this->lang->line("user_zip_num");?>'
                                },
                                stringLength: {
                                max: 10,
                                message: '<?php echo $this->lang->line("reg_string_length_error");?>'
                                }

                            }
                        },
                        phone: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_phone_empty");?>'
                                },
                                digits: {
                                    message: '<?php echo $this->lang->line("user_phone_num");?>'
                                },
                                stringLength: {
                                max: 15,
                                message: '<?php echo $this->lang->line("user_phone_max_limit");?>'
                                }

                            }
                        },
                        
                        city: {
                            validators: {
                                notEmpty: {
                                    message: '<?php echo $this->lang->line("user_city_empty");?>'
                                },
                                regexp: {
                                    regexp: /^[a-z ]+$/i,
                                    message: '<?php echo $this->lang->line("user_city_alpha");?>'
                                }

                            }
                        }
                       
                }
                })
               
				// trim polyfill : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim
				if (!String.prototype.trim) {
					(function() {
						// Make sure we trim BOM and NBSP
						var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
						String.prototype.trim = function() {
							return this.replace(rtrim, '');
						};
					})();
				}

				[].slice.call( document.querySelectorAll( 'input.input__field' ) ).forEach( function( inputEl ) {
					// in case the input is already filled..
					if( inputEl.value.trim() !== '' ) {
						classie.add( inputEl.parentNode, 'input--filled' );
					}

					// events:
					inputEl.addEventListener( 'focus', onInputFocus );
					inputEl.addEventListener( 'blur', onInputBlur );
				} );

				function onInputFocus( ev ) {
					classie.add( ev.target.parentNode, 'input--filled' );
				}

				function onInputBlur( ev ) {
					if( ev.target.value.trim() === '' ) {
						classie.remove( ev.target.parentNode, 'input--filled' );
					}
				}
			})();
		</script>
    </script>
<!-- <script src="<?php echo base_url();?>styles/js/main.js"></script> -->
<!-- <script type="text/javascript" src="<?php echo base_url();?>styles/js/owl.carousel.min.js"></script> -->
 <!-- <script src="<?php echo base_url();?>styles/js/classie.js"></script> -->
 <!-- <script type="text/javascript">
	$(document).ready(function($) {
	$("#owl-example").owlCarousel({   
	 nav:true,
	 
	 items : 8, 
    itemsCustom : false,
    itemsDesktop : [1199,8],
    itemsDesktopSmall : [980,5],
    itemsTablet: [768,5],
    itemsTabletSmall: [768,4],
    itemsMobile : [479,2],
    singleItem : false,
    itemsScaleUp : true,
	    navigation : true,
    navigationText : ["",""],
    rewindNav : true,
    scrollPerPage : false,
	});
	}); 
	</script>  --> 
<?php $this->load->view('user/common_script');?>
</body>
</html>
