Project

General

Profile

Project progress work #50 » outbound_inquiry_report.php

Yutthapong Sricha, 20 Oct 2023 08:12

 
1
<?
2

    
3
#error_reporting(E_ALL ^ E_DEPRECATED);
4
#error_reporting(E_ALL ^ E_NOTICE);
5
error_reporting(0);
6

    
7

    
8
DEFINE('__NO_AUTHENTICATE_REQUIRED__', '');
9

    
10
require_once "global_env.php";
11
$logger = Logger::getInstance($_SERVER['PHP_SELF']);
12

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

    
18
include_once "lib/sanitize.php";
19
//ob_start("sanitize_html");
20

    
21
$db_user = $mcache->get(session_id() . MCACHE_SUFFIX);
22
if (!$db_user) {
23
  // go to index.php
24
  header("Location: signin.php");
25
  exit();
26
}
27

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

    
36
require_once "lib/Outbound.php";
37
require_once "lib/Customer.php";
38
require_once "lib/Item.php";
39
require_once "lib/PackageType.php";
40
require_once "lib/Location.php";
41
require_once "lib/DBFactory.php";
42
require_once "lib/ext/DateTimeUtil.php";
43

    
44

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

    
49
  $a = $_POST;
50
  $affected_rows = 0;
51
  $id = 0;
52

    
53
  //$logger->debug(print_r($_POST, true));
54

    
55
  switch ($a['cmd']) {
56

    
57
    case 'cancel':
58

    
59
      $where = " id='" . $a['data'][0]['id'] . "' ";
60

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

    
67
      $affected_rows = (new Outbound())->cancel($cols, $where);
68

    
69
      $id = $a['data'][0]['id'];
70
      break;
71

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

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

    
86
  return;
87
}
88

    
89
// Inquiry datas
90

    
91
$outbounds = 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 ob.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 ob.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'); // DB_SERVER_TIMEZONE
105
  $WHERE .= " AND ob.create_dt < '" . $dt . "'";
106
}
107

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

    
113
if (isset($_GET['item'])) {
114
  // example input 00000001-001,00000001-002,00000001-003,00000001-004
115
  $WHERE .= " AND ob.item_id IN (" . Util::encapsulateWithQuote($_GET['item']) . ")";
116
}
117

    
118
// echo ' SELECT ob.*, u.name AS user_name, it.unit_price, it.unit_price*ob.qty AS amount
119
// FROM Outbound ob
120
// INNER JOIN
121
// (
122
//   SELECT a.id, a.division, b.name FROM
123
//   (
124
//     SELECT id, max(division) AS division FROM Users WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
125
//   ) a INNER JOIN (
126
//     SELECT id,division,name FROM Users
127
//   ) b
128
//   ON a.id=b.id AND a.division=b.division
129
// ) u
130
// ON u.id = ob.create_user_id
131
// INNER JOIN Item it
132
// ON it.id = ob.item_id
133
// AND it.division = ob.item_dvsn_id
134
// WHERE ' . $WHERE. ' ORDER BY ob.update_dt DESC';
135
$outbounds = (new DBFactory())->query(
136
  '  SELECT ob.*, u.name AS user_name, it.unit_price, it.unit_price*ob.qty AS amount
137
    FROM Outbound ob
138
    INNER JOIN
139
    (
140
      SELECT a.id, a.division, b.name FROM
141
      (
142
        SELECT id, max(division) AS division FROM Users WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
143
      ) a INNER JOIN (
144
        SELECT id,division,name FROM Users
145
      ) b
146
      ON a.id=b.id AND a.division=b.division
147
    ) u
148
    ON u.id = ob.create_user_id
149
    INNER JOIN Item it
150
    ON it.id = ob.item_id
151
    AND it.division = ob.item_dvsn_id
152
    WHERE ' . $WHERE. ' ORDER BY ob.update_dt DESC'
153
);
154

    
155
// create paring object from fetch rows
156
$items = (new DBFactory())->query(
157
  'SELECT a.id, a.division, b.name FROM
158
  (
159
    SELECT id, max(division) AS division FROM Item WHERE 1=1' . WHERE_PERIOD . ' GROUP BY id
160
  ) a INNER JOIN (
161
    SELECT id,division,name FROM Item
162
  ) b
163
  ON a.id=b.id AND a.division=b.division');
164
$items_pair = Item::DbRows2ArrayMapWithDivisions((new Item())->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
if (isset($_GET['cmd'] && $_GET['cmd'] == 'search')) {
183

    
184
}
185
*/
186

    
187
const _MAX_NEW_ENTRY = 10;
188
?>
189

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

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

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

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

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

    
232
  <script>
233
    // var qs_=qs();
234
    // var qs_ = <?=json_encode($_GET ?? null)?>;
235

    
236
    function select_all(e) {
237
      if (!$(e).hasClass('md-inactive')) {
238
        $(e).addClass('md-inactive').attr('title', 'Deselect all');
239
        $('#table_preview').DataTable().rows().select();
240
      } else {
241
        $(e).removeClass('md-inactive').attr('title', 'Select all');
242
        $('#table_preview').DataTable().rows().deselect();
243
      }
244
    }
245

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

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

    
259
    }
260

    
261

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

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

    
283
    $(document).ready(function() {
284

    
285
      update_default_value();
286

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

    
293

    
294
      $(window).click(function() { $('.popupMenu').remove(); });
295
      $('.menu-icon').click(function(event){ event.stopPropagation(); });
296
      $(".menu-icon").each(function(){
297
        $(this).click(function(){
298
          toggle_menu($(this)[0]);
299
        });
300
      });
301

    
302

    
303
      $.fn.dataTable.ext.search.push(
304
        function(settings, data, dataIndex) {
305
          return $(table.row(dataIndex).node()).hasClass('hidden');
306
        }
307
      );
308

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

    
362
      });
363

    
364
      $('input[id^=tbDate]').datetimepicker({
365
        dateFormat: 'yy-mm-dd'
366
      });
367

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

    
377
      $('#btn_search').on('click', function(evt) {
378
        evt.preventDefault();
379

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

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

    
410

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

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

    
426
        $('#frm-primary').submit();
427

    
428
      });
429

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

    
444
        //console.log(data_);
445
        if (data_.length == 0) return false;
446

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

    
451
        var params = {
452
          cmd : 'cancel',
453
          data : data_,
454
        }
455

    
456
        params = removeUndefined(params);
457
        $.post("", params).done( function (data) {
458
          var json = JSON.parse(data);
459
          //var display_obj = $(this);
460
          if (json.status == "success" && json.affected_rows != 0) {
461
             $('#info-pane', top.document).html('Data has been cancel successfully.');
462
              $("#"+json.id+"_status").html("Cancel").addClass("font-red");
463
              $("."+json.id+"_btn_cancel").addClass("hide-btn-cancel");
464
          } else {
465
            $('#warn-pane', top.document).html('Error! ' + json.error);
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> Outbound 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
            Customer :
503
            <div class="custom-drop-down-list">
504
<?
505
              print Util::convert2DropDownList('customer_from',$customers,'id','id',null,null,$customers[0]['id'],null,'parse_query_str');
506
?>
507
            </div>
508
            ~
509
            <div class="custom-drop-down-list">
510
<?
511
              print Util::convert2DropDownList('customer_to',$customers,'id','id',null,null,$customers[count($customers)-1]['id'],null,'parse_query_str');
512
?>
513
            </div>
514
          </div>
515
          <div>
516
            Outbound date :
517
            <input type="text" id="tbDate1" name="date_from" placeholder="select a date" class="parse_query_str xlwidth tbDate" autocomplete="off" />
518
            ~
519
            <input type="text" id="tbDate2" name="date_to" placeholder="select a date" class="parse_query_str xlwidth tbDate" autocomplete="off" />
520
          </div>
521
          <div class="float-right">
522
            <input id="btn_search" type="submit" value="Search">
523
            <input id="btn_clear" type="button" value="Clear">
524
            <input id="btn_cancel" type="button" value="Delete" style="display:none;">
525
          </div>
526
          <div>
527
            Item code :
528
            <div class="custom-drop-down-list">
529
<?
530
              print Util::convert2DropDownList('item_from',$items,'id','id',null,null,$items[0]['id'],null,'parse_query_str');
531

    
532
?>
533
            </div>
534
            ~
535
            <div class="custom-drop-down-list">
536
<?
537
              print Util::convert2DropDownList('item_to',$items,'id','id',null,null,$items[count($items)-1]['id'],null,'parse_query_str');
538
?>
539
            </div>
540
          </div>
541
        </form>
542
     </div>
543

    
544
<!--
545
  +++++ Table preview section +++++
546
 -->
547
    <div class="display" id="display_div" style="width:100% !important;">
548
      <table id="table_preview" class="display dataTable">
549
        <thead>
550
          <tr>
551
            <th><i class="data-editor dd-icon fas fa-black fa-check-double" for="select_all" title="select all"></i></th>
552
            <th>Outbound date</th>
553
            <th>Item code</th>
554
            <th>Item name</th>
555
            <th>Customer code</th>
556
            <th>Package</th>
557
            <th>Package quantity</th>
558
            <th>Quantity</th>
559
            <th>Status</th>
560
            <th>Slip divide</th>
561
            <th>HT type</th>
562
            <th>User name</th>
563
            <th>User code</th>
564
            <th>Updated date</th>
565
            <th>Unit price</th>
566
            <th>Amount</th>
567
            <th></th>
568
          </tr>
569
        </thead>
570
        <tbody>
571
<? 
572
            $packageTypes = (new PackageType())->get(PackageType::$__COLUMNS, 'item_id=\'*\'');
573
            $packageTypes_pair = PackageType::DbRows2ArrayMap($packageTypes ,'id','package_id');
574
            $OutboundStatus = ItemStatus::getArrayConstants('val', 'id');
575
            $slipDivide = SlipDivide::getArrayConstants('val', 'id');
576
            $acttypeob = ActTypeOb::getArrayConstants('val', 'id');
577

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

    
663
      </tbody>
664
        <tfoot>
665
          <tr>
666
              <th>#</th>
667
              <th>Outbound date</th>
668
              <th>Item code</th>
669
              <th>Item name</th>
670
              <th>Customer code</th>
671
              <th>Package</th>
672
              <th>Package quantity</th>
673
              <th>Quantity</th>
674
              <th>Status</th>
675
              <th>Slip divide</th>
676
              <th>HT type</th>
677
              <th>User name</th>
678
              <th>User code</th>
679
              <th>Updated date</th>
680
              <th>Unit price</th>
681
              <th>Amount</th>
682
              <th></th>
683
          </tr>
684
        </tfoot>
685
      </table>
686
    </div>
687
  </div>
688
</body>
689

    
690
<script src="js/custom-drop-down-list.js"></script>
691
</html>
(4-4/6)