<?php
include('nav.php');
include('response.php');






?>


 
<script>
	$(function(){
    $("#datepicker22").datepicker({
        dateFormat: "yy/mm/dd"
    });	
});
</script>
<script>
	$(function(){
    $("#datepicker23").datepicker({
        dateFormat: "yy/mm/dd"
    });	
});
</script> 

<div style="margin-top: 10px;" class="hp-main-layout-content">
                <div class="row mb-32 gy-32">
                <div class="col-12">
            <div class="col-12">
    <div style="padding-left: 10px;"  class="page-header-modern">
            <h2 class="header-modern">New Transacton</h2>

    <div class="user-dropdown dropdown">
        <button class="btn btn-user" type="button" data-toggle="dropdown">
            <i class=""></i>
             <img src="images/icon/invoice360-user.png" height=30px; width=30px;>
            <span class="caret"></span>
        </button>

        <ul class="dropdown-menu user-menu" aria-labelledby="userDropdown">
            <li>
                <a class="dropdown-item" href="">
                    <i class="fa fa-user me-2"></i> <?php echo strtok($_SESSION['user_name'], ' ');?> (<?php echo $_SESSION['role']; ?>)
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/payment-details.php">
                    <i class="fa fa-credit-card"></i> Billing history
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/company-profile.php">
                    <i class="fa fa-cog me-2"></i> Settings
                </a>
            </li>

            <li><hr class="dropdown-divider"></li>

            <li>
                <a class="dropdown-item text-danger" href="logout.php">
                    <i class="fa fa-sign-out me-2"></i> Sign Out
                </a>
            </li>
        </ul>
        </div>
    </div>
</div>
</div>
                </div>


                    <div class="content-body">
    <div class="container-fluid">
       
    <div id="response" class="alert alert-success" style="display:none;">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<div class="message"></div>
		</div>
       
      


                    <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    
                            
                        <div class="card-body">
                        <div class="form-validation">
                        <form class="needs-validation" method="post" enctype="multipart/form-data" id="add_expense">
							<input type="hidden" name="action" value="add_expense">
<div class="divider"></div>

<div class="row" style="margin-top: 25px;">
    <div class="col-xs-12 
                col-sm-10 col-sm-offset-1 
                col-md-8  col-md-offset-2 
                col-lg-10 col-lg-offset-1">

        <div class="panel panel-default">
            <div class="panel-body">
                
            </div>

            <div class="panel-body form-group">
                <div class="row">
<?php
$peekNextTransactionNumber = previewNextTransactionNumber($mysqli, $_SESSION['company_id']);
?>
                    <div class="col-sm-4 col-xs-12">
                        <div class="form-group">
                            <label class="col-form-label">Transaction ID</label>
                            <input type="text" class="form-control margin-bottom copy-input required" name="expense_id" placeholder="" value="<?= htmlspecialchars($peekNextTransactionNumber) ?>" readonly>
                        </div> 
                         <input type="hidden" name="preview_transaction_number" value="<?= $previewTransactionNumber ?>">
                    </div>
                    <div class="col-sm-4 col-xs-12">
                        <div class="form-group">
                            <label class="col-form-label">Reference No.</label>
                            <input type="text" class="form-control margin-bottom" name="reference_no" placeholder="">
                        </div> 
                    </div>
                    <div class="col-sm-4 col-xs-12">
                        <div class="form-group">
                            <label class="col-form-label">Transaction Date</label>
                            <div class="input-group"><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>  
                                                             
                                <input style="border-radius: 7px;" type="text" id="datepicker22" class="form-control required" name="expense_date" placeholder="Date" data-date-format="<?php echo DATE_FORMAT ?>" />
                            </div>
                            
                        </div> 
                    </div>

                    <div class="col-sm-6 col-xs-12">
                        <div class="form-group">
                            <label class="col-form-label">Transaction Type</label>
                            <select style="border-radius: 7px;" name="transaction_type"  class="form-control required">
								<option value="income">Income</option>
								<option value="expenditure" selected>Expenditure</option>
							</select>
                        </div>

                         <div class="form-group no-margin-bottom">
                            <label class="col-form-label">Authorised By</label>
                            <label class="col-form-label"></label>
                            <input type="text" class="form-control" name="authorised_by">
                        </div>

                        <div class="form-group">
                            <label class="col-form-label">Authorised By</label>
                            <input type="text" class="form-control margin-bottom copy-input" class="form-control required" name="authorised_by2">
                        </div>

                        
                    </div>

                    <div class="col-sm-6 col-xs-12">

                        <div class="form-group">
                            <label class="col-form-label">Amount</label>

                            <div class="input-group">
                                <span style="border-radius: 7px;" class="input-group-addon"><?php echo $currency ?></span>                                           
                                <input style="border-radius: 7px;" type="text" class="form-control required" name="expense_amount" class="form-control required" placeholder="0.00" aria-describedby="sizing-addon1" required>
                            </div>
                                                
                        </div>
                        


                        <div class="form-group">
                            <label class="col-form-label">Transaction Status</label>
                            <select style="border-radius: 7px;" name="transaction_status"  class="form-control required">
                                <option value="pending">Pending</option>
								<option value="completed" selected>Completed</option>
                            </select>    
                        </div>

                        <div class="form-group">
                            <label class="col-form-label">Transaction Mode</label>
                            <select style="border-radius: 7px;" name="transaction_mode"  class="form-control">
                                <option value="bank-transfer" selected>Bank Transfer</option>
								<option value="cash">Cash</option>
                                <option value="cheque">Cheque</option>
                                <option value="pos">POS</option>
                            </select>    
                        </div>

                       

                    </div>

                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="col-form-label">Description</label>
                            <textarea rows="5" class="form-control" name="expense_desc" placeholder="Additional Notes..."></textarea>
                        </div>
                    </div>


                   <div class="col-xs-6"> 
                        <div class="form-group">
                            <label class="col-form-label">Upload File</label>
                            <input type="file" class="form-control" name="expense_doc">
                        </div>
                   </div>

                    <div class="col-xs-6">
                        <div class="form-group no-margin-bottom">
                            <label class="col-form-label">Created By</label>
                            <label class="col-form-label"></label>
                            <input type="text" class="form-control required" name="created_by" 
                            value="<?php 
                                    if (!isset($_SESSION['user_id'])) {
                                         header('Location: login.php'); exit;
                                            }        
                                        echo $_SESSION['user_name']; 
                                     ?>">
                        </div>

                    </div>    

                </div>
            </div>
        </div>

    </div>
</div>






<div class="divider"></div>


                          
 <div class="row mt-3">
    
    <!-- LEFT: CANCEL BUTTON -->
    <div class="col-6">
        <button type="button" class="btn btn-secondary w-auto float-left">
            Cancel
        </button>
    </div>

    <!-- RIGHT: SUBMIT BUTTON -->
    <div class="col-6 text-end">
        <input type="submit" id="action_add_expense" 
               class="btn btn-primary w-auto float-right"
               value="Submit" 
               data-loading-text="Creating...">
    </div>

 </div>

</form>                                        
                                       
                                       
                                            
                        </div>
                    </div>
                    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
<div style="height: 500px"></div>

                        
                    
                


<!-- Plugin -->

<script src="app-assets/js/plugin/bootstrap.bundle.min.js"></script>
    <script src="app-assets/js/plugin/swiper-bundle.min.js"></script>
    <script src="app-assets/js/plugin/jquery.mask.min.js"></script>
    <script src="app-assets/js/plugin/autocomplete.min.js"></script>
    <script src="app-assets/js/plugin/moment.min.js"></script>

    <!-- Layouts -->
    <script src="app-assets/js/layouts/header-search.js"></script>
    <script src="app-assets/js/layouts/sider.js"></script>
    <script src="app-assets/js/components/input-number.js"></script>

    <!-- Base -->
    <script src="app-assets/js/base/index.js"></script>
    <!-- Customizer -->
    <script src="app-assets/js/customizer.js"></script>

    <!-- Charts -->
    <script src="app-assets/js/plugin/apexcharts.min.js"></script>
    <script src="app-assets/js/charts/apex-chart.js"></script>

    <!-- Cards -->
    <script src="app-assets/js/cards/card-advance.js"></script>
    <script src="app-assets/js/cards/card-analytic.js"></script>
    <script src="app-assets/js/cards/card-statistic.js"></script>

    <!-- Pages -->
    <script src="app-assets/js/pages/dashboard-ecommerce.js"></script>

    <!-- Custom -->
    <script src="assets/js/main.js"></script> 
</body>


</html>