Hi @zia, have you you enabled Negative Inventory in Setup?
276 05/20/2019 02:36:28 am
Re: Items Cost in negative in inventory sales report (35 replies, posted in Items and Inventory)
277 05/18/2019 10:47:17 am
Re: Customer Trial Balance Report (11 replies, posted in Reporting)
in rep115.php Line # 234 shall be modified as below
if (db_num_rows($res) == 0 && !$no_zeros)
278 05/18/2019 10:34:05 am
Re: Customer Trial Balance Report (11 replies, posted in Reporting)
In rep206.php Line # 168 shall be modified as below
if (db_num_rows($res) == 0 && !$no_zeros)
and Line # 181 shall be commented, Because ignoring the loop here is not adding up the values of $curr_cr, $curr_db and $item variables.
279 05/16/2019 10:05:56 am
Re: Writing Arabic in Fields with English User (5 replies, posted in Translations)
Great @rafat that worked for me thanks.
280 05/15/2019 07:09:34 pm
Topic: Writing Arabic in Fields with English User (5 replies, posted in Translations)
When logged in as a User with Language as English, Writing Arabic in Fields like Customer Name shows ?????????
While being logged in as a User with language as Arabic accepts it.
Even any customer name added in Arabic as an Arabic User shows as ??????? when logged in as English User.
How can we use Arabic to input some fields while Logged in as Arabic User?
281 05/07/2019 02:36:27 am
Re: Add stamp or watermark to reports on the fly – ad hoc. (15 replies, posted in FA Modifications)
Hmmm. I was trying from Customer Transaction Inquiry. So there shall be an option to Fix the Water Mark in Company Preferences so that even from Customer Transaction Inquiry the WaterMark appears.
282 05/07/2019 01:48:25 am
Re: Add stamp or watermark to reports on the fly – ad hoc. (15 replies, posted in FA Modifications)
Can't find any watermark in this report
283 05/05/2019 06:00:41 am
Re: Default Theme Redesigned And available For testing (47 replies, posted in Modules Add-on's)
@joe, can you provide the download link of flatcolor2 theme
284 04/28/2019 03:31:37 am
Re: How can i update my Arabic Language (12 replies, posted in Translations)
Hello @emiangel839 I just finished updating my arabic language using following steps. You also try them
1. Download POEdit
2. Add your Msg Strings like one below in PO file
msgid "Cost Centers"
msgstr "مراكز التكلفة"
3. Open PO file using this application
4. Validate your PO file
5. Compile PO file in MO file
6. Upload both files to the cloud server
7. Restart your Web Server (Apache).
8. Logout and then Login FA.
Note: If you are using a shared hosting then you won't be able to restart apache.
285 04/28/2019 02:47:41 am
Re: Cannot Download Repo Index File (6 replies, posted in Report Bugs here)
Facing this error on my live site
fopen(../tmp/ar_EG-2.4.1-3.pkg): failed to open stream: No such file or directory in file: /home/pakerp/web/pakerp.net/public_html/includes/remote_url.inc at line 81
/home/pakerp/web/pakerp.net/public_html/includes/remote_url.inc:81: fopen('../tmp/ar_EG-2.4.1-3.pkg','wb')
/home/pakerp/web/pakerp.net/public_html/includes/packages.inc:381: url_copy('http://anonymous:password@repo.frontaccounting.eu/2.4/languages/ar_EG-2.4.1-3.pkg','../tmp/ar_EG-2.4.1-3.pkg')
/home/pakerp/web/pakerp.net/public_html/includes/packages.inc:613: get_pkg_or_list('language','ar_EG')
/home/pakerp/web/pakerp.net/public_html/admin/inst_lang.php:273: install_language('ar_EG')
Cannot download 'http://anonymous:password@repo.frontaccounting.eu/2.4/languages/ar_EG-2.4.1-3.pkg' file.
/home/pakerp/web/pakerp.net/public_html/includes/ui/ui_msgs.inc:14: trigger_error('Cannot download 'http://anonymous:password@repo.frontaccounting.eu/2.4/languages/ar_EG-2.4.1-3.pkg' file.','256')
/home/pakerp/web/pakerp.net/public_html/includes/packages.inc:382: display_error('Cannot download 'http://anonymous:password@repo.frontaccounting.eu/2.4/languages/ar_EG-2.4.1-3.pkg' file.')
/home/pakerp/web/pakerp.net/public_html/includes/packages.inc:613: get_pkg_or_list('language','ar_EG')
/home/pakerp/web/pakerp.net/public_html/admin/inst_lang.php:273: install_language('ar_EG')
Package 'ar_EG' not found.
/home/pakerp/web/pakerp.net/public_html/includes/ui/ui_msgs.inc:14: trigger_error('Package 'ar_EG' not found.','256')
/home/pakerp/web/pakerp.net/public_html/includes/packages.inc:646: display_error('Package 'ar_EG' not found.')
/home/pakerp/web/pakerp.net/public_html/admin/inst_lang.php:273: install_language('ar_EG')
While on the latest repo I can download it. Unable to find the reason
286 04/25/2019 07:32:53 am
Re: Cost of Inventory For Back Dated Transactions (5 replies, posted in Items and Inventory)
Yes, I am also at Fix. Will think over it and try then revert
287 04/25/2019 06:25:55 am
Re: Cost of Inventory For Back Dated Transactions (5 replies, posted in Items and Inventory)
Yes, this can be done manually. He was insisting that system shall be smart enough to handle this automatically
288 04/25/2019 03:10:52 am
Topic: Cost of Inventory For Back Dated Transactions (5 replies, posted in Items and Inventory)
I have been put in a situation by one of my client (a chartered accountant).
Taking transactions of Item A.
Month 1: By Recording Sales and Purchases the Weight Avg Cost of Item A comes at 85.
Month 2: By Recording Sales and Purchases the Weight Avg Cost of Item A comes at 80.
Month 3: By Recording Sales and Purchases the Weight Avg Cost of Item A comes at 73.
Now client says that after reconciliation he found that he missed on Sales Entry of Month1. When he recorded that on backdate the system recorded the cost of inventory @ 73.
He says that by this the profit of Month1 is Over Valued. The system shall record the Back Dated Transactions on the cost of inventory prevailing in that date.
Can anyone help me how to combat this argument? Is it possible to record the back dated transactions the way he is suggesting and then adjusting the latest Average Cost accordingly.
Regards
289 04/22/2019 06:50:36 pm
Re: barcode (9 replies, posted in Reporting)
@apmuthu, thanks for this report. Very useful for me.
290 04/16/2019 07:17:36 am
Re: Website Transfer. (7 replies, posted in Announcements)
@Joe, I hope 2.5 Alpha will also incorporate the Dashboard widgets developed by @notrinos?
291 04/15/2019 09:51:53 am
Re: Website Transfer. (7 replies, posted in Announcements)
2.5 Alpha is anxiously awaited.
292 02/26/2019 05:40:14 pm
Re: Tax Inquiry - Does not show output tax info (114 replies, posted in Reporting)
config.php would be useful if one FA instance is used for one Company only. Since FA has the power to operate multiple companies with one instance, putting in config.php will contradict with each other may be.
293 02/26/2019 09:42:21 am
Re: Tax Inquiry - Does not show output tax info (114 replies, posted in Reporting)
Instead of config.php, better option is to add in company_preferences.php I guess.
294 02/26/2019 03:30:33 am
Re: Tax Inquiry - Does not show output tax info (114 replies, posted in Reporting)
@BraathWate, Now I could catch the bug. It appears only when Sales Tax Account is added as GL Line Item. It is duplicating the row in the rep709, hence the input tax value is incremented.
Apart from this that it is a Bug, I am unable to understand that why one needs to enter Sales Tax Account in the GL Line Item. When Sales Tax is Auto Applied to the Item being invoiced then why to enter Sales Tax Account in GL Line Item?
However, since we can't stop any one to select this Account (for any given reason) so this bug needs to be Fixed.
295 02/25/2019 05:29:47 pm
Re: Tax Inquiry - Does not show output tax info (114 replies, posted in Reporting)
Hello All,
I have tested on the latest repo without any customization suggested by @BraatWate.
My findings are that I can't find any bug related to #1 and #2.
Here is the screenshot.
You can also login to verify at
pakerp.net/fa242org
id: admin
pass: Pakistan1947
I can see both Inquiry and Report is showing the same results. And Input Tax is also included in both.
Regarding #3 I agree with @itronics but adding a check box is a good option.
I didn't test #4.
296 02/22/2019 02:58:12 am
Re: Tax Inquiry - Does not show output tax info (114 replies, posted in Reporting)
I have gone through the whole thread today. Unfortunately none of my Sites are using Purchase Taxes so I never hear of any bug from my clients. I will try to test it myself and shall revert.
297 02/21/2019 04:05:54 pm
Re: Bug in rep101.php (3 replies, posted in Report Bugs here)
@kvvaradha I am using the latest repo.
In the above thread you mentioned, your fix covers the transaction debiting customer through Journal Entry.
While my fix also covers the transactions crediting customers through journal entry.
Check the Screen Shot I attached.
298 02/20/2019 01:16:16 pm
Topic: Bug in rep101.php (3 replies, posted in Report Bugs here)
The line # 242 shall be fixed as below
if (($trans['type'] == ST_JOURNAL && $item[0]) || $trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT)
Other wise Any Transaction crediting Customer through JE will not be contained when the report is viewed Show Balance = No
299 02/19/2019 06:06:56 pm
Re: RepGen (4 replies, posted in Modules Add-on's)
@rafat, yes RepGen has issues. The default report however produces pdf but later you are not able to do anything.
Some points were discussed earlier here but couldn't get solution to it.
However the line
$file = $comp_path.'/'.user_company(). '/pdf_files/'.$id.'.pdf';
can be fixed as below
$file = $SysPrefs->comp_path.'/'.user_company(). '/pdf_files/'.$id.'.pdf';
300 02/13/2019 05:57:01 am
Topic: Customer Ledger as Inquiry (0 replies, posted in Accounts Receivable)
Here is the Code for Customer Ledger as Inquiry. For quick review of Customer's Ledger this is useful.
Here is the screen shot
<?php
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
Released under the terms of the GNU General Public License, GPL,
as published by the Free Software Foundation, either version 3
of the License, or (at your option) 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 License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_GLTRANSVIEW';
$path_to_root = "../..";
include_once($path_to_root . "/includes/session.inc");
include($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/admin/db/fiscalyears_db.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/modules/party_ledger/includes/addon.inc");// added by faisal
include_once($path_to_root . "/gl/includes/gl_db.inc");
$js = '';
set_focus('account');
if ($SysPrefs->use_popup_windows)
$js .= get_js_open_window(800, 500);
if (user_use_date_picker())
$js .= get_js_date_picker();
page(_($help_context = "General Ledger Inquiry"), false, false, '', $js);
//----------------------------------------------------------------------------------------------------
// Ajax updates
//
if (get_post('Show'))
{
$Ajax->activate('trans_tbl');
}
if (isset($_GET["account"]))
$_POST["account"] = $_GET["account"];
if (isset($_GET["TransFromDate"]))
$_POST["TransFromDate"] = $_GET["TransFromDate"];
if (isset($_GET["TransToDate"]))
$_POST["TransToDate"] = $_GET["TransToDate"];
if (isset($_GET["Dimension"]))
$_POST["Dimension"] = $_GET["Dimension"];
if (isset($_GET["Dimension2"]))
$_POST["Dimension2"] = $_GET["Dimension2"];
if (isset($_GET["amount_min"]))
$_POST["amount_min"] = $_GET["amount_min"];
if (isset($_GET["amount_max"]))
$_POST["amount_max"] = $_GET["amount_max"];
if (!isset($_POST["amount_min"]))
$_POST["amount_min"] = price_format(0);
if (!isset($_POST["amount_max"]))
$_POST["amount_max"] = price_format(0);
//----------------------------------------------------------------------------------------------------
function gl_inquiry_controls()
{
$dim = get_company_pref('use_dimension');
start_form();
start_table(TABLESTYLE_NOBORDER);
start_row();
//modified below by faisal
// gl_all_accounts_list_cells(_("Account:"), 'account', null, false, false, _("All Accounts"));
customer_list_cells(_('Select customer'), 'customer_id', null, false, true); //Edited by Phuong(Flat theme)
hidden('account', get_company_pref('debtors_act'));
//faisal modification ends
date_cells(_("from:"), 'TransFromDate', '', null, -user_transaction_days());
date_cells(_("to:"), 'TransToDate');
end_row();
end_table();
start_table(TABLESTYLE_NOBORDER);
start_row();
if ($dim >= 1)
dimensions_list_cells(_("Dimension")." 1:", 'Dimension', null, true, " ", false, 1);
if ($dim > 1)
dimensions_list_cells(_("Dimension")." 2:", 'Dimension2', null, true, " ", false, 2);
ref_cells(_("Memo:"), 'Memo', '',null, _('Enter memo fragment or leave empty'));
small_amount_cells(_("Amount min:"), 'amount_min', null, " ");
small_amount_cells(_("Amount max:"), 'amount_max', null, " ");
check_cells( _("By Entry Date:"), 'ByEntryDate', null);//added by faisal for Search by Entry Date
submit_cells('Show',_("Show"),'','', 'default');
end_row();
end_table();
echo '<hr>';
end_form();
}
//----------------------------------------------------------------------------------------------------
function show_results()
{
global $path_to_root, $systypes_array;
if (!isset($_POST["account"]))
$_POST["account"] = null;
$act_name = $_POST["account"] ? get_gl_account_name($_POST["account"]) : "";
$dim = get_company_pref('use_dimension');
/*Now get the transactions */
if (!isset($_POST['Dimension']))
$_POST['Dimension'] = 0;
if (!isset($_POST['Dimension2']))
$_POST['Dimension2'] = 0;
$result = get_gl_transactions($_POST['TransFromDate'], $_POST['TransToDate'], -1,
$_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], null,
input_num('amount_min'), input_num('amount_max'),PT_CUSTOMER, $_POST['customer_id'], $_POST['Memo'], check_value('ByEntryDate')); //modified by faisal
$colspan = ($dim == 2 ? "8" : ($dim == 1 ? "5" : "4")); //modified by faisal to accommodate entrydate
if ($_POST["account"] != null)
display_heading($_POST["account"]. " ".$act_name);
// Only show balances if an account is specified AND we're not filtering by amounts
$show_balances = $_POST["account"] != null &&
input_num("amount_min") == 0 &&
input_num("amount_max") == 0;
start_table(TABLESTYLE);
$first_cols = array(_("Type"), _("#"),_("Reference"), _("Date"), _("Entry Date"));
if ($_POST["account"] == null)
$account_col = array(_("Account"));
else
$account_col = array();
if ($dim == 2)
$dim_cols = array(_("Dimension")." 1", _("Dimension")." 2");
elseif ($dim == 1)
$dim_cols = array(_("Dimension"));
else
$dim_cols = array();
if ($show_balances)
$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Balance"), _("Memo"), "");
else
$remaining_cols = array(_("Person/Item"), _("Debit"), _("Credit"), _("Memo"), "");
$th = array_merge($first_cols, $account_col, $dim_cols, $remaining_cols);
table_header($th);
if ($_POST["account"] != null && is_account_balancesheet($_POST["account"]))
$begin = "";
else
{
$begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']);
if (date1_greater_date2($begin, $_POST['TransFromDate']))
$begin = $_POST['TransFromDate'];
$begin = add_days($begin, -1);
}
$bfw = 0;
if ($show_balances) {
$bfw = bx_get_gl_balance_from_to($begin, $_POST['TransFromDate'], $_POST["account"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['customer_id']); //modified by faisal
start_row("class='inquirybg'");
label_cell("<b>"._("Opening Balance")." - ".$_POST['TransFromDate']."</b>", "colspan=$colspan");
display_debit_or_credit_cells($bfw, true);
//below block added by faisal
if ($bfw>0)
{
$debit_total += $bfw;
}
else
{
$credit_total += ABS($bfw);
}
label_cell("");
label_cell("");
end_row();
}
$running_total = $bfw;
$j = 1;
$k = 0; //row colour counter
$debit_total = 0; //added by faisal
$credit_total =0;
while ($myrow = db_fetch($result))
{
alt_table_row_color($k);
$running_total += $myrow["amount"];
//below block added by faisal
if ($myrow["amount"]>0)
{
$debit_total += $myrow["amount"];
}
else
{
$credit_total += ABS($myrow["amount"]);
}
$trandate = sql2date($myrow["tran_date"]);
$entrydate = sql2date($myrow["stamp"]); //added by faisal
label_cell($systypes_array[$myrow["type"]]);
label_cell(get_gl_view_str($myrow["type"], $myrow["type_no"], $myrow["type_no"], true));
label_cell(get_trans_view_str($myrow["type"],$myrow["type_no"],$myrow['reference']));
label_cell($trandate);
label_cell($entrydate); //added by faisal
if ($_POST["account"] == null)
label_cell($myrow["account"] . ' ' . get_gl_account_name($myrow["account"]));
if ($dim >= 1)
label_cell(get_dimension_string($myrow['dimension_id'], true));
if ($dim > 1)
label_cell(get_dimension_string($myrow['dimension2_id'], true));
label_cell(payment_person_name($myrow["person_type_id"],$myrow["person_id"]));
display_debit_or_credit_cells($myrow["amount"]);
if ($show_balances)
amount_cell($running_total);
if ($myrow['memo_'] == "")
$myrow['memo_'] = get_comments_string($myrow['type'], $myrow['type_no']);
label_cell($myrow['memo_']);
if ($myrow["type"] == ST_JOURNAL)
echo "<td>" . trans_editor_link( $myrow["type"], $myrow["type_no"]) . "</td>";
else
label_cell("");
end_row();
$j++;
if ($j == 12)
{
$j = 1;
table_header($th);
}
}
//end of while loop
if ($show_balances) {
start_row("class='inquirybg'");
label_cell("<b>" . _("Ending Balance") ." - ".$_POST['TransToDate']. "</b>", "colspan=$colspan");
amount_cell($debit_total);
amount_cell($credit_total); //Added to display Debit and Creidt Total by Faisal
// display_debit_or_credit_cells($running_total, true); //commented by faisal
label_cell("");
label_cell("");
end_row();
}
end_table(2);
if (db_num_rows($result) == 0)
display_note(_("No general ledger transactions have been created for the specified criteria."), 0, 1);
}
//----------------------------------------------------------------------------------------------------
gl_inquiry_controls();
div_start('trans_tbl');
if (get_post('Show') || get_post('account'))
show_results();
div_end();
//----------------------------------------------------------------------------------------------------
end_page();
This page uses following function
function bx_get_gl_balance_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0, $person_id=null)
{
$from = date2sql($from_date);
$to = date2sql($to_date);
$sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans
WHERE account='$account'";
if ($from_date != "")
$sql .= " AND tran_date > '$from'";
if ($to_date != "")
$sql .= " AND tran_date < '$to'";
if ($dimension != 0)
$sql .= " AND dimension_id = ".($dimension<0 ? 0 : db_escape($dimension));
if ($dimension2 != 0)
$sql .= " AND dimension2_id = ".($dimension2<0 ? 0 : db_escape($dimension2));
if ($person_id)
$sql .= " AND person_id=".db_escape($person_id);
$result = db_query($sql, "The starting balance for account $account could not be calculated");
$row = db_fetch_row($result);
return $row[0];
}
core Function get_gl_transactions is customized to view ledger ByEntryDate. Sometimes it is needed for Audit purpose. If you dont' want to update core then rename it and use for this Inquiry module.
function get_gl_transactions($from_date, $to_date, $trans_no=0,
$account=null, $dimension=0, $dimension2=0, $filter_type=null,
$amount_min=null, $amount_max=null,$person_type=null, $person_id=null, $memo = '', $byentrydate=0) //argument added by faisal
{
global $SysPrefs;
$from = date2sql($from_date);
$to = date2sql($to_date);
//added a.stamp by faisal
if ($byentrydate == false)
{
$sql = "SELECT gl.*, a.stamp, j.event_date, j.doc_date, a.gl_seq, u.user_id, st.supp_reference, gl.person_id subcode,
IFNULL(IFNULL(sup.supp_name, debt.name), bt.person_id) as person_name,
IFNULL(gl.person_id, IFNULL(sup.supplier_id, IFNULL(debt.debtor_no, bt.person_id))) as person_id,
IF(gl.person_id, gl.person_type_id, IF(sup.supplier_id,". PT_SUPPLIER . "," . "IF(debt.debtor_no," . PT_CUSTOMER . "," .
"IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id,
IFNULL(st.tran_date, IFNULL(dt.tran_date, IFNULL(bt.trans_date, IFNULL(grn.delivery_date, gl.tran_date)))) as doc_date,
coa.account_name, ref.reference, IF(ISNULL(c.memo_), gl.memo_, CONCAT(gl.memo_,' ',c.memo_)) AS memo
FROM "
.TB_PREF."gl_trans gl
LEFT JOIN ".TB_PREF."voided v ON gl.type_no=v.id AND v.type=gl.type
LEFT JOIN ".TB_PREF."supp_trans st ON gl.type_no=st.trans_no AND st.type=gl.type AND (gl.type NOT IN (".ST_JOURNAL.",".ST_BULKDEPOSIT.") OR gl.person_id=st.supplier_id)
LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE."
LEFT JOIN ".TB_PREF."debtor_trans dt ON gl.type_no=dt.trans_no AND dt.type=gl.type AND (gl.type NOT IN (".ST_JOURNAL.",".ST_BULKDEPOSIT.") OR gl.person_id=dt.debtor_no)
LEFT JOIN ".TB_PREF."suppliers sup ON st.supplier_id=sup.supplier_id
LEFT JOIN ".TB_PREF."cust_branch branch ON dt.branch_code=branch.branch_code
LEFT JOIN ".TB_PREF."debtors_master debt ON dt.debtor_no=debt.debtor_no
LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
AND (bt.person_id != '' AND !ISNULL(bt.person_id))
LEFT JOIN ".TB_PREF."journal j ON j.type=gl.type AND j.trans_no=gl.type_no
LEFT JOIN ".TB_PREF."audit_trail a ON a.type=gl.type AND a.trans_no=gl.type_no AND NOT ISNULL(gl_seq)
LEFT JOIN ".TB_PREF."users u ON a.user=u.id
LEFT JOIN ".TB_PREF."comments c ON c.id=gl.type_no AND c.type=gl.type
LEFT JOIN ".TB_PREF."refs ref ON ref.type=gl.type AND ref.id=gl.type_no,"
.TB_PREF."chart_master coa
WHERE coa.account_code=gl.account
AND ISNULL(v.date_)
AND gl.tran_date >= '$from'
AND gl.tran_date <= '$to'
AND gl.amount <> 0";
if ($trans_no > 0)
$sql .= " AND gl.type_no LIKE ".db_escape('%'.$trans_no);;
if ($account != null)
$sql .= " AND gl.account = ".db_escape($account);
if ($dimension != 0)
$sql .= " AND gl.dimension_id = ".($dimension<0 ? 0 : db_escape($dimension));
if ($dimension2 != 0)
$sql .= " AND gl.dimension2_id = ".($dimension2<0 ? 0 : db_escape($dimension2));
if ($filter_type != null)
$sql .= " AND gl.type IN (" . $filter_type .")";
if ($amount_min != null)
$sql .= " AND ABS(gl.amount) >= ABS(".db_escape($amount_min).")";
if ($amount_max != null)
$sql .= " AND ABS(gl.amount) <= ABS(".db_escape($amount_max).")";
if ($memo)
$sql .= " AND (gl.memo_ LIKE ". db_escape("%$memo%") . " OR c.memo_ LIKE " . db_escape("%$memo%") . ")";
$sql .= " GROUP BY counter";
$sql .= " HAVING TRUE";
if ($person_type != 0)
$sql .= " AND person_type_id=".db_escape($person_type);
if ($person_id != 0)
$sql .= " AND person_id=".db_escape($person_id);
$sql .= " ORDER BY tran_date, counter";
}
else {
$sql = "SELECT gl.*, a.stamp, j.event_date, j.doc_date, a.gl_seq, u.user_id, st.supp_reference, gl.person_id subcode,
IFNULL(IFNULL(sup.supp_name, debt.name), bt.person_id) as person_name,
IFNULL(gl.person_id, IFNULL(sup.supplier_id, IFNULL(debt.debtor_no, bt.person_id))) as person_id,
IF(gl.person_id, gl.person_type_id, IF(sup.supplier_id,". PT_SUPPLIER . "," . "IF(debt.debtor_no," . PT_CUSTOMER . "," .
"IF(bt.person_id != '' AND !ISNULL(bt.person_id), bt.person_type_id, -1)))) as person_type_id,
IFNULL(st.tran_date, IFNULL(dt.tran_date, IFNULL(bt.trans_date, IFNULL(grn.delivery_date, gl.tran_date)))) as doc_date,
coa.account_name, ref.reference, IF(ISNULL(c.memo_), gl.memo_, CONCAT(gl.memo_,' ',c.memo_)) AS memo
FROM "
.TB_PREF."gl_trans gl
LEFT JOIN ".TB_PREF."voided v ON gl.type_no=v.id AND v.type=gl.type
LEFT JOIN ".TB_PREF."supp_trans st ON gl.type_no=st.trans_no AND st.type=gl.type AND (gl.type NOT IN (".ST_JOURNAL.",".ST_BULKDEPOSIT.") OR gl.person_id=st.supplier_id)
LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE." AND gl.person_id=grn.supplier_id
LEFT JOIN ".TB_PREF."debtor_trans dt ON gl.type_no=dt.trans_no AND dt.type=gl.type AND (gl.type NOT IN (".ST_JOURNAL.",".ST_BULKDEPOSIT.") OR gl.person_id=dt.debtor_no)
LEFT JOIN ".TB_PREF."suppliers sup ON st.supplier_id=sup.supplier_id OR grn.supplier_id=sup.supplier_id
LEFT JOIN ".TB_PREF."cust_branch branch ON dt.branch_code=branch.branch_code
LEFT JOIN ".TB_PREF."debtors_master debt ON dt.debtor_no=debt.debtor_no
LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
AND bt.person_type_id=gl.person_type_id AND bt.person_id=gl.person_id
LEFT JOIN ".TB_PREF."journal j ON j.type=gl.type AND j.trans_no=gl.type_no
LEFT JOIN ".TB_PREF."audit_trail a ON a.type=gl.type AND a.trans_no=gl.type_no AND NOT ISNULL(gl_seq)
LEFT JOIN ".TB_PREF."users u ON a.user=u.id
LEFT JOIN ".TB_PREF."comments c ON c.id=gl.type_no AND c.type=gl.type
LEFT JOIN ".TB_PREF."refs ref ON ref.type=gl.type AND ref.id=gl.type_no,"
.TB_PREF."chart_master coa
WHERE coa.account_code=gl.account
AND ISNULL(v.date_)
AND a.stamp >= '$from'
AND a.stamp <= '$to'
AND gl.amount <> 0";
if ($trans_no > 0)
$sql .= " AND gl.type_no LIKE ".db_escape('%'.$trans_no);;
if ($account != null)
$sql .= " AND gl.account = ".db_escape($account);
if ($dimension != 0)
$sql .= " AND gl.dimension_id = ".($dimension<0 ? 0 : db_escape($dimension));
if ($dimension2 != 0)
$sql .= " AND gl.dimension2_id = ".($dimension2<0 ? 0 : db_escape($dimension2));
if ($filter_type != null)
$sql .= " AND gl.type IN (" . $filter_type .")";
if ($amount_min != null)
$sql .= " AND ABS(gl.amount) >= ABS(".db_escape($amount_min).")";
if ($amount_max != null)
$sql .= " AND ABS(gl.amount) <= ABS(".db_escape($amount_max).")";
if ($memo)
$sql .= " AND (gl.memo_ LIKE ". db_escape("%$memo%") . " OR c.memo_ LIKE " . db_escape("%$memo%") . ")";
$sql .= " GROUP BY counter";
$sql .= " HAVING TRUE";
if ($person_type != 0)
$sql .= " AND person_type_id=".db_escape($person_type);
if ($person_id != 0)
$sql .= " AND person_id=".db_escape($person_id);
$sql .= " ORDER BY tran_date, counter";
return db_query($sql, "The transactions for could not be retrieved");
}
return db_query($sql, "The transactions for could not be retrieved");
}