<?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/expenses.js?v1"></script>
 
<!-- Main content -->
<section class="content">

    <div class="box box-primary">
        
        <div class="box-header with-border">
            <h3 class="box-title">Expenses</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">
                <br>               
                <div class="form-group">
                    <a onclick="new_inv();" class="btn btn-default btn-sm">
                        <span class="fa fa-user-plus"></span> &nbsp; New
                    </a>

                    <a onclick="save_inv();" class="btn btn-success btn-sm">
                        <span class="fa fa-save"></span> &nbsp; Save
                    </a>
                    <a onclick="print_inv();" class="btn btn-default">
                            <span class="fa fa-print"></span> &nbsp; Print
                        </a>

                    <a onclick="NewWindow('expenses_search.php', 'mywin', '800', '700', 'yes', 'center');
                            return false" class="btn btn-info  btn-sm">
                        <span class="fa fa-search"></span> &nbsp; Search
                    </a>
                    
                    <a onclick="cancel_inv();" class="btn btn-danger btn-sm">
                            <span class="fa fa-trash"></span> &nbsp; Cancel
                     </a>


                </div>
                <div id="msg_box"  class="span12 text-center"  ></div>
                <div class="col-sm-3">
                    <input type="text" placeholder="Uniq"  id="uniq" class="form-control hidden input-sm">
                </div>   

                <div class="form-group"></div>
                <div class="form-group">  
                	<label class="col-sm-1 control-label talign" for="invno">Ref No</label>
                    <div class="col-sm-3">
                        <input type="text"  class="form-control input-sm"  disabled="" id="refno">
                    </div>
                </div> 

                <div class="form-group">
                    <label class="col-sm-1 control-label talign" for="sdate">Date</label>
                    <div class="col-sm-3">
                        <input type="date" name="sdate"     id="sdate" value="<?php echo date('y-m-d')?>"  class="form-control   input-sm">    
                    </div>
                </div> 
                
                <div class="form-group">
                    <label class="col-sm-1 control-label talign" for="invno">Type</label>
                    <div class="col-sm-3">
                       <select id="type" name="type" class="form-control input-sm" >
                            <?php
                                  $sql="select * from s_expense_type where  CANCELL='0'  order by REFNO";
                                
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value='".$row["REFNO"]."'>  ".$row["NAME"]."</option>";
                                    }
                            ?> 
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-1 control-label talign"   for="invno">Department</label>
                    <div class="col-md-3">   
                        <select id="department" class="form-control" >
                            <?php
                                if ($_SESSION["CURRENT_DEP"] != "") {
                                   $sql="select * from s_stomas where  act='1' and SCOM='".$_SESSION["company"] ."'  and CODE='".$_SESSION["CURRENT_DEP"] ."' order by CODE";
                                }else{
                                  $sql="select * from s_stomas where  act='1' and SCOM='".$_SESSION["company"] ."'  order by CODE";
                                }
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value='".$row["CODE"]."'>  ".$row["DESCRIPTION"]."</option>";
                                    }
                                ?> 
                        </select> 
                    </div>
                </div> 

                <div class="form-group">  
                    <label class="col-sm-1 control-label talign" for="invno">Employee</label>
                    <div class="col-md-3"> 
                        <select id="employee" name="employee" class="form-control input-sm" >
                            <option value=''>Select Employee</option>
                            <?php
                                $sql="select * from s_employee where CANCELL='0'  ";
                                
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value='".$row["NAME"]."'>  ".$row["NAME"]."</option>";
                                    }
                            ?>
                        </select>
                    </div>
                </div> 

                <div class="form-group"> 
                    <label class="col-sm-1 control-label talign" for="invno">Amount</label>
                     <div class="col-sm-3">
                        <input type="number"  class="form-control input-sm"  id="amount" name="amount">
                    </div>
                </div> 

                <div class="form-group">  
                    <label class="col-sm-1 control-label talign" for="invno">Remark</label>
                     <div class="col-sm-3">
                        <textarea type="text"  class="form-control input-sm"  id="remark" name="remark" row="5"></textarea>
                    </div> 
                    
                </div>           

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

<script>new_inv();</script> 
    