PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/modules/stock_take/current.php

https://github.com/buitenzorg812/slims3-stable15-jquery
PHP | 142 lines | 95 code | 12 blank | 35 comment | 16 complexity | 4b335c240906cfa3f7e3eda987ca7757 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Copyright (C) 2007,2008 Arie Nugraha (dicarve@yahoo.com)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. *
  19. */
  20. /* Stock Take */
  21. // main system configuration
  22. require '../../../sysconfig.inc.php';
  23. // start the session
  24. require SENAYAN_BASE_DIR.'admin/default/session.inc.php';
  25. require SENAYAN_BASE_DIR.'admin/default/session_check.inc.php';
  26. require SIMBIO_BASE_DIR.'simbio_GUI/table/simbio_table.inc.php';
  27. require SIMBIO_BASE_DIR.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
  28. require SIMBIO_BASE_DIR.'simbio_GUI/paging/simbio_paging.inc.php';
  29. require SIMBIO_BASE_DIR.'simbio_DB/datagrid/simbio_dbgrid.inc.php';
  30. // privileges checking
  31. $can_read = utility::havePrivilege('stock_take', 'r');
  32. $can_write = utility::havePrivilege('stock_take', 'w');
  33. if (!($can_read AND $can_write)) {
  34. die('<div class="errorBox">'.__('You don\'t have enough privileges to access this area!').'</div>');
  35. }
  36. // show only current user stock take item flag
  37. if (isset($_GET['listShow']) && $_GET['listShow'] == '1') {
  38. $show_only_current = 1;
  39. }
  40. // check if there is any active stock take proccess
  41. $stk_query = $dbs->query('SELECT * FROM stock_take WHERE is_active=1');
  42. if ($stk_query->num_rows < 1) {
  43. echo '<div class="errorBox">'.__('NO stock taking proccess initialized yet!').'</div>';
  44. } else {
  45. // check view mode
  46. $view = 'e';
  47. if (isset($_GET['view']) AND $_GET['view']) {
  48. $view = trim($_GET['view']);
  49. }
  50. ?>
  51. <fieldset class="menuBox">
  52. <div class="menuBoxInner stockTakeIcon">
  53. <?php
  54. if ($view != 'm') {
  55. echo __('STOCK TAKE PROCCESS - Insert Item Code/Barcode with keyboard or barcode scanner').'<hr />
  56. <form name="stockTakeForm" class="notAJAX" action="'.MODULES_WEB_ROOT_DIR.'stock_take/stock_take_action.php" target="stockTakeAction" method="post" style="display: inline;">
  57. <div><div style="width: 140px; float: left;">'.__('Item Code').':</div><input type="text" id="itemCode" name="itemCode" size="30" /> <input type="submit" value="'.__('Change Status').'" class="button" /></div>
  58. <div style="margin-top: 3px;"><div style="width: 140px; float: left;">'.__('List stocktakes by').':</div>
  59. <input type="radio" id="listShow" name="listShow" value="1" onclick="setContent(\'mainContent\', \''.MODULES_WEB_ROOT_DIR.'stock_take/current.php?listShow=1\', \'get\')" '.( isset($show_only_current)?'checked="checked"':'' ).' /> '.__('Current User Only').'
  60. <input type="radio" id="listShow2" name="listShow" value="0" onclick="setContent(\'mainContent\', \''.MODULES_WEB_ROOT_DIR.'stock_take/current.php?listShow=0\', \'get\')" '.( isset($show_only_current)?'':'checked="checked"' ).' /> '.__('All User').'
  61. <iframe name="stockTakeAction" style="width: 0; height: 0; visibility: hidden;"></iframe></div>
  62. </form>';
  63. } else {
  64. echo __('Current Missing/Lost Items').'<hr />';
  65. }
  66. ?>
  67. <form name="search" id="search" action="<?php echo MODULES_WEB_ROOT_DIR; ?>stock_take/current.php" method="get" style="display: inline;">
  68. <div style="margin-top: 3px;"><div style="width: 90px; float: left;"><?php echo __('Search'); ?> : </div><input type="text" name="keywords" size="30" /> <input type="hidden" name="view" value="<?php echo $view; ?>" /> <input type="submit" id="doSearch" value="<?php echo __('Search'); ?>" class="button" /></div>
  69. </form>
  70. </div>
  71. </fieldset>
  72. <!-- give focus to itemCode text field -->
  73. <script type="text/javascript">
  74. Form.Element.focus('itemCode');
  75. </script>
  76. <div id="stError" class="errorBox" style="display: none;">&nbsp;</div>
  77. <?php
  78. /* CURRENT STOCK TAKE ITEM LIST */
  79. // table spec
  80. $table_spec = 'stock_take_item AS sti';
  81. // create datagrid
  82. $datagrid = new simbio_datagrid();
  83. $datagrid->setSQLColumn('item_code AS \''.__('Item Code').'\'',
  84. 'title AS \''.__('Title').'\'',
  85. 'coll_type_name AS \''.__('Collection Type').'\'',
  86. 'classification AS \''.__('Classification').'\'',
  87. 'IF(sti.status=\'e\', \''.__('Exists').'\', IF(sti.status=\'l\', \''.__('On Loan').'\', \''.__('Missing').'\')) AS \'Status\'');
  88. $datagrid->setSQLorder("last_update DESC");
  89. $criteria = 'item_id <> 0 ';
  90. // is there any search
  91. if (isset($_GET['keywords']) AND $_GET['keywords']) {
  92. $keyword = $dbs->escape_string(trim($_GET['keywords']));
  93. $words = explode(' ', $keyword);
  94. if (count($words) > 1) {
  95. $concat_sql = ' (';
  96. foreach ($words as $word) {
  97. $concat_sql .= " (title LIKE '%$word%' OR item_code LIKE '%$word%') AND";
  98. }
  99. // remove the last AND
  100. $concat_sql = substr_replace($concat_sql, '', -3);
  101. $concat_sql .= ') ';
  102. $criteria .= ' AND '.$concat_sql." AND status='".$view."'";
  103. } else {
  104. $criteria .= " AND (title LIKE '%$keyword%' OR item_code LIKE '%$keyword%') AND status='".$view."'";
  105. }
  106. } else {
  107. $criteria .= " AND status='".$view."'";
  108. }
  109. if (isset($show_only_current)) {
  110. $criteria .= ' AND checked_by=\''.$_SESSION['realname'].'\'';
  111. }
  112. // set criteria
  113. $datagrid->setSQLCriteria($criteria);
  114. // set table and table header attributes
  115. $datagrid->table_attr = 'align="center" id="dataList" cellpadding="5" cellspacing="0"';
  116. $datagrid->table_header_attr = 'class="dataListHeader" style="font-weight: bold;"';
  117. // set delete proccess URL
  118. $datagrid->delete_URL = $_SERVER['PHP_SELF'];
  119. $datagrid->column_width = array('10%', '60%', '10%', '10%', '10%');
  120. $datagrid->disableSort('Current Status');
  121. // put the result into variables
  122. $datagrid_result = $datagrid->createDataGrid($dbs, $table_spec, 20, false);
  123. if (isset($_GET['keywords']) AND $_GET['keywords']) {
  124. $msg = str_replace('{result->num_rows}', $datagrid->num_rows, __('Found <strong>{result->num_rows}</strong> from your keywords')); //mfc
  125. echo '<div class="infoBox">'.$msg.' : "'.$_GET['keywords'].'"</div>';
  126. }
  127. echo $datagrid_result;
  128. /* main content end */
  129. }
  130. ?>