<?php include('header.php');?>
<?php include('sidebar.php');?>
<?php
if(isset($_REQUEST['submit'])=="submit"){ 
$values = $_POST;
unset($values['submit']);
$image=$helper->image_upload($_FILES['frm_filename'],"users");
$photo=array("image"=>$image);
$values=array_merge($values,$photo);
$helper->update("tbl_admin", $values,array("userid"=>$user_id), array());
}
if(isset($_REQUEST['updatepass'])=="Update Password"){ 
 $pass=$_REQUEST['password'];
 $conpass=$_REQUEST['conpassword'];
 
if($pass==$conpass){
	$password=md5($pass);
	$required = array("password");
	$helper->update("tbl_admin", array("password"=>$password),array("userid"=>$user_id),$required);
	header("location:logout.php");
}
else{
	$error="Password not Matching";
}
}
?>
<?php 
if(isset($user_id)){
	echo("select * from tbl_admin where userid=$user_id");
$userdetails1=mysqli_query($con,"select * from tbl_admin where userid=$user_id");
$userdetails=mysqli_fetch_array($userdetails1);
}
else {
$userdetails1=mysqli_query($con,"select * from tbl_members where memberid=$member_id");
$userdetails=mysqli_fetch_array($userdetails1);
}
?>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
     
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>
        <li class="active"><?php echo AL_MYPROFILE;?></li>
      </ol>
       <h1>
        Profile
   
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-md-4 right">

          <!-- Profile Image -->
          <div class="box box-primary">
            <div class="box-body box-profile">
              <img class="profile-user-img img-responsive img-circle" src="<?php echo $site_url;?>thumb.php?src=<?php echo $site_url;?>images/users/<?php echo $userdetails['image'];?>&w=160&h=160" alt="<?php echo $userdetails['firstname'];?>">

              <h3 class="profile-username text-center"><?php echo $userdetails['firstname']." ".$userdetails['middlename']." ".$userdetails['lastname'];?></h3>

              <p class="text-muted text-center"></p>

              <ul class="list-group list-group-unbordered">
                <li class="list-group-item">
                  <b><?php echo AL_EMAIL;?>: </b> <?php echo $userdetails['email'];?>
                </li>
                <li class="list-group-item">
                  <b><?php echo AL_PHONE;?>: </b> <?php echo $userdetails['phone'];?>
                </li>
                <li class="list-group-item">
                  <b><?php echo AL_MOBILE;?>: </b> <?php echo $userdetails['mobile'];?>
                </li>
                <li class="list-group-item">
                  <b><?php echo AL_ADDRESS;?>: </b> <?php echo $userdetails['address'];?>
                </li>
                 <li class="list-group-item">
                  <b><?php echo AL_CITY;?>: </b> <?php echo $userdetails['city'];?>
                </li>
                <li class="list-group-item">
                  <?php
                  $mycountry= $helper->select("tbl_country","countryid,country",array("countryid"=>$userdetails['country']));
				  ?>
                  <b><?php echo AL_COUNTRY;?>: </b> <?php echo $mycountry[0]['country'];?>
                </li>
              </ul>
                 
            </div>
            <!-- /.box-body -->
          </div>
           
        </div>
        <!-- /.col -->
        <div class="col-md-8 left">
          
          <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title">Edit Profile</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
              <div class="box-body">
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_FIRSTNAME;?></label>

                  <div class="col-sm-8">
                    <input type="text" required="required" value="<?php echo $userdetails['firstname'];?>" class="form-control" id="firstname" name="firstname" placeholder="First Name">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_MIDDLENAME;?></label>

                  <div class="col-sm-8">
                    <input type="text" class="form-control" id="middlename" value="<?php echo $userdetails['middlename'];?>" name="middlename" placeholder="First Name">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_LASTNAME;?></label>

                  <div class="col-sm-8">
                    <input type="text"  required="required" class="form-control" id="lastname" value="<?php echo $userdetails['lastname'];?>" name="lastname" placeholder="Last Name">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_EMAIL;?></label>

                  <div class="col-sm-8">
                    <input type="email" required="required" class="form-control" value="<?php echo $userdetails['email'];?>"  id="email" name="email" placeholder="Email Address">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_PHONE;?></label>

                  <div class="col-sm-8">
                    <input type="text" required="required" class="form-control" value="<?php echo $userdetails['phone'];?>" id="phone" name="phone" placeholder="Phone">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_MOBILE;?></label>

                  <div class="col-sm-8">
                    <input type="text" required="required" class="form-control" id="mobile" value="<?php echo $userdetails['mobile'];?>" name="mobile" placeholder="Mobile">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_ADDRESS;?></label>

                  <div class="col-sm-8">
                    <input type="text" class="form-control" value="<?php echo $userdetails['address'];?>" id="address" name="address" placeholder="Address">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_CITY;?></label>

                  <div class="col-sm-8">
                    <input type="text" class="form-control" id="city" value="<?php echo $userdetails['city'];?>"  placeholder="City">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_COUNTRY;?></label>

                  <div class="col-sm-8">
                  <?php
                  $countries= $helper->select("tbl_country","countryid,country",array());				   
				  ?>
                  <select name="country" class="form-control" id="country">
                  <?php
				  foreach($countries as $country){
				  ?>
                  <option <?php if($country['countryid']==$userdetails['country']){ echo "selected";}?> value="<?php echo $country['countryid'];?>"><?php echo $country['country'];?></option>
                  <?php
				  }
				  ?>
                  </select>
                   </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_ZIPCODE;?></label>

                  <div class="col-sm-8">
                    <input type="text" class="form-control" id="zipcode" value="<?php echo $userdetails['zipcode'];?>" name="zipcode" placeholder="Zipcode">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_IMAGE;?></label>

                  <div class="col-sm-8">
                    <input type="file" class="" name="frm_filename">
                  </div>
                </div>
                
              </div>
              <!-- /.box-body -->
              <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-right"/>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box -->
          <!-- general form elements disabled -->
          <div class="box box-warning">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo AL_CHANGEPASSWORD;?></h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
            <?php
			if($error!=""){
			?>
            <button class="btn btn-block btn-success btn-flat" type="button"><?php echo $error;?></button>
			<?php	
			}
			?>
              <form class="form-horizontal" action="" method="post">
               
                <!-- text input -->
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_NEWPASSWORD;?></label>

                  <div class="col-sm-8">
                    <input required="required" type="password" name="password" class="form-control" id="password" placeholder="Password">
                  </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_CONFIRMPASSWORD;?></label>

                  <div class="col-sm-8">
                    <input required="required" type="password" name="conpassword" class="form-control" id="conpassword" placeholder="Confirm Password">
                  </div>
                </div>
                 
                <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" class="btn btn-info pull-right" name="updatepass" value="<?php echo AL_UPDATEPASSWORD;?>"/>
              </div>
                

              </form>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->

    </section>
    <!-- /.content -->
  </div>

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