<?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;?><?=($_REQUEST['ref_id2']<>"")?' - '.$_REQUEST['ref_id2']:'';?></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">
                
                
                <input type="hidden" id="type_report" name="type_report" value="<?=$_REQUEST['s_booking_status'];?>" >
                <input type="hidden" id="s_booking_status_m" name="s_booking_status_m" value="<?=$_REQUEST['s_booking_status_m'];?>" >
                
                <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>Type : </label>&nbsp; <select id="p_type" name="p_type">
                 								<option value="">-All-</option>
                                                <option value=">">Debit (Recived)</option>
                                                <option value="<">Credit (Given)</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']<>"" or $_REQUEST['ref_id2']<>"")
  			$d = date("01-01-2016");
		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=" ">
                       
                     
                        
                         
                       
                        
                      
                      
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	 
                        
                        <?php 
						
							  $s  = "select * from customer where code = '".$data['sponsor_code']."'";
							  $r = mysql_query($s);
							  $ro = mysql_fetch_assoc($r);
							  ?>
                        
                           <label>Customer Code/Mobile Number: <span class="tx-danger">*</span></label>
                           <input type="text" name="<?=$name='sponsor_code';?>" maxlength="10" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['customer_code'];?>" placeholder=""  required>
                             
                        </div><!-- form-group -->
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          <label>Customer Name : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='sponsor_name';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['name'];?>" placeholder="" readonly="readonly" >
                        </div><!-- form-group -->
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	 
                        
                        <?php 
						
							  $s  = "select * from customer where code = '".$data['sponsor_code']."'";
							  $r = mysql_query($s);
							  $ro = mysql_fetch_assoc($r);
							  ?>
                        
                           <label>Booking for Mobile Number: <span class="tx-danger">*</span></label>
                           <input type="text" name="<?=$name='bookfor_mobile';?>" maxlength="10" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['mobile'];?>" placeholder=""  required>
                             
                        </div><!-- form-group -->
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0"> 
                          <label>Booking for Name : <span class="tx-danger">*</span></label>
                          <input type="text" name="<?=$name='bookfor_name';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['name'];?>" placeholder=""  >
                        </div><!-- form-group -->
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	 
                       
                          <label>Scheme : <span class="tx-danger">*</span></label>
                         	   <?php 
									$table = " schemes";	//$table = name of table
									$fields = "*";			//Fields = Fields of tables
									$matchField = "status";		//$matchField = matching fields
									$code = "1";				//$code = where $code
									$class = "form-control selct wd-200 wd-sm-250";			//$class = css classs 
									$sel = $data['scheme'];				//$sel = selected fields
									$function ="";			//$function = javascript function
									$id = "scheme";		//$id = id of select
									$displayName = "scheme_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>Amount : </label>
                             <input type="number" min='5000' max='10000000000000'    name="<?=$name='amount';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['name'];?>" placeholder="" readonly="readonly"  required  >
                        </div>
                        
                        
                        
                        <!-- form-group -->
                        
                      </div> 
                      
                       
                        
                       
                        
                        <!-- form-group -->
                        
                      </div>
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">                              
                              <label>Plan Details : </label>
                              <div id="<?=$name='plan_details';?>"  class="form-control wd-250 wd-sm-250" >&nbsp;</div>
                        </div><!-- form-group -->                        
                      </div>
                       
                      
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                         
                         
                       
                          <label>Mode of Payment : <span class="tx-danger">*</span></label>
                         	   <?php 
							$table = " master_payment_mode";	//$table = name of table
							$fields = "*";			//Fields = Fields of tables
							$matchField = "";		//$matchField = matching fields
							$code = "";				//$code = where $code
							$class = "form-control select wd-200 wd-sm-250";			//$class = css classs 
							$sel = $data['payment_mode'];				//$sel = selected fields
							$function ="";			//$function = javascript function
							$id = "payment_mode";		//$id = id of select
							$displayName = "name";		//displayName = display name
							$value ="name";  			// $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 paytm" c style=" <?=($data['payment_type']<>'paytm')?'display:none;':'';?>"> 
                              <label>Paytm Transaction Number : </label>
                             <input type="text"  name="<?=$name='paytm_transaction_no';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$ro['name'];?>" placeholder="" <?=($data['payment_type']=='paytm')?'required':'';?>  >
                        </div>
                        
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0  bank" c style=" <?=($data['payment_type']<>'bank')?'display:none;':'';?>"> 
                              <label>Bank Name : <span class="tx-danger">*</span></label>
                             
                         	   <?php 
								$table = " bank_master";	//$table = name of table
								$fields = "*";			//Fields = Fields of tables
								$matchField = "";		//$matchField = matching fields
								$code = "";				//$code = where $code
								$class = "form-control select wd-100 wd-sm-150";			//$class = css classs 
								$sel = $data['bank_name'];				//$sel = selected fields
								$function ="";			//$function = javascript function
								$id = "bank_name";		//$id = id of select
								$displayName = "bank_name";		//displayName = display name
								$value ="bank_name";  			// $value = value of Select
								$other =" "; 
								
								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  bank" c style=" <?=($data['payment_type']<>'bank')?'display:none;':'';?>"> 
                              <label>Type : <span class="tx-danger">*</span></label>
                             
                         	   <?php 
								$table = " bank_master_type";	//$table = name of table
								$fields = "*";			//Fields = Fields of tables
								$matchField = "";		//$matchField = matching fields
								$code = "";				//$code = where $code
								$class = "form-control select wd-100 wd-sm-150";			//$class = css classs 
								$sel = $data['bank_t_type'];				//$sel = selected fields
								$function ="";			//$function = javascript function
								$id = "bank_t_type";		//$id = id of select
								$displayName = "name";		//displayName = display name
								$value ="name";  			// $value = value of Select
								$other =" "; 
								
								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 bank" c style=" <?=($data['payment_type']<>'bank')?'display:none;':'';?>"> 
                              <label>Cheque/Transaction Number : <span class="tx-danger">*</span></label>
                             <input type="text"  name="<?=$name='bank_transaction_no';?>" id="<?=$name;?>" class="form-control wd-100 wd-sm-150" value="<?=$ro['name'];?>" placeholder="" <?=($data['payment_type']=='bank')?'required':'';?>  >
                        </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_emp_code']<=0 and $data['code']<=0)
									$data['sale_emp_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_emp_code" name="sale_emp_code" class="form-control selct wd-200 wd-sm-250" >';
								$out .='<option value="" >--Select--</option>';
								
								while($result=mysql_fetch_array($res))
								{	
									$sel='';
									 if($data['sale_emp_code']==$result['admin_id'])
									 	$sel = 'selected';
									 $out .='<option '.$sel.' value="'.$result['admin_id'].'"  >'.$result['name'].' ('.$result['designation_name'].')</option>';
									 
								}
								$out .= '</select>';
								echo  $out;
								
								?>
                           </div>
                        
                         
                        
                          
                         
                        
                        
                         
                      </div>
                      
                      
                      <div class="d-md-flex mg-b-30"  >
                        
                         
                         
                         
                           <div class="ckbox blinking" id="agree_box" >
                              
                            </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>
