X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Fincludes%2Freports_classes.inc;h=56148d70e8607a537daa3ca1a3f4285ad9d4f0fd;hb=5a3cbfe6d2df1c8c32edcab8bf93e8a8432a15fc;hp=97bfa0f6e2845a4b5aba147316831815a8d48968;hpb=303eb17e9cdd9702eee9fdfcaee51e654a1da541;p=fa-stable.git diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index 97bfa0f6..56148d70 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -9,106 +9,121 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ + +// Standard report classess +define('RC_CUSTOMER', 0); +define('RC_SUPPLIER', 1); +define('RC_INVENTORY', 2); +define('RC_MANUFACTURE', 3); +define('RC_DIMENSIONS', 4); +define('RC_BANKING', 5); +define('RC_GL', 6); +define('RC_FIXEDASSETS', 7); + class BoxReports { - var $ar_classes; + var $ar_classes; // report class names + var $ar_reports; var $ctrl_handlers = array(); - function ReportClasses() + function __construct() { $this->ar_classes = array(); } - function addReportClass($class_name) + function addReportClass($class_name, $class_id=null) { - $this->ar_classes[$class_name] = array(); + if (!$class_id) + $class_id = count($this->ar_classes); + $this->ar_classes[$class_id] = $class_name; + + return $class_id; } - function addReport($class_name, $id, $rep_name, $params=null) + function addReport($class, $id, $rep_name, $params=null) { - unset($this->ar_classes[$class_name][$id]); // unset std report if any - $this->ar_classes[$class_name][$id] = new Report($id, $rep_name, $params); + unset($this->ar_reports[$class][$id]); // unset std report if any + $this->ar_reports[$class][$id] = new Report($id, $rep_name, $params); } function getDisplay($class=null) { - global $table_style, $comp_path, $path_to_root, $pdf_debug, $Ajax; + global $path_to_root, $SysPrefs, $Ajax; + if (find_submit('Rep') != -1) { + include($path_to_root.'/reporting/prn_redirect.php'); + return; + } $temp = array_values($this->ar_classes); $display_class = $class==null ? $temp[0] : $this->ar_classes[$class]; - $class_counter = 0; - $rep_counter = 0; $st_reports = ""; $st_params = ""; $st_classes = "" . _("Report Classes:") . "
"; - foreach($this->ar_classes as $key=>$value) + + if (isset($_GET['Class'])) + set_focus('class'.$_GET['Class']); + + $cur_class = $_REQUEST['Class']; + + foreach($this->ar_classes as $class_id => $name) { - $style = $class_counter==$_REQUEST['Class'] ? '' : "style='display:none'"; - $acc = access_string($key); + if (!isset($this->ar_reports[$class_id])) + continue; // e.g. no dimensions + + $acc = access_string($name); $st_classes .= "$acc[0]
"; - $st_reports .= "\n"; - foreach($value as $report) + .$_SERVER['PHP_SELF']."?Class=$class_id'" + ." style='font-weight:". ($cur_class == $class_id ? 'bold' : 'normal')."'" + ." class='repclass_link' id='".'class'.$class_id."'" + ."$acc[1]>$acc[0]
"; + + $style = $class_id==$cur_class ? '' : "style='display:none'"; + $st_reports .= "
" . _("Reports For Class: ") . " $key
\n"; + foreach($this->ar_reports[$class_id] as $rep_id => $report) { $acc = access_string($report->name); - $st_reports .= "
" . _("Reports For Class: ") . " $name
id'" - ." id='".default_focus()."'" + $st_reports .= "
id'" + ." style='font-weight:". (@$_REQUEST['REP_ID'] == $report->id ? 'bold' : 'normal')."'" + ." id='".$id = default_focus()."'" ."$acc[1]>$acc[0]
\n"; - if (isset($_REQUEST['rep_id']) && $_REQUEST['rep_id']==$report->id) { - $action = $path_to_root.'/reporting/prn_redirect.php'; - - $st_params = "
\n" + if (@$_REQUEST['REP_ID'] == $report->id) { + $Ajax->activate($id); + } + + if (isset($_REQUEST['REP_ID']) && $_REQUEST['REP_ID']==$report->id) { + // parameters form + $action = $_SERVER['PHP_SELF']; + $st_params = "
\n" . "
\n"; $st_params .= submit('Rep'.$report->id, _("Display: ") . access_string($report->name, true), - false, '', $pdf_debug ? false : 'default') . hidden('REP_ID', $report->id, false).'

'; - $st_params .= $this->getOptions($report->get_controls()); - $st_params .= "\n
\n"; + false, '', $SysPrefs->pdf_debug ? false : 'default process') . hidden('REP_ID', $report->id, false).'

'; + $st_params .= $this->getOptions($report->get_controls(), $report->id); + $st_params .= "\n" + ."\n
\n"; set_focus('Rep'.$report->id); $Ajax->addUpdate(true, 'rep_form', $st_params); } } $st_reports .= "
"; - $class_counter++; } $st_params = "
". "$st_params
"; - - $st = " - "; - $st .= ""; + $st = "
"; $st .= ""; - $st .= ""; + $st .= ""; $st .= ""; $st .= "
$st_classes$st_reports$st_reports$st_params

"; return $st; } - function getOptions($controls) + function getOptions($controls, $id = 0) { $st = ''; if ($controls == null) @@ -123,6 +138,11 @@ class BoxReports if ($ctrl) break; } if ($ctrl == '') { + if (($id == 102 || $id == 202) && $cnt == 3) // set default Show Also Allocated to Yes in aged reports 2014-09-19 Joe Hunt + $_POST['PARAM_'.$cnt] = 1; + + if (isset($_COOKIE['select'][$id][$cnt])) // saved parameters 2010-10-06 Joe Hunt + $_POST['PARAM_'.$cnt] = $_COOKIE['select'][$id][$cnt]; $ctrl = $this->get_ctrl('PARAM_'.$cnt, $type); } if ($ctrl != '') { @@ -148,7 +168,8 @@ class BoxReports // function get_ctrl($name, $type) { - global $path_to_root, $use_date_picker, $pdf_debug, $print_invoice_no; + global $path_to_root, $SysPrefs, + $type_shortcuts; $st = ''; switch ($type) @@ -164,35 +185,43 @@ class BoxReports case 'DATEENDM': case 'DATEBEGINTAX': case 'DATEENDTAX': - if ($type == 'DATEBEGIN') - $date = begin_fiscalyear(); - elseif ($type == 'DATEEND') - $date = end_fiscalyear(); - else - $date = Today(); - if ($type == 'DATEBEGINM') - $date = begin_month($date); - elseif ($type == 'DATEENDM') - $date = end_month($date); - elseif ($type == 'DATEBEGINTAX' || $type == 'DATEENDTAX') + if (!isset($_POST[$name])) { - $row = get_company_prefs(); - $edate = add_months($date, -$row['tax_last']); - $edate = end_month($edate); - if ($type == 'DATEENDTAX') - $date = $edate; + if ($type == 'DATEBEGIN') + $date = begin_fiscalyear(); + elseif ($type == 'DATEEND') + $date = end_fiscalyear(); else + $date = Today(); + if ($type == 'DATEBEGINM') + $date = begin_month($date); + elseif ($type == 'DATEENDM') + $date = end_month($date); + elseif ($type == 'DATEBEGINTAX' || $type == 'DATEENDTAX') { - $bdate = begin_month($edate); - $bdate = add_months($bdate, -$row['tax_prd'] + 1); - $date = $bdate; + $row = get_company_prefs(); + $edate = add_months($date, -$row['tax_last']); + $edate = end_month($edate); + if ($type == 'DATEENDTAX') + $date = $edate; + else + { + $bdate = begin_month($edate); + $bdate = add_months($bdate, -$row['tax_prd'] + 1); + $date = $bdate; + } } } - + else // saved parameters + $date = $_POST[$name]; $st = ""; - if ($use_date_picker) + if (user_use_date_picker()) + { + $calc_image = (file_exists("$path_to_root/themes/".user_theme()."/images/cal.gif")) ? + "$path_to_root/themes/".user_theme()."/images/cal.gif" : "$path_to_root/themes/default/images/cal.gif"; $st .= "" - . " "._(\n"; + . " "._(\n"; + } return $st; break; @@ -200,12 +229,21 @@ class BoxReports return yesno_list($name); case 'PAYMENT_LINK': - $sel = array(_("No payment Link"), "PayPal"); - return array_selector($name, null, $sel); + return payment_services($name, null); case 'DESTINATION': $sel = array(_("PDF/Printer"), "Excel"); - return array_selector($name, null, $sel); + $def = 0; + if (user_def_print_destination() == 1) + $def = 1; + return array_selector($name, $def, $sel); + + case 'ORIENTATION': + $sel = array(_("Portrait"), _("Landscape")); + $def = 0; + if (user_def_print_orientation() == 1) + $def = 1; + return array_selector($name, $def, $sel); case 'COMPARE': $sel = array(_("Accumulated"), _("Period Y-1"), _("Budget")); @@ -226,7 +264,8 @@ class BoxReports return ""; case 'TEXTBOX': - return ""; + $value = (isset($_POST[$name]) ? $_POST[$name] : ""); + return ""; case 'ACCOUNTS': // not used return gl_account_types_list($name, null, _("No Account Group Filter"), true); @@ -260,108 +299,137 @@ class BoxReports case 'CUSTOMERS_NO_FILTER': case 'CUSTOMERS': - $sql = "SELECT debtor_no, name FROM ".TB_PREF."debtors_master"; if ($type == 'CUSTOMERS_NO_FILTER') - return combo_input($name, '', $sql, 'debtor_no', 'name',array('spec_option'=>_("No Customer Filter"),'spec_id'=>ALL_NUMERIC)); -// FIX allitems numeric! -// return customer_list($name, null, _("No Customer Filter")); + return customer_list($name, null, _("No Customer Filter")); else - return combo_input($name, '', $sql, 'debtor_no', 'name', null); -// return customer_list($name); + return customer_list($name); case 'SUPPLIERS_NO_FILTER': case 'SUPPLIERS': - $sql = "SELECT supplier_id, supp_name FROM ".TB_PREF."suppliers"; if ($type == 'SUPPLIERS_NO_FILTER') - return combo_input($name, '', $sql, 'supplier_id', 'supp_name',array('spec_option'=>_("No Supplier Filter"),'spec_id'=>ALL_NUMERIC)); -// FIX allitems numeric! -// return supplier_list($name, null, _("No Supplier Filter")); + return supplier_list($name, null, _("No Supplier Filter")); else - return combo_input($name, '', $sql, 'supplier_id', 'supp_name', null); -// return supplier_list($name); + return supplier_list($name); case 'INVOICE': - $IV = _("IV"); - $CN = _("CN"); - $ref = ($print_invoice_no == 1 ? "trans_no" : "reference"); - $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', - ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, 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"; + $IV = $type_shortcuts[ST_SALESINVOICE]; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO, + concat('$IV ', debtor_trans.$ref,' ', debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."debtor_trans debtor_trans + WHERE type=".ST_SALESINVOICE." AND debtor.debtor_no=debtor_trans.debtor_no + ORDER BY debtor_trans.trans_no DESC"; + return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); + + case 'CREDIT': + $CN = $type_shortcuts[ST_CUSTCREDIT]; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO, + concat('$CN ', debtor_trans.$ref,' ', debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."debtor_trans debtor_trans + WHERE type=".ST_CUSTCREDIT." AND debtor.debtor_no=debtor_trans.debtor_no + ORDER BY debtor_trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); case 'DELIVERY': - $DN = _("DN"); - $sql = "SELECT - 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=".ST_CUSTDELIVERY." AND ".TB_PREF."debtors_master.debtor_no=". - TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + $DN = $type_shortcuts[ST_CUSTDELIVERY]; + $sql = "SELECT concat(debtor_trans.trans_no, '-', debtor_trans.type) AS TNO, + concat(debtor_trans.trans_no, ' $DN ', debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."debtor_trans debtor_trans + WHERE type=".ST_CUSTDELIVERY." AND debtor.debtor_no=debtor_trans.debtor_no + ORDER BY debtor_trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); case 'ORDERS': - $ref = ($print_invoice_no == 1 ? "order_no" : "reference"); - $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.$ref, '-', - ".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_SALESORDER." ORDER BY ".TB_PREF."sales_orders.order_no DESC"; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "order_no" : "reference"); + $sql = "SELECT sorder.order_no, concat(sorder.$ref, '-', debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."sales_orders sorder + WHERE debtor.debtor_no=sorder.debtor_no AND sorder.trans_type=".ST_SALESORDER + ." ORDER BY sorder.order_no DESC"; return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false)); case 'QUOTATIONS': - $ref = ($print_invoice_no == 1 ? "order_no" : "reference"); - $sql = "SELECT ".TB_PREF."sales_orders.order_no, concat(".TB_PREF."sales_orders.$ref, '-', - ".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"; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "order_no" : "reference"); + $sql = "SELECT sorder.order_no, concat(sorder.$ref, '-', debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."sales_orders sorder + WHERE debtor.debtor_no=sorder.debtor_no AND sorder.trans_type=".ST_SALESQUOTE + ." ORDER BY sorder.order_no DESC"; return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false)); case 'PO': - $ref = ($print_invoice_no == 1 ? "order_no" : "reference"); - $sql = "SELECT ".TB_PREF."purch_orders.order_no, concat(".TB_PREF."purch_orders.$ref, '-', - ".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"; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "order_no" : "reference"); + $sql = "SELECT po.order_no, concat(po.$ref, '-', supplier.supp_name) as IName + FROM ".TB_PREF."suppliers supplier," + .TB_PREF."purch_orders po + WHERE supplier.supplier_id=po.supplier_id + ORDER BY po.order_no DESC"; return combo_input($name, '', $sql, 'order_no', 'IName',array('order'=>false)); case 'REMITTANCE': - $BP = _("BP"); - $SP = _("SP"); - $CN = _("CN"); - $ref = ($print_invoice_no == 1 ? "trans_no" : "reference"); - $sql = "SELECT concat(".TB_PREF."supp_trans.trans_no, '-', - ".TB_PREF."supp_trans.type) AS TNO, concat(".TB_PREF."supp_trans.$ref, if (type=".ST_BANKPAYMENT.", ' $BP ', if (type=".ST_SUPPAYMENT.", ' $SP ', ' $CN ')), ".TB_PREF."suppliers.supp_name) as IName - FROM ".TB_PREF."suppliers, ".TB_PREF."supp_trans WHERE (type=".ST_BANKPAYMENT." OR type=".ST_SUPPAYMENT." OR type=".ST_SUPPCREDIT.") AND ".TB_PREF."suppliers.supplier_id=".TB_PREF."supp_trans.supplier_id ORDER BY ".TB_PREF."supp_trans.trans_no DESC"; + $BP = $type_shortcuts[ST_BANKPAYMENT]; + $SP = $type_shortcuts[ST_SUPPAYMENT]; + $CN = $type_shortcuts[ST_SUPPCREDIT]; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(trans.trans_no, '-',trans.type) AS TNO, + concat(trans.$ref, IF(type=".ST_BANKPAYMENT.", ' $BP ', IF(type=".ST_SUPPAYMENT.", ' $SP ', ' $CN ')), supplier.supp_name) as IName + FROM ".TB_PREF."suppliers supplier, " + .TB_PREF."supp_trans trans + WHERE type IN(".ST_BANKPAYMENT.",".ST_SUPPAYMENT.",".ST_SUPPCREDIT.") + AND supplier.supplier_id=trans.supplier_id + ORDER BY trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); case 'RECEIPT': - $BD = _("BD"); - $CP = _("CP"); - $CN = _("CN"); - $ref = ($print_invoice_no == 1 ? "trans_no" : "reference"); - $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', - ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, if (type=".ST_BANKDEPOSIT.", ' $BD ', if (type=".ST_CUSTPAYMENT.", ' $CP ', ' $CN ')), ".TB_PREF."debtors_master.name) as IName - FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_BANKDEPOSIT." OR type=".ST_CUSTPAYMENT." 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"; + $BD = $type_shortcuts[ST_BANKDEPOSIT]; + $CP = $type_shortcuts[ST_CUSTPAYMENT]; + $ref = ($SysPrefs->print_invoice_no() == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(trans.trans_no, '-', trans.type) AS TNO, + concat(trans.$ref, IF(type=".ST_BANKDEPOSIT.", ' $BD ', ' $CP '), debtor.name) as IName + FROM ".TB_PREF."debtors_master debtor," + .TB_PREF."debtor_trans trans + WHERE type IN(".ST_BANKDEPOSIT.",".ST_CUSTPAYMENT.",".ST_CUSTCREDIT.") AND debtor.debtor_no=trans.debtor_no + ORDER BY trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); case 'ITEMS': return stock_manufactured_items_list($name); + case 'ITEMS_ALL': + return stock_manufactured_items_list($name, null, true); + + case 'ITEMS_P': + return stock_purchasable_items_list($name, null, true); + 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"; + $sql = "SELECT wo.id, concat(wo.id, '-', item.description) as IName + FROM ".TB_PREF."stock_master item," + .TB_PREF."workorders wo + LEFT JOIN ".TB_PREF."voided v ON wo.id=v.id and v.type=".ST_WORKORDER." + WHERE item.stock_id=wo.stock_id + ORDER BY wo.id DESC"; return combo_input($name, '', $sql, 'id', 'IName',array('order'=>false)); case 'LOCATIONS': return locations_list($name, null, _("No Location Filter")); + case 'FLOCATIONS': + return locations_list($name, null, _("No Location Filter"), false, true); case 'CATEGORIES': return stock_categories_list($name, null, _("No Category Filter")); - + case 'FCATEGORIES': + return stock_categories_list($name, null, _("No Category Filter"), false, true); + case 'FCLASS': + return fixed_asset_classes_list($name, null, _("No Class Filter"), false); case 'SALESTYPES': return sales_types_list($name); case 'AREAS': - return sales_areas_list($name); + return sales_areas_list($name, null, _("No Areas Filter")); case 'SALESMEN': return sales_persons_list($name, null, _("No Sales Folk Filter")); @@ -379,7 +447,7 @@ class BoxReports $tag_type = TAG_ACCOUNT; else $tag_type = TAG_DIMENSION; - return tag_list($name, 5, $tag_type, true, _("No tags")); + return tag_list($name, 5, $tag_type, true); } return ''; @@ -393,7 +461,7 @@ class Report var $ar_params; var $controls; - function Report($id, $name, $ar_params = null) + function __construct($id, $name, $ar_params = null) { $this->id = $id; $this->name = $name; @@ -429,25 +497,29 @@ function gl_systypes_list($name, $value=null, $spec_opt=false) ) ); } - +/* + Add extension/custom reports to report manager. +*/ function add_custom_reports(&$reports) { - global $installed_extensions, $path_to_root, $comp_path; + global $installed_extensions, $path_to_root; // include reports installed inside extension modules if (count($installed_extensions) > 0) { $extensions = $installed_extensions; foreach ($extensions as $ext) - if (($ext['active'] && $ext['type'] == 'module')) { + if (($ext['active'] && $ext['type'] == 'extension')) { $file = $path_to_root.'/'.$ext['path']."/reporting/reports_custom.php"; - if (file_exists($file)) + if (file_exists($file)) { + set_ext_domain($ext['path']); include_once($file); + set_ext_domain(); + } } } - $file = $comp_path.'/'.user_company()."/reporting/reports_custom.php"; + $file = company_path()."/reporting/reports_custom.php"; if (file_exists($file)) include_once($file); } -?> \ No newline at end of file