1<?php 2/********************************************************************** 3 Copyright (C) FrontAccounting, LLC. 4 Released under the terms of the GNU General Public License, GPL, 5 as published by the Free Software Foundation, either version 3 6 of the License, or (at your option) any later version. 7 This program is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>. 11***********************************************************************/ 12 13$page_security = 'SA_GLANALYTIC'; 14$path_to_root="../.."; 15 16include($path_to_root . "/includes/db_pager.inc"); 17include_once($path_to_root . "/includes/session.inc"); 18 19include_once($path_to_root . "/includes/date_functions.inc"); 20include_once($path_to_root . "/includes/ui.inc"); 21$js = ""; 22if ($use_popup_windows) 23 $js .= get_js_open_window(800, 500); 24if ($use_date_picker) 25 $js .= get_js_date_picker(); 26 27page(_($help_context = "Journal Inquiry"), false, false, "", $js); 28 29//----------------------------------------------------------------------------------- 30// Ajax updates 31// 32if (get_post('Search')) 33{ 34 $Ajax->activate('journal_tbl'); 35} 36//-------------------------------------------------------------------------------------- 37if (!isset($_POST['filterType'])) 38 $_POST['filterType'] = -1; 39 40start_form(); 41 42start_table(TABLESTYLE_NOBORDER); 43start_row(); 44 45ref_cells(_("Reference:"), 'Ref', '',null, _('Enter reference fragment or leave empty')); 46 47journal_types_list_cells(_("Type:"), "filterType"); 48date_cells(_("From:"), 'FromDate', '', null, 0, -1, 0); 49date_cells(_("To:"), 'ToDate'); 50 51check_cells( _("Show closed:"), 'AlsoClosed', null); 52 53submit_cells('Search', _("Search"), '', '', 'default'); 54end_row(); 55start_row(); 56ref_cells(_("Memo:"), 'Memo', '',null, _('Enter memo fragment or leave empty')); 57end_row(); 58end_table(); 59 60function journal_pos($row) 61{ 62 return $row['gl_seq'] ? $row['gl_seq'] : '-'; 63} 64 65function systype_name($dummy, $type) 66{ 67 global $systypes_array; 68 69 return $systypes_array[$type]; 70} 71 72function view_link($row) 73{ 74 return get_trans_view_str($row["type"], $row["type_no"]); 75} 76 77function gl_link($row) 78{ 79 return get_gl_view_str($row["type"], $row["type_no"]); 80} 81 82$editors = array( 83 ST_JOURNAL => "/gl/gl_journal.php?ModifyGL=Yes&trans_no=%d&trans_type=%d", 84 ST_BANKPAYMENT => "/gl/gl_bank.php?ModifyPayment=Yes&trans_no=%d&trans_type=%d", 85 ST_BANKDEPOSIT => "/gl/gl_bank.php?ModifyDeposit=Yes&trans_no=%d&trans_type=%d", 86// 4=> Funds Transfer, 87 ST_SALESINVOICE => "/sales/customer_invoice.php?ModifyInvoice=%d", 88// 11=> 89// free hand (debtors_trans.order_==0) 90// "/sales/credit_note_entry.php?ModifyCredit=%d" 91// credit invoice 92// "/sales/customer_credit_invoice.php?ModifyCredit=%d" 93// 12=> Customer Payment, 94 ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d", 95// 16=> Location Transfer, 96// 17=> Inventory Adjustment, 97// 20=> Supplier Invoice, 98// 21=> Supplier Credit Note, 99// 22=> Supplier Payment, 100// 25=> Purchase Order Delivery, 101// 28=> Work Order Issue, 102// 29=> Work Order Production", 103// 35=> Cost Update, 104); 105 106function edit_link($row) 107{ 108 global $editors; 109 110 $ok = true; 111 if ($row['type'] == ST_SALESINVOICE) 112 { 113 $myrow = get_customer_trans($row["type_no"], $row["type"]); 114 if ($myrow['alloc'] != 0 || get_voided_entry(ST_SALESINVOICE, $row["type_no"]) !== false) 115 $ok = false; 116 } 117 return isset($editors[$row["type"]]) && !is_closed_trans($row["type"], $row["type_no"]) && $ok ? 118 pager_link(_("Edit"), 119 sprintf($editors[$row["type"]], $row["type_no"], $row["type"]), 120 ICON_EDIT) : ''; 121} 122 123$sql = get_sql_for_journal_inquiry(get_post('filterType', -1), get_post('FromDate'), 124 get_post('ToDate'), get_post('Ref'), get_post('Memo'), check_value('AlsoClosed')); 125 126$cols = array( 127 _("#") => array('fun'=>'journal_pos', 'align'=>'center'), 128 _("Date") =>array('name'=>'tran_date','type'=>'date','ord'=>'desc'), 129 _("Type") => array('fun'=>'systype_name'), 130 _("Trans #") => array('fun'=>'view_link'), 131 _("Reference"), 132 _("Amount") => array('type'=>'amount'), 133 _("Memo"), 134 _("User"), 135 _("View") => array('insert'=>true, 'fun'=>'gl_link'), 136 array('insert'=>true, 'fun'=>'edit_link') 137); 138 139if (!check_value('AlsoClosed')) { 140 $cols[_("#")] = 'skip'; 141} 142 143$table =& new_db_pager('journal_tbl', $sql, $cols); 144 145$table->width = "80%"; 146 147display_db_pager($table); 148 149end_form(); 150end_page(); 151 152?> 153