<?php
require_once('constants.php');
class General
{
	public function __construct()
	{
		
		?>
         
        <script language="javascript" src="js/index_sub.js?t=<?=time();?>" type="text/javascript">       
        </script>
        
        <?php
	}
	
	 
	public function showGeneralList()
	{
		//if(count($_SESSION['cat'])<=0)
			 
				/*echo '<PRE/>';
				print_r($_SESSION['cat']);
				echo '<PRE/>';*/
	
	?>
      
 

      <div class="am-mainpanel">
      <div class="am-pagebody">

        <div class="card pd-20 pd-sm-20">
          <h6 class="card-body-title"><?=TITLE_PAGE;?></h6>
           
		  
          <div class="mg-0  col-md-12 mg-b-10 search_options">	
           <form action="#" id="searching_arguments">
          		<input type="hidden" id="task" name="task" value="GeneralDetails">
                
                <div class="input-group col-md-12" > 
                 <label>Search : </label>&nbsp;<input type="text" name="searchtext" id="searchtext" value="<?=$_REQUEST['ref_id'];?>" class="form-control">                 
                 <label>SMS : </label>&nbsp; <select id="s_sms" name="s_sms">
                 								<option value="">-All-</option>
                                                <option value="0">Only Important SMS</option>
                                                <option value="1">Enabled SMS Service</option>
                                                </select>
                 
                 <label>Date From : </label>&nbsp; 
                      
                      
                      
  <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <?php if($_REQUEST['ref_id']<>"")
  			$d = date("01-01-2018");
		else
			$d = date("01-m-Y");
			?>
  <input type="text" class="form-control fc-datepicker" placeholder="DD/MM/YYYY" name="s_date_from" id="s_date_from" value="<?=$d;?>">
  
   <label>Date To : </label>&nbsp; 
                      
                      
                      
  <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input type="text" class="form-control fc-datepicker" placeholder="DD/MM/YYYY" name="s_date_to" id="s_date_to" value="<?=date("d-m-Y");?>">
  <label> </label>&nbsp; 
   <button type="button" onclick="GeneralDetails(1);" style="float:right; margin:0px;" class="dt-button buttons-pdf buttons-html5 btn-sm"><i class="fa fa-search mg-r-5"></i>Search</button>
</div>
                                                                    
                 
          		
          </form>
          </div>
          <div class="table-wrapper">
             
             <div class="x_content" id="main_result_div">
                     <script language="javascript" type="text/javascript">GeneralDetails(1);</script>
					
					
                  </div>
             
          </div><!-- table-wrapper -->
        </div><!-- card -->

           
                     
    <?php
	}
	
	//Add 
		public function add_edit($data='',$extra='')
		{
			
			//echo $_SESSION['role_level'];
			
			
			 
			$data['id'] = $data['code'];
			
			/*if($data['dob'])
				$data['dob'] = $data['dob'];
			else
				$data['dob'] = date("Y-m-d");
				*/
		?> 

            <div id="add_edit"  >
                <form   name="add_edit_form" id="add_edit_form" method="post" enctype="multipart/form-data" action='../ajaximage/ajaximage.php' data-parsley-validate >
               <div class="header_box"><?=($data['id']>0)?'Edit - ':'Add - ';?><?=TITLE_PAGE;?></div>
               <div class="body_box"> <?php if($data['id']>0) { 
				
				?>
                	<input type="hidden" name="task2" id="task2" value="update"  />
                    <input type="hidden" name="id" id="id" value="<?=$data['id'];?>"  />
                   
				   
                   
				   <?php }else{ 
				   
				   //$data['under'] = $extra['under'];
				  // $data['designation'] = $extra['designation'];
				   ?>
                   <input type="hidden"  name="task2" id="task2" value="Add"  />
                   <input type="hidden" name="id" id="id" value=""  />
                   <?php } ?>
                   
                 
              	
                
                    <div class=" ">
                       
                     
                        
                        <?php 
						if($data['id']>0) { ?>
                        
                        <div class="d-md-flex mg-b-0">
                        <div class="form-group mg-b-0">                          
                         <H4>Customer Code :  <?=$data['member_code'];?> </H4>                  
                           
                            
                        </div> </div>
                      <Hr/> 
                        <?php } ?>
                        
                       
                        
                     
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Name : <span class="tx-danger">*</span></label>                           
                          <input type="text" name="<?=$name='name';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""   required>
                            
                        </div><!-- form-group -->
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Mobile Number : <span class="tx-danger">*</span></label>
                           
                           <input type="number" maxlength="10" min='1' max='9999999999' name="<?=$name='mobile';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  required>
                            
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Email <span class="tx-danger"></span></label>
                           
                           <input type="email"  name="<?=$name='email';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder="">
                        </div>
                        
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          
                          <label>Date of Birth : <span class="tx-danger">*</span></label>
                           
                           <div class="input-group">
                        
                           <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input readonly="readonly" type="text" class="form-control fc-datepicker form-control wd-200 wd-sm-250" placeholder="DD/MM/YYYY"  name="<?=$name='dob';?>" id="<?=$name;?>" value="<?=date("d-m-Y",strtotime(clear_blank_date($data[$name])));?>">
                             
                             </div>
                            
                        </div>
                        
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Date of Anniversary : <span class="tx-danger"></span></label>
                           
                           <div class="input-group">
                        
                           <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input readonly="readonly" type="text" class="form-control fc-datepicker form-control wd-200 wd-sm-250" placeholder="DD/MM/YYYY"  name="<?=$name='doa';?>" id="<?=$name;?>" value="<?=date("d-m-Y",strtotime(clear_blank_date($data[$name])));?>">
                             
                             </div>
                        </div>
                        <?php
						if($data['id']>0){ ?>
                         <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                           <label>Password : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='password';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  required >
                        </div>
                        <?php } ?>
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	 <label>Address (Line 1) : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='add_1';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  required>
                             
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                           <label>Address (Line 2) : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='add_2';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""  >
                        </div><!-- form-group -->
                         
                         <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                           <label>Area : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='area';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder="Area" required   >
                        </div><!-- form-group -->
                         
                      </div>
                      
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	<label>Country : <span class="tx-danger"></span></label>
                          	
                            
                            <?php 
							$table = "bm_countries_for_ip";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['country'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "country";		//$id = id of select
							$displayName = "countries_name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?>
                             
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                            <label>State : <span class="tx-danger">*</span></label>
                          <div id="state_display">
					 <?php 
							$table = "bm_states";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "country";		//$matchField = matching fields
							$code = $data['country'];				//$code = where $code
							$class = "form-control wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['state'];				//$sel = selected fields
							$function =" ";			//$function = javascript function
							$id = "state";		//$id = id of select
							$displayName = "state_name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							
							
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?>
                            </div>
                        </div><!-- form-group -->
                         <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                            <label>City : <span class="tx-danger">*</span></label>
                          <div id="city_display">
					 <?php 
							
							$table = "bm_districts";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "state";		//$matchField = matching fields
							$code = $data['state'];				//$code = where $code
							$class = "form-control wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['city'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "city";		//$id = id of select
							$displayName = "district_name";		//displayName = display name
							$value ="code";  			// $value = value of Select
								
							
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?>
                            </div>
                        </div>
                         
                      </div>
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	<label>Postal Code : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='pin_code';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""   >
                             
                        </div>
                         
                         <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          
                            
                        </div>
                         
                      </div>
                      <HR/>
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Nominee Name : <span class="tx-danger"></span></label>                           
                          <input type="text" name="<?=$name='nominee';?>" id="<?=$name;?>" class="form-control wd-100 wd-sm-150" value="<?=$data[$name];?>" placeholder=""    >
                            
                        </div><!-- form-group -->
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Nominee DOB : <span class="tx-danger"></span></label>
                           
                           <div class="input-group">
                        
                           <span class="input-group-addon"><i class="icon ion-calendar tx-16 lh-0 op-6"></i></span>
  <input type="text" readonly="readonly" class="form-control fc-datepicker form-control wd-200 wd-sm-250" placeholder="DD/MM/YYYY"  name="<?=$name='nominee_dob';?>" id="<?=$name;?>" value="<?=date("d-m-Y",strtotime(clear_blank_date($data['nominee_dob'])));?>">
                             
                             </div>
                            
                        </div>
                        
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Nominee Mobile Number : <span class="tx-danger"></span></label>
                           
                           <input type="number" maxlength="10" min='0' max='9999999999' name="<?=$name='nominee_contact_no';?>" id="<?=$name;?>" class="form-control wd-100 wd-sm-150" value="<?=$data[$name];?>" placeholder=""   >
                            
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Nominee Relationship <span class="tx-danger"></span></label>
                           
                           <input type="text"  name="<?=$name='nominee_relationship';?>" id="<?=$name;?>" class="form-control wd-100 wd-sm-150" value="<?=$data[$name];?>" placeholder="" >
                        </div>
                        
                      </div>
                      <HR/>
                      
                      
                      <!--<div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                          <label>SMS Notification : <span class="tx-danger"></span></label>
                         	    <select name="sms" class="form-control selct wd-200 wd-sm-250" id="sms" required>
                                <option value="1" selected="selected">All SMS</option>
                                <option value="0" <?php if($data['sms']=="0") echo 'selected="selected"'; ?> >Only Important SMS</option>
                              </select>
                              
                               
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Calling Status : <span class="tx-danger"></span></label>
                           
                            <select name="customer_calling_status"  id="customer_calling_status" class="form-control selct wd-200 wd-sm-250" required>
                                <option value="0" selected="selected"> - </option>
                                <option value="1" <?php if($data['customer_calling_status']=="1") echo 'selected="selected"'; ?> >Never Call</option>
                                <option value="1" <?php if($data['customer_calling_status']=="2") echo 'selected="selected"'; ?> >Do not call for this month payment</option>
                              </select>
                        </div>
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                           <label>Hear about us : <span class="tx-danger">*</span></label>
                           
                            <?php 
							$table = "hear_about";	//$table = name of table
							$fields = "*";//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['hear_about'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "hear_about";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							
							
							echo  common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value); ?>
                        </div>
                        
                      </div>-->
                      
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                           
                        
                           <label>Sale Employee : <span class="tx-danger">*</span></label>
                          <?php
							   
							    
								if($data['sale_employee_code']<=0 and $data['code']<=0)
									$data['sale_employee_code'] = $_SESSION['admin_code'];
									
								
								
								  $qry = "SELECT s.*,designation_name FROM admin_users s 
									INNER JOIN  designation b  ON s.is_deleted=0     and b.code=s.designation   ";
								 
								
								if($matchField=="")
							
								 
								$res=mysql_query($qry);
								
								$out = '<select id="sale_employee_code_new" name="sale_employee_code_new"  class="form-control select2" data-placeholder="Choose Browser" >';//multiple
								$out .='<option value="" >--Select--</option>';
								
								while($result=mysql_fetch_array($res))
								{	
									$sel='';
									 if($data['sale_employee_code_new']==$result['admin_id'])
									 	$sel = 'selected';
									 $out .='<option '.$sel.' value="'.$result['admin_id'].'"  >'.$result['name'].' ('.$result['designation_name'].')</option>';
									 
								}
								$out .= '</select>';
								echo  $out;
								
								?>
                           </div>
                        
                         
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                        
                        <label>Referrer Code (if any) <span class="tx-danger"></span></label>
                           
                           <input type="text"  name="<?=$name='sponsor_code';?>" id="<?=$name;?>" class="form-control wd-100 wd-sm-150" value="<?=$data[$name];?>" placeholder="" >
                        </div>
                        
                        <?php
						 $sql = "Select * from customer where member_code = '".trim($data['sponsor_code'])."'   and  is_deleted=0";

						$res = mysql_query($sql);
			
						$rows2 = mysql_fetch_assoc($res);
			 
							
						?>
                         
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                        
                                <label>Referrer Name <span class="tx-danger"></span></label>
                                   
                                   <input type="text" readonly="readonly"  name="<?=$name='sponsor_name';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$rows2['name'];?>" placeholder="" >
                                </div>
                        
                        
                         
                      </div>
                       <HR/>
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                          <label>SMS Notification : <span class="tx-danger">*</span></label>
                         	   <select name="sms" class="mandatory form-control selct wd-200 wd-sm-250" id="sms">
                                <option value="1" selected="selected">All SMS</option>
                                <option value="0" <?php if($data['sms']=="0") echo 'selected="selected"'; ?> >Only Important SMS</option>
                              </select>
                        </div>
                      <!--<div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                          <label>Status : <span class="tx-danger">*</span></label>
                         	   <?php 
							$table = " master_status";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['status'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "status";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="code";  			// $value = value of Select
							$other =" required"; 
							
							echo common_select($table,$fields,$matchField,$code,$class,$sel,$function,$id,$displayName,$value,$other)
					?>
                        </div>
                        
                         <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                          <label>Admin Notes : <span class="tx-danger"></span></label>
                           
                           <input type="text"  name="<?=$name='admin_notes';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>"    >
                            
                        </div>
                      -->
                      </div>
                      
                      <div class="d-md-flex">
                         <div  id="res"></div>
                      </div>
                       <div class="d-md-flex mg-b-30">
                        <button type="submit"  id="submit_66"  class="dt-button btn btn-primary btn-success btn-sm">Submit</button> 
                        
                        <button type="button" class="dt-button btn btn-default btn-success btn-sm" onclick="GeneralDetails(<?=$_SESSION['page'];?>)">Go Back</button>
                        </div>
                    </div>
           <!--
           		<button type="button" id="btnInsertPro" name="btnInsertPro" onclick="addNew_Key(this.form)">Save</button>
                <button type="button" id="as" name="as" onclick="GeneralDetails(<?=$_SESSION['page'];?>)" >Go Back</button>-->
            
            	</form>
            </div>
                
		 
        <?php
	}
	
}

?>
</div>
