HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/inventory.breadsecret.com/view/item/list.php
<?php
include("view/layout/meta.php");
include("view/layout/head.php");
?>
<style>
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
</style>
<div class="main-panel">
<?php
include("view/layout/headExt.php");
?>  			
   <div class="container">
      <div class=""></div>
         <div class="row">
            <div class="col-md-12">
               <div class="card">
                  <div class="card-header">
                     <div class="d-flex align-items-center">
                        <h4 class="card-title"><?=L('menu.item');?></h4>
                        <button class="btn btn-primary btn-round btn-sm ms-auto addItemBtn">
                           <i class="fa fa-plus"></i>
                        </button>
                     </div>    
                  </div>
                  <div class="card-body">
                     <div class="table-responsive">
                        <table id="itemTable" class="display table table-striped table-hover dataTable">
                           <?=Controller\item::genTableHeader();?>
                           <?=Controller\item::genTableFooter();?>                     
                           <tbody>
                           <?php
                              $content = Controller\item::genTableContentData();
                              foreach($content as $listObj) {
                                 echo Controller\item::genTableBodyRow($listObj);                                    
                              } 
                           ?>
                           </tbody>
                        </table>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <?php include("view/layout/foot.php"); ?>   
   </div>
   
</div>
<?php
include("view/layout/js.php");
include("view/layout/endpage.php");
?>
<script>
$(document).ready(function () {

   var myCallback = function () { 

      var table = $('.dataTable').DataTable(); // Initialize your DataTable
      var lastColumnIndex = table.columns().count() - 1; // Get the last column index
      table.columns().every(function() {
         var column = this;

         if (column.index() === lastColumnIndex) {
               return; // exits the function, being the last (and desired) column
         }
         
         var select = $('<select class="form-select"><option value=""></option></select>')
            .appendTo($(column.footer()).empty())
            .on('change', function() {

            var val = $.fn.dataTable.util.escapeRegex(
               $(this).val()
            );
            column
               .search(val ? '^' + val + '$' : '', true, false)
               .draw();
            });

         column.data().unique().sort().each(function(d, j) {
            select.append('<option value="' + d + '">' + d + '</option>')
         });
      });            
   }; 

   var itemTable = $("#itemTable").DataTable({
      pageLength: 25,
      processing: false,
      serverSide: true,
      serverMethod: 'post',
      ajax: '<?=$request->baseUrl();?>/script/itemList.php',
      "columns": [
         { data: 'column_itemID' },
         { data: 'column_itemTypeName' },
         { data: 'column_itemName' },
         { data: 'column_supplierName' },
         { data: 'column_unitName' },
         { data: 'column_itemQty' },
         { data: 'column_itemTotalValue' },
         { data: 'column_itemStatus' },
         { data: 'column_function' }
      ],
      rowId: 'column_itemID', 
      initComplete: function () {
      this.api()
         .columns([0,1,2,3,4,5,6,7])
         .every(function () {
            var column = this;
            var select = $(
            '<select class="form-select"><option value=""></option></select>'
            )
            .appendTo($(column.footer()).empty())
            .on("change", function () {
               var val = $.fn.dataTable.util.escapeRegex($(this).val());

               column
                  .search(val ? "^" + val + "$" : "", true, false)
                  .draw();
            });

            column
            .data()
            .unique()
            .sort()
            .each(function (d, j) {
               select.append(
                  '<option value="' + d + '">' + d + "</option>"
               );
            });
         });
      }
   });
   
   $(".addItemBtn").click(function(e){
      var button = $(e.currentTarget);
      e.preventDefault();
      ajaxFunc.apiCall("GET", "item/formAdd", null, null,  function (form_data) { 
         if(form_data.content.success) {
            $('#msgBox').one('show.bs.modal', function (ev) {
               var modal = $(this);
               modal.find('.modal-dialog').addClass("modal-xl");
               modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
               
                  modal.find('.modal-body').html(form_data.content.message);                    
                  modal.find('#msgBoxBtnPri').off('click');
                  modal.find('#msgBoxBtnPri').on('click', function (event) {  
                     if(document.getElementById("form-addItem")!==null){    
                        var data = new FormData(document.getElementById("form-addItem"));  
                        ajaxFunc.apiCall("POST", "item", data, "multipart/form-data", function(return_data){
                           if(return_data.content.success) {
                              $("#msgBox").modal("hide");    
                              swal({
                                 title: return_data.content.message,
                                 text: return_data.content.message,
                                 type: "warning",
                                 buttons: {
                                    confirm: {
                                       text: "<?=L('OK');?>",
                                       className: "btn btn-success",
                                    }
                                 },
                              }).then((willOK) => {
                                 if (willOK) {
                                    itemTable.ajax.reload(myCallback, false);   
                                 } 
                              });    
                           } else {
                              $("#form-addItem").find(".form-group").removeClass("has-error");
                              $("#form-addItem").find(".form-group").find(".hintHelp").text("");
                              $("#form-addItem").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                              $("#form-addItem").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                              $("#form-addItem").find("#"+return_data.content.field).focus();
                           }
                        });
                     }      
                  });  

                  $("#itemTypeID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "itemType/formAdd", null, null,  function (form_data) { 
                           $('#msgBox2').one('show.bs.modal', function (ev) {
                              var modal = $(this);
                              modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                              if(form_data.content.success) {
                                 modal.find('.modal-body').html(form_data.content.message);                     
                                 modal.find('#msgBoxBtnPri').off('click');
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    if(document.getElementById("form-addItemType")!==null){    
                                       var data = new FormData(document.getElementById("form-addItemType"));  
                                       ajaxFunc.apiCall("POST", "itemType", data, "multipart/form-data", function(return_data){
                                          if(return_data.content.success) {
                                             $("#msgBox2").modal("hide");    
                                             swal({
                                                title: return_data.content.message,
                                                text: return_data.content.message,
                                                type: "warning",
                                                buttons: {
                                                   confirm: {
                                                      text: "<?=L('OK');?>",
                                                      className: "btn btn-success",
                                                   }
                                                },
                                             }).then((willOK) => {
                                                if (willOK) {
                                                   $("#msgBox2").modal("hide");                                                        
                                                   $("#msgBox").find("#itemTypeID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                   $("#itemTypeID option[value='"+return_data.content.id+"']").prop('selected',true); 
                                                } 
                                             });    
                                          } else {
                                             $("#form-addItemType").find(".form-group").removeClass("has-error");
                                             $("#form-addItemType").find(".form-group").find(".hintHelp").text("");
                                             $("#form-addItemType").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                             $("#form-addItemType").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                             $("#form-addItemType").find("#"+return_data.content.field).focus();
                                          }
                                       });
                                    }      
                                 });  
                              } else {
                                 modal.find('.modal-body').html(form_data.content.message);
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    $("#msgBox2").modal("hide");   
                                 });
                              }                    

                           }).modal('show')
                        });


                     }
                  });
                     
                  $("#unitID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "unit/formAdd", null, null,  function (form_data) { 
                           $('#msgBox2').one('show.bs.modal', function (ev) {
                              var modal = $(this);
                              modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                              if(form_data.content.success) {
                                 modal.find('.modal-body').html(form_data.content.message);                     
                                 modal.find('#msgBoxBtnPri').off('click');
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    if(document.getElementById("form-addUnit")!==null){    
                                       var data = new FormData(document.getElementById("form-addUnit"));  
                                       ajaxFunc.apiCall("POST", "unit", data, "multipart/form-data", function(return_data){
                                          if(return_data.content.success) {
                                             $("#msgBox2").modal("hide");    
                                             swal({
                                                title: return_data.content.message,
                                                text: return_data.content.message,
                                                type: "warning",
                                                buttons: {
                                                   confirm: {
                                                      text: "<?=L('OK');?>",
                                                      className: "btn btn-success",
                                                   }
                                                },
                                             }).then((willOK) => {
                                                if (willOK) {
                                                   $("#msgBox2").modal("hide");                                                        
                                                   $("#msgBox").find("#unitID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                   $("#unitID option[value='"+return_data.content.id+"']").prop('selected',true);
                                                } 
                                             });   
                                          } else {
                                             $("#form-addUnit").find(".form-group").removeClass("has-error");
                                             $("#form-addUnit").find(".form-group").find(".hintHelp").text("");
                                             $("#form-addUnit").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                             $("#form-addUnit").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                             $("#form-addUnit").find("#"+return_data.content.field).focus();
                                          }
                                       });
                                    }      
                                 });  
                              } else {
                                 modal.find('.modal-body').html(form_data.content.message);
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    $("#msgBox2").modal("hide");   
                                 });
                              }                    

                           }).modal('show')
                        });


                     }
                  });

                  $("#supplierID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "supplier/formAdd", null, null,  function (form_data) { 
                        $('#msgBox2').one('show.bs.modal', function (ev) {
                           var modal = $(this);
                           modal.find('.modal-dialog').addClass("modal-xl");
                           modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                           if(form_data.content.success) {
                              modal.find('.modal-body').html(form_data.content.message);        
                              $("#supplierCategoryID option[value='Add']").remove();                 
                              modal.find('#msgBoxBtnPri').off('click');
                              modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                 if(document.getElementById("form-addSupplier")!==null){    
                                    var data = new FormData(document.getElementById("form-addSupplier"));  
                                    ajaxFunc.apiCall("POST", "supplier", data, "multipart/form-data", function(return_data){
                                       if(return_data.content.success) {
                                          $("#msgBox2").modal("hide");    
                                          swal({
                                             title: return_data.content.message,
                                             text: return_data.content.message,
                                             type: "warning",
                                             buttons: {
                                                confirm: {
                                                   text: "<?=L('OK');?>",
                                                   className: "btn btn-success",
                                                }
                                             },
                                          }).then((willOK) => {
                                             if (willOK) {
                                                $("#msgBox2").modal("hide");                                                        
                                                $("#msgBox").find("#supplierID").append($('<option>').val(return_data.content.id).text(return_data.content.name));   
                                                                                             
                                                $("#supplierID option[value='"+return_data.content.id+"']").prop('selected',true);   
                                             } 
                                          });    
                                       } else {
                                          $("#form-addSupplier").find(".form-group").removeClass("has-error");
                                          $("#form-addSupplier").find(".form-group").find(".hintHelp").text("");
                                          $("#form-addSupplier").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                          $("#form-addSupplier").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                          $("#form-addSupplier").find("#"+return_data.content.field).focus();
                                       }
                                    });
                                 }      
                              });                                   
                           } else {
                              modal.find('.modal-body').html(form_data.content.message);
                              modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                 $("#msgBox2").modal("hide");   
                              });
                           } 

                        }).modal('show')

                        $('#msgBox2').on('hidden.bs.modal', function (e) {
                           $(this).find('.modal-dialog').removeClass("modal-xl");
                        })   
                     });                          

                     }
                  });

               
            }).modal('show')

            $('#msgBox').on('hidden.bs.modal', function (e) {
               $(this).find('.modal-dialog').removeClass("modal-xl");
            })   
         } else {
            if(form_data.content.note=="signIn") {
               showLoginNotice(form_data.content.message);
            } else {
               $('#msgBox').one('show.bs.modal', function (ev) {                 
                  var modal = $(this);
                  modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                  modal.find('.modal-body').html(form_data.content.message);                     
                  modal.find('#msgBoxBtnPri').on('click', function (event) {  
                     $("#msgBox").modal("hide");   
                  });                               
               }).modal('show')  
            }     
         }
      });
   });
   
   $('#itemTable tbody').on('click', '.btnEdit', function (e) {
      e.preventDefault();
      var button = $(e.currentTarget);
      ajaxFunc.apiCall("GET", "item/formEdit/"+button.data('id'), null, null,  function (form_data) { 
         if(form_data.content.success) {
            $('#msgBox').one('show.bs.modal', function (ev) {                 
               var modal = $(this);
               modal.find('.modal-dialog').addClass("modal-xl");
               modal.find('#msgBoxLabel').html("<?=L('Edit');?> <?=L('Record');?>");    
                  modal.find('.modal-body').html(form_data.content.message);
                  
                  modal.find('#msgBoxBtnPri').off('click');
                  modal.find('#msgBoxBtnPri').on('click', function (event) {  
                     
                     if(document.getElementById("form-editItem")!==null){    
                        var data = new FormData(document.getElementById("form-editItem"));  
                        ajaxFunc.apiCall("POST", "item/"+button.data('id'), data, "multipart/form-data", function(return_data){
                           if(return_data.content.success) {
                              $("#msgBox").modal("hide");    
                              swal({
                                 title: return_data.content.message,
                                 text: return_data.content.message,
                                 type: "warning",
                                 buttons: {
                                    confirm: {
                                       text: "<?=L('OK');?>",
                                       className: "btn btn-success",
                                    }
                                 },
                              }).then((willOK) => {
                                 if (willOK) {
                                    itemTable.ajax.reload(myCallback, false);       
                                 } 
                              });    
                           } else {
                              $("#form-editItem").find(".form-group").removeClass("has-error");
                              $("#form-editItem").find(".form-group").find(".hintHelp").text("");
                              $("#form-editItem").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                              $("#form-editItem").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                              $("#form-editItem").find("#"+return_data.content.field).focus();
                           }
                        });
                     } 
                     
                  }); 

                  $("#itemTypeID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "itemType/formAdd", null, null,  function (form_data) { 
                           $('#msgBox2').one('show.bs.modal', function (ev) {
                              var modal = $(this);
                              modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                              if(form_data.content.success) {
                                 modal.find('.modal-body').html(form_data.content.message);                     
                                 modal.find('#msgBoxBtnPri').off('click');
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    if(document.getElementById("form-addItemType")!==null){    
                                       var data = new FormData(document.getElementById("form-addItemType"));  
                                       ajaxFunc.apiCall("POST", "itemType", data, "multipart/form-data", function(return_data){
                                          if(return_data.content.success) {
                                             $("#msgBox2").modal("hide");    
                                             swal({
                                                title: return_data.content.message,
                                                text: return_data.content.message,
                                                type: "warning",
                                                buttons: {
                                                   confirm: {
                                                      text: "<?=L('OK');?>",
                                                      className: "btn btn-success",
                                                   }
                                                },
                                             }).then((willOK) => {
                                                if (willOK) {
                                                   $("#msgBox2").modal("hide");                                                        
                                                   $("#msgBox").find("#itemTypeID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                   $("#itemTypeID option[value='"+return_data.content.id+"']").prop('selected',true); 
                                                } 
                                             });    
                                          } else {
                                             $("#form-addItemType").find(".form-group").removeClass("has-error");
                                             $("#form-addItemType").find(".form-group").find(".hintHelp").text("");
                                             $("#form-addItemType").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                             $("#form-addItemType").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                             $("#form-addItemType").find("#"+return_data.content.field).focus();
                                          }
                                       });
                                    }      
                                 });  
                              } else {
                                 modal.find('.modal-body').html(form_data.content.message);
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    $("#msgBox2").modal("hide");   
                                 });
                              }                    

                           }).modal('show')
                        });


                     }
                  });
                     
                  $("#unitID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "unit/formAdd", null, null,  function (form_data) { 
                           $('#msgBox2').one('show.bs.modal', function (ev) {
                              var modal = $(this);
                              modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                              if(form_data.content.success) {
                                 modal.find('.modal-body').html(form_data.content.message);                     
                                 modal.find('#msgBoxBtnPri').off('click');
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    if(document.getElementById("form-addUnit")!==null){    
                                       var data = new FormData(document.getElementById("form-addUnit"));  
                                       ajaxFunc.apiCall("POST", "unit", data, "multipart/form-data", function(return_data){
                                          if(return_data.content.success) {
                                             $("#msgBox2").modal("hide");    
                                             swal({
                                                title: return_data.content.message,
                                                text: return_data.content.message,
                                                type: "warning",
                                                buttons: {
                                                   confirm: {
                                                      text: "<?=L('OK');?>",
                                                      className: "btn btn-success",
                                                   }
                                                },
                                             }).then((willOK) => {
                                                if (willOK) {
                                                   $("#msgBox2").modal("hide");                                                        
                                                   $("#msgBox").find("#unitID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                   $("#unitID option[value='"+return_data.content.id+"']").prop('selected',true);
                                                } 
                                             });   
                                          } else {
                                             $("#form-addUnit").find(".form-group").removeClass("has-error");
                                             $("#form-addUnit").find(".form-group").find(".hintHelp").text("");
                                             $("#form-addUnit").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                             $("#form-addUnit").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                             $("#form-addUnit").find("#"+return_data.content.field).focus();
                                          }
                                       });
                                    }      
                                 });  
                              } else {
                                 modal.find('.modal-body').html(form_data.content.message);
                                 modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                    $("#msgBox2").modal("hide");   
                                 });
                              }                    

                           }).modal('show')
                        });


                     }
                  });    
                  
                  $("#supplierID").change(function(e){
                     if($(this).val()=="Add") {
                        e.preventDefault();

                        ajaxFunc.apiCall("GET", "supplier/formAdd", null, null,  function (form_data) { 
                        $('#msgBox2').one('show.bs.modal', function (ev) {
                           var modal = $(this);
                           modal.find('.modal-dialog').addClass("modal-xl");
                           modal.find('#msgBoxLabel').html("<?=L('Add');?> <?=L('Record');?>");
                           if(form_data.content.success) {
                              modal.find('.modal-body').html(form_data.content.message);        
                              $("#supplierCategoryID option[value='Add']").remove();                 
                              modal.find('#msgBoxBtnPri').off('click');
                              modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                 if(document.getElementById("form-addSupplier")!==null){    
                                    var data = new FormData(document.getElementById("form-addSupplier"));  
                                    ajaxFunc.apiCall("POST", "supplier", data, "multipart/form-data", function(return_data){
                                       if(return_data.content.success) {
                                          $("#msgBox2").modal("hide");    
                                          swal({
                                             title: return_data.content.message,
                                             text: return_data.content.message,
                                             type: "warning",
                                             buttons: {
                                                confirm: {
                                                   text: "<?=L('OK');?>",
                                                   className: "btn btn-success",
                                                }
                                             },
                                          }).then((willOK) => {
                                             if (willOK) {
                                                $("#msgBox2").modal("hide");                                                        
                                                $("#msgBox").find("#supplierID").append($('<option>').val(return_data.content.id).text(return_data.content.name));   
                                                                                             
                                                $("#supplierID option[value='"+return_data.content.id+"']").prop('selected',true);   
                                             } 
                                          });    
                                       } else {
                                          $("#form-addSupplier").find(".form-group").removeClass("has-error");
                                          $("#form-addSupplier").find(".form-group").find(".hintHelp").text("");
                                          $("#form-addSupplier").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                          $("#form-addSupplier").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                          $("#form-addSupplier").find("#"+return_data.content.field).focus();
                                       }
                                    });
                                 }      
                              });                                   
                           } else {
                              modal.find('.modal-body').html(form_data.content.message);
                              modal.find('#msgBoxBtnPri').on('click', function (event) {  
                                 $("#msgBox2").modal("hide");   
                              });
                           } 

                        }).modal('show')

                        $('#msgBox2').on('hidden.bs.modal', function (e) {
                           $(this).find('.modal-dialog').removeClass("modal-xl");
                        })  
                     });                          

                     }
                  });                     
               
                              
            }).modal('show')

            $('#msgBox').on('hidden.bs.modal', function (e) {
               $(this).find('.modal-dialog').removeClass("modal-xl");
            })   
         } else {
            if(form_data.content.note=="signIn") {
               showLoginNotice(form_data.content.message);
            } else {
               $('#msgBox').one('show.bs.modal', function (ev) {                 
                  var modal = $(this);
                  modal.find('#msgBoxLabel').html("<?=L('Edit');?> <?=L('Record');?>");
                  modal.find('.modal-body').html(form_data.content.message);                     
                  modal.find('#msgBoxBtnPri').on('click', function (event) {  
                     $("#msgBox").modal("hide");   
                  });                               
               }).modal('show')   
            }     
         }
      });

   });
   
   $('#itemTable tbody').on('click', '.btnDel', function (e) {

      e.preventDefault();

      var button = $(e.currentTarget);

      swal({
         title: "<?=L('DeleteAlertTitle');?>",
         text: "<?=L('DeleteAlertMessage');?>",
         type: "warning",
         buttons: {
            confirm: {
               text: "<?=L('Y');?>",
               className: "btn btn-success",
            },                
            cancel: {
               visible: true,
               text: "<?=L('N');?>",
               className: "btn btn-danger",
            },
         },
      }).then((willDelete) => {
         if (willDelete) {

            ajaxFunc.apiCall("DELETE", "item/"+button.data('id'), null, null, function(return_data){
               if(return_data.content.success) {
                  swal(return_data.content.message, {
                     icon: "success",
                     buttons: {
                        confirm: {
                           className: "btn btn-success",
                        },
                     },
                  }).then((willReload) => {
                     if (willReload) {
                        itemTable.ajax.reload(myCallback, false);   
                     }
                  });                          
               } else {
                  swal(return_data.content.message, {
                     icon: "error",
                     buttons: {
                        confirm: {
                           className: "btn btn-danger",
                        },
                     },
                  });                    
               }
            });
         } 
      });
      
   });

   
   $('#itemTable tbody').on('click', '.btnView', function (e) {
      e.preventDefault();
      var button = $(e.currentTarget);
      show_item_detail(button.data('id'));
   });

   $('#itemTable').on('click', 'tbody tr td:not(:last-child)', function(e) {
      e.preventDefault();
      show_item_detail($(this).parent().attr('id'));                 
   });   
   
   function show_item_detail(itemID) {
      ajaxFunc.apiCall("GET", "item/getStockDetail/"+itemID, null, null,  function (form_data) { 
         if(form_data.content.success) {
            $('#msgBox').one('show.bs.modal', function (ev) {                 
               var modal = $(this);
               modal.find('.modal-dialog').addClass("modal-xl");
               modal.find('#msgBoxLabel').html("<?=L('menu.inventoryMain');?>");
               modal.find('.modal-body').html(form_data.content.message);                     
               modal.find('#msgBoxBtnPri').on('click', function (event) {  
                  $("#msgBox").modal("hide");   
               });                               
            }).modal('show')
            
            $('#msgBox').on('hidden.bs.modal', function (e) {
               $(this).find('.modal-dialog').removeClass("modal-xl");
            })              
         } else {
            if(form_data.content.note=="signIn") {
               showLoginNotice(form_data.content.message);
            } else {
               $('#msgBox').one('show.bs.modal', function (ev) {                 
                  var modal = $(this);
                  modal.find('#msgBoxLabel').html("<?=L('menu.inventoryMain');?>");
                  modal.find('.modal-body').html(form_data.content.message);                     
                  modal.find('#msgBoxBtnPri').on('click', function (event) {  
                     $("#msgBox").modal("hide");   
                  });                               
               }).modal('show') 
            }               
         }
      });
      
   }     

});


</script>