D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
shubmkcj
/
urbane.createerp.com
/
Filename :
add_category.php
back
Copy
<?php ob_start(); session_start(); include 'config.php'; $login = $_SESSION['login_email']; $category=""; if($login == ''){ echo '<script>location.replace("index.php")</script>'; } if(isset($_SESSION["source_id"])){ $source_id = $_SESSION['source_id']; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Invoice Management | Invoice</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" /> <!-- DataTables --> <link href="plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <link href="plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- Responsive datatable examples --> <link href="plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <script src="assets/js/modernizr.min.js"></script> <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">Category</h4> <ol class="breadcrumb float-right"> <li class="breadcrumb-item ">Inventory</li> <li class="breadcrumb-item active">Category</li> </ol> <div class="clearfix"></div> </div> </div> </div> <!-- end row --> <div class="row"> <div class="col-lg-12"> <div class="card-box table-responsive"> <?php if($access->getInventoryAdd($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <div class="row"> <div class="col-lg-12 pb-20 text-right"> <button class="btn btn-info btn-primary" onclick="openModal('')">Add New Category</button> </div> </div> <?php } ?> <table id="datatable" class="table table-bordered"> <thead> <tr class="bg-grey"> <th>Category</th> <th>Action</th> </tr> </thead> <tbody> <?php $sqlGetCategory = "SELECT * FROM category WHERE is_deleted = 'NO' AND source_id = '$source_id' ORDER BY id DESC"; $resultGetCategory = mysqli_query($conn, $sqlGetCategory); if($resultGetCategory){ if(mysqli_num_rows($resultGetCategory) > 0){ while($rowGetCategory = mysqli_fetch_assoc($resultGetCategory)){ ?> <tr class="gradeX"> <td><?php echo $rowGetCategory["category"]; ?></td> <td class="actions text-center" width="15%"> <?php if($access->getInventoryEdit($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <button type="button" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" data-original-title="Edit" onclick="openModal('<?php echo $rowGetCategory["id"]; ?>')"> <i class="fa fa-pencil"></i> </button> <?php } ?> <?php if($access->getInventoryDelete($_SESSION["login_email"], $_SESSION["source_id"]) == "on") { ?> <button type="button" class="btn btn-sm btn-danger" data-toggle="tooltip" data-placement="top" data-original-title="Delete" onclick="deleteCategory('<?php echo $rowGetCategory["id"]; ?>')"> <i class="fa fa-trash-o"></i> </button> <?php } ?> </td> </tr> <?php } } } ?> </tbody> </table> </div> </div> <!-- end Panel --> </div> </div> <!-- container --> </div> <div id="categoryModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false" aria-hidden="true"> <form method="post" id = "frmCategory"> <div class="modal-dialog "> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Add New Category</h4> </div> <div class="modal-body"> <input type="hidden" name="categoryId" id="categoryId"> <input type="hidden" name="sourcedId" id="sourcedId" value="<?php echo $source_id; ?>"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="field-8" class="control-label">Category</label> <input type="text" class="form-control" id="category" name="category" required> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Close</button> <button type="button" id="btnsubmit" class="btn btn-info waves-effect waves-light">Submit</button> </div> </div> </div> </form> </div><!-- /.modal --> <!-- content --> <?php include 'copyrignt.php' ?> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> </div> <!-- END wrapper --> <!-- 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> --> <!-- Required datatable js --> <script src="plugins/datatables/jquery.dataTables.min.js"></script> <script src="plugins/datatables/dataTables.bootstrap4.min.js"></script> <!-- Buttons examples --> <script src="plugins/datatables/dataTables.buttons.min.js"></script> <script src="plugins/datatables/buttons.bootstrap4.min.js"></script> <script src="plugins/datatables/jszip.min.js"></script> <script src="plugins/datatables/pdfmake.min.js"></script> <script src="plugins/datatables/vfs_fonts.js"></script> <script src="plugins/datatables/buttons.html5.min.js"></script> <script src="plugins/datatables/buttons.print.min.js"></script> <script src="plugins/datatables/buttons.colVis.min.js"></script> <!-- Responsive examples --> <script src="plugins/datatables/dataTables.responsive.min.js"></script> <script src="plugins/datatables/responsive.bootstrap4.min.js"></script> <script src="plugins/sweet-alert2/sweetalert2.min.js"></script> <script src="plugins/jquery-toastr/jquery.toast.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('#datatable').DataTable(); //Buttons examples var table = $('#datatable-buttons').DataTable({ lengthChange: false, buttons: ['copy', 'excel', 'pdf', 'colvis'] }); table.buttons().container() .appendTo('#datatable-buttons_wrapper .col-md-6:eq(0)'); }); $(document).ready(function(){ if (localStorage.getItem("CategoryAdded") == "true") { successMessage("Category Successfully Saved."); localStorage.setItem("CategoryAdded", "false"); } if (localStorage.getItem("CategoryDeleted") == "true") { successMessage("Category Successfully deleted."); localStorage.setItem("CategoryDeleted", "false"); } }); function openModal(categoryId) { var categoryName = "", tax = "", id = "",categoryFor=""; if(categoryId.trim() != ""){ $.ajax({ url : "PHP/response.php", data : "action=getCategoryById&categoryId="+categoryId, method : "POST", async : false, success : function(response){ var str = JSON.parse(response); id = str.id; categoryName = str.category; tax = str.tax; categoryFor = str.category_for }, error:function(){} }); } $("#categoryId").val(id); $("input[name=categoryFor][value='"+categoryFor+"']").prop("checked",true); $("#category").val(categoryName); $("#tax").val(tax); $("#categoryModal").modal("toggle"); } $("#btnsubmit").click(function(){ // alert($("#frmCategory").serialize()); $.ajax({ url : "PHP/response.php", data : $("#frmCategory").serialize()+"&action=addUpdateCategory", method : "POST", async : false, success : function(response){ if(response.trim() == "SUCCESS"){ localStorage.setItem("CategoryAdded", "true"); location.reload(); } else{ errorMessage("Category could not be saved."); } }, error : function(err){ } }); }) function deleteCategory(categoryId){ swal({ title: 'Are you sure?', text: "Do You really want to delete this category??", type: 'warning', showCancelButton: true, confirmButtonColor: '#4fa7f3', cancelButtonColor: '#d57171', confirmButtonText: "Yes, I'm Sure!" }).then(function () { $.ajax({ url : "PHP/response.php", data : "action=deleteCategory&categoryId="+categoryId, method : "POST", async : false, success : function(response){ if(response.trim() == "SUCCESS"){ localStorage.setItem("CategoryDeleted", "true"); location.reload(); } else{ errorMessage("Category could not be deleted."); } }, error : function(err){ } }); }); } 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' }); } </script> </body> </html>