Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include '../../styles/dashboard/ProfileController/fetch_profile.php'; ?>
- <?php
- $conn = $pdo->open();
- $cont_id = $_GET['container_id'];
- $stmt = $conn->prepare("SELECT container_status FROM container WHERE container_id=:cont_id");
- $stmt->execute(['cont_id' => $cont_id]);
- $container_status = $stmt->fetchColumn();
- if ($container_status != 0){
- $_SESSION['error'] = 'Container Has Been Finalized Already!! Please Ask The IT Department For Editing.';
- header('Location: manage_container.php');
- }
- else{
- ?>
- <?php
- if (!isset($_SESSION['releasing']) || $_SESSION["position"] == null){
- unset($_SESSION['position']); //Position ID
- unset($_SESSION['releasing']); //Position
- $_SESSION['unathorized'] = "We Are Watching You, You've Visiting Unathorized Access..";
- header('Location: /');
- exit();
- }
- ?>
- <?php include '../../styles/dashboard/user-navigation/header.php'; ?>
- <body class="hold-transition skin-blue sidebar-mini">
- <div class="wrapper">
- <?php include '../../styles/dashboard/user-navigation/navbar.php'; ?>
- <?php include '../../styles/dashboard/user-Sidebar/sidebarReleasing.php'; ?>
- <div class="content-wrapper">
- <section class="content-header">
- <h1>Container Under Procurement</h1>
- <ol class="breadcrumb">
- <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
- <li><a href="#"><i class="fa fa-cubes"></i>Product</a></li>
- <li class="active">QR Products</li>
- </ol>
- </section>
- <section class="content">
- <?php include '../../styles/message.php'; ?>
- <input type="hidden" id="container_id" value="<?php echo $_GET['container_id'];?>">
- <div class="row">
- <div class="col-xs-6">
- <div class="box">
- <div class="box-header with-border">
- <h3><strong>Container Details</strong></h3>
- <hr>
- <h4>Container Number:<strong><span id="procure_container_name"></span></strong> </h4>
- <h4>Item Quantity:<strong><span id="procure_container_qty" style="font-style:italic;"></span></strong></h4>
- </div>
- <div class="box-body">
- <div class="col-sm-12">
- <strong> <span>Select Brand:</span></strong>
- <input type="hidden" id="selected_brand_id">
- <select id="select_brand" class="form-control"></select>
- </div>
- <div class="col-sm-12">
- <strong> <span>Select Model:</span></strong>
- <input type="hidden" id="selected_model_id">
- <select id="select_model" class="form-control"></select>
- </div>
- <div class="col-sm-12">
- <strong> <span>Input QR Code:</span></strong><input type="text" class="form-control" id="input_qr_code">
- </div>
- </div>
- <div class="box-footer">
- <div>
- <button type="submit" class='btn btn-success btn-flat' style="float:right" id="add_item"><i class='fa fa-plus'></i> Add Item </button>
- </div>
- </div>
- </div>
- </div>
- <div class="col-xs-6">
- <div class="box">
- <div class="box-header with-border">
- <button type="button" class="btn btn-success btn-flat" id="item-container-success" style="display:none;">Click me</button>
- <button type="button" class="btn btn-danger btn-flat" id="item-container-delete" style="display:none;">Click me</button>
- <h3><strong>Container Product Lists</strong><button type="submit" class='btn btn-primary btn-flat' style="float:right" id="finalize_container" style="display:none;"><i class='fa fa-check'></i> Finalize </button></h3>
- </div>
- <div class="box-body">
- <table id="container_product_tbl" class="table table-bordered">
- <thead>
- <th>QR Code</th>
- <th>Brand Name</th>
- <th>Model Name</th>
- <th>Delete Item</th>
- </thead>
- <tbody>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </section>
- </div>
- <?php include '../../styles/dashboard/user-navigation/footer.php'; ?>
- </div>
- <?php include '../../styles/dashboard/user-navigation/scripts.php'; ?>
- <script>
- $(function(){
- $(document).ready(function(){
- var container_id = $('#container_id').val();
- // GET CONTAINER NUMBER
- $.ajax({
- type: 'POST',
- url: 'AJAX/getContainerDetails.php',
- data:
- {
- container_id:container_id
- },
- dataType: 'json',
- success:function(result){
- $('#procure_container_name').text(result[0].container_number);
- }
- });
- var container_product_tbl = $('#container_product_tbl').DataTable({
- lengthMenu: [ [5, 10, 15, 20, 25, -1], [5, 10, 15, 20, 25, "All"] ],
- pageLength: 5,
- paging: true,
- searching: true,
- bLengthChange: true,
- bFilter: true,
- bInfo: false,
- bAutoWidth: false,
- responsive:true,
- order: [],
- ajax:
- {
- url:'AJAX/container_procurement_result.php',
- type: 'POST',
- data:
- {
- container_id:container_id
- },
- dataType: 'json',
- dataSrc: "container_procurement_result"
- },
- fnDrawCallback: function() {
- var oSettings = this.fnSettings();
- var iTotalRecords = oSettings.fnRecordsTotal();
- $('#procure_container_qty').text(iTotalRecords + ' ' + 'PC/s');
- if (iTotalRecords == "0") {
- $('#finalize_container').css('display', 'none');
- } else {
- $('#finalize_container').css('display', 'block');
- }
- },
- columnDefs:
- [
- { className: 'text-center', targets: [0], orderable:false },
- { className: 'text-center', targets: [1], orderable:false },
- { className: 'text-center', targets: [2], orderable:false },
- { className: 'text-center', targets: [3], orderable:false }
- ],
- columns:
- [
- { data: 'qr_code' },
- { data: 'brand_name' },
- { data: 'model_name' },
- { data: 'product_id', data: 'container_id',
- render: function (data, type, row, meta){
- return type === 'display' ?
- '<button class="btn btn-danger btn-sm delete btn-flat" data-product_id='+row.product_id+' data-container_id='+row.container_id+'><i class="fa fa-trash"></i> Delete</button>' : data;
- }
- }
- ],
- createdRow: function (row, data, dataIndex) {
- var deleteProductItem = $(row).find('.delete');
- $(deleteProductItem).on('click', function(e){
- e.preventDefault();
- var product_id = $(this).data('product_id');
- var container_id = $(this).data('container_id');
- var container_number = $('#procure_container_name').text();
- // console.log(container_number);
- $.ajax({
- type: 'POST',
- url: 'AJAX/deleteProductItem.php',
- data:
- {
- product_id:product_id,
- container_id:container_id,
- // FOR USER LOG
- container_number:container_number
- },
- dataType: 'json',
- success: function(result){
- if (result[0].result == true) {
- $('#item-container-delete').click();
- container_product_tbl.ajax.reload();
- }
- }
- });
- });
- }
- });
- // SELECT BRAND
- $.ajax({
- type: 'POST',
- url: 'AJAX/selectBrand.php',
- dataType: 'json',
- success: function(result){
- // MAKE SELECT EMPTY FIRST
- $('#select_brand').empty();
- // APPEND DEFAULT OPTION VALUE
- $('#select_brand').append('<option selected disabled readonly>Choose Brand</option>');
- // APPEND AJAX VALUE TO OPTION
- $.each(result, function(i, v){
- $('#select_brand').append('<option value='+v.brand_id+'>'+v.brand_name+'</option>');
- });
- }
- });
- $('#select_brand').select2();
- $('#select_brand').on('change', function(){
- $('#selected_brand_id').val($('#select_brand option:selected').val());
- var selected_brand_id = $('#selected_brand_id').val();
- $.ajax({
- type: 'POST',
- url: 'AJAX/selectModel.php',
- data:
- {
- selected_brand_id:selected_brand_id
- },
- dataType: 'json',
- success: function(result){
- // MAKE SELECT EMPTY FIRST
- $('#select_model').empty();
- // APPEND DEFAULT OPTION VALUE
- $('#select_model').append('<option selected disabled readonly>Choose Model</option>');
- // APPEND AJAX VALUE TO OPTION
- $.each(result, function(i, v){
- $('#select_model').append('<option value='+v.model_id+'>'+v.model_name+'</option>');
- });
- }
- });
- $('#select_model').select2();
- $('#select_model').on('change', function(){
- $('#selected_model_id').val($('#select_model option:selected').val());
- });
- });
- $("#input_qr_code").keyup(function(event){
- if(event.keyCode == 13){
- $("#add_item").click();
- }
- });
- // INSERT ITEM
- $('#add_item').on('click', function(e){
- e.preventDefault();
- var selected_brand_id = $("#selected_brand_id").val();
- var selected_model_id = $("#selected_model_id").val();
- var input_qr = $('#input_qr_code').val();
- var procure_container_name = $('#procure_container_name').text();
- if (selected_brand_id == "" || selected_brand_id == "0") {
- swal(
- {
- icon: 'error',
- title: 'Invalid Action!',
- text: 'Kindly Choose a Brand!'
- }
- )
- } else if (selected_model_id == "" || selected_model_id == "0") {
- swal(
- {
- icon: 'error',
- title: 'Invalid Action!',
- text: 'Kindly Choose a Model!'
- }
- )
- } else if (input_qr == "" || input_qr == "0") {
- swal(
- {
- icon: 'error',
- title: 'Invalid Action!',
- text: 'Please Input QR Code!'
- }
- )
- } else {
- $.ajax({
- type: 'POST',
- url: 'AJAX/insertContainerItem.php',
- data:
- {
- selected_model_id:selected_model_id,
- input_qr:input_qr,
- container_id:container_id,
- procure_container_name:procure_container_name
- },
- dataType:'json',
- success: function(result){
- if (result == false) {
- swal(
- {
- icon: 'error',
- title: 'Invalid Action!',
- text: 'QR Code Already Exist!'
- }
- )
- } else if (result == true){
- $('#item-container-success').click();
- $('#input_qr_code').val('');
- container_product_tbl.ajax.reload();
- }
- }
- });
- }
- });
- // FINALIZE CONTAINER
- $("#finalize_container").on('click', function(){
- var procure_container_name = $('#procure_container_name').text();
- $.ajax({
- type: 'POST',
- url: 'AJAX/confirm_container_finalize.php',
- data:
- {
- container_id:container_id,
- procure_container_name:procure_container_name
- },
- dataType: 'json',
- success: function(result){
- if (result[0].result == true) {
- swal({
- title: "Success!",
- text: "Container Finalize Success!",
- icon: "success",
- button: {
- text: "Redirect"
- },
- closeOnEsc: false,
- closeOnClickOutside: false
- }).then(function() {
- window.location = "http://localhost/OneTrinity/Users/Releasing/manage_container.php";
- });
- }
- }
- });
- });
- });
- });
- </script>
- </body>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement