Project

General

Profile

Project progress work #50 » inbound_inquiry_report.php

Yutthapong Sricha, 18 Oct 2023 11:09

 
1
<?
2
//error_reporting(E_ALL ^ E_DEPRECATED);
3
//error_reporting(E_ALL ^ E_NOTICE);
4
error_reporting(0);
5
DEFINE('__NO_AUTHENTICATE_REQUIRED__', '');
6

    
7
require_once "global_env.php";
8
$logger = Logger::getInstance($_SERVER['PHP_SELF']);
9

    
10
// memcached integrated
11
require_once "lib/Memcached_pool.php";
12
$mcache = new Memcached();
13
$mcache->addServers($GLOBALS['memcached-sets'][DEFAULT_MEMCACHED_SET]);
14

    
15
include_once "lib/sanitize.php";
16
//ob_start("sanitize_html");
17

    
18
// this will replace by login session
19
$db_user = $mcache->get(session_id() . MCACHE_SUFFIX);
20
if (!$db_user) {
21
  // go to index.php
22
  header("Location: signin.php");
23
  exit();
24
}
25

    
26
// Verify page authority
27
const pageid = 'menu01.02';
28
if (!isset($db_user['authority'][pageid])) {
29
  // go to index.php
30
  header("Location: signout.php");
31
  exit();
32
}
33

    
34
require_once "lib/Inbound.php";
35
//require_once "lib/Supplier.php";
36
require_once "lib/Customer.php";
37
require_once "lib/Item.php";
38
require_once "lib/PackageType.php";
39
require_once "lib/Location.php";
40
require_once "lib/DBFactory.php";
41
require_once "lib/ext/DateTimeUtil.php";
42

    
43
if (isset($_POST['cmd']) && $_POST['cmd']!="search") {
44
  $status = "success";
45
  $error = "";
46

    
47
  $a = $_POST;
48
  $affected_rows = 0;
49
  $id = 0;
50

    
51
  //$logger->debug(print_r($_POST, true));
52

    
53
  switch ($a['cmd']) {
54

    
55
    case 'cancel':
56

    
57
      $where = " id='" . $a['data'][0]['id'] . "' ";
58

    
59
      $cols = Inbound::$__COLUMNS;
60
      $data = (new Inbound())->get($cols, $where);
61
      $cols = $data[0];
62
      $cols['status'] = 3;
63
      $cols['update_user_id'] = $db_user['user']['id'];
64

    
65
      $affected_rows = (new Inbound())->cancel($cols, $where);
66

    
67
      $id = $a['data'][0]['id'];
68
      break;
69

    
70
    default:
71
      $status = "error";
72
      $error = "unknown command : " . $a['cmd'];
73
      break;
74
  }
75

    
76
  $arry = array(
77
    'status' => $status,
78
    'error' => $error,
79
    'affected_rows' => $affected_rows,
80
    'id' => $id,
81
  );
82
  print json_encode($arry);
83

    
84
  return;
85
}
86

    
87

    
88

    
89
// Inquiry datas
90
$inbounds = null;
91
//$suppliers = null;
92
$customers = null;
93
$items = null;
94
$WHERE = "1=1";
95

    
96
if (isset($_GET['date_from']) && !empty($_GET['date_from']) && isset($_GET['date_to']) && !empty($_GET['date_to'])) {
97
  $df = convertTz($_GET['date_from'], $db_user['timezone']['time_zone'], 'Asia/Bangkok');
98
  $dt = convertTz($_GET['date_to'], $db_user['timezone']['time_zone'], 'Asia/Bangkok');
99
  $WHERE .= " AND ib.create_dt BETWEEN '" . $df . "' AND '" . $dt . "'";
100
} else if (isset($_GET['date_from']) && !empty($_GET['date_from'])) {
101
  $df = convertTz($_GET['date_from'], $db_user['timezone']['time_zone'], 'Asia/Bangkok');
102
  $WHERE .= " AND ib.create_dt > '" . $df . "'";
103
} else if (isset($_GET['date_to']) && !empty($_GET['date_to'])) {
104
  $dt = convertTz($_GET['date_to'], $db_user['timezone']['time_zone'], 'Asia/Bangkok');
105
  $WHERE .= " AND ib.create_dt < '" . $dt . "'";
106
}
107

    
108

    
109
if (isset($_GET['customer'])) {
110
  // example input 00000001-001,00000001-002,00000001-003,00000001-004
111
  $WHERE .= " AND ib.customer_id IN (" . Util::encapsulateWithQuote($_GET['customer']) . ")";
112
}
113

    
114
// if (isset($_POST['supplier'])) {
115
//   // example input 00000001-001,00000001-002,00000001-003,00000001-004
116
//   $WHERE .= " AND ib.customer_id IN (" . Util::encapsulateWithQuote($_POST['supplier']) . ")";
117
// }
118

    
119
if (isset($_GET['item'])) {
120
  // example input 00000001-001,00000001-002,00000001-003,00000001-004
121
  $WHERE .= " AND ib.item_id IN (" . Util::encapsulateWithQuote($_GET['item']) . ")";
122
}
123

    
124

    
125

    
126
//$inbounds = (new Inbound())->get(Inbound::$__COLUMNS, $WHERE);
127
$inbounds = (new DBFactory())->query(
128
  '  SELECT ib.*, u.name AS user_name, it.unit_price, it.unit_price*ib.qty AS amount
129
    FROM Inbound ib
130
    INNER JOIN
131
    (
132
      SELECT a.id, a.division, b.name FROM
133
      (
134
        SELECT id, max(division) AS division FROM Users WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
135
      ) a INNER JOIN (
136
        SELECT id,division,name FROM Users
137
      ) b
138
      ON a.id=b.id AND a.division=b.division
139
    ) u
140
    ON u.id = ib.create_user_id
141
    INNER JOIN Item it
142
    ON it.id = ib.item_id
143
    AND it.division = ib.item_dvsn_id
144
    WHERE ' . $WHERE. ' ORDER BY ib.update_dt DESC'
145
);
146
// create paring object from fetch rows
147
$items = (new DBFactory())->query(
148
  'SELECT a.id, a.division, b.name FROM
149
  (
150
    SELECT id, max(division) AS division FROM Item WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
151
  ) a INNER JOIN (
152
    SELECT id,division,name FROM Item
153
  ) b
154
  ON a.id=b.id AND a.division=b.division');
155
$items_pair = Item::DbRows2ArrayMapWithDivisions((new Item())->getAll(),'id','name','division');
156
// $suppliers = (new DBFactory())->query(
157
//   'SELECT a.id, a.division, b.name FROM
158
//   (
159
//     SELECT id, max(division) AS division FROM Supplier WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
160
//   ) a INNER JOIN (
161
//     SELECT id,division,name FROM Supplier
162
//   ) b
163
//   ON a.id=b.id AND a.division=b.division');
164
// $suppliers_pair = Supplier::DbRows2ArrayMapWithDivisions((new Supplier())->getAll(),'id','name','division');
165
$customers = (new DBFactory())->query(
166
  'SELECT a.id, a.division, b.name FROM
167
  (
168
    SELECT id, max(division) AS division FROM Customer WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
169
  ) a INNER JOIN (
170
    SELECT id,division,name FROM Customer
171
  ) b
172
  ON a.id=b.id AND a.division=b.division');
173
$locations = (new DBFactory())->query(
174
  'SELECT a.id, a.division, b.name FROM
175
  (
176
    SELECT id, max(division) AS division FROM Location WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
177
  ) a INNER JOIN (
178
    SELECT id,division,name FROM Location
179
  ) b
180
  ON a.id=b.id AND a.division=b.division');
181

    
182

    
183
// if (isset($_POST['cmd']) && $_POST['cmd'] == 'search') {
184

    
185
// }
186

    
187

    
188
const _MAX_NEW_ENTRY = 10;
189
?>
190

    
191
<!DOCTYPE html>
192
<html lang="en">
193
<head>
194
  <meta charset="UTF-8">
195
  <meta name="viewport" content="width=device-width, initial-scale=1">
196
  <title>Pegasus System -- Inbound Inquiry Report</title>
197
  <link rel="stylesheet" href="vendor/jquery/css/jquery.dataTables.min.css">
198
  <link href="vendor/jquery/css/jquery-ui.css" rel="stylesheet" />
199
  <link rel="stylesheet" href="vendor/fontawesome-free/css/fontawesome.min.css">
200
  <link rel="stylesheet" href="vendor/fontawesome-free/css/regular.css">
201
  <link rel="stylesheet" href="vendor/fontawesome-free/css/v4-shims.css">
202
  <link rel="stylesheet" href="vendor/fontawesome-free/css/solid.css">
203
  <link rel="stylesheet" href="vendor/jquery/css/buttons.dataTables.min.css">
204
  <link href="css/main.css" rel="stylesheet" />
205

    
206
  
207
  <link href="css/google-material-icons.css" rel="stylesheet">
208
  <link href="css/menu-popup.css" rel="stylesheet" />
209
  <link href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" />
210
  <link href="css/custom-drop-down-list.css" rel="stylesheet" />
211

    
212
  
213
  <script type="text/javascript" src="vendor/jquery/js/jquery.min.js"></script>
214
  <script type="text/javascript" src="vendor/jquery/js/jquery-ui.js"></script>
215

    
216
  <script src="vendor/jquery/js/jquery.dataTables.min.js"></script>
217
  <script src="vendor/jquery/js/dataTables.buttons.min.js"></script>
218
  <script src="vendor/jquery/js/buttons.flash.min.js"></script>
219
  <script src="vendor/jquery/js/jszip.min.js"></script>
220
  <script src="vendor/jquery/js/pdfmake.min.js"></script>
221
  <script src="vendor/jquery/js/vfs_fonts.js"></script>
222
  <script src="vendor/jquery/js/buttons.html5.min.js"></script>
223
  <script src="vendor/jquery/js/buttons.print.min.js"></script>
224
  <script src="vendor/jquery/js/buttons.html5.styles.min.js"></script>
225
  <script src="vendor/jquery/js/buttons.html5.styles.templates.min.js"></script>
226
  <script src="vendor/jquery/js/dataTables.select.min.js" type="text/javascript"></script>
227

    
228
  <script src="js/utils.js"></script>
229
  <script src="js/menu-popup.js"></script>
230
  <script src="js/dd-icon.js"></script>
231
  <script src="js/jquery-ui-timepicker-addon.js"></script>
232

    
233
  <script>
234
    var modified_data = false;
235
    function select_all(e) {
236
      if (!$(e).hasClass('md-inactive')) {
237
        $(e).addClass('md-inactive').attr('title', 'Deselect all');
238
        $('#table_preview').DataTable().rows().select();
239
      } else {
240
        $(e).removeClass('md-inactive').attr('title', 'Select all');
241
        $('#table_preview').DataTable().rows().deselect();
242
      }
243
    }
244

    
245
    function update_default_value() {
246
      var qs_=qs();
247
      for(var q in qs_) {
248
        $('.info').find('.parse_query_str')
249
          .filter(function(){return $(this).attr('name')==q}).val(qs_[q]);
250
      }
251

    
252
      $('.custom-drop-down-list').find('select.parse_query_str').each(function() {
253
        var key = $(this).attr('name');
254
        $(this).parent().find('.select-items div')
255
          .filter(function(){return $(this).html()==qs_[key]}).click();
256
      });
257

    
258
    }
259

    
260
    function do_cmd(e, cmd) {
261
      if (cmd == 'edit') {
262
        $(e).closest('tr').find('.data-display').hide();
263
        $(e).closest('tr').find('.data-editor').show();
264
      } else if (cmd == 'cancel') {
265
        $('#table_preview').DataTable().rows().deselect();
266
        $('#table_preview').DataTable().rows($(e).closest('tr')).select();
267
        $('#btn_cancel').trigger('click');
268
      }
269
    }
270

    
271
    function toggle_menu(e) {
272
      $('.popupMenu').remove();
273
      var data = JSON.parse($(e).attr('data'));
274
      var menu_list = {
275
          Cancel : function(){do_cmd(e, 'cancel');},
276
        };
277
      (new Menu('popupMenu', menu_list)).create(e,{margin:'58px 0 0 10px', width:'100px'});
278
    }
279

    
280
    $(document).ready(function() {
281

    
282
      update_default_value();
283

    
284
      var today = {
285
        year: new Date().getFullYear(),
286
        month: (new Date().getMonth()+1).pad(2),
287
        date: new Date().getDate().pad(2)
288
      };
289

    
290
      $(window).click(function() { $('.popupMenu').remove(); });
291
      $('.menu-icon').click(function(event){ event.stopPropagation(); });
292
      $(".menu-icon").each(function(){
293
        $(this).click(function(){
294
          toggle_menu($(this)[0]);
295
        });
296
      });
297

    
298
      $.fn.dataTable.ext.search.push(
299
        function(settings, data, dataIndex) {
300
          return $(table.row(dataIndex).node()).hasClass('hidden');
301
        }
302
      );
303

    
304
      var dtable = $('#table_preview').DataTable( {
305
        dom: 'B<"clear">lfrtip',
306
        buttons: [
307
            {
308
              extend: 'excelHtml5',
309
              text: 'Excel Output',
310
              filename:  today.year + '-' + today.month + '-' + today.date + ' - Inbound_inquiry_report',
311
              exportOptions: {
312
                  columns: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
313
              }
314
            },
315
            {
316
              extend: 'pdfHtml5',
317
              orientation: 'landscape',
318
              pageSize: 'LEGAL',
319
              text: 'PDF Output',
320
              filename:  today.year + '-' + today.month + '-' + today.date + ' - Inbound_inquiry_report',
321
              customize: function(doc) {
322
                doc['header'] = (function(page, pages) {
323
                  return {
324
                    columns: [
325
                      {
326
                        alignment: 'right',
327
                        text: [
328
                          'page ',
329
                          { text: page.toString(), italics: true },
330
      					          ' / ',
331
                          { text: pages.toString(), italics: true }
332
      				          ]
333
                    }],
334
                    margin: [10, 10]
335
                  }
336
                });
337
              },
338
              exportOptions: {
339
                  columns: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
340
              }
341
            }
342
        ],
343
        select: {
344
            style:    'multi',
345
            selector: 'tr:not(.no-select) td'
346
        },
347
        'pagingType': 'full_numbers',
348
        'searching': false,
349
        "order": [[ 15, "desc" ]],
350
        /* no any columns unsortable*/
351
        'columnDefs': [ {
352
          'targets': [0],
353
          'orderable': false,
354
        }],
355
        "pageLength": <?=isset($_POST['length']) ? $_POST['length'] : 25?>,
356

    
357
      });
358

    
359
      $('input[id^=tbDate]').datetimepicker({
360
        dateFormat: 'yy-mm-dd'
361
      });
362

    
363
      $('#btn_clear').on('click', function() {
364
        $('#frm-primary').trigger('reset');
365
        $('#ddl_customer_from, #ddl_customer_to, #ddl_item_from, #ddl_item_to').each(function() {
366
          $(this).parent().find('.same-as-selected').removeClass('same-as-selected');
367
          $(this).parent().find('.select-selected')
368
            .html($(this).children("option:selected").text());
369
        });
370
      });
371

    
372
      $('#btn_search').on('click', function(evt) {
373
        evt.preventDefault();
374

    
375
        customer_ = '';
376
        var keep = false;
377
        $('#ddl_customer_from > option').each(function() {
378
          if ($(this).val() == $('#ddl_customer_from').children("option:selected").val()) {
379
            keep = true;
380
          }
381
          if (keep) {
382
            customer_ += $(this).val() + ",";
383
          }
384
          if ($(this).val() == $('#ddl_customer_to').children("option:selected").val()) {
385
            keep = false;
386
            return;
387
          }
388
        });
389

    
390
        item_ = '';
391
        var keep = false;
392
        $('#ddl_item_from > option').each(function() {
393
          if ($(this).val() == $('#ddl_item_from').children("option:selected").val()) {
394
            keep = true;
395
          }
396
          if (keep) {
397
            item_ += $(this).val() + ",";
398
          }
399
          if ($(this).val() == $('#ddl_item_to').children("option:selected").val()) {
400
            keep = false;
401
            return;
402
          }
403
        });
404

    
405
      
406

    
407
        var params = {
408
          cmd : 'search',
409
          date_from: $('#tbDate1').val(),
410
          date_to: $('#tbDate2').val(),
411
          customer : customer_.slice(0, -1),
412
          item : item_.slice(0, -1),
413
          length : $('#table_preview_length').find('select').children("option:selected").val(),
414
        };
415

    
416
      
417
        params = removeUndefined(params);
418
        //console.log(params); return false;
419
        for (var key in params) {
420
          $('<input>').attr({ type: 'hidden', name: key, value: params[key] }).appendTo('#frm-primary');
421
        }
422
        //console.log(params); return false;
423
        $('#frm-primary').submit();
424

    
425
      });
426
    
427
      $('#btn_cancel').on('click', function(evt) {
428
        evt.preventDefault();
429
        var data_ = new Array();
430
        $('tbody tr.selected').each(function( evt ) {
431
          /* check proper data */
432
          var id = $(this).find('span[id^=id]').html();
433
         
434
          var data = {
435
            id : id
436
          };
437
          //console.log(data);
438
          data_.push(data);
439
        });
440

    
441
        //console.log(data_);
442
        if (data_.length == 0) return false;
443

    
444
        if (!confirm('Confirmation to Cancel ' + data_.length + ' row' + (data_.length>1?'s':'')+ '?')) {
445
          return false;
446
        }
447

    
448
        var params = {
449
          cmd : 'cancel',
450
          data : data_,
451
        }
452

    
453
        params = removeUndefined(params);
454
        $.post("", params).done( function (data) {
455
          var json = JSON.parse(data);
456
          //var display_obj = $(this);
457
          if (json.status == "success" && json.affected_rows != 0) {
458
             $('#info-pane', top.document).html('Data has been cancel successfully.');
459
              $("#"+json.id+"_status").html("Cancel").addClass("font-red");
460
              $("."+json.id+"_btn_cancel").addClass("hide-btn-cancel"); // 
461
             
462
          } else {
463
            $('#warn-pane', top.document).html('Error! ' + json.error);
464
          }
465
        });
466

    
467
        
468
      });
469
    
470
    
471
    });
472

    
473

    
474
  </script>
475

    
476
  <style>
477
  @import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
478
  *{
479
    margin: 0;
480
    padding: 0;
481
    box-sizing: border-box;
482
    list-style: none;
483
    text-decoration: none;
484
    font-family: 'Josefin Sans', sans-serif;
485
  }
486

    
487
  .font-red {
488
    color:red !important;
489
  }
490

    
491
  .hide-btn-cancel{
492
    display:none !important;
493
  }
494
  </style>
495
</head>
496
<body>
497
  <div class="main_content">
498
    <div class="header" style="text-align: center; background: #0070c0; color: white;"><h2> Inbound Inquiry Report </h2><p style="text-align:right; font-size: 10px;">Version 1.0</p></div>
499
      <div class="info" >
500
        <form method="GET" id="frm-primary">
501
          <!-- <div class="float-right"> -->
502
            <!-- Supplier : -->
503
            <!-- <div class="custom-drop-down-list"> -->
504
<?
505
              // print Util::convert2DropDownList('customer_from',$suppliers,'id','id',null,null,$suppliers[0]['id'],null,'parse_query_str');
506
?>
507
            <!-- </div> -->
508
            <!-- ~ -->
509
            <!-- <div class="custom-drop-down-list"> -->
510
<?
511
              // print Util::convert2DropDownList('customer_to',$suppliers,'id','id',null,null,$suppliers[count($suppliers)-1]['id'],null,'parse_query_str');
512
?>
513
            <!-- </div> -->
514
          <!-- </div> -->
515

    
516
          <div class="float-right">
517
            Customer :
518
            <div class="custom-drop-down-list">
519
<?
520
              print Util::convert2DropDownList('customer_from',$customers,'id','id',null,null,$customers[0]['id'],null,'parse_query_str');
521
?>
522
            </div>
523
            ~
524
            <div class="custom-drop-down-list">
525
<?
526
              print Util::convert2DropDownList('customer_to',$customers,'id','id',null,null,$customers[count($customers)-1]['id'],null,'parse_query_str');
527
?>
528
            </div>
529
          </div>
530
          <div>
531
            Inbound date :
532
            <input type="text" id="tbDate1" name="date_from" placeholder="select a date" class="parse_query_str xlwidth tbDate" autocomplete="off" />
533
            ~
534
            <input type="text" id="tbDate2" name="date_to" placeholder="select a date" class="parse_query_str xlwidth tbDate" autocomplete="off" />
535
          </div>
536
          <div class="float-right">
537
            <input id="btn_search" type="submit" value="Search">
538
            <input id="btn_clear" type="button" value="Clear">
539
            <input id="btn_cancel" type="button" value="Delete" style="display:none;">
540
          </div>
541
          <div>
542
            Item code :
543
            <div class="custom-drop-down-list">
544
<?
545
              print Util::convert2DropDownList('item_from',$items,'id','id',null,null,$items[0]['id'],null,'parse_query_str');
546

    
547
?>
548
            </div>
549
            ~
550
            <div class="custom-drop-down-list">
551
<?
552
              print Util::convert2DropDownList('item_to',$items,'id','id',null,null,$items[count($items)-1]['id'],null,'parse_query_str');
553
?>
554
            </div>
555
          </div>
556
        </form>
557
     </div>
558

    
559
<!--
560
  +++++ Table preview section +++++
561
 -->
562
      <div class="display" id="display_div">
563
        <table id="table_preview" class="display dataTable">
564
          <thead>
565
            <tr>
566
              <th><i class="data-editor dd-icon fas fa-black fa-check-double" for="select_all" title="select all"></i></th>
567
              <th>Inbound date</th>
568
              <th>Item code</th>
569
              <th>Item name</th>
570
              <!-- <th>Product date</th> -->
571
              <th>Customer code</th>
572
              <th>Package</th>
573
              <th>Package quantity</th>
574
              <th>Quantity</th>
575
              <!-- <th>Location</th> -->
576
              <th>Status</th>
577
              <th>Slip divide</th>
578
              <th>HT type</th>
579
              <th>User name</th>
580
              <th>User code</th>
581
              <th>Updated date</th>
582
              <th>Unit price</th>
583
              <th>Amount</th>
584
              <th></th>
585
            </tr>
586
          </thead>
587
          <tbody>
588
<?
589
            $packageTypes = (new PackageType())->get(PackageType::$__COLUMNS, 'item_id=\'*\'');
590
            $packageTypes_pair = PackageType::DbRows2ArrayMap($packageTypes ,'id','package_id');
591
            $inboundStatus = ItemStatus::getArrayConstants('val', 'id');
592
            $slipDivide = SlipDivide::getArrayConstants('val', 'id');
593
            $acttypeib = ActTypeIb::getArrayConstants('val', 'id');
594

    
595
            $i = 0;
596
            $display_cols = array(
597
              'id'=>0,
598
              'create_dt'=>0,
599
              'item_id'=>0,
600
              // 'product_date'=>0,
601
              'customer_id'=>0,
602
              'package_type'=>0,
603
              'package_qty'=>0,
604
              'qty'=>0,
605
             // 'location_id'=>0,
606
              'status'=>0,
607
              'slip_divide'=>0,
608
              'act_type'=>0,
609
              'user_name'=>0,
610
              'create_user_id'=>0,
611
              'update_dt'=>0,
612
              'unit_price'=>0,
613
              'amount'=>0,
614
            );
615
            foreach ($inbounds as $index => $row) {
616
              echo '<tr>';
617
              foreach ($display_cols as $key => $val) {
618
                if ($row[$key] instanceof DateTime) {
619
                  if ($key == 'create_dt') {
620
                    $tmp = "obdate";
621
                    $format = "Y-m-d H:i:s";
622
                    echo '<td><span id="' . $key . '" map="tbDate_edit_' . $row['id'] . '" class="data-display">'
623
                      . convertTz($row[$key]->format($format), 'Asia/Bangkok', $db_user['timezone']['time_zone']) . "</span>"
624
                      . '</td>';
625
                  } else {
626
                    $tmp = "product";
627
                    $format = "Y-m-d";
628
                    echo '<td><span id="' . $key . '" map="tbDate_edit_' . $row['id'] . '" class="data-display">'
629
                      . $row[$key]->format($format) . "</span>"
630
                      . '</td>';
631
                  }
632
                } else if ($key == 'item_id') {
633
                  echo '<td><span id="' . $key . '" map="ddl_item_code" class="data-display">' . $row[$key]  . "</span>"
634
                    . '</td>';
635
                  echo '<td><span class="data-display" map="item_name">' . $items_pair[$row[$key]][$row['item_dvsn_id']] . '</span></td>';
636
                } else if ($key == 'customer_id') {
637
                  echo '<td><span id="' . $key . '" map="ddl_customer_code" class="data-display">' . $row[$key] . "</span>"
638
                    . '</td>';
639
                } else if ($key == 'package_type') {
640
                  echo '<td><span id="' . $key . '" map="ddl_package_type" class="data-display">' . $packageTypes_pair[$row[$key]] . "</span>"
641
                    . '</td>';
642
                } else if ($key == 'status') {
643
                  $fcolor = ($row[$key]==3)?'font-red':'';
644
                  echo '<td><span id="' . $row['id'] . '_status" map="ddl_inbound_status" class="data-display '.$fcolor.'">' . ItemStatus::getConstant($row[$key])->toString() . "</span>"
645
                    . '</td>';
646
                } else if ($key == 'slip_divide') {
647
                  echo '<td><span id="' . $key . '" map="ddl_slip_divide" class="data-display">' . SlipDivide::getConstant($row[$key])->toString() . "</span>"
648
                    . '</td>';
649
                } else if ($key == 'act_type') {
650
                    echo '<td><span id="' . $key . '" map="ddl_slip_divide" class="data-display">' . ActTypeIb::getConstant($row[$key])->toString() . "</span>"
651
                      . '</td>';
652
                }  else if ($key == 'id') {
653
                  echo '<td><span id="' . $key . '" style="display:none;">' . $row[$key] . '</span>' . ++$i
654
                    . '</td>';
655
                } else if ($key == 'unit_price' || $key == 'amount') {
656
                  echo '<td><span id="' . $key . '_' . $row['id'] . '" map="' . $key . '_' . $row['id'] . '" class="data-display">' . number_format($row[$key], 2) . '</span>'
657
                    . '</td>';
658
                } else {
659
                  echo '<td><span id="' . $key . '_' . $row['id'] . '" map="' . $key . '_' . $row['id'] . '" class="data-display">' . $row[$key] . '</span>'
660
                    . '</td>';
661
                }
662
              }
663
                  echo '<td style="display:inline-flex" class="td-icons">';
664
                    if( $row['status']<3 ){
665
                        echo '<i class="data-editor dd-icon fa fa-red fa-remove" for="cancel_edit" title="cancel" style="display:none"></i>'
666
                              . '<i id="more_vert" class="'. $row['id'] .'_btn_cancel menu-icon data-display fa fa-black fa-ellipsis-v" title="click for action"'
667
                              . ' data=\'{"id": "' . $row['id'] . '"}\''
668
                              . '></i>';
669
                    }
670
                  echo '</td>';   
671
              echo '</tr>';
672
            }
673
?>
674

    
675
      </tbody>
676
      <tfoot>
677
        <tr>
678
            <th>#</th>
679
            <th>Inbound date</th>
680
            <th>Item code</th>
681
            <th>Item name</th>
682
            <!-- <th>Product date</th> -->
683
            <th>Customer code</th>
684
            <th>Package</th>
685
            <th>Package quantity</th>
686
            <th>Quantity</th>
687
            <!-- <th>Location</th> -->
688
            <th>Status</th>
689
            <th>Slip divide</th>
690
            <th>HT type</th>
691
            <th>User name</th>
692
            <th>User code</th>
693
            <th>Updated date</th>
694
            <th>Unit price</th>
695
            <th>Amount</th>
696
            <th></th>
697
        </tr>
698
      </tfoot>
699
    </table>
700
    </div>
701
  </div>
702
</body>
703

    
704
<script src="js/custom-drop-down-list.js"></script>
705
</html>
(1-1/6)