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

    $session_data = $this->session->userdata('logged_in');
 $finalendate=date("Y-m-d H:59:59");
  $finalstartdate=date("Y-m-d 00:00:00");
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];


				 $mydate=date("Y-m-d");
				
				$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
		
		
					    $AddAgents=$this->usermodel->populatuserpermissionsdataarray('deals','AddAgents',$userid);

		
		?>

 
 <div class="row">
  
   	

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

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>



 
 <span class="pull-right"> View agents/ Reseller</span>		 

				
				<?php
		
		 if($AddAgents==true){

			 ?> 
 					    <a data-toggle='modal' data-target='#addModal' class="btn btn-default">Add Agent </a>
			
	<?php

 }else{
 }
  ?>
  	
		




 

				
            	</div>
            </div>
			<div class="panel-body">

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


								?>	
					<div class="row">
						<div class="col-md-12">
						All agents/resellers
							
							<div class="panel-body">
	<div class="col-md-12">
        <?php 
	
		
		
		
		
		
		 echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
       
	   //echo form_open("user/searchallmembers", $attr);

	   echo form_open("", $attr);?>
            <div class="form-group">
			
                <div class="col-md-5">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for members.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                <div class="col-md-4">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/allresellers"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>
        </div>
									
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
		      <th>Name</th>
   <th>Campany</th>

	     <th>Email</th>
<th>Phone</th>	
    <th>ID Number</th>
	    <th>Comments</th>
		   <th>status</th> 
		

<th>Action</th>


                 </tr>
             </thead><tbody>
<?php

 if(!is_array($viewmember)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='8'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  
  	foreach ($viewmember as $c): 

		 

             ?>



             <tr>
			   <td><?php echo $c->firstname ; ?></td>
                 <td><?php echo $c->company ; ?></td>
            <?php 
$id=$c->id;


?>

              


    <td><?php echo $c->email ; ?></td>
	  <td><?php echo $c->phone ; ?></td>
	  <td><?php echo $c->idno ; ?></td>
	  	  <td><?php echo $c->website ; ?></td>

  <td><?php  

  //$mystatus="";
$mystatus=$c->status;
			  if( $mystatus =="1"){
				 echo $mystatus="active"; 
			  } else if( $mystatus =="0"){
				    echo $mystatus="inactive";
				  
			  }else{
echo $c->status ;
}

?></td>
		 
		 
		 
		 
		 
		 
		 		 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
										 <li> 
										                     <a  id="more" target="blank" class="btn btn-primary" href="<?php echo base_url();?>user/editmember?randomitemidentifier=<?php   {echo  $id;}  ?>">Edit  </a>
</br>
 </li>


										  <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  id="more" target="blank" class="btn btn-default" href="<?php echo base_url();?>user/viewfollowups?randomitemidentifier=<?php   {echo  $id;}  ?>&type=Customer">Follow Ups  </a>
												</li>
</br>


							
														</br>
   
						

											
                                    </ul>
										
                                </div>
</td>
     		  
             </tr>

	<?php endforeach;} ?>

            
       <tbody> </table>
	   
        <div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Members. " ;?>    </span>

        
        </div>
   
			
	</div>
	
	
	
	
	
	
	
	
	
		<div id="addModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new  Customer/ Contact</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		      $mydate=date("Y-m-d");
			  
			  		      $myyear=date("Y");
						    $myyear= $myyear+1;
						  		      $mymonth=date("m-d");

			$finalnextyeardate=$myyear."-". $mymonth;

                 echo form_open('user/addmember' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
<input type="hidden" name="status" value="1"id="status" class="form-control" required placeholder="Enter status">
<input type="hidden" name="view" value="user/allresellers"id="view" class="form-control" required placeholder="Enter status">



					<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 value=""   >---Select category---</option>
<!--
	<option value="member"  >Customer</option>
		<option value="supplier"  >Supplier</option>
				<option value="user"  >Employee</option>
				
								<option value="accomodation" >Accomodation</option>

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

	</select>		 
				
		<span class="text-danger"> <?php echo form_error('category'); ?>
		
		</span>
	</div>
  </div>
				



		
 <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',$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="inputfirstname" class="col-sm-2 control-label">Customer	Names<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" class="form-control" required placeholder="Enter first and last name">
		 
				
		<span class="text-danger"> <?php echo form_error('firstname'); ?>
		
		</span>
	</div>
  </div>
 <div class="form-group">
    <label for="inputcompany" class="col-sm-2 control-label">	Company<span style="color:red;"></span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="company" value="<?php echo set_value('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="inputphone" class="col-sm-2 control-label">	Phone <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		 			  		<input type="text" name="phone"   minlength="12"	maxlength="14"   value="<?php echo set_value('phone'); ?>" class="form-control" required placeholder="Enter phone e.g 254712345678">

				
		<span class="text-danger"> e.g 254712345678 <?php echo form_error('phone'); ?>
		
		</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'); ?>" class="form-control"  placeholder="Enter ID.No if any ">
		 
				
		<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" minlength="11"	maxlength="14" value="<?php echo set_value('idnumber'); ?>"   class="form-control"  placeholder="Enter Pin if any">
		 
				
		<span class="text-danger"> <?php echo form_error('idnumber'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphoneaddress_1" class="col-sm-2 control-label">Card Number/ Phone 2 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="address_1" value="<?php echo set_value('address_1'); ?>" class="form-control"  placeholder="Enter Card Number/ Phone 2">
		 
				
		<span class="text-danger"> <?php echo form_error('address_1'); ?>
		
		</span>
	</div>
  </div>
  

 
   	<div class="form-group">
    <label for="inputphonegender" class="col-sm-2 control-label">	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
	
	<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" id="groupname" >		
    <label for="inputcategoryid" class="col-sm-2 control-label">Default Group Name?</label>
    <div class="col-sm-10">
	<select class="form-control" name="categoryid" >
	
	<option value=""  >---Select Group Name---</option>

	
	<?php 
					 
			
	


if(is_array($mycategory)) {

   foreach($mycategory 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="inputcountry" class="col-sm-2 control-label">Country?</label>
    <div class="col-sm-10">
	<select class="form-control" name="country" >
	


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


if(is_array($mycountry)) {

   foreach($mycountry as $mycountryrow){

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



	<?php

}} else {
    echo 'No country available.';
}
	
?>
	<option value=""  >---Select country---</option>
</select>
		
						<span class="text-danger"><?php echo form_error('country'); ?>

	</div>
  </div>
  
  
  
  
    	<div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">	Email</label>
    <div class="col-sm-10">
	
		  		<input type="email" name="email" value="<?php echo set_value('email'); ?>" class="form-control"  placeholder="Enter Your email">
		 
				
		<span class="text-danger"> <?php echo form_error('email'); ?>
		
		</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'); ?>" 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 / Start date  	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="entrydate" value="<?php echo set_value('entrydate',$mydate); ?>" 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',$finalnextyeardate); ?>" class="form-control"  placeholder="Enter Renewal Date">
		 
				
		<span class="text-danger"> <?php echo form_error('zip'); ?>
		
		</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'); ?>" 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="inputsalesperson" class="col-sm-2 control-label">	Sales Person 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="salesperson" value="<?php echo set_value('city'); ?>" class="form-control"  placeholder="Enter sales person">
		 
				
		<span class="text-danger"> <?php echo form_error('salesperson'); ?>
		
		</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'); ?>" 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="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'); ?>"  class="form-control"  placeholder="Enter comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="member" name="btn_addmember" class="btn btn-default"> Add Customer   </button>

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

    

				</div>

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

	
	
	
	
	
	
	
	
	
				<div id="addsupplierModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Add new  Supplier</h4>
      </div>
      <div class="modal-body">
      
	  	

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

				echo $this->session->flashdata('msg'); 
		      $mydate=date("Y-m-d");
			   $myyear=date("Y");
						    $myyear= $myyear+1;
			  		    //  $myyear=date("Y")+1;
						  		      $mymonth=date("m-d");

			$finalnextyeardate=$myyear."-". $mymonth;


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

<input type="hidden" name="view" value="user/viewsupplier"id="view" class="form-control" required placeholder="Enter status">


	
		  		<input type="hidden" name="category" readonly     value="<?php echo set_value('category','supplier'); ?>" class="form-control"  placeholder="Enter ocategory">
		 
				
				
						
						
					<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" required value="<?php echo set_value('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"> Contact	Names<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" class="form-control" required placeholder="Enter first and last name">
		 
				
		<span class="text-danger"> <?php echo form_error('firstname'); ?>
		
		</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'); ?>" class="form-control" required placeholder="Enter phone e.g 254712345678">
		 
				
		<span class="text-danger"> e.g 254712345678 <?php echo form_error('phone'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphoneaddress_1" class="col-sm-2 control-label">Phone 2	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="address_1" value="<?php echo set_value('address_1'); ?>" class="form-control"  placeholder="Enter other line e.g 254712345678">
		 
				
		<span class="text-danger">Other Number e.g 254712345678 <?php echo form_error('address_1'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphonegender" class="col-sm-2 control-label">Contact	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
	
	<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="inputcountry" class="col-sm-2 control-label">Country?</label>
    <div class="col-sm-10">
	<select class="form-control" name="country" >
	


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


if(is_array($mycountry)) {

   foreach($mycountry as $mycountryrow){

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



	<?php

}} else {
    echo 'No country available.';
}
	
?>
	<option value=""  >---Select country---</option>
</select>
		
						<span class="text-danger"><?php echo form_error('country'); ?>

	</div>
  </div>
  
  
  
  
    	<div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">	Email </label>
    <div class="col-sm-10">
	
		  		<input type="email" name="email" value="<?php echo set_value('email'); ?>" class="form-control"  placeholder="Enter Your email">
		 
				
		<span class="text-danger"> <?php echo form_error('email'); ?>
		
		</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'); ?>" class="form-control"  placeholder="Enter idno if any or Campany Pin">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  
  
  
     
  
  
  
  
    
  	<div class="form-group">
    <label for="inputcity" class="col-sm-2 control-label">	City 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="city" value="<?php echo set_value('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',$mydate); ?>" 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'); ?>" 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="inputwebsite" class="col-sm-2 control-label">	Comments	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="website" value="<?php echo set_value('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'); ?>"  class="form-control"  placeholder="Enter comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="member" name="btn_addmember" class="btn btn-primary"> Add Supplier   </button>

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

    

				</div>

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

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

 
</div>


















