/modules/inventory/pages/popup_assy/pre_process.php
PHP | 92 lines | 55 code | 9 blank | 28 comment | 13 complexity | 242f9b7547ed2993bd2c9dc25226c91b MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
- <?php
- // +-----------------------------------------------------------------+
- // | PhreeBooks Open Source ERP |
- // +-----------------------------------------------------------------+
- // | Copyright (c) 2008, 2009, 2010, 2011, 2012 PhreeSoft, LLC |
- // | http://www.PhreeSoft.com |
- // +-----------------------------------------------------------------+
- // | This program is free software: you can redistribute it and/or |
- // | modify it under the terms of the GNU General Public License as |
- // | published by the Free Software Foundation, either version 3 of |
- // | the License, or any later version. |
- // | |
- // | This program is distributed in the hope that it will be useful, |
- // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- // | GNU General Public License for more details. |
- // +-----------------------------------------------------------------+
- // Path: /modules/inventory/pages/popup_assy/pre_process.php
- //
- $security_level = validate_user(0, true);
- /************** include page specific files *********************/
- require(DIR_FS_WORKING . 'functions/inventory.php');
-
- /************** page specific initialization *************************/
- $acct_period = ($_GET['search_period']) ? $_GET['search_period'] : $_POST['search_period'];
- if (!$acct_period) $acct_period = CURRENT_ACCOUNTING_PERIOD;
- $period_filter = ($acct_period == 'all') ? '' : (' and m.period = ' . $acct_period);
- $search_text = ($_POST['search_text']) ? db_input($_POST['search_text']) : db_input($_GET['search_text']);
- if ($search_text == TEXT_SEARCH) $search_text = '';
- $action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
- if (!$action && $search_text <> '') $action = 'search'; // if enter key pressed and search not blank
- // load the sort fields
- $_GET['sf'] = $_POST['sort_field'] ? $_POST['sort_field'] : $_GET['sf'];
- $_GET['so'] = $_POST['sort_order'] ? $_POST['sort_order'] : $_GET['so'];
- /*************** hook for custom actions ***************************/
- $custom_path = DIR_FS_WORKING . 'custom/pages/popup_assy/extra_actions.php';
- if (file_exists($custom_path)) { include($custom_path); }
-
- /*************** Act on the action request *************************/
- switch ($action) {
- case 'go_first': $_GET['list'] = 1; break;
- case 'go_previous': $_GET['list']--; break;
- case 'go_next': $_GET['list']++; break;
- case 'go_last': $_GET['list'] = 99999; break;
- case 'search':
- case 'search_reset':
- case 'go_page':
- default:
- }
-
- /***************** prepare to display templates *************************/
- // build the list header
- $heading_array = array(
- 'm.post_date' => TEXT_DATE,
- 'purchase_invoice_id' => TEXT_REFERENCE,
- 'total_amount' => TEXT_AMOUNT,
- 'description' => TEXT_DESCRIPTION,
- );
- $extras = (ENABLE_MULTI_BRANCH) ? array(TEXT_BRANCH) : array();
- $result = html_heading_bar($heading_array, $_GET['sf'], $_GET['so'], $extras);
- $list_header = $result['html_code'];
- $disp_order = $result['disp_order'];
-
- // build the list for the page selected
- if (isset($search_text) && $search_text <> '') {
- $search_fields = array('i.sku', 'm.purchase_invoice_id', 'i.debit_amount', 'i.credit_amount', 'i.description');
- // hook for inserting new search fields to the query criteria.
- if (is_array($extra_search_fields)) $search_fields = array_merge($search_fields, $extra_search_fields);
- $search = ' and (' . implode(' like \'%' . $search_text . '%\' or ', $search_fields) . ' like \'%' . $search_text . '%\')';
- } else {
- $search = '';
- }
-
- $field_list = array('m.id', 'm.purchase_invoice_id', 'm.post_date', 'm.store_id', 'i.description', 'i.qty');
-
- // hook to add new fields to the query return results
- if (is_array($extra_query_list_fields) > 0) $field_list = array_merge($field_list, $extra_query_list_fields);
-
- $query_raw = "select " . implode(', ', $field_list) . "
- from " . TABLE_JOURNAL_MAIN . " m left join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id
- where i.gl_type = 'asy' and m.journal_id = 14" . $period_filter . $search . " order by $disp_order, m.id";
-
- $query_split = new splitPageResults($_GET['list'], MAX_DISPLAY_SEARCH_RESULTS, $query_raw, $query_numrows);
- $query_result = $db->Execute($query_raw);
-
- $include_header = false;
- $include_footer = true;
- $include_tabs = false;
- $include_calendar = false;
- $include_template = 'template_main.php';
- define('PAGE_TITLE', GEN_HEADING_PLEASE_SELECT);
- ?>