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/storageLocationArea/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.storageLocationArea');?></h4>
                      <button class="btn btn-primary btn-round btn-sm ms-auto addStorageLocationAreaBtn">
                        <i class="fa fa-plus"></i>
                      </button>
                    </div>    
               </div>
               <div class="card-body">
                  <div class="table-responsive">
                     <table id="storageLocationAreaTable" class="display table table-striped table-hover datatable">
                     <?=Controller\storageLocationArea::genTableHeader();?>
                     <?=Controller\storageLocationArea::genTableFooter();?>                     
                     <tbody>
                     <?php
                        $content = Controller\storageLocationArea::genTableContentData();
                        foreach($content as $listObj) {
                           echo Controller\storageLocationArea::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 storageLocationAreaTable = $("#storageLocationAreaTable").DataTable({
         pageLength: 25,
         processing: false,
         serverSide: true,
         serverMethod: 'post',
         ajax: '<?=$request->baseUrl();?>/script/storageLocationAreaList.php',
         "columns": [
            { data: 'column_storageLocationAreaID' },
            { data: 'column_storageLocationName' },
            { data: 'column_storageLocationAreaName' },
            { data: 'column_storageLocationAreaStatus' },
            { data: 'column_function' }
         ],
         rowId: 'column_storageLocationAreaID', 
         initComplete: function () {
         this.api()
            .columns([0,1,2,3,4])
            .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>"
                  );
               });
            });
         },
      });

      
      $(".addStorageLocationAreaBtn").click(function(e){
         var button = $(e.currentTarget);
         e.preventDefault();
         ajaxFunc.apiCall("GET", "storageLocationArea/formAdd", null, null,  function (form_data) { 

            if(form_data.content.success) {

               $('#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').off('click');
                     modal.find('#msgBoxBtnPri').on('click', function (event) {  
                        if(document.getElementById("form-addStorageLocationArea")!==null){    
                           var data = new FormData(document.getElementById("form-addStorageLocationArea"));  
                           ajaxFunc.apiCall("POST", "storageLocationArea", 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) {
                                       storageLocationAreaTable.ajax.reload(myCallback, false);      
                                    } 
                                 });    
                              } else {
                                 $("#form-addStorageLocationArea").find(".form-group").removeClass("has-error");
                                 $("#form-addStorageLocationArea").find(".form-group").find(".hintHelp").text("");
                                 $("#form-addStorageLocationArea").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                 $("#form-addStorageLocationArea").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                 $("#form-addStorageLocationArea").find("#"+return_data.content.field).focus();
                              }
                           });
                        }      
                     });  


                     $("#storageLocationID").change(function(e){
                        if($(this).val()=="Add") {
                           e.preventDefault();
                           ajaxFunc.apiCall("GET", "storageLocation/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-addStorageLocation")!==null){    
                                          var data = new FormData(document.getElementById("form-addStorageLocation"));  
                                          ajaxFunc.apiCall("POST", "storageLocation", 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("#storageLocationID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                      $("#storageLocationID option[value='"+return_data.content.id+"']").prop('selected',true);
                                                   } 
                                                });    
                                             } else {
                                                $("#form-addStorageLocation").find(".form-group").removeClass("has-error");
                                                $("#form-addStorageLocation").find(".form-group").find(".hintHelp").text("");
                                                $("#form-addStorageLocation").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                                $("#form-addStorageLocation").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                                $("#form-addStorageLocation").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')
                           });
                        }
                     });

                  
               }).modal('show')

            } 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')   
               }                 
            }
         });
      });

      
      $('#storageLocationAreaTable tbody').on('click', '.btnEdit', function (e) {
         e.preventDefault();
         var button = $(e.currentTarget);
         ajaxFunc.apiCall("GET", "storageLocationArea/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('#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-editStorageLocationArea")!==null){    
                           var data = new FormData(document.getElementById("form-editStorageLocationArea"));  
                           ajaxFunc.apiCall("POST", "storageLocationArea/"+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) {
                                       storageLocationAreaTable.ajax.reload(myCallback, false);      
                                    } 
                                 });    
                              } else {
                                 $("#form-editStorageLocationArea").find(".form-group").removeClass("has-error");
                                 $("#form-editStorageLocationArea").find(".form-group").find(".hintHelp").text("");
                                 $("#form-editStorageLocationArea").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                 $("#form-editStorageLocationArea").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                 $("#form-editStorageLocationArea").find("#"+return_data.content.field).focus();
                              }
                           });
                        } 
                        
                     }); 


                     $("#storageLocationID").change(function(e){
                        if($(this).val()=="Add") {
                           e.preventDefault();
                           ajaxFunc.apiCall("GET", "storageLocation/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-addStorageLocation")!==null){    
                                          var data = new FormData(document.getElementById("form-addStorageLocation"));  
                                          ajaxFunc.apiCall("POST", "storageLocation", 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("#storageLocationID").append($('<option>').val(return_data.content.id).text(return_data.content.name));                                                     
                                                      $("#storageLocationID option[value='"+return_data.content.id+"']").prop('selected',true);
                                                   } 
                                                });    
                                             } else {
                                                $("#form-addStorageLocation").find(".form-group").removeClass("has-error");
                                                $("#form-addStorageLocation").find(".form-group").find(".hintHelp").text("");
                                                $("#form-addStorageLocation").find("#"+return_data.content.field).closest(".form-group").addClass("has-error");
                                                $("#form-addStorageLocation").find("#"+return_data.content.field+"Help").text(return_data.content.message);
                                                $("#form-addStorageLocation").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')
                           });
                        }
                     });                     
                  

                                 
               }).modal('show')

            } 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')   
               }   
            }
         });

      });
      
      $('#storageLocationAreaTable 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", "storageLocationArea/"+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) {
                           storageLocationAreaTable.ajax.reload(myCallback, false);      
                        }
                     });                          
                  } else {
                     swal(return_data.content.message, {
                        icon: "error",
                        buttons: {
                           confirm: {
                              className: "btn btn-danger",
                           },
                        },
                     });                    
                  }
               });
            } 
         });
         
      });
               
      $('#storageLocationAreaTable tbody').on('click', '.btnView', function (e) {
         e.preventDefault();
         var button = $(e.currentTarget);
         show_storageLocationArea_detail(button.data('id'));
      });

      $('#storageLocationAreaTable').on('click', 'tbody tr td:not(:last-child)', function(e) {
         e.preventDefault();
         show_storageLocationArea_detail($(this).parent().attr('id'));                 
      });   
      
      function show_storageLocationArea_detail(storageLocationAreaID) {
         ajaxFunc.apiCall("GET", "storageLocationArea/getStockDetail/"+storageLocationAreaID, 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>