<?php
require_once('constants.php');
class General
{
	public function __construct()
	{
		
		?>
         
        <script language="javascript" src="js/index_sub.js?t=<?=time();?>" type="text/javascript">       
        </script>
         <script language="javascript" src="js/index_2.js?t=<?=time();?>" type="text/javascript"></script>
        <script language="javascript" src="js/index_extra2.js?t=<?=time();?>" type="text/javascript"></script>
		
		<script language="javascript" src="js/sugestion2.js?t=<?=time();?>" type="text/javascript">
        
			
        </script>
        <style>

#result {

	height:20px;

	font-size:16px;

	font-family:Arial, Helvetica, sans-serif;

	color:#333;

	padding:5px;

	margin-bottom:0px;

	background-color:#FFFF99;

}

 

.suggestionsBox {

	position: absolute;

	left: 0px;

	top:0px;

	margin: 6px 0px 0px 0px;

	width: 300px;

	padding:0px;

	background-color: #000;

	border-top: 3px solid #000;

	color: #fff;

	z-index:999!important;

	

}

.suggestionList {

	margin: 0px;

	padding: 0px;

	z-index:3000 !important;

}

.suggestionList ul li {

	list-style:none;

	margin: 0px;

	padding: 6px;

	border-bottom:1px dotted #666;

	cursor: pointer;

	z-index:3000 !important;

}

.suggestionList ul li:hover {

	background-color: #FC3;

	color:#000;

}

ul {

	font-family:Arial, Helvetica, sans-serif;

	font-size:11px;

	color:#FFF;

	padding:0;

	margin:0;

	z-index:3000 !important;

}



.load{

background-image:url(loader.gif);

background-position:right;

background-repeat:no-repeat;

}



.suggest {

	position:relative;

	z-index:20;

}



    </style>
        
        <?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=" ">
                       
                     
                       
                        
                       
                        <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Customer Type : <span class="tx-danger">*</span></label>                           
                          <select name="customer_type" id="customer_type"  class="form-control wd-200 wd-sm-250 mandatory" >
                    	 
                        <option value="old" <?=($data['customer_type']=='self' or $data['customer_type']=='')?'selected="selected"':'';?>>Existing Customer</option>
                        <option value="new" >New Customer</option>
                        
                       <!-- <option value="new" <?=($data['payment']=='ship')?'selected="selected"':'';?>> New customer</option>-->
                        </select>
                            
                        </div><!-- form-group -->
                        
                        
                        
                      </div>
                     
                      <div class="d-md-flex mg-b-30 old">
                        <div class="form-group mg-b-0 old">
                          
                          <label>Customer Code : <span class="tx-danger">*</span></label>                           
                          <input type="text" name="<?=$name='customer_code';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250 oldf" 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><BR/></label>
                           <BR/>
                          <span style="font-size:13px;" id="res_jbc"></span>
                            
                        </div>
                        
                        
                      </div>
                      
                      <?php $name='policy_code';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style=" visibility:hidden;"     readonly="readonly"  /> 
                      <Hr/>
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                          
                          <label>Billing 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>Billing 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>
                      
                      
                      <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=""  >
                             
                        </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>
                      
                      
                       <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	 <label>City : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='city';?>" 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"> 
                          
                           <label>State : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='state';?>" 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>Country : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='country';?>" 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"> 
                          
                           	<label>Postal Code : <span class="tx-danger"></span></label>
                          <input type="text" name="<?=$name='postal_code';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>" placeholder=""   >
                             
                        </div> 
                         
                      </div>
                      
                      
                     <input type="checkbox" id="shipping_same" style="display:none;"  name="shipping_same" <?=($data['shipping_same']==1 or $data['shipping_same']=='')?'checked="checked"':'';?> value="1"> 
                      
                      
                      
                      
                      
                      
                      
                      
                      
                        
                      
                      
                        
                      
                      
                       
                      
                       
                      <HR/>
                      <div class="d-md-flex mg-b-30">
                        
                      <table width="100%" border="0" cellspacing="0" cellpadding="2">

  <tr>

    <th width="4%">SNo.</th>

    <th width="67%"  >Product</th>

    <th width="9%">Price</th>
    <th width="9%">Qty </th>
    <th width="9%">Total</th>
    </tr>

  <?php

  $k=1;

  

  $total = 0;

  $sql_product = "SELECT * FROM despatch_details  WHERE purchase_code='".$data['code']."' and   purchase_code>0	  ";
  $row_product = mysql_query($sql_product);
  while($row_p = mysql_fetch_assoc($row_product))
  {

  ?>

  <tr>

    <td valign="top" id="sr_<?=$k;?>"><?=$k;?></td>

    <td valign="top"><input name="product_code_<?=$k;?>" id="product_code_<?=$k;?>" value="<?=$row_p['product_code'];?>" type="hidden" class="codes" /><input name="product_<?=$k;?>"  <?=$disabled;?> id="product_<?=$k;?>" value="<?=$row_p['product_name'];?>" style="min-width:600px; width:100%;" type="text" onkeyup="suggest_product(<?=$k;?>,this.value);" onblur="fill_product(<?=$k;?>,'');"    />
     
     <div  id="product_detail_<?=$k;?>"></div>
      
      
       
      <div id="suggest_<?=$k;?>"  class="suggest"> <div class="suggestionsBox" id="suggestions_<?=$k;?>" style="display:none;"> <img src="arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
        
        <div class="suggestionList" id="suggestionsList_<?=$k;?>"> &nbsp; </div>
        
        </div>
      </div>      </td>
	<td valign="top"><input name="product_price_<?=$k;?>"  <?=$disabled;?> id="product_price_<?=$k;?>" style="width:90px; text-align:center;" value="<?=abs($row_p['price']);?>" type="txt" class="numaric" />
    <input name="product_price_<?=$k;?>"  <?=$disabled;?> id="product_price_<?=$k;?>" style="width:60px; text-align:center; display:none;" value="<?=abs($row_p['price']);?>" type="txt" class="numaric" />    </td>
    
    <td valign="top"><input name="product_qty_<?=$k;?>"  <?=$disabled;?> id="product_qty_<?=$k;?>" style="width:90px; text-align:center;" value="<?=abs($row_p['qty']);?>" type="txt" class="numaric" /></td>
   </tr> 
    <?php 

  $k++;

  }

  

  while($k<=10) { ?>

  <tr>

    <td valign="top" id="sr_<?=$k;?>"><?=$k;?></td>

    <td valign="top"><input name="product_code_<?=$k;?>" id="product_code_<?=$k;?>" value="<?=$row_p['product_code'];?>" type="hidden" class="codes" /><input name="product_<?=$k;?>"  <?=$disabled;?> id="product_<?=$k;?>" value="<?=$row_p['product_name'];?>" style="min-width:600px; width:100%;" type="text" onkeyup="suggest_product(<?=$k;?>,this.value);"  onblur="fill_product(<?=$k;?>,'');"    />
      <div  id="product_detail_<?=$k;?>"></div>
      <div id="suggest_<?=$k;?>"  class="suggest"> <div class="suggestionsBox" id="suggestions_<?=$k;?>" style="display:none;"> <img src="arrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
        
        <div class="suggestionList" id="suggestionsList_<?=$k;?>"> &nbsp; </div>
        
        </div>
      </div>    </td> 
	<td valign="top"><input name="product_ourprice_<?=$k;?>"  <?=$disabled;?> id="product_ourprice_<?=$k;?>" style="width:120px; text-align:center;" value="<?=abs($row_p['ourprice']);?>" type="txt" class="numaric" readonly="readonly"/>
    <input name="product_price_<?=$k;?>"  <?=$disabled;?> id="product_price_<?=$k;?>" style="min-width:90px; width:100%;text-align:center; display:none;" value="<?=abs($row_p['price']);?>" type="txt" class="numaric" />    </td>
    
    <td valign="top"><input name="product_qty_<?=$k;?>"  <?=$disabled;?> id="product_qty_<?=$k;?>" style="min-width:60px;width:100%; text-align:center;" value="<?=abs($row_p['qty']);?>" type="txt" class="numaric qty" /></td>
    
    <td valign="top"><input name="product_total_<?=$k;?>"  <?=$disabled;?> id="product_total_<?=$k;?>" style="min-width:120px;width:100%; text-align:right;" value="<?=abs($row_p['ourprice'] * $row_p['qty']);?>" readonly="readonly" type="txt" class="numaric" /></td>
   </tr> 
<input name="product_total_before_tax_<?=$k;?>"  <?=$disabled;?> id="product_total_before_tax_<?=$k;?>" style=" display:none;" value="<?=abs($row_p['ourprice'] * $row_p['qty']);?>" readonly="readonly" type="txt" class="numaric" />
  

  

  <?php 
  $total+= ($row_p['ourprice'] * $row_p['qty']);
  $k++; } ?>

   <tr>
        <td colspan="4" style="text-align:right;color:#000; font-size:14px; "  >Sub Total : </td> 
        <td  colspan="2" style="text-align:right; color:#000; font-size:14px;"  id="t_amount"></td>
   </tr>   
   
   <tr>
    	<td colspan="6" style="text-align:right;color:#F00;  font-size:14px; " id="promotional_wallet_place"></td> 
   </tr>
   
   
   	<tr>

    <td colspan="6" style="text-align:right;color:#F00;  font-size:14px; " id="booking_list"></td> 
   </tr>
   
   
<tr>

    <td colspan="4" style="text-align:right;color:#F00;  font-size:14px; " id="offer_name">Adjustment for Policies</td>
 
    <td  colspan="2" style="text-align:right; color:#F00; font-size:14px;"  id="offer_amount"></td>
   </tr>
   
   <tr>
        <td colspan="4" style="text-align:right;color:#000; font-size:14px; font-weight:bold; "  >Shipping : </td> 
        <td  colspan="2" style="text-align:right; color:#000; font-size:14px; font-weight:bold;"  ><input style="text-align:right; color:#0000CC" type="text" id="shipping" name="shipping" class="policy_dis2" value="0"></td>
   </tr>
   
   <tr>
        <td colspan="4" style="text-align:right;color:#000; font-size:14px; font-weight:bold; "  >Sub Total after Discount before TAX : </td> 
        <td  colspan="2" style="text-align:right; color:#000; font-size:14px; font-weight:bold;"  id="t_amount_bt"></td>
   </tr>
   
   <tr>
        <td colspan="4" style="text-align:right;color:#000099; font-size:14px; "  >GST (3%) : </td> 
        <td  colspan="2" style="text-align:right; color:#000099; font-size:14px;"  id="t_tax"></td>
   </tr>
   

   
   
<tr>

    <td colspan="4" style="text-align:right;font-size:14px;">Payable Order Total : </td>
 
    <td  colspan="2"><input name="order_total"  <?=$disabled;?> id="order_total" style="min-width:150px; width:100%; border:0px; background-color:#FFFF00; font-size:16px; font-weight:bold;text-align:right;" value="<?=abs($total);?>" type="txt" class="numaric" readonly="readonly" /></td>
   </tr>
</table><input name="pro_list" id="pro_list" value="10" type="hidden"  />     
                      </div>
                      <HR/>
                      
                   
                      
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                       
                           
                        
                           <label>Product Taking for Self/other : <span class="tx-danger">*</span></label>
                         	
                            
                            <select name="product_taking_for" id="product_taking_for"  class="form-control wd-200 wd-sm-250" >
                    	<option value="" >--Product Taking for--</option>
                        <option value="self" <?=($data['product_taking']=='self')?'selected="selected"':'';?>>Self</option>
                        <option value="other" <?=($data['product_taking']=='other')?'selected="selected"':'';?>>Other</option>
                        </select>
                        
                        
                       
							 
                           </div>
                        
                         
                        
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">
                        
                          <table width="500px;" border="0" cellspacing="0" cellpadding="0" class="shipping" style="display:none;">
                        <tr>
                        	<th colspan="2">Who is taking Product?</th>
                        </tr>
                        <tr>
                   	<td valign="top" >Receiver Name :</td>
                    <td><?php $name='receiver_name';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:200px;" maxlength="240" class="shippingf" /></td>
                </tr>
                <tr>
                   	<td valign="top" >Receiver Mobile :</td>
                    <td><?php $name='receiver_mobile';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:200px;" maxlength="240" class="shippingf" /></td>
                </tr>
                
                
                <tr>
                   	<td valign="top" >OTP sent to Owner :</td>
                    <td><?php $name='otp';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:50px;" maxlength="240" class="shippingf" />
<button id="send_otp" type="button" name="send_otp">Send One time password</button><br /><span id="opt_msg"></span></td>
                </tr>
                
                
                
                
          		  
</table>
                           
                            
                        </div>
                        
                         
                      </div>
                      
                      
                       <div class="d-md-flex mg-b-30">						<div class="form-group mg-b-0">
							<label>Payment : <span class="tx-danger">*</span></label>
							<select name="payment" id="payment"  class="form-control wd-200 wd-sm-250" >
								<option value="" >--Payment Option--</option>
								<option value="cash" <?=($data['payment']=='cash')?'selected="selected"':'';?>>Cash</option>								<option value="card" <?=($data['payment']=='card')?'selected="selected"':'';?>>Card</option>								<option value="check" <?=($data['payment']=='ship')?'selected="selected"':'';?>>Check / DD</option>								<option value="upi" <?=($data['payment']=='card')?'selected="selected"':'';?>>Gpay / Paytm</option>								<option value="split" <?=($data['payment']=='card')?'selected="selected"':'';?>>Split (Card / Cash)</option>
							</select>
						</div>						
                        <div class="form-group mg-b-0 mg-md-l-20 mg-t-20 mg-md-t-0">							<table width="500px;" border="0" cellspacing="0" cellpadding="0" class="payment" style="display:none;">
							<tr>
							<th colspan="2">Payment Details</th>
							</tr>
							<tr>
							<td valign="top" >Received Mode:</td>
							<td><?php $name='payment_mode';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=($data[$name])?$data[$name]:'Demmand Draft';?>" style="width:200px;" maxlength="240" class="paymentf" /></td>
							</tr>
							<tr>
							<td valign="top" id="tran_label" >Ch/DD/Bank Number :</td>
							<td><?php $name='dd_no';?><input type="text" id="<?=$name;?>" name="<?=$name;?>" value="<?=$data[$name];?>" style="width:200px;" maxlength="90" class="paymentf" /></td>
							</tr>
							</table> 
                        </div>                      </div>
                        
                      <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0">
                        	  
                        
                         <label>Remarks : <span class="tx-danger"></span></label>
                           
                           <input type="text"  name="<?=$name='remarks';?>" id="<?=$name;?>" class="form-control wd-200 wd-sm-250" value="<?=$data[$name];?>"    >
                            
                        </div>
                       </div> 
                        <div class="d-md-flex mg-b-30">
                        <div class="form-group mg-b-0 agree"  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>
