<?php
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
<?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
+ 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
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
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_SUPPLIERANALYTIC';
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_SUPPLIERANALYTIC';
{
$todate = date2sql($to);
$PastDueDays1 = get_company_pref('past_due_days');
$PastDueDays2 = 2 * $PastDueDays1;
// Revomed allocated from sql
{
$todate = date2sql($to);
$PastDueDays1 = get_company_pref('past_due_days');
$PastDueDays2 = 2 * $PastDueDays1;
// Revomed allocated from sql
- $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)";
+ if ($all)
+ $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)";
+ else
+ $value = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_BANKDEPOSIT.",
+ (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount - ".TB_PREF."supp_trans.alloc),
+ (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount + ".TB_PREF."supp_trans.alloc))";
$due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)";
$sql = "SELECT ".TB_PREF."supp_trans.type,
".TB_PREF."supp_trans.reference,
$due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)";
$sql = "SELECT ".TB_PREF."supp_trans.type,
".TB_PREF."supp_trans.reference,
AND ".TB_PREF."suppliers.supplier_id = ".TB_PREF."supp_trans.supplier_id
AND ".TB_PREF."supp_trans.supplier_id = $supplier_id
AND ".TB_PREF."supp_trans.tran_date <= '$todate'
AND ".TB_PREF."suppliers.supplier_id = ".TB_PREF."supp_trans.supplier_id
AND ".TB_PREF."supp_trans.supplier_id = $supplier_id
AND ".TB_PREF."supp_trans.tran_date <= '$todate'
- AND ABS(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) > 0.004
- ORDER BY ".TB_PREF."supp_trans.tran_date";
+ AND ABS(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) > ".FLOAT_COMP_DELTA." ";
+ if (!$all)
+ $sql .= "AND ABS(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount) - ".TB_PREF."supp_trans.alloc > ".FLOAT_COMP_DELTA." ";
+ $sql .= "ORDER BY ".TB_PREF."supp_trans.tran_date";
- $summaryOnly = $_POST['PARAM_3'];
- $no_zeros = $_POST['PARAM_4'];
- $graphics = $_POST['PARAM_5'];
- $comments = $_POST['PARAM_6'];
- $destination = $_POST['PARAM_7'];
+ $show_all = $_POST['PARAM_3'];
+ $summaryOnly = $_POST['PARAM_4'];
+ $no_zeros = $_POST['PARAM_5'];
+ $graphics = $_POST['PARAM_6'];
+ $comments = $_POST['PARAM_7'];
+ $orientation = $_POST['PARAM_8'];
+ $destination = $_POST['PARAM_9'];
if ($destination)
include_once($path_to_root . "/reporting/includes/excel_report.inc");
else
include_once($path_to_root . "/reporting/includes/pdf_report.inc");
if ($destination)
include_once($path_to_root . "/reporting/includes/excel_report.inc");
else
include_once($path_to_root . "/reporting/includes/pdf_report.inc");
2 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''),
3 => array('text' => _('Currency'),'from' => $currency,'to' => ''),
4 => array('text' => _('Type'), 'from' => $summary,'to' => ''),
2 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''),
3 => array('text' => _('Currency'),'from' => $currency,'to' => ''),
4 => array('text' => _('Type'), 'from' => $summary,'to' => ''),
- 5 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
+ 5 => array('text' => _('Show Also Allocated'), 'from' => $show, 'to' => ''),
+ 6 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
- $rep = new FrontReport(_('Aged Supplier Analysis'), "AgedSupplierAnalysis", user_pagesize());
+ $rep = new FrontReport(_('Aged Supplier Analysis'), "AgedSupplierAnalysis", user_pagesize(), 9, $orientation);
+ if ($orientation == 'L')
+ recalculate_cols($cols);
$rep->Font();
$rep->Info($params, $cols, $headers, $aligns);
$rep->NewPage();
$rep->Font();
$rep->Info($params, $cols, $headers, $aligns);
$rep->NewPage();
$pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days');
$sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers";
$pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days');
$sql = "SELECT supplier_id, supp_name AS name, curr_code FROM ".TB_PREF."suppliers";
$sql .= " WHERE supplier_id=".db_escape($fromsupp);
$sql .= " ORDER BY supp_name";
$result = db_query($sql, "The suppliers could not be retrieved");
$sql .= " WHERE supplier_id=".db_escape($fromsupp);
$sql .= " ORDER BY supp_name";
$result = db_query($sql, "The suppliers could not be retrieved");
- $supprec = get_supplier_details($myrow['supplier_id'], $to);
- foreach ($supprec as $i => $value)
- $supprec[$i] *= $rate;
+ $supprec = get_supplier_details($myrow['supplier_id'], $to, $show_all);
+ if (!$supprec)
+ continue;
+ $supprec['Balance'] *= $rate;
+ $supprec['Due'] *= $rate;
+ $supprec['Overdue1'] *= $rate;
+ $supprec['Overdue2'] *= $rate;
$str = array($supprec["Balance"] - $supprec["Due"],
$supprec["Due"]-$supprec["Overdue1"],
$str = array($supprec["Balance"] - $supprec["Due"],
$supprec["Due"]-$supprec["Overdue1"],
$pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2);
$pg->title = $rep->title;
$pg->axis_x = _("Days");
$pg->axis_y = _("Amount");
$pg->graphic_1 = $to;
$pg->type = $graphics;
$pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2);
$pg->title = $rep->title;
$pg->axis_x = _("Days");
$pg->axis_y = _("Amount");
$pg->graphic_1 = $to;
$pg->type = $graphics;
- $pg->fontfile = $path_to_root . "/reporting/fonts/Vera.ttf";
- $pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
- $filename = company_path(). "/pdf_files/test.png";
+ $pg->latin_notation = ($SysPrefs->decseps[user_dec_sep()] != ".");
+ $filename = company_path(). "/pdf_files/". uniqid("").".png";