D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
add_expense.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; if(!isset($_SESSION['login_email']) || $_SESSION['login_email'] == ''){ echo '<script>location.replace("index.php")</script>'; } $login = $_SESSION['login_email']; if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } $companyGST = ""; $sqlGetCompanyGST = "SELECT * FROM company_details WHERE id = '$source_id'"; $resultGetGST = mysqli_query($conn, $sqlGetCompanyGST); if($resultGetGST){ if(mysqli_num_rows($resultGetGST) > 0){ while($rowGetGST = mysqli_fetch_assoc($resultGetGST)){ $companyGST = $rowGetGST["GSTIN"]; } } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Invoice Management | Expense</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" /> <meta content="Coderthemes" name="author" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Font Awsome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!-- App favicon --> <link rel="shortcut icon" href="assets/images/favicon.png"> <!-- Pie Chart Css --> <link href="assets/pie charts/style.css" rel="stylesheet" type="text/css" /> <!-- App css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/icons.css" rel="stylesheet" type="text/css" /> <link href="assets/css/metismenu.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/style.css" rel="stylesheet" type="text/css" /> <script src="assets/js/modernizr.min.js"></script> <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> <link href="plugins/sweet-alert2/sweetalert2.min.css" rel="stylesheet" type="text/css"> <link href="plugins/jquery-toastr/jquery.toast.min.css" rel="stylesheet" /> </head> <body> <!-- Begin page --> <div id="wrapper"> <!-- Top Bar Start --> <?php include 'top-header.php'; ?> <!-- Top Bar End --> <!-- ========== Left Sidebar Start ========== --> <?php include 'left-sidebar.php'; ?> <!-- Left Sidebar End --> <!-- ============================================================== --> <!-- Start right Content here --> <!-- ============================================================== --> <div class="content-page"> <!-- Start content --> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="page-title-box"> <h4 class="page-title float-left" id="crumb1">Add Expense</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item ">Expenses</li> <li class="breadcrumb-item active" id="crumb2">Add Expense</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <div class="card-box"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="taxableExpense"> <input type="radio" value="Taxable" checked="checked" name="taxableExpense" id="taxableExpense"> Taxable Expense </label> <label for="taxableExpense1"> <input type="radio" value="Other" name="taxableExpense" id="taxableExpense1"> Other Expense </label> </div> </div> </div> <form method="post" role="form" id="taxable_form"> <input type="hidden" name="taxExpenseId" id="taxExpenseId"> <input type="hidden" name="taxSourceId" id="taxSourceId" value="<?php echo $source_id; ?>"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="date_of_expense">Date of Expense</label> <input type="text" class="form-control" name="date_of_expense" id="date_of_expense"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="vendor_name">Vendor Name</label> <input type="text" class="form-control" name="vendor_name" id="vendor_name" placeholder="Vendor Name"> </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="vendor_gstin">Vendor GSTIN</label> <input type="text" class="form-control" name="vendor_gstin" id="vendor_gstin" placeholder="Vendor GSTIN"> </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="invoice_no">Invoice No</label> <input type="text" class="form-control" name="invoice_no" id="invoice_no" placeholder="Invoice No"> </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="item_name">Item Name</label> <input type="text" class="form-control" name="item_name" id="item_name" placeholder="Item Name"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="amount">Amount without Tax</label> <input type="number" class="form-control" name="amount" id="amount" placeholder="Amount"> </div> </div> <div class="col-lg-4" id="cgst_div" style="display:none"> <div class="form-group"> <label for="cgst">CGST</label> <input type="number" class="form-control" name="cgst" id="cgst" placeholder="CGST"> </div> </div> <div class="col-md-4" id="sgst_div" style="display:none"> <div class="form-group"> <label for="sgst">SGST</label> <input type="number" class="form-control" name="sgst" id="sgst" placeholder="SGST"> </div> </div> <div class="col-lg-4" id="igst_div" style="display:none"> <div class="form-group"> <label for="igst">IGST</label> <input type="number" class="form-control" name="igst" id="igst" placeholder="IGST"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="payment_mode">Payment Mode</label> <select class="form-control" name="payment_mode" id="payment_mode"> <option value="">-- Select Payment Mode --</option> <option value="Cash">Cash</option> <option value="Cheque">Cheque</option> <option value="Bank Transfer">Bank Transfer</option> <option value="Payment Gateway">Payment Gateway</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="payment_remarks">Payment Detail</label> <input type="text" class="form-control" name="payment_remarks" id="payment_remarks" placeholder="Payment Remarks" > </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="remarks">Remarks</label> <input type="text" class="form-control" name="remarks" id="remarks" placeholder="Remarks"> </div> </div> </div> <div class="row"> <div class="col-lg-4"> <div class="form-group"> <button type="button" id="btnSubmit" class="btn btn-purple waves-effect waves-light">Submit</button> </div> </div> </div> </form> <form method="post" role="form" id="non_taxable_form" style="display:none"> <input type="hidden" name="ntExpenseId" id="ntExpenseId"> <input type="hidden" name="ntSourceId" id="ntSourceId" value="<?php echo $source_id; ?>"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="nt_date_of_expense">Date of Expense</label> <input type="text" class="form-control" name="nt_date_of_expense" id="nt_date_of_expense"> </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="nt_item_name">Item Name</label> <input type="text" class="form-control" name="nt_item_name" id="nt_item_name" placeholder="Item Name"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="nt_amount">Amount</label> <input type="text" class="form-control" name="nt_amount" id="nt_amount" placeholder="Amount"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="nt_payment_mode">Payment Mode</label> <select class="form-control" name="nt_payment_mode" id="nt_payment_mode"> <option value="">-- Select Payment Mode --</option> <option value="Cash">Cash</option> <option value="Cheque">Cheque</option> <option value="Bank Transfer">Bank Transfer</option> <option value="Payment Gateway">Payment Gateway</option> </select> </div> </div> <div class="col-lg-4"> <div class="form-group"> <label for="nt_remarks">Remarks</label> <input type="text" class="form-control" name="nt_remarks" id="nt_remarks" placeholder="Remarks"> </div> </div> </div> <div class="row"> <div class="col-lg-4"> <div class="form-group"> <button type="button" id="nt_btnSubmit" class="btn btn-purple waves-effect waves-light">Submit</button> </div> </div> </div> </form> </div> </div> <!-- container --> </div> <!-- content --> <?php include 'copyrignt.php' ?> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> </div> <!-- END wrapper --> <div class="modal fade" id="thankyourestore" tabindex="-1" role="dialog"> <div class="modal-dialog"> <div class="modal-content" style="padding:20px 10px"> <!-- Modal body --> <div class="modal-body text-center"> <h3 class="modal-title">Invalid GSTIN Number</h3> </div> <div class="col-md-12 text-center"> <button type="button" class="btn btn-danger " data-dismiss="modal" style="padding:10px 20px">Ok</button> </div> </div> </div> </div> <!-- Chart Js --> <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.js'></script> <!-- jQuery --> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/popper.min.js"></script><!-- Popper for Bootstrap --> <script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/metisMenu.min.js"></script> <script src="assets/js/waves.js"></script> <script src="assets/js/jquery.slimscroll.js"></script> <!-- Dashboard init --> <script src="assets/pages/jquery.dashboard.js"></script> <!-- App js --> <script src="assets/js/jquery.core.js"></script> <script src="assets/js/jquery.app.js"></script> <!-- Chart Js --> <!-- <!-- <script src="assets/pie charts/script.js"></script> --> --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script src="plugins/sweet-alert2/sweetalert2.min.js"></script> <script src="plugins/jquery-toastr/jquery.toast.min.js" type="text/javascript"></script> <?php if(isset($_POST["expenseId"]) && $_POST["expenseId"] != ""){ ?> <script> $(document).ready(function(){ $.ajax({ url : "PHP/response.php", data : "action=GetExpenseById&id=<?php echo $_POST["expenseId"]; ?>", async : false, method : "POST", success : function(response){ var str = JSON.parse(response); if(str != "" && str != null){ if(str.is_taxable == "YES"){ $("#taxExpenseId").val("<?php echo $_POST["expenseId"]; ?>"); $("#date_of_expense").datepicker("setDate", new Date(str.date_of_expense)); $("#vendor_name").val(str.vendor_name); $("#vendor_gstin").val(str.vendor_gst); $("#invoice_no").val(str.invoice_no); $("#item_name").val(str.item_name); $("#amount").val(str.amount); var companyGSTIN = "<?php echo $companyGST; ?>"; var companyRes = companyGSTIN.substring(0, 2); var vendorGSTIN = str.vendor_gst; var vendorRes = vendorGSTIN.substring(0, 2); if(companyRes === vendorRes){ $("#cgst").val("0.00"); $("#sgst").val("0.00"); $("#igst").val(str.igst); $("#cgst_div").css({"display" : "none"}); $("#sgst_div").css({"display" : "none"}); $("#igst_div").css({"display" : "block"}); } else{ $("#igst").val("0.00"); $("#cgst").val(str.cgst); $("#sgst").val(str.sgst); $("#cgst_div").css({"display" : "block"}); $("#sgst_div").css({"display" : "block"}); $("#igst_div").css({"display" : "none"}); } $("#payment_mode").val(str.payment_mode); $("#payment_remarks").val(str.payment_remarks); $("#remarks").val(str.item_remarks); $("#crumb1, #crumb2").text("Update Expense"); } else{ $('#taxableExpense').prop('checked', false); $("#ntExpenseId").val("<?php echo $_POST["expenseId"]; ?>"); $("#nt_date_of_expense").datepicker("setDate", new Date(str.date_of_expense)); $("#nt_item_name").val(str.item_name); $("#nt_amount").val(str.amount); $("#nt_payment_mode").val(str.payment_mode); $("#nt_remarks").val(str.item_remarks); $("#taxable_form").css({"display":"none"}); $("#non_taxable_form").css({"display":"block"}); } } }, error : function(err){ alert("ERROR"); } }); }); </script> <?php } ?> <script type="text/javascript"> $("input[name=taxableExpense]").click(function(){ if($(this).val() == "Taxable"){ $("#taxable_form").css({"display":"block"}); $("#non_taxable_form").css({"display":"none"}); } else{ $("#taxable_form").css({"display":"none"}); $("#non_taxable_form").css({"display":"block"}); } }); $(document).ready(function() { $("#date_of_expense, #nt_date_of_expense").datepicker({ dateFormat: 'dd MM yy' }); $("#date_of_expense, #nt_date_of_expense").datepicker("setDate", new Date()); }); function errorToast(msg){ $.toast({ heading: 'Error!', text: msg, position: 'top-right', loaderBg: '#bf441d', icon: 'error', hideAfter: 3000, stack: 1 }); } function successMessage(msg){ swal({ title: 'Success!', text: msg, type: 'success', confirmButtonColor: '#4fa7f3' }); } function errorMessage(msg){ swal({ title: 'Error!', text: msg, type: 'error', confirmButtonColor: '#4fa7f3' }); } $("#btnSubmit").click(function(){ if(validateTaxableForm()){ $.ajax({ url : "PHP/response.php", data : $("#taxable_form").serialize()+"&action=AddTaxableResponse&createdBy=<?php echo $_SESSION['login_email']; ?>", async : false, method : "POST", success : function(response){ if(response.trim() == "SUCCESS"){ localStorage.setItem("expenseAdded", "true"); <?php if(isset($_POST["expenseId"]) && $_POST["expenseId"] != ""){ echo "location.replace('".$_SERVER["HTTP_REFERER"]."')"; } else{ echo "location.replace('all_expenses.php')"; } ?> } else{ errorMessage("Expense could not be Added."); } }, error : function(err){} }); } }); $("#nt_btnSubmit").click(function(){ if(validateNonTaxableForm()){ $.ajax({ url : "PHP/response.php", data : $("#non_taxable_form").serialize()+"&action=AddNonTaxableResponse&createdBy=<?php echo $_SESSION['login_email']; ?>", async : false, method : "POST", success : function(response){ if(response.trim() == "SUCCESS"){ localStorage.setItem("expenseAdded", "true"); <?php if(isset($_POST["expenseId"]) && $_POST["expenseId"] != ""){ echo "location.replace('".$_SERVER["HTTP_REFERER"]."')"; } else{ echo "location.replace('all_expenses.php')"; } ?> } else{ errorMessage("Expense could not be Added."); } }, error : function(err){} }); } }); function validateTaxableForm(){ var reg = /^([0-9]{2}[a-zA-Z]{4}([a-zA-Z]{1}|[0-9]{1})[0-9]{4}[a-zA-Z]{1}([a-zA-Z]|[0-9]){3}){0,15}$/; if($("#date_of_expense").val() == ""){ errorToast("Please enter date of expense."); $("#date_of_expense").focus(); return false; } if($("#vendor_name").val() == ""){ errorToast("Please enter vendor name."); $("#vendor_name").focus(); return false; } if($("#vendor_gstin").val() == ""){ errorToast("Please enter vendor GSTIN."); $("#vendor_gstin").focus(); return false; } if (! $("#vendor_gstin").val().match(reg)) { errorToast("Please enter valid GSTIN."); $("#vendor_gstin").focus(); return false; } if($("#invoice_no").val() == ""){ errorToast("Please enter Invoice Number."); $("#invoice_no").focus(); return false; } if($("#item_name").val() == ""){ errorToast("Please enter item name."); $("#item_name").focus(); return false; } if($("#amount").val() == ""){ errorToast("Please enter amount."); $("#amount").focus(); return false; } if($("#payment_mode").val() == ""){ errorToast("Please select payment mode."); $("#payment_mode").focus(); return false; } if($("#payment_remarks").val() == ""){ errorToast("Please enter payment remarks."); $("#payment_remarks").focus(); return false; } if($("#remarks").val() == ""){ errorToast("Please enter remarks."); $("#remarks").focus(); return false; } return true; } function validateNonTaxableForm(){ if($("#nt_date_of_expense").val() == ""){ errorToast("Please enter date of expense."); $("#nt_date_of_expense").focus(); return false; } if($("#nt_item_name").val() == ""){ errorToast("Please enter item name."); $("#nt_item_name").focus(); return false; } if($("#nt_amount").val() == ""){ errorToast("Please enter amount."); $("#nt_amount").focus(); return false; } if($("#nt_payment_mode").val() == ""){ errorToast("Please select payment mode."); $("#nt_payment_mode").focus(); return false; } if($("#nt_remarks").val() == ""){ errorToast("Please enter remarks."); $("#nt_remarks").focus(); return false; } return true; } $("#vendor_gstin").blur(function(){ var companyGSTIN = "<?php echo $companyGST; ?>"; var companyRes = companyGSTIN.substring(0, 2); var vendorGSTIN = $(this).val(); var vendorRes = vendorGSTIN.substring(0, 2); if(companyRes === vendorRes){ $("#igst").val("0.00"); $("#cgst_div").css({"display" : "block"}); $("#sgst_div").css({"display" : "block"}); $("#igst_div").css({"display" : "none"}); } else{ $("#cgst").val("0.00"); $("#sgst").val("0.00"); $("#cgst_div").css({"display" : "none"}); $("#sgst_div").css({"display" : "none"}); $("#igst_div").css({"display" : "block"}); } }); </script> </body> </html>