<?php
session_start();
ini_set('session.gc_maxlifetime', 30 * 60 * 60 * 60);
include_once 'connectioni.php';

if ($_SESSION['company'] == "") { 
        exit("Please Login");
    }
    if ($_SESSION['CURRENT_USER'] == "") { 
        exit("Please Login");
    }
    
?>
  
<style>

    .talign{
        text-align: left !important; 

    }
    .text{
        font-weight: 600; 
        color: black;
    }
    .form-horizontal .form-group{
        margin-top:-10px !important;
   }
</style>
<script language="JavaScript" src="js/cus_register.js?v1"></script>
 
<!-- Main content -->
<section class="content">

    <div class="box box-primary">
        
        <div class="box-header with-border">
            <h3 class="box-title">CUSTOMER REGISTER</h3>
            <!--<b style="margin-top: -10px;"><p style="float: right; color: black" id="time"></p></b> -->
        </div>

        <form role="form" name ="form1" class="form-horizontal">
            <div class="box-body" style='background-color:white;'>
                <br>               
                <div class="form-group">
                    <a onclick="location.reload();" class="btn btn-default btn-sm">
                        <span class="fa fa-user-plus"></span> &nbsp; New
                    </a>

                </div>

<!--HIDDEN ITEMS-->
<div hidden>
    <input type="text" name="cus_code" id="cus_code"  class="form-control   input-sm">
</div>
<!--HIDDEN ITEMS-->

                <div id="msg_box"  class="span12 text-center"  ></div>
                <div class="form-group"></div>
                
                
                <div class='row'>
                    <div class='col-sm-3'>
                        <div class="form-group">
                            <label class="col-sm-8 control-label" for="invno">Customer List</label>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12"> 
                                <select id="cus_type" name="cus_type" class="form-control input-sm" onchange='load_cus_inv();'  onclick='load_cus_inv();' onkeyup='load_cus_inv();'>
                                    <option value="ALL">ALL</option>
                                    <option value="OUTSTANDING">OUTSTANDING</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12"> 
                                <input type="text" name="cus_name" id="cus_name" placeholder="Search Customer" class="form-control   input-sm" onchange='load_cus_inv();'  onclick='load_cus_inv();' onkeyup='load_cus_inv();'>  
                            </div>
                        </div>
                        <div id="cus_detail"> 
                            <table class="table table-bordered"> 
                                <tr class="info">
                                    <td width="70%"><b>Customer Name</b></td>
                                    <td width="30%"><b>Balance</b></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    
                    <div class='col-sm-9'>
                        <div class="form-group">
                            <label class="col-sm-2 control-label talign" for="invno">Selected Customer</label>
                            <label class="col-sm-5 control-label talign" for="invno" id="selected_cus" style="color:red; font-size:14px;"></label>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-1 control-label" for="invno">Department</label>
                            <div class="col-sm-2">
                                <select id="dep" name="dep" class="form-control input-sm" onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'> 
                                    <option value="">ALL</option>
                                    <?php
                                    $sql="select * from s_stomas order by CODE";
                                    foreach ($conn->query($sql) as $row) { 
                                    echo "<option value='" . $row["CODE"] . "'>" . $row["CODE"] . " " . $row["DESCRIPTION"] . "</option>";
                                    }
                                    ?>
                                </select> 
                            </div><label class="col-sm-1 control-label" for="invno">Sales Ex</label>
                            <div class="col-sm-2">
                                <select id="salerep" name="salerep" class="form-control input-sm" onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'>
                                    <option value="">ALL</option> 
                                    <?php
                                    $sql="select * from s_salrep where pactive='1' and  SCODE='" . $_SESSION['company'] . "' order by REPCODE";
                                    foreach ($conn->query($sql) as $row) { 
                                    echo "<option value='".$row["REPCODE"]."'>".$row["REPCODE"]." ".$row["Name"]."</option>";
                                    }
                                    ?>
                                </select>                            
                            </div>
                            <label class="col-sm-1 control-label" for="invno">Date From</label>
                            <div class="col-sm-2">
                                <input type="date" name="dtfrom" id="dtfrom" value="<?php echo date('Y-m-d'); ?>" class="form-control   input-sm" onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'> 
                            </div> 
                            <div class="col-sm-2">
                                <input type="date" name="dtto" id="dtto" value="<?php echo date('Y-m-d'); ?>" class="form-control   input-sm" onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'> 
                            </div>
                             <div class="col-sm-1">
                                <input type="checkbox" name="selected_data" id="selected_data" class="input-sm" checked onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'> 
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="col-sm-1 control-label" for="invno">Type</label>
                            <div class="col-sm-3"> 
                                <select id="type" name="type" class="form-control input-sm" onchange='pass_data();'  onclick='pass_data();' onkeyup='pass_data();'> 
                                    <option value="ALL">ALL</option>
                                    <option value="INVOICE">INVOICE</option>
                                    <option value="RETURN">RETURN</option>
                                    <option value="CREDIT NOTE">CREDIT NOTE</option>
                                    <option value="RECEIPT DETAILS">PAYMENT RECEIPT DETAIL</option>
                                    <option value="RECEIPT SUMMRY">PAYMENT RECEIPT SUMMRY</option>
                                    <option value="SETTLEMENT">SETTLEMENT</option>
                                    <option value="DEFECTIVE">DEFECTIVE</option>
                                    <option value="UTILIZATION">UTILIZATION</option>
                                    <option value="OVER PAY">OVER PAYMENT</option>
                                    <option value="CHEQUE LIST">CHEQUE LIST</option>
                                    <option value="CANCEL INVOICE">CANCEL INVOICE</option>
                                </select>
                            </div>
                           
                        </div>
                        
                        <div id="item_details"> 
                        </div>
                    </div>
                </div>

        </form>
    </div>
</div>
</div>
</section>

<script>load_cus_inv();</script> 
    