X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Freports_classes.inc;h=f08a13b38ee06b3e9060bbba09ff4ed62e69836d;hb=510d6e1925c4d1621ae3efd85e117cc9bb4320f0;hp=a979588fe3cc55e8d959a56819142a56eb63ed7f;hpb=7b10804aae7a48abbe9f43eea1c85fe9ca41171a;p=fa-stable.git
diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc
index a979588f..f08a13b3 100644
--- a/reporting/includes/reports_classes.inc
+++ b/reporting/includes/reports_classes.inc
@@ -122,7 +122,7 @@ class Report
function getDisplay()
{
- global $path_to_root, $use_date_picker, $pdf_debug;
+ global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no;
$st = '';
$dummy = "";
@@ -134,8 +134,8 @@ class Report
switch ($param->param_type)
{
case 'CURRENCY':
- $sql = "SELECT curr_abrev, concat(curr_abrev,' - ', currency) FROM ".TB_PREF."currencies";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Currency Filter"));
+ $sql = "SELECT curr_abrev, concat(curr_abrev,' - ', currency) AS name FROM ".TB_PREF."currencies";
+ $st .= combo_input("PARAM_$index", '', $sql, 'curr_abrev', 'name',array('spec_option'=>_("No Currency Filter"),'spec_id'=>ALL_TEXT,'order'=>false));
break;
case 'DATE':
case 'DATEBEGIN':
@@ -163,8 +163,9 @@ class Report
$date = $edate;
else
{
- $bdate = add_months($edate, -$row['tax_prd'] + 1);
- $date = begin_month($bdate);
+ $bdate = begin_month($edate);
+ $bdate = add_months($bdate, -$row['tax_prd'] + 1);
+ $date = $bdate;
}
}
$name = "PARAM_$index";
@@ -196,7 +197,8 @@ class Report
$st .= dup_simple_name_list("PARAM_$index", $sel);
break;
case 'SYS_TYPES':
- $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), true);
+ case 'SYS_TYPES_ALL':
+ $st .= dup_systypes_list("PARAM_$index", $dummy, true, _("No Type Filter"), ($param->param_type=='SYS_TYPES_ALL'));
break;
case 'TEXT':
$st .= "";
@@ -205,64 +207,75 @@ class Report
$st .= "";
break;
case 'ACCOUNTS':
- $sql = "SELECT id, name FROM ".TB_PREF."chart_types ORDER BY name";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Account Group Filter"), true);
+ $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('spec_option'=>_("No Account Group Filter"),'spec_id'=>ALL_NUMERIC));
+ break;
+ case 'ACCOUNTS_NO_FILTER':
+ $sql = "SELECT id, name FROM ".TB_PREF."chart_types";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name', null);
break;
case 'GL_ACCOUNTS':
- $sql = "SELECT account_code, concat(account_code, ' - ', account_name) as account_name FROM ".TB_PREF."chart_master ORDER BY account_code";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
+ FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type WHERE chart.account_type=type.id";
+ $st .= combo_input("PARAM_$index", '', $sql, 'chart.account_code', 'chart.account_name',
+ array('format' => '_format_account','order' => array('type.id','account_code'),'async' => false,'category' => 2));
break;
case 'BANK_ACCOUNTS':
- $sql = "SELECT ".TB_PREF."bank_accounts.id, concat(bank_account_name, if (bank_curr_code=curr_default,'', concat(' - ', bank_curr_code))) FROM ".TB_PREF."bank_accounts, ".TB_PREF."company";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT ".TB_PREF."bank_accounts.id, concat(bank_account_name, if (bank_curr_code=curr_default,'', concat(' - ', bank_curr_code))) AS name FROM ".TB_PREF."bank_accounts, ".TB_PREF."company";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('order'=>array('id')));
break;
case 'DIMENSION':
- $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
break;
case 'DIMENSIONS':
- $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
+ $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
break;
case 'DIMENSION1':
- $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index". "_$index", $dummy);
+ $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=1";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
break;
case 'DIMENSIONS1':
- $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1 ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
+ $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=1";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
break;
case 'DIMENSION2':
- $sql = "SELECT reference, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT id, concat(reference, ' - ', name) AS DimName FROM ".TB_PREF."dimensions WHERE type_=2";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('order'=>array('reference')));
break;
case 'DIMENSIONS2':
- $sql = "SELECT reference, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2 ORDER BY reference";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Dimension Filter"), true);
+ $sql = "SELECT id, concat(reference, ' - ', name) as DimName FROM ".TB_PREF."dimensions WHERE type_=2";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'DimName',array('spec_option'=>_("No Dimension Filter"),'spec_id'=>0,'order'=>array('reference')));
break;
case 'CUSTOMERS_NO_FILTER':
case 'CUSTOMERS':
- $sql = "SELECT debtor_no, name FROM ".TB_PREF."debtors_master ORDER BY name";
+ $sql = "SELECT debtor_no, name FROM ".TB_PREF."debtors_master";
if ($param->param_type == 'CUSTOMERS_NO_FILTER')
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Customer Filter"), true);
+ $st .= combo_input("PARAM_$index", '', $sql, 'debtor_no', 'name',array('spec_option'=>_("No Customer Filter"),'spec_id'=>ALL_NUMERIC));
else
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $st .= combo_input("PARAM_$index", '', $sql, 'debtor_no', 'name', null);
break;
case 'SUPPLIERS_NO_FILTER':
case 'SUPPLIERS':
- $sql = "SELECT supplier_id, supp_name FROM ".TB_PREF."suppliers ORDER BY supp_name";
+ $sql = "SELECT supplier_id, supp_name FROM ".TB_PREF."suppliers";
if ($param->param_type == 'SUPPLIERS_NO_FILTER')
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Supplier Filter"), true);
+ $st .= combo_input("PARAM_$index", '', $sql, 'supplier_id', 'supp_name',array('spec_option'=>_("No Supplier Filter"),'spec_id'=>ALL_NUMERIC));
else
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $st .= combo_input("PARAM_$index", '', $sql, 'supplier_id', 'supp_name', null);
break;
case 'INVOICE':
$IV = _("IV");
$CN = _("CN");
- $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
- ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=10, ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
- FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=10 OR type=11) AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ if ($print_invoice_no == 1)
+ $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+ ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, if (type=".ST_SALESINVOICE.", ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+ else
+ $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-',
+ ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.reference, if (type=".ST_SALESINVOICE.", ' $IV ', ' $CN '), ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_SALESINVOICE." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
+ $st .= combo_input("PARAM_$index", '', $sql, 'TNO', 'IName',array('order'=>false));
break;
case 'DELIVERY':
$DN = _("DN");
@@ -270,53 +283,76 @@ class Report
concat(".TB_PREF."debtor_trans.trans_no, '-', ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.trans_no, ' $DN ',
".TB_PREF."debtors_master.name) as IName
FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans
- WHERE type=13 AND ".TB_PREF."debtors_master.debtor_no=".
+ WHERE type=".ST_CUSTDELIVERY." AND ".TB_PREF."debtors_master.debtor_no=".
TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $st .= combo_input("PARAM_$index", '', $sql, 'TNO', 'IName',array('order'=>false));
break;
case 'ORDERS':
$sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-',
".TB_PREF."debtors_master.name) as IName
- FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no ORDER BY ".TB_PREF."sales_orders.order_no DESC";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no
+ AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." ORDER BY ".TB_PREF."sales_orders.order_no DESC";
+ $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
+ break;
+ case 'QUOTATIONS':
+ $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.order_no, '-',
+ ".TB_PREF."debtors_master.name) as IName
+ FROM ".TB_PREF."debtors_master, ".TB_PREF."sales_orders WHERE ".TB_PREF."debtors_master.debtor_no=".TB_PREF."sales_orders.debtor_no
+ AND ".TB_PREF."sales_orders.trans_type=".ST_SALESQUOTE." ORDER BY ".TB_PREF."sales_orders.order_no DESC";
+ $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
break;
case 'PO':
$sql = "SELECT ".TB_PREF."purch_orders.order_no, concat(".TB_PREF."purch_orders.order_no, '-',
".TB_PREF."suppliers.supp_name) as IName
FROM ".TB_PREF."suppliers, ".TB_PREF."purch_orders WHERE ".TB_PREF."suppliers.supplier_id=".TB_PREF."purch_orders.supplier_id ORDER BY ".TB_PREF."purch_orders.order_no DESC";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $st .= combo_input("PARAM_$index", '', $sql, 'order_no', 'IName',array('order'=>false));
break;
case 'ITEMS':
- $sql = "SELECT stock_id, concat(stock_id, '-', description) as name FROM ".TB_PREF."stock_master WHERE (mb_flag='A' OR mb_flag='M') ORDER BY stock_id";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT stock_id, concat(stock_id, '-', description) as name FROM ".TB_PREF."stock_master WHERE (mb_flag='A' OR mb_flag='M')";
+ $st .= combo_input("PARAM_$index", '', $sql, 'stock_id', 'name',array('order'=>array('stock_id')));
+ break;
+ case 'WORKORDER':
+ $sql = "SELECT ".TB_PREF."workorders.id, concat(".TB_PREF."workorders.id, '-',
+ ".TB_PREF."stock_master.description) as IName
+ FROM ".TB_PREF."stock_master, ".TB_PREF."workorders WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id ORDER BY ".TB_PREF."workorders.id DESC";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'IName',array('order'=>false));
break;
case 'LOCATIONS':
- $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations ORDER BY location_name";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Location Filter"), false);
+ $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations";
+ $st .= combo_input("PARAM_$index", '', $sql, 'loc_code', 'location_name',array('spec_option'=>_("No Location Filter"),'spec_id'=>ALL_TEXT));
break;
case 'CATEGORIES':
- $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category ORDER BY description";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Category Filter"), true);
+ $sql = "SELECT category_id, description FROM ".TB_PREF."stock_category";
+ $st .= combo_input("PARAM_$index", '', $sql, 'category_id', 'description',array('spec_option'=>_("No Category Filter"),'spec_id'=>ALL_NUMERIC));
break;
case 'SALESTYPES':
- $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types ORDER BY sales_type";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT id, sales_type FROM ".TB_PREF."sales_types";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'sales_type', null);
break;
case 'AREAS':
- $sql = "SELECT area_code, description FROM ".TB_PREF."areas ORDER BY description";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Area Filter"), true);
+ $sql = "SELECT area_code, description FROM ".TB_PREF."areas";
+ $st .= combo_input("PARAM_$index", '', $sql, 'area_code', 'description',array('spec_option'=>_("No Area Filter"),'spec_id'=>ALL_NUMERIC));
break;
case 'SALESMEN':
- $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman ORDER BY salesman_name";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Sales Folk Filter"), true);
+ $sql = "SELECT salesman_code, salesman_name FROM ".TB_PREF."salesman";
+ $st .= combo_input("PARAM_$index", '', $sql, 'salesman_code', 'salesman_name',array('spec_option'=>_("No Sales Folk Filter"),'spec_id'=>ALL_NUMERIC));
break;
case 'TRANS_YEARS':
- $sql = "SELECT DISTINCT YEAR(tran_date), YEAR(tran_date) FROM ".TB_PREF."gl_trans";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ $sql = "SELECT DISTINCT YEAR(tran_date) AS tran_date, YEAR(tran_date) AS tran_date2 FROM ".TB_PREF."gl_trans";
+ $st .= combo_input("PARAM_$index", '', $sql, 'tran_date', 'tran_date2',array('order'=>array('tran_date')));
break;
- case 'ACCOUNTS_NO_FILTER':
- $sql = "SELECT id, name FROM ".TB_PREF."chart_types ORDER BY name";
- $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy);
+ case 'USERS':
+ $sql = "SELECT id, user_id FROM ".TB_PREF."users";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'user_id',array('spec_option'=>_("No Users Filter"),'spec_id'=>ALL_NUMERIC));
+ break;
+ case 'ACCOUNTTAGS':
+ case 'DIMENSIONTAGS':
+ if ($param->param_type == 'ACCOUNTTAGS')
+ $type = TAG_ACCOUNT;
+ else
+ $type = TAG_DIMENSION;
+ $sql = "SELECT id, name FROM ".TB_PREF."tags WHERE type=$type";
+ $st .= combo_input("PARAM_$index", '', $sql, 'id', 'name',array('spec_option'=>_("No tags"),'spec_id' => ALL_NUMERIC,'multi'=>true,'height'=>5));
break;
}
@@ -338,62 +374,6 @@ class ReportParam
}
}
-function dup_simple_codeandname_list($sql, $name, &$selected_id,
- $all_option=false, $all_option_name=null, $all_option_numeric=false,
- $submit_on_change=false)
-{
- if ($submit_on_change == true)
- $st = "