<?php
				$session_data = $this->session->userdata('logged_in');

$id=$itemid;
$image_id=   $member[0]['image_id'];


 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];


				 $mydate=date("Y-m-d");
				
				$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
	 
				$data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 
	 	 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	 		  		  	      $advance=$this->usermodel->populatuserpermissionsdataarray('sales','advance',$userid);
	 		  		  	      $updatepeople=$this->usermodel->populatuserpermissionsdataarray('members','update',$userid);


?>

 
 <div class="row">
  
   	

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

  
		

			
	<div class="widget-content nopadding table_holder table-responsive" >				
			
		

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update  Customer details </h4>
      </div>
      <div class="modal-body">
      	<a class="btn btn-primary" href="<?php echo base_url(); ?>user/viewmember"> Back?</a>

<center>
					<div class="btn-group"  >
					
                                    <button type="button" class="btn btn-info btn-sm dropdown-toggle" data-toggle="dropdown">
                                     Click to view   More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
	  <li> 

	 <a class="btn btn-primary editbtn" id="editbtn"  data-customerid1='<?php echo  $id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Opening Balance
                                                </a>
                                                        </li>
										
										
												</br>
 <li>
											   <a  id="more" target="_blank" class="btn btn-default" href="<?php echo base_url();?>user/viewfollowups?randomitemidentifier=<?php   {echo  $id;}  ?>&currentid=<?php   {echo  $id;}  ?>&type=Customer">Follow Ups  </a>
												</li>
																								</br>














														
												







										
										
										
										
										  <li> 
										                              <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewmygrouping?randomitemidentifier=<?php   {echo  $id;}  ?>">Group  </a>

                                                        </li>
														
														
</br>

																<li> 
										                              <a target="_blank" id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewmydocuments?randomitemidentifier=<?php   {echo  $id;}  ?>&image_id=<?php   {echo  $image_id;}  ?>">Documents  </a>

                                                        </li>
												
</br>                                
												<li>											  
 	</br>
											   <a  id="more" target="_blank" class="btn btn-default" href="<?php echo base_url();?>user/employeenote?randomitemidentifier=<?php   {echo  $id;}  ?>&currentid=<?php   {echo  $id;}  ?>&type=Customer">Employee Notes   </a>
												</li>
</br>

												  <li> 
                     <a  id="more" target="_blank" class="btn btn-primary" href="<?php echo base_url();?>user/getinvoivebysupplier?randomitemidentifier=<?php   {echo  $id;}  ?>">All Invoices  </a>

                                                        </li>
														</br>
   
									        

											
                                    </ul>
										
                                </div>
	  	</center>

				<?PHP
//$session_data = $this->session->userdata('logged_in',$member[0]['company']);

				echo $this->session->flashdata('msg',$member[0]['company']); 
		
                 echo form_open('user/updatemember' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data',$member[0]['company']));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
<input type="hidden" name="myid" value="<?php echo $itemid; ?>"  id="myid" class="form-control" required placeholder="Enter status">






		
 <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">Branch</label>
    <div class="col-sm-10">
				
				
				<select class="form-control" name="branchid"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter to Open--</option>

									
								
<?php
	     $mybranch=$this->usermodel->populateall('branch','id',$member[0]['branchid']);


if(is_array($mybranch)) {

   foreach($mybranch as $branchrow){

   ?>
					<option selected="selected" value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>




	<?php

}} else {
    echo 'No Branch available.';
}
	
?>
	
	
	
	
	
	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $maincategoryrow->id;   ?>"><?=  $maincategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No main counter available.';
}
	
?>
</select>
				
		</div>
  </div>
					
		
	
		
		




 	<div class="form-group">
    <label for="inputcompany" class="col-sm-2 control-label">	Company Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="company" value="<?php echo set_value('company',$member[0]['company']); ?>" class="form-control"  placeholder="Enter company name if any">
		 
				
		<span class="text-danger"> <?php echo form_error('company'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputfirstname" class="col-sm-2 control-label">Customer First Names <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="firstname" value="<?php echo set_value('firstname',$member[0]['firstname']); ?>" class="form-control" required placeholder="Enter first and last name">
		 
				
		<span class="text-danger"> <?php echo form_error('firstname',$member[0]['company']); ?>
		
		</span>
	</div>
  </div>
<div class="form-group">
    <label for="inputlastname"  class="col-sm-2 control-label">Customer Last name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="lastname" value="<?php echo set_value('lastname',$member[0]['lastname']); ?>" class="form-control"  placeholder="Enter last name">
		 
				
		
		</span>
	</div>
  </div>
<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">	ID Number		 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno',$member[0]['idno']); ?>" class="form-control"  placeholder="Enter  ID.No">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  <div class="form-group">
    <label for="inputidnumber" class="col-sm-2 control-label">	Pin Number		 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idnumber" value="<?php echo set_value('idnumber',$member[0]['idnumber']); ?>" class="form-control"  placeholder="Enter your Pin">
		 
				
		<span class="text-danger"> <?php echo form_error('idnumber'); ?>
		
		</span>
	</div>
  </div>
  
    
  <div class="form-group">
    <label for="inputnumber" class="col-sm-2 control-label">		Emp Number	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="number" value="<?php echo set_value('number',$member[0]['number']); ?>" class="form-control"  placeholder="Enter Emp Number">
		 
				
		<span class="text-danger"> <?php echo form_error('number'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
  
  
  	<div class="form-group">
    <label for="inputphone" class="col-sm-2 control-label">	Phone <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="phone" value="<?php echo set_value('phone',$member[0]['phone']); ?>" class="form-control" required placeholder="Enter phone e.g 254712345678">
		 
				
		<span class="text-danger">Enter phone e.g 254712345678 <?php echo form_error('phone',$member[0]['company']); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputgender" class="col-sm-2 control-label">	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
		<option selected="selected" value="<?php echo $member[0]['gender']?>"  ><?php echo$member[0]['gender']?></option>
	<option value=""  >---Select Gender---</option>
	<option value="female"  >female</option>
		<option value="male"  >male</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('gender'); ?>
		
		</span>
	</div>
  </div>
  
  
  
    <div class="form-group">
    <label for="inputcategoryid" class="col-sm-2 control-label">Default Group</label>
    <div class="col-sm-10">
	<?php
		$mycategory=$this->usermodel->populateallarray('category','id', $member[0]['group']);
		$mycategoryname=$mycategory[0]['name'];
	
	
	?>
	<select class="form-control" name="categoryid" >
	

	<?php 
			if(	$mycategoryname !=""){
				?>
							<option selected="selected" value="<?php echo $member[0]['group']?>"  ><?php echo$mycategoryname;?></option>

<?php
			}else{				
							?>
	<option value="" selected="selected"  >---Select default  Category---</option>

<?php
				}

		$categories=$this->usermodel->populateall('category','companyid', $companyid);

if(is_array($categories)) {

   foreach($categories as $mycategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $mycategoryrow->id;   ?>"><?=  $mycategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No category/ group available.';
}
			
?>
</select>
		
						<span class="text-danger"><?php echo form_error('categoryid'); ?>

	</div>
  </div>
  
  
  
  
  
  
  
  
   	<div class="form-group">
    <label for="inputphoneaddress_1" class="col-sm-2 control-label">	Card No/Membership No	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="address_1" value="<?php echo set_value('address_1',$member[0]['address_1']); ?>" class="form-control"  placeholder="Enter Card No/Membership No e.g 254712345678 if any">
		 
				
		<span class="text-danger"> <?php echo form_error('address_1'); ?>
		
		</span>
	</div>
  </div>
    
   	<div class="form-group">
    <label for="inputaccount" class="col-sm-2 control-label">	Card Serial No </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="account" value="<?php echo set_value('account',$member[0]['account']); ?>" class="form-control"  placeholder="Enter Card Serial No 254712345678 if any">
		 
				
		<span class="text-danger"> <?php echo form_error('account'); ?>
		
		</span>
	</div>
  </div>
  
    
   	<div class="form-group">
    <label for="inputcategory" class="col-sm-2 control-label">	Category	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="category" >
		<option selected="selected" value="<?php echo $member[0]['category']?>"  ><?php echo$member[0]['category']?></option>
	<option value=""  >---Select category---</option>
	<option value="member"  >Customer</option>
		<option value="supplier"  >Supplier</option>
				<option value="user"  >Employee</option>
								<option value="prospects"  >Prospect</option>

								<option value="accomodation" >Accomodation</option>

				<option value="reseller"  >Reseller/Agents</option>

	</select>		 
				
		<span class="text-danger"> <?php echo form_error('category'); ?>
		
		</span>
	</div>
  </div>
      <div class="form-group">
    <label for="inputcustomerlimit" class="col-sm-2 control-label">	Customer Credit Limit	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="customerlimit" required>
		<option selected="selectted" value="<?php echo $member[0]['customerlimit']?>"  ><?php echo $mymember=$member[0]['customerlimit'];  ?></option>
	<option value=""  >---Do you want to put customer credit limit?--</option>
	<option value="no"  >no</option>
		<option value="yes"  >yes</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('customerlimit'); ?>
		
		</span>
	</div>
  </div>
  
  
    <div class="form-group">
    <label for="inputrate" class="col-sm-2 control-label">	Commission rate	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="rate" value="<?php echo set_value('rate',$member[0]['rate']); ?>" class="form-control"  placeholder="Enter commission rate if any ">
		 
				
		<span class="text-danger"> <?php echo form_error('rate'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
  
      <div class="form-group">
    <label for="inputlimitamount" class="col-sm-2 control-label">	Amount Limit 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="limitamount" value="<?php echo set_value('limitamount',$member[0]['limitamount']); ?>" class="form-control"  placeholder="Enter limit amount if any">
		 
				
		<span class="text-danger"> <?php echo form_error('limitamount'); ?>
		
		</span>
	</div>
  </div>
  
  <div class="form-group">
    <label for="inputsavedpoints" class="col-sm-2 control-label">	Customer Points	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="savedpoints" readonly value="<?php echo set_value('savedpoints',$member[0]['savedpoints']); ?>" class="form-control"  placeholder="Enter total points if any">
		 
				
		<span class="text-danger"> <?php echo form_error('savedpoints'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
    
  <div class="form-group">
    <label for="inputsavedcoins" class="col-sm-2 control-label">	Customer Saved Coins	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="savedcoins" value="<?php echo set_value('savedcoins',$member[0]['savedcoins']); ?>" class="form-control"  placeholder="Enter total coins if any">
		 
				
		<span class="text-danger"> <?php echo form_error('savedcoins'); ?>
		
		</span>
	</div>
  </div>
  
  
  
      
  <div class="form-group">
    <label for="inputbalance" class="col-sm-2 control-label">	Customer Balance	 </label>
    <div class="col-sm-10">
	
	
	
	
	
	
	
					<?php
										if($advance==true){
											
											?>

				  		<input type="text" name="balance" value="<?php echo set_value('balance',$member[0]['balance']); ?>" class="form-control"  placeholder="Enter total customer balance if any">

		 
										<?php
										}else{
										
										?>	
											
											
												  		<input type="text"  readonly name="balance" value="<?php echo set_value('balance',$member[0]['balance']); ?>" class="form-control"  placeholder="Enter total customer balance if any">
	
											
											
										<?php	
										}
	
										?>
	
	
	
	
	
	
		 
				
		<span class="text-danger"> <?php echo form_error('balance'); ?>
		
		</span>
	</div>
  </div>
  
  
  
    <div class="form-group">
    <label for="inputsupplierbalance" class="col-sm-2 control-label">	Supplier Balance	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="supplierbalance" value="<?php echo set_value('balance',$member[0]['supplierbalance']); ?>" class="form-control"  placeholder="Enter total supplier balance if any">
		 
				
		<span class="text-danger"> <?php echo form_error('supplierbalance'); ?>
		
		</span>
	</div>
  </div>
  

  
    	<div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">	Email </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="email" value="<?php echo set_value('email',$member[0]['email']); ?>" class="form-control"  placeholder="Enter Your email">
		 
				
		<span class="text-danger"> <?php echo form_error('email',$member[0]['company']); ?>
		
		</span>
	</div>
  </div>
  
 
  
  
	
  	
   	<div class="form-group">
    <label for="inputcountry" class="col-sm-2 control-label">Country  </label>
    <div class="col-sm-10"> 
	
		
		
		
		
				
<select name="country" id="country"class="form-control" >
    <?php
 $countryid= $member[0]['country'];
$country = $this->nationmodel->getcountrybyid($countryid);


if(is_array($country)) {

   foreach($country as $countryrow){
 ?>
	    <option value="<?php echo set_value('nation',$countryrow->id); ?> "><?=$countryrow->name;?></option>
<?php

}} else {
 ?>
<option selected value=""  >---Select one option--</option>

<?php 
}?>

	<?php 
$nation = $this->nationmodel->populatenation();


if(is_array($nation)) {

   foreach($nation as $nationrow){

    ?>
	    <option value="<?php echo set_value('nation',$nationrow->id); ?> "><?=$nationrow->name;?></option>

   
    <?php

}} else {
    echo 'There is no any country data available.... try again.';
}

?>
	</select>
		
	<span class="text-danger"> <?php echo form_error('nation'); ?>
		
		</span>
	</div>
  </div>
  
      
  
  
  
  
  
  
  
  
  
  
  
  
 
 
  <div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">	Status	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="status" required>
		<option selected="selectted" value="<?php echo $member[0]['status']?>"  ><?php $mymember=$member[0]['status']; if($mymember=="1"){echo "active";}else if($mymember=="0"){ echo "inactive";} ?></option>
	<option value=""  >---Select status---</option>
	<option value="1"  >active</option>
		<option value="0"  >inactive</option>
				<option value="Submited"  >Submited</option>
				<option value="Pending"  >Pending</option>
								<option value="Approved"  >Approved</option>
								<option value="Shortlisted"  >Shortlisted</option>
								<option value="Rejected"  >Rejected</option>
								<option value="Recruited"  >Recruited</option>


	</select>		 
				
		<span class="text-danger"> <?php echo form_error('status'); ?>
		
		</span>
	</div>
  </div>
  	<div class="form-group">
    <label for="inputcity" class="col-sm-2 control-label">	Town 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="city" value="<?php echo set_value('city',$member[0]['city']); ?>" class="form-control"  placeholder="Enter City or town">
		 
				
		<span class="text-danger"> <?php echo form_error('city'); ?>
		
		</span>
	</div>
  </div>
  
  
  
   	<div class="form-group">
    <label for="inputentrydate" class="col-sm-2 control-label">	Entry date  	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="entrydate" value="<?php echo set_value('entrydate',$member[0]['entrydate']); ?>" class="form-control"  placeholder="Enter Entry date">
		 
				
		<span class="text-danger"> <?php echo form_error('entrydate'); ?>
		
		</span>
	</div>
  </div>
  
  
 
  	<div class="form-group">
    <label for="inputzip" class="col-sm-2 control-label">Due Date	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="zip" value="<?php echo set_value('zip',$member[0]['zip']); ?>" class="form-control"  placeholder="Enter due date">
		 
				
		<span class="text-danger"> <?php echo form_error('zip'); ?>
		
		</span>
	</div>
  </div>
  
  
   	<div class="form-group">
    <label for="inputdob" class="col-sm-2 control-label">	Date of Birth  	 </label>
    <div class="col-sm-10">
	
		  		<input type="date" name="dob" value="<?php echo set_value('dob',$member[0]['dob']); ?>" class="form-control"  placeholder="Enter date of birh ">
		 
				
		<span class="text-danger"> <?php echo form_error('dob'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  		  	<div class="form-group">
    <label for="inputsalesperson" class="col-sm-2 control-label">	Sales Person /Agent Name	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="salesperson" value="<?php echo set_value('salesperson',$member[0]['salesperson']); ?>" class="form-control"  placeholder="Enter sales person">
		 
				
		<span class="text-danger"> <?php echo form_error('salesperson'); ?>
		
		</span>
	</div>
  </div>
	
	  	<div class="form-group" style="display:none">
    <label for="inputpassword" class="col-sm-2 control-label">Password	 </label>
    <div class="col-sm-10">
	
		  		<input type="password" name="password" value="<?php echo set_value('password',$member[0]['password']); ?>" class="form-control"  placeholder="Enter password if anay">
		 
				
		<span class="text-danger"> <?php echo form_error('password'); ?>
		
		</span>
	</div>
  </div>
  
	
	
  	<div class="form-group">
    <label for="inputrenewaldetails" class="col-sm-2 control-label">	Renewal Details	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="renewaldetails" value="<?php echo set_value('renewaldetails',$member[0]['renewaldetails']); ?>" class="form-control"  placeholder="Enter renewaldetails if any">
		 
				
		<span class="text-danger"> <?php echo form_error('renewaldetails'); ?>
		
		</span>
	</div>
  </div>
 
  
    	<div class="form-group">
    <label for="inputwebsite" class="col-sm-2 control-label">Renewal Comments	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="website" value="<?php echo set_value('website',$member[0]['website']); ?>" class="form-control"  placeholder="Enter comments if any">
		 
				
		<span class="text-danger"> <?php echo form_error('website'); ?>
		
		</span>
	</div>
  </div>
  
 
  
  <div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">Company Address details</label>
    <div class="col-sm-10">

				<textarea name="comments" value="<?php echo set_value('comments',$member[0]['comments']); ?>"  class="form-control"  placeholder="Enter comments"><?php echo set_value('comments',$member[0]['comments']); ?></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		
  
 <div class="form-group" style="display:none">
    <label for="inputcomputerno" class="col-sm-2 control-label">Computer Serial</label>
    <div class="col-sm-10">
		  		<input type="text" name="computerno" value="<?php echo set_value('computerno',$member[0]['computerno']); ?>" class="form-control"  placeholder="Enter computerno">

			
		<span class="text-danger"> <?php echo form_error('computerno'); ?>
		
		</span>
	</div>
  </div>
		
    
  <div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">Details</label>
    <div class="col-sm-10">

				<textarea readonly  name="computernouserdata" value="<?php echo set_value('computernouserdata',$member[0]['computernouserdata']); ?>"  class="form-control"  placeholder="Enter other details"><?php echo set_value('computernouserdata',$member[0]['computernouserdata']); ?></textarea>
			
		<span class="text-danger"> <?php echo form_error('computernouserdata'); ?>
		
		</span>
	</div>
  </div>
		
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	 
	 
	 
	 
	 
	
					<?php
										if($updatepeople==true){
											
											?>

	         <button type="submit"  value="member" name="btn_addmember" class="btn btn-primary"> Update Member   </button>

		 
										<?php
										}else{
											echo"You do not have role to update people";
										
										?>	
											
											
	
											
											
										<?php	
										}
	
										?>
	
	
	 
	 
	 
	 
	 
	 
	 
	 

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	  						
									
									
									
									
							</div>
						</div>
				

			
			</div>



















