From: Janusz Dobrowolski Date: Thu, 24 Dec 2009 11:29:03 +0000 (+0000) Subject: Merged changes from main trunk 2.2.1-2.2.2 X-Git-Tag: v2.4.2~19^2~1005 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=49d2702ed98abe7a564a4abb4c8c5fa225f362e8 Merged changes from main trunk 2.2.1-2.2.2 --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d01617b5..8c55b45f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,110 @@ Legend: ! -> Note $ -> Affected files +24-Dec-2009 Merged changes from main trunk 2.2.1-2.2.2 as follows + +! Release 2.2.2 +$ /update.html +! Changed so Printed Sales Order (Quotation) shows TOTAL VAT INCL. if it is. +$ /reporting/rep109.php + /reporting/rep111.php + /reporting/includes/doctext.inc + /reporting/includes/doctext2.inc +# Restoring journal entry sql to previous without join with bank_trans + due to error in joins. Tom Hallman works on it until 2.2.3 +$ /gl/inquiry/journal_inquiry.php +! Replaced all deprecated functions so FA runs in php >= 5.3.0 as well. +$ /admin/db/maintenance_db.inc + /gl/gl_bank.php + /includes/db_pager.inc + /includes/session.inc + /includes/lang/language.php + /includes/page/header.inc + /install/save.php + /inventory/adjustments.php + /inventory/transfers.php + /purchasing/supplier_invoice.php + /purchasing/allocations/supplier_allocate.php + /purchasing/includes/ui/po_ui.inc + /reporting/includes/class.graphic.inc + /reporting/includes/tcpdf.php + /reporting/includes/Workbook.php + /sales/allocations/customer_allocate.php + +22-Dec-2009 Joe Hunt +! Some additional changes in pdf_report.inc for supporting report extensions. +$ /reporting/includes/pdf_report.inc + /reporting/includes/excel_report.inc + +21-Dec-2009 Chaitanya/Janusz Dobrowolski +# [0000184] Bad source document quantities update and invalid qtys during + derivative document entry. +$ /sales/includes/cart_class.inc + /sales/includes/sales_db.inc +# Fixed quantity columns descriptions in delivery edition. +$ /sales/customer_delivery.php + +21-Dec-2009 Joe Hunt +# Function money_format function doesn't exist in OS Win. Fix in current_user.inc + Some errors in header3() in pdf_report.inc. +$ /includes/current_user.inc + /reporting/includes/pdf_report.inc + +18-Dec-2009 Joe Hunt +# Allowing a quantity of 0 in a PO item line when modifying caused strange result. + Fixed depending on the decimals in the stock item to not allow less than minimum. +$ /purchasing/po_entry_items.php + +12-Dec-2009 Joe Hunt +! Implemented search on categories as well in sales_items_list... +$ /includes/ui/ui_lists.inc + +09-Dec-2009 Janusz Dobrowolski ++ Added system diagnostics page +$ /admin/system_diagnostics.php + /applications/setup.php + +08-Dec-2009 Tom Hallman/Joe Hunt ++ Extended the Report Engine to better support own reports +$ /reporting/includes/class.pdf.inc + /reporting/includes/excel_report.inc + /reporting/includes/pdf_report.inc + /reporting/includes/tcpdf.php + /reporting/fonts/courier.php (new file) + /reporting/fonts/times.php (new file) + /reporting/fonts/timesb.php (new file) + /reporting/fonts/timesbi.php (new file) + /reporting/fonts/timesi.php (new file) + /reporting/fonts/symbol.php (new file) + /reporting/fonts/zapfdingbats.php (new file) + +07-Dec-2009 Joe Hunt +! Providing use of alternative providers for exchange rates. +$ /gl/includes/db/gl_db_rates.inc + +06-Dec-2009 Janusz Dobrowolski +# Safer algorithm for company removal, additional prefix check on company add. +$ /admin/create_coy.php + /admin/db/maintenance_db.inc + +04-Dec-2009 Janusz Dobrowolski +# [0000179] Cannot allocate ST_BANKPAYMENT type payments +$ /includes/ui/allocation_cart.inc +# False currency rate error on first opening of sales order page when customer_list is off. +$ /sales/includes/cart_class.inc + +04-Dec-2009 Joe Hunt +# Print Statement prints balances in wrong place. +$ /reporting/rep108.php +! Better date2sql in date_functions.inc +$ /includes/date_functions.inc + +03-Dec-2009 Janusz Dobrowolski +# Fixed bug [0000178] data error in supplier allocations +$ /includes/ui/allocation_cart.inc + +---------- End of changes from main trunk 2.2.1-2.2.2 + 10-Dec-2009 Joe Hunt + Enhanced Quick Entries to also support Balance Based source amount. Monthly or Yearly (all) Only works with type Journal Entry. diff --git a/admin/create_coy.php b/admin/create_coy.php index 1a03e39d..6667ea45 100644 --- a/admin/create_coy.php +++ b/admin/create_coy.php @@ -52,7 +52,7 @@ function check_data() display_error(_("This database settings are already used by another company.")); return false; } - if ($_POST['tbpref'] == 0 || $con['tbpref'] == '') + if (($_POST['tbpref'] == 0) ^ ($con['tbpref'] == '')) { display_error(_("You cannot have table set without prefix together with prefixed sets in the same database.")); return false; @@ -160,22 +160,39 @@ function handle_submit() function handle_delete() { - global $comp_path, $def_coy, $db_connections, $comp_subdirs; + global $comp_path, $def_coy, $db_connections, $comp_subdirs, $path_to_root; $id = $_GET['id']; - $cdir = $comp_path.'/'.$id; - @flush_dir($cdir, true); - if (!rmdir($cdir)) + // First make sure all company directories from the one under removal are writable. + // Without this after operation we end up with changed per-company owners! + for($i = $id; $i < count($db_connections); $i++) { + if (!is_dir($comp_path.'/'.$i) || !is_writable($comp_path.'/'.$i)) { + display_error(_('Broken company subdirectories system. You have to remove this company manually.')); + return; + } + } + // make sure config file is writable + if (!is_writeable($path_to_root . "/config_db.php")) { - display_error(_("Cannot remove company data directory ") . $cdir); + display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation.")); + return; + } + // rename directory to temporary name to ensure all + // other subdirectories will have right owners even after + // unsuccessfull removal. + $cdir = $comp_path.'/'.$id; + $tmpname = $comp_path.'/old_'.$id; + if (!@rename($cdir, $tmpname)) { + display_error(_('Cannot rename subdirectory to temporary name.')); return; } - for($i = $id+1; $i < count($db_connections); $i++) { + // 'shift' company directories names + for ($i = $id+1; $i < count($db_connections); $i++) { if (!rename($comp_path.'/'.$i, $comp_path.'/'.($i-1))) { display_error(_("Cannot rename company subdirectory")); return; - } + } } $err = remove_connection($id); if ($err == 0) @@ -190,8 +207,17 @@ function handle_delete() display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php"); else if ($error == -3) display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation.")); - if ($error != 0) + if ($error != 0) { + @rename($tmpname, $cdir); return; + } + // finally remove renamed company directory + @flush_dir($tmpname, true); + if (!@rmdir($tmpname)) + { + display_error(_("Cannot remove temporary renamed company data directory ") . $tmpname); + return; + } meta_forward($_SERVER['PHP_SELF']); } diff --git a/admin/db/maintenance_db.inc b/admin/db/maintenance_db.inc index 225d57f7..0cb76d08 100644 --- a/admin/db/maintenance_db.inc +++ b/admin/db/maintenance_db.inc @@ -104,7 +104,7 @@ function write_config_db($new = false) $filename = $path_to_root . "/config_db.php"; // Check if the file exists and is writable first. - if (!file_exists($filename) || (is_writable($path_to_root) && is_writable($filename))) + if ((!file_exists($filename) && is_writable($path_to_root)) || is_writable($filename)) { if (!$zp = fopen($filename, 'w')) { @@ -461,7 +461,7 @@ function db_unzip($mode, $path) $all = implode("", file($path)); // convert path to name of ziped file - $filename = ereg_replace(".*/", "", $path); + $filename = preg_replace("/.*\//", "", $path); $filename = substr($filename, 0, strlen($filename) - 4); // compare filname in zip and filename from $_GET diff --git a/admin/system_diagnostics.php b/admin/system_diagnostics.php new file mode 100644 index 00000000..45fa5dd1 --- /dev/null +++ b/admin/system_diagnostics.php @@ -0,0 +1,324 @@ +. +***********************************************************************/ +$page_security = 'SA_SOFTWAREUPGRADE'; +$path_to_root=".."; + +include($path_to_root . "/includes/session.inc"); + +page(_($help_context = "System Diagnostics")); + +include($path_to_root . "/includes/ui.inc"); + +// Type of requirement for positive test result +$test_level = array( + 0 => _('Info'), + 1 => _('Optional'), + 2 => _('Recomended'), + 3 => _('Required ') +); + +$system_tests = array('tst_mysql', 'tst_php', 'tst_server', 'tst_system', 'tst_browser', + 'tst_gettext', 'tst_debug', 'tst_logging', + 'tst_dbversion', 'tst_subdirs', 'tst_langs', 'tst_tmpdir', 'tst_sessionpath', + 'tst_dbconfig', 'tst_config', 'tst_extconfig' + ); + +function tst_mysql() +{ + $test['descr'] = _('MySQL version'). ' >3.23.58'; + $test['type'] = 3; + $test['test'] = mysql_get_server_info(); + $test['result'] = $test['test']>'3.23.58'; + $test['comments'] = _('Upgrade MySQL server to version at least 3.23.58'); + + return $test; +} + +function tst_php() +{ + $test['descr'] = _('PHP version').' >4.3.2'; + $test['type'] = 3; + $test['test'] = phpversion(); + $test['result'] = $test['test']>'4.3.2'; + $test['comments'] = _('Upgrade PHP to version at least 4.3.2'); + + return $test; +} + +function tst_system() +{ + $test['descr'] = _('Server system'); + $test['type'] = 0; + $test['test'] = PHP_OS; + $test['result'] = true; + + return $test; +} + +function tst_sessionpath() +{ + $test['descr'] = _('Session save path'); + $test['type'] = 0; + $test['test'] = session_save_path(); + $test['result'] = true; + + return $test; +} + +function tst_browser() +{ + $test['descr'] = _('Browser type'); + $test['type'] = 0; + $test['test'] = $_SERVER['HTTP_USER_AGENT']; + $test['result'] = true; + $test['comments'] = _('Any browser is supported'); + + return $test; +} + +function tst_server() +{ + $test['descr'] = _('Http server type'); + $test['test'] = $_SERVER['SERVER_SOFTWARE']; + $test['type'] = 0; + $test['result'] = true; + $test['comments'] = _('Any server is supported'); + + return $test; +} + +function tst_gettext() +{ + $test['descr'] = _('Native gettext'); + $test['test'] = function_exists('gettext') ? _('Yes'): _('No'); + $test['type'] = 1; + $test['result'] = true; + $test['comments'] = _('In case of no getext support, php emulation is used'); + + return $test; +} + +function tst_debug() +{ + global $go_debug; + $test['descr'] = _('Debugging mode'); + $test['type'] = 0; + $test['test'] = $go_debug ? _("Yes") : _("No"); + $test['result'] = $go_debug != 0; + $test['comments'] = _('To switch debugging on set $go_debug=1 in config.php file'); + + return $test; +} + +function tst_logging() +{ + global $error_logfile; + + $test['descr'] = _('Error logging'); + $test['type'] = 2; + // if error lgging is on, but log file does not exists try write + if ($error_logfile && !is_file($error_logfile)) + { + @fclose(@fopen($error_logfile, 'w')); + } + $test['result'] = @$error_logfile != '' && is_writable($error_logfile); + $test['test'] = @$error_logfile == '' ? _("Disabled") : $error_logfile; + + if (@$error_logfile == '') + $test['comments'] = _('To switch error logging set $error_logging in config.php file'); + else + if (!is_writable($error_logfile)) + $test['comments'] = _('Log file is not writeable'); + + return $test; +} +// +// Installed FA database structure version +// +function tst_dbversion() +{ + $test['descr'] = _('Current database version'); + $test['type'] = 3; + $test['test'] = get_company_pref('version_id'); + $test['result'] = $test['test'] == '2.2'; + $test['comments'] = _('Database structure seems to be not upgraded to current version') + .' (2.2)'; + + return $test; +} + + +function tst_subdirs() +{ + global $db_connections, $comp_path; + + $comp_subdirs = array('images', 'pdf_files', 'backup','js_cache'); + + $test['descr'] = _('Company subdirectories consistency'); + $test['type'] = 3; + $test['test'] = array($comp_path.'/*'); + foreach($comp_subdirs as $sub) { + $test['test'][] = $comp_path.'/*/'.$sub; + } + $test['result'] = true; + + if (!is_dir($comp_path) || !is_writable($comp_path) ) { + $test['result'] = false; + $test['comments'][] = sprintf(_("'%s' is not writeable"), $comp_path); + return $test; + }; + foreach ($db_connections as $n => $comp) { + $path = "$comp_path/$n"; + if (!is_dir($path) || !is_writable($path) ) { + $test['result'] = false; + $test['comments'][] = sprintf(_("'%s' is not writeable"), $path); + continue; + }; + foreach($comp_subdirs as $sub) { + $spath = $path.'/'.$sub; + if (!is_dir($spath) || !is_writable($spath) ) { + $test['result'] = false; + $test['comments'][] = sprintf(_("'%s' is not writeable"), $spath); + } + } + } + return $test; +} + +function tst_tmpdir() +{ + global $path_to_root; + + $test['descr'] = _('Temporary directory'); + $test['type'] = 3; + $test['test'] = $path_to_root.'/tmp'; + $test['result'] = is_dir($test['test']) && is_writable($test['test']); + $test['comments'][] = sprintf(_("'%s' is not writeable"), $test['test']); + return $test; +} + +function tst_langs() +{ + global $installed_languages, $path_to_root; + + $test['descr'] = _('Language configuration consistency'); + $test['type'] = 3; + $test['result'] = true; + $test['comments'] = array(); + + $old = setlocale(LC_MESSAGES, '0'); + + $langs = array(); + + foreach ($installed_languages as $lang) { + $langs[] = $lang['code']; + if ($lang['code'] == 'en_GB') continue; // native FA language + + $file = $path_to_root.'/lang/'.$lang['code'].'/LC_MESSAGES/'.$lang['code']; + $file .= function_exists('gettext') ? '.mo' : '.po'; + + if (!is_file($file)) { + $test['result'] = false; + $test['comments'][] = sprintf( _('Missing %s translation file.'), $file); + } + if (!setlocale(LC_MESSAGES, $lang['code'].".".$lang['encoding'])) + { + $test['result'] = false; + $test['comments'][] = sprintf(_('Missing system locale: %s'), $lang['code'].".".$lang['encoding']); + }; + } + + setlocale(LC_MESSAGES, $old); + + $test['test'] = $langs; + + return $test; +} + +function tst_config() +{ + global $path_to_root; + + $test['descr'] = _('Main config file'); + $test['type'] = 2; + $test['test'] = $path_to_root.'/config.php'; + $test['result'] = is_file($test['test']) && !is_writable($test['test']); + $test['comments'][] = sprintf(_("'%s' file should be read-only"), $test['test']); + return $test; +} + +function tst_dbconfig() +{ + global $path_to_root; + + $test['descr'] = _('Database auth file'); + $test['type'] = 2; + $test['test'] = $path_to_root.'/config_db.php'; + $test['result'] = is_file($test['test']) && !is_writable($test['test']); + $test['comments'][] = sprintf(_("'%s' file should be read-only if you do not plan to add or change companies"), $test['test']); + + return $test; +} + +function tst_extconfig() +{ + global $path_to_root, $db_connections, $comp_path; + + $test['descr'] = _('Extensions configuration files'); + $test['type'] = 3; + $test['test'] = $path_to_root.'/installed_extensions.php'; + $test['result'] = is_file($test['test']) && is_writable($test['test']); + $test['test'] . ','.$comp_path.'/*/installed_extensions.php'; + $test['comments'][] = sprintf(_("'%s' file should be writeable"), $test['test']); + + foreach ($db_connections as $n => $comp) { + $path = "$comp_path/$n"; + if (!is_dir($path)) continue; + + $path .= "/installed_extensions.php"; + if (!is_file($path) || !is_writable($path) ) { + $test['result'] = false; + $test['comments'][] = sprintf(_("'%s' is not writeable"), $path); + continue; + }; + } + return $test; +} +//------------------------------------------------------------------------------------------------- + +start_table("$table_style width=80%"); +$th = array(_("Test"), _('Test type'), _("Value"), _("Comments")); +table_header($th); + +$k = 0; //row colour counter +foreach ($system_tests as $test) +{ + alt_table_row_color($k); + $result = $test(); + if (!$result) continue; + label_cell($result['descr']); + label_cell($test_level[$result['type']]); + + $res = is_array(@$result['test']) ? implode('
', $result['test']) + : $result['test']; + label_cell($res); + + $comm = is_array(@$result['comments']) ? implode('
', $result['comments']) + : @$result['comments']; + label_cell($result['result'] ? _('Ok') : ''.$comm.''); + end_row(); +} + +end_table(); +end_page(); + +?> diff --git a/applications/setup.php b/applications/setup.php index ac392123..3f1f652c 100644 --- a/applications/setup.php +++ b/applications/setup.php @@ -57,6 +57,9 @@ class setup_app extends application "admin/view_print_transaction.php?", 'SA_VIEWPRINTTRANSACTION'); $this->add_lapp_function(2, _("&Attach Documents"), "admin/attachments.php?filterType=20", 'SA_ATTACHDOCUMENT'); + $this->add_lapp_function(2, _("System &Diagnostics"), + "admin/system_diagnostics.php?", 'SA_OPEN'); + $this->add_rapp_function(2, _("&Backup and Restore"), "admin/backups.php?", 'SA_BACKUP'); $this->add_rapp_function(2, _("Create/Update &Companies"), diff --git a/config.default.php b/config.default.php index 6c3fbe40..67bb2dd2 100644 --- a/config.default.php +++ b/config.default.php @@ -56,7 +56,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // Main Title $app_title = "FrontAccounting"; // application version - $version = "2.2.1"; + $version = "2.3 CVS"; // Build for development purposes $build_version = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt")); diff --git a/gl/gl_bank.php b/gl/gl_bank.php index 3510dbd4..d3825201 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -102,7 +102,7 @@ function handle_new_order($type) unset ($_SESSION['pay_items']); } - session_register("pay_items"); + //session_register("pay_items"); $_SESSION['pay_items'] = new items_cart($type); diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 02a78229..5db9ba24 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -80,15 +80,28 @@ function retrieve_exrate($curr_b, $date) if (method_exists($Hooks, 'retrieve_exrate')) return $Hooks->retrieve_exrate($curr_b, $date); else - return get_ecb_rate($curr_b); + return get_extern_rate($curr_b, 'ECB', $date); } //----------------------------------------------------------------------------- -function get_ecb_rate($curr_b) +function get_extern_rate($curr_b, $provider = 'ECB', $date) { $curr_a = get_company_pref('curr_default'); - $ecb_filename = '/stats/eurofxref/eurofxref-daily.xml'; - $ecb_site = 'www.ecb.int'; + if ($provider == 'ECB') + { + $filename = "/stats/eurofxref/eurofxref-daily.xml"; + $site = "www.ecb.int"; + } + elseif ($provider == 'YAHOO') + { + $filename = "/q?s={$curr_a}{$curr_b}=X"; + $site = "finance.yahoo.com"; + } + elseif ($provider == 'GOOGLE') + { + $filename = "/finance/converter?a=1&from={$curr_a}&to={$curr_b}"; + $site = "finance.google.com"; + } $contents = ''; if (function_exists('curl_init')) @@ -96,7 +109,7 @@ function get_ecb_rate($curr_b) $retry = 1; do { $ch = curl_init(); - curl_setopt ($ch, CURLOPT_URL, 'http://'.$ecb_site.$ecb_filename); + curl_setopt ($ch, CURLOPT_URL, 'http://'.$site.$filename); curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); @@ -106,11 +119,11 @@ function get_ecb_rate($curr_b) curl_close($ch); // due to resolver bug in some curl versions (e.g. 7.15.5) // try again for constant IP. - $ecb_site="195.128.2.97"; + $site="195.128.2.97"; } while( ($contents == '') && $retry--); } else { - $handle = @fopen("http://".$ecb_site.$ecb_filename, 'rb'); + $handle = @fopen("http://".$site.$filename, 'rb'); if ($handle) { do { @@ -124,27 +137,52 @@ function get_ecb_rate($curr_b) } // end handle } if (!$contents) { - display_warning(_('Cannot retrieve currency rate from ECB page. Please set the rate manually.')); + display_warning(_("Cannot retrieve currency rate from $provider page. Please set the rate manually.")); } - $contents = str_replace (" |i"; - preg_match ( $from_mask, $contents, $out ); - $val_a = isset($out[1]) ? $out[1] : 0; - $val_a = str_replace ( ',', '', $val_a ); - $to_mask = "||i"; - preg_match ( $to_mask, $contents, $out ); - $val_b = isset($out[1]) ? $out[1] : 0; - $val_b = str_replace ( ',', '', $val_b ); - if ($val_b) + if ($provider == 'ECB') { - $val = $val_a / $val_b; - } - else + $contents = str_replace (" |i"; + preg_match ( $from_mask, $contents, $out ); + $val_a = isset($out[1]) ? $out[1] : 0; + $val_a = str_replace ( ',', '', $val_a ); + $to_mask = "||i"; + preg_match ( $to_mask, $contents, $out ); + $val_b = isset($out[1]) ? $out[1] : 0; + $val_b = str_replace ( ',', '', $val_b ); + if ($val_b) + { + $val = $val_a / $val_b; + } + else + { + $val = 0; + } + } + elseif ($provider == 'YAHOO') { - $val = 0; + $val = ''; + if (preg_match('/Last\sTrade:(.*?)Trade\sTime/s', $contents, $matches)) { + $val = strip_tags($matches[1]); + $val = str_replace(',', '', $val); + if ($val != 0) + $val = 1 / $val; + } } + elseif ($provider == 'GOOGLE') + { + $val = ''; + $regexp = "%([\d|.]+)\s+{$curr_a}\s+=\s+([\d|.]+)\s+{$curr_b}\s*%s"; + if (preg_match($regexp, $contents, $matches)) + { + $val = $matches[3]; + $val = str_replace(',', '', $val); + if ($val != 0) + $val = 1 / $val; + } + } return $val; -} // end function get_ecb_rate +} /* end function get_extern_rate */ //----------------------------------------------------------------------------- diff --git a/gl/inquiry/journal_inquiry.php b/gl/inquiry/journal_inquiry.php index b7a787a9..08610201 100644 --- a/gl/inquiry/journal_inquiry.php +++ b/gl/inquiry/journal_inquiry.php @@ -110,7 +110,6 @@ function edit_link($row) sprintf($editors[$row["type"]], $row["type_no"], $row["type"]), ICON_EDIT) : ''; } - $sql = get_sql_for_journal_inquiry(); $cols = array( diff --git a/includes/current_user.inc b/includes/current_user.inc index e9125bcd..023da535 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -239,6 +239,15 @@ function price_decimal_format($number, &$dec) } return number_format2($number, $dec); } +// function money_format doesn't exist in OS Win. +if (!function_exists('money_format')) +{ + function money_format($format, $number) + { + return price_format($number); + } +} + // 2008-06-15. Added extra parameter $stock_id and reference for $dec //-------------------------------------------------------------------- function qty_format($number, $stock_id=null, &$dec) { diff --git a/includes/date_functions.inc b/includes/date_functions.inc index 182e09c8..94654c35 100644 --- a/includes/date_functions.inc +++ b/includes/date_functions.inc @@ -318,52 +318,15 @@ and converts to a yyyy/mm/dd format */ return ""; $date_ = trim($date_); - $date_ = str_replace($sep, "", $date_); + $year = $month = $day = 0; - if (strlen($date_) == 6) - { - if ($how == 0) - { - $day = substr($date_,2,2); - $month = substr($date_,0,2); - $year = substr($date_,4,2); - } - elseif ($how == 1) - { - $day = substr($date_,0,2); - $month = substr($date_,2,2); - $year = substr($date_,4,2); - } - else - { - $day = substr($date_,4,2); - $month = substr($date_,2,2); - $year = substr($date_,0,2); - } - } - elseif (strlen($date_) == 8) - { - if ($how == 0) - { - $day = substr($date_,2,2); - $month = substr($date_,0,2); - $year = substr($date_,4,4); - } - elseif ($how == 1) - { - $day = substr($date_,0,2); - $month = substr($date_,2,2); - $year = substr($date_,4,4); - } - else - { - $day = substr($date_,6,2); - $month = substr($date_,4,2); - $year = substr($date_,0,4); - } - } - else - $year = $month = $day = 0; + // Split up the date by the separator based on "how" to split it + if ($how == 0) // MMDDYYYY + list($month, $day, $year) = explode($sep, $date_); + elseif ($how == 1) // DDMMYYYY + list($day, $month, $year) = explode($sep, $date_); + else // $how == 2, YYYYMMDD + list($year, $month, $day) = explode($sep, $date_); //to modify assumption in 2030 if ($date_system == 0 || $date_system == 3) @@ -385,6 +348,13 @@ and converts to a yyyy/mm/dd format */ list($year, $month, $day) = jalali_to_gregorian($year, $month, $day); else if ($date_system == 2) list($year, $month, $day) = islamic_to_gregorian($year, $month, $day); + + // Pad with 0s if needed + if (strlen($month) == 1) + $month = "0$month"; + if (strlen($day) == 1) + $day = "0$day"; + return $year."-".$month."-".$day; }// end of function diff --git a/includes/db_pager.inc b/includes/db_pager.inc index e09659a0..cf67659a 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -453,7 +453,7 @@ function &new_db_pager($name, $sql, $coldef, $table = null, $key = null, $page_l unset($_SESSION[$name]); // kill pager if sql has changed } if (!isset($_SESSION[$name])) { - $_SESSION[$name] =& new db_pager($sql, $name, $table, $page_len); + $_SESSION[$name] = new db_pager($sql, $name, $table, $page_len); $_SESSION[$name]->main_tbl = $table; $_SESSION[$name]->key = $key; $_SESSION[$name]->set_sql($sql); diff --git a/includes/lang/language.php b/includes/lang/language.php index 89609283..e983384f 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -27,7 +27,7 @@ class language function language($name, $code, $encoding, $dir = 'ltr') { $this->name = $name; - $this->code = $code; + $this->code = $code ? $code : 'en_GB'; $this->encoding = $encoding; $this->dir = $dir; } diff --git a/includes/page/header.inc b/includes/page/header.inc index 9bff3d2f..b0364cbe 100644 --- a/includes/page/header.inc +++ b/includes/page/header.inc @@ -101,8 +101,8 @@ function page_header($title, $no_menu=false, $is_index=false, $onload="", $js="" { $no_menu = false; } - if (!isset($_SESSION["sel_app"])) - session_register("sel_app"); + //if (!isset($_SESSION["sel_app"])) + // session_register("sel_app"); if (isset($_SESSION["App"]) && is_object($_SESSION["App"]) && isset($_SESSION["App"]->selected_application) && $_SESSION["App"]->selected_application != "") $sel_app = $_SESSION["App"]->selected_application; diff --git a/includes/session.inc b/includes/session.inc index ea1c12a5..ba703dee 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -186,7 +186,7 @@ include_once($path_to_root . "/config.php"); include_once($path_to_root . "/includes/main.inc"); // Ajax communication object -$Ajax =& new Ajax(); +$Ajax = new Ajax(); // js/php validation rules container $Validate = array(); diff --git a/includes/ui/allocation_cart.inc b/includes/ui/allocation_cart.inc index 6d081aef..bd84f5cc 100644 --- a/includes/ui/allocation_cart.inc +++ b/includes/ui/allocation_cart.inc @@ -341,7 +341,9 @@ function check_allocations() } $amount = $_SESSION['alloc']->amount; - if ($_SESSION['alloc']->type == 21 || $_SESSION['alloc']->type == 22) + + + if (in_array($_SESSION['alloc']->type, array(ST_BANKPAYMENT, ST_SUPPCREDIT, ST_SUPPAYMENT))) $amount = -$amount; if ($total_allocated - ($amount + input_num('discount')) > $SysPrefs->allocation_settled_allowance()) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index b9ef39d5..d84b0d9d 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -746,7 +746,7 @@ function sales_items_list($name, $selected_id=null, $all_option=false, 'spec_option' => $all_option===true ? _("All Items") : $all_option, 'spec_id' => $all_items, 'search_box' => true, - 'search' => array("i.item_code", "i.description"), + 'search' => array("i.item_code", "c.description", "i.description"), 'search_submit' => get_company_pref('no_item_list')!=0, 'size'=>15, 'select_submit'=> $submit_on_change, diff --git a/install/save.php b/install/save.php index 98b1191e..1e568b65 100644 --- a/install/save.php +++ b/install/save.php @@ -265,7 +265,7 @@ if (!isset($_POST['admin_email']) || $_POST['admin_email'] == '') } else { - if (eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['admin_email'])) + if (preg_match("/^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/i", $_POST['admin_email'])) { $admin_email = $_POST['admin_email']; } diff --git a/inventory/adjustments.php b/inventory/adjustments.php index 20ac09d1..51b097be 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -67,7 +67,7 @@ function handle_new_order() unset ($_SESSION['adj_items']); } - session_register("adj_items"); + //session_register("adj_items"); $_SESSION['adj_items'] = new items_cart(ST_INVADJUST); $_POST['AdjDate'] = new_doc_date(); diff --git a/inventory/transfers.php b/inventory/transfers.php index 49e66e5e..9e6cbd85 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -65,7 +65,7 @@ function handle_new_order() unset ($_SESSION['transfer_items']); } - session_register("transfer_items"); + //session_register("transfer_items"); $_SESSION['transfer_items'] = new items_cart(ST_LOCTRANSFER); $_POST['AdjDate'] = new_doc_date(); diff --git a/purchasing/allocations/supplier_allocate.php b/purchasing/allocations/supplier_allocate.php index 5f77c152..82530c76 100644 --- a/purchasing/allocations/supplier_allocate.php +++ b/purchasing/allocations/supplier_allocate.php @@ -37,7 +37,7 @@ function clear_allocations() unset($_SESSION['alloc']->allocs); unset($_SESSION['alloc']); } - session_register("alloc"); + //session_register("alloc"); } //-------------------------------------------------------------------------------- diff --git a/purchasing/includes/db/supp_trans_db.inc b/purchasing/includes/db/supp_trans_db.inc index b9624809..30294e69 100644 --- a/purchasing/includes/db/supp_trans_db.inc +++ b/purchasing/includes/db/supp_trans_db.inc @@ -37,7 +37,6 @@ function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $sup if ($err_msg == "") $err_msg = "Cannot insert a supplier transaction record"; -error_log($sql); db_query($sql, $err_msg); add_audit_trail($type, $trans_no, $date_); diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 042c0640..830f483f 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -37,7 +37,7 @@ function create_new_po() unset ($_SESSION['PO']); } - session_register("PO"); + //session_register("PO"); $_SESSION['PO'] = new purch_order; $_POST['OrderDate'] = new_doc_date(); diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index a09b2e14..d25cba3c 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -157,9 +157,12 @@ function handle_cancel_po() function check_data() { - if (!check_num('qty',0)) + $dec = get_qty_dec($_POST['stock_id']); + $min = 1 / pow(10, $dec); + if (!check_num('qty',$min)) { - display_error(_("The quantity of the order item must be numeric and not less than zero.")); + $min = number_format2($min, $dec); + display_error(_("The quantity of the order item must be numeric and not less than ").$min); set_focus('qty'); return false; } @@ -185,19 +188,21 @@ function handle_update_item() { $allow_update = check_data(); - if ($allow_update && - ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > input_num('qty') || - $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > input_num('qty'))) + if ($allow_update) { - display_error(_("You are attempting to make the quantity ordered a quantity less than has already been invoiced or received. This is prohibited.") . - "
" . _("The quantity received can only be modified by entering a negative receipt and the quantity invoiced can only be reduced by entering a credit note against this item.")); - set_focus('qty'); - return; - } + if ($_SESSION['PO']->line_items[$_POST['line_no']]->qty_inv > input_num('qty') || + $_SESSION['PO']->line_items[$_POST['line_no']]->qty_received > input_num('qty')) + { + display_error(_("You are attempting to make the quantity ordered a quantity less than has already been invoiced or received. This is prohibited.") . + "
" . _("The quantity received can only be modified by entering a negative receipt and the quantity invoiced can only be reduced by entering a credit note against this item.")); + set_focus('qty'); + return; + } - $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'), - $_POST['req_del_date']); - unset_form_variables(); + $_SESSION['PO']->update_order_item($_POST['line_no'], input_num('qty'), input_num('price'), + $_POST['req_del_date']); + unset_form_variables(); + } line_start_focus(); } diff --git a/purchasing/supplier_invoice.php b/purchasing/supplier_invoice.php index 6b24fe27..40c62435 100644 --- a/purchasing/supplier_invoice.php +++ b/purchasing/supplier_invoice.php @@ -66,7 +66,7 @@ if (isset($_GET['New'])) } //session_register("SuppInv"); - session_register("supp_trans"); + //session_register("supp_trans"); $_SESSION['supp_trans'] = new supp_trans; $_SESSION['supp_trans']->is_invoice = true; } diff --git a/reporting/fonts/courier.php b/reporting/fonts/courier.php new file mode 100644 index 00000000..1ce3afc8 --- /dev/null +++ b/reporting/fonts/courier.php @@ -0,0 +1,33 @@ +600,1=>600,2=>600,3=>600,4=>600,5=>600,6=>600,7=>600,8=>600,9=>600, +10=>600,11=>600,12=>600,13=>600,14=>600,15=>600,16=>600,17=>600,18=>600,19=>600, +20=>600,21=>600,22=>600,23=>600,24=>600,25=>600,26=>600,27=>600,28=>600,29=>600, +30=>600,31=>600,32=>600,33=>600,34=>600,35=>600,36=>600,37=>600,38=>600,39=>600, +40=>600,41=>600,42=>600,43=>600,44=>600,45=>600,46=>600,47=>600,48=>600,49=>600, +50=>600,51=>600,52=>600,53=>600,54=>600,55=>600,56=>600,57=>600,58=>600,59=>600, +60=>600,61=>600,62=>600,63=>600,64=>600,65=>600,66=>600,67=>600,68=>600,69=>600, +70=>600,71=>600,72=>600,73=>600,74=>600,75=>600,76=>600,77=>600,78=>600,79=>600, +80=>600,81=>600,82=>600,83=>600,84=>600,85=>600,86=>600,87=>600,88=>600,89=>600, +90=>600,91=>600,92=>600,93=>600,94=>600,95=>600,96=>600,97=>600,98=>600,99=>600, +100=>600,101=>600,102=>600,103=>600,104=>600,105=>600,106=>600,107=>600,108=>600, +109=>600,110=>600,111=>600,112=>600,113=>600,114=>600,115=>600,116=>600,117=>600, +118=>600,119=>600,120=>600,121=>600,122=>600,123=>600,124=>600,125=>600,126=>600, +127=>600,128=>600,129=>600,130=>600,131=>600,132=>600,133=>600,134=>600,135=>600, +136=>600,137=>600,138=>600,139=>600,140=>600,141=>600,142=>600,143=>600,144=>600, +145=>600,146=>600,147=>600,148=>600,149=>600,150=>600,151=>600,152=>600,153=>600, +154=>600,155=>600,156=>600,157=>600,158=>600,159=>600,160=>600,161=>600,162=>600, +163=>600,164=>600,165=>600,166=>600,167=>600,168=>600,169=>600,170=>600,171=>600, +172=>600,173=>600,174=>600,175=>600,176=>600,177=>600,178=>600,179=>600,180=>600, +181=>600,182=>600,183=>600,184=>600,185=>600,186=>600,187=>600,188=>600,189=>600, +190=>600,191=>600,192=>600,193=>600,194=>600,195=>600,196=>600,197=>600,198=>600, +199=>600,200=>600,201=>600,202=>600,203=>600,204=>600,205=>600,206=>600,207=>600, +208=>600,209=>600,210=>600,211=>600,212=>600,213=>600,214=>600,215=>600,216=>600, +217=>600,218=>600,219=>600,220=>600,221=>600,222=>600,223=>600,224=>600,225=>600, +226=>600,227=>600,228=>600,229=>600,230=>600,231=>600,232=>600,233=>600,234=>600, +235=>600,236=>600,237=>600,238=>600,239=>600,240=>600,241=>600,242=>600,243=>600, +244=>600,245=>600,246=>600,247=>600,248=>600,249=>600,250=>600,251=>600,252=>600, +253=>600,254=>600,255=>600); +?> diff --git a/reporting/fonts/symbol.php b/reporting/fonts/symbol.php new file mode 100644 index 00000000..9068a79a --- /dev/null +++ b/reporting/fonts/symbol.php @@ -0,0 +1,32 @@ +250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250, +10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250, +20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250, +30=>250,31=>250,32=>250,33=>333,34=>713,35=>500,36=>549,37=>833,38=>778,39=>439, +40=>333,41=>333,42=>500,43=>549,44=>250,45=>549,46=>250,47=>278,48=>500,49=>500, +50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278, +60=>549,61=>549,62=>549,63=>444,64=>549,65=>722,66=>667,67=>722,68=>612,69=>611, +70=>763,71=>603,72=>722,73=>333,74=>631,75=>722,76=>686,77=>889,78=>722,79=>722, +80=>768,81=>741,82=>556,83=>592,84=>611,85=>690,86=>439,87=>768,88=>645,89=>795, +90=>611,91=>333,92=>863,93=>333,94=>658,95=>500,96=>500,97=>631,98=>549,99=>549, +100=>494,101=>439,102=>521,103=>411,104=>603,105=>329,106=>603,107=>549,108=>549, +109=>576,110=>521,111=>549,112=>549,113=>521,114=>549,115=>603,116=>439,117=>576, +118=>713,119=>686,120=>493,121=>686,122=>494,123=>480,124=>200,125=>480,126=>549, +127=>0,128=>0,129=>0,130=>0,131=>0,132=>0,133=>0,134=>0,135=>0,136=>0,137=>0, +138=>0,139=>0,140=>0,141=>0,142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0, +149=>0,150=>0,151=>0,152=>0,153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0, +160=>750,161=>620,162=>247,163=>549,164=>167,165=>713,166=>500,167=>753,168=>753, +169=>753,170=>753,171=>1042,172=>987,173=>603,174=>987,175=>603,176=>400,177=>549, +178=>411,179=>549,180=>549,181=>713,182=>494,183=>460,184=>549,185=>549,186=>549, +187=>549,188=>1000,189=>603,190=>1000,191=>658,192=>823,193=>686,194=>795,195=>987, +196=>768,197=>768,198=>823,199=>768,200=>768,201=>713,202=>713,203=>713,204=>713, +205=>713,206=>713,207=>713,208=>768,209=>713,210=>790,211=>790,212=>890,213=>823, +214=>549,215=>250,216=>713,217=>603,218=>603,219=>1042,220=>987,221=>603,222=>987, +223=>603,224=>494,225=>329,226=>790,227=>790,228=>786,229=>713,230=>384,231=>384, +232=>384,233=>384,234=>384,235=>384,236=>494,237=>494,238=>494,239=>494,240=>0, +241=>329,242=>274,243=>686,244=>686,245=>686,246=>384,247=>384,248=>384,249=>384, +250=>384,251=>384,252=>494,253=>494,254=>494,255=>0); +?> diff --git a/reporting/fonts/times.php b/reporting/fonts/times.php new file mode 100644 index 00000000..8cae5a7b --- /dev/null +++ b/reporting/fonts/times.php @@ -0,0 +1,33 @@ +250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250, +10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250, +20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250, +30=>250,31=>250,32=>250,33=>333,34=>408,35=>500,36=>500,37=>833,38=>778,39=>180, +40=>333,41=>333,42=>500,43=>564,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500, +50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>278,59=>278, +60=>564,61=>564,62=>564,63=>444,64=>921,65=>722,66=>667,67=>667,68=>722,69=>611, +70=>556,71=>722,72=>722,73=>333,74=>389,75=>722,76=>611,77=>889,78=>722,79=>722, +80=>556,81=>722,82=>667,83=>556,84=>611,85=>722,86=>722,87=>944,88=>722,89=>722, +90=>611,91=>333,92=>278,93=>333,94=>469,95=>500,96=>333,97=>444,98=>500,99=>444, +100=>500,101=>444,102=>333,103=>500,104=>500,105=>278,106=>278,107=>500,108=>278, +109=>778,110=>500,111=>500,112=>500,113=>500,114=>333,115=>389,116=>278,117=>500, +118=>500,119=>722,120=>500,121=>500,122=>444,123=>480,124=>200,125=>480,126=>541, +127=>350,128=>500,129=>350,130=>333,131=>500,132=>444,133=>1000,134=>500,135=>500, +136=>333,137=>1000,138=>556,139=>333,140=>889,141=>350,142=>611,143=>350,144=>350, +145=>333,146=>333,147=>444,148=>444,149=>350,150=>500,151=>1000,152=>333,153=>980, +154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500, +163=>500,164=>500,165=>500,166=>200,167=>500,168=>333,169=>760,170=>276,171=>500, +172=>564,173=>333,174=>760,175=>333,176=>400,177=>564,178=>300,179=>300,180=>333, +181=>500,182=>453,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750, +190=>750,191=>444,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>889, +199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333, +208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>564,216=>722, +217=>722,218=>722,219=>722,220=>722,221=>722,222=>556,223=>500,224=>444,225=>444, +226=>444,227=>444,228=>444,229=>444,230=>667,231=>444,232=>444,233=>444,234=>444, +235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500, +244=>500,245=>500,246=>500,247=>564,248=>500,249=>500,250=>500,251=>500,252=>500, +253=>500,254=>500,255=>500); +?> diff --git a/reporting/fonts/timesb.php b/reporting/fonts/timesb.php new file mode 100644 index 00000000..68766ca5 --- /dev/null +++ b/reporting/fonts/timesb.php @@ -0,0 +1,33 @@ +250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250, +10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250, +20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250, +30=>250,31=>250,32=>250,33=>333,34=>555,35=>500,36=>500,37=>1000,38=>833,39=>278, +40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500, +50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333, +60=>570,61=>570,62=>570,63=>500,64=>930,65=>722,66=>667,67=>722,68=>722,69=>667, +70=>611,71=>778,72=>778,73=>389,74=>500,75=>778,76=>667,77=>944,78=>722,79=>778, +80=>611,81=>778,82=>722,83=>556,84=>667,85=>722,86=>722,87=>1000,88=>722,89=>722, +90=>667,91=>333,92=>278,93=>333,94=>581,95=>500,96=>333,97=>500,98=>556,99=>444, +100=>556,101=>444,102=>333,103=>500,104=>556,105=>278,106=>333,107=>556,108=>278, +109=>833,110=>556,111=>500,112=>556,113=>556,114=>444,115=>389,116=>333,117=>556, +118=>500,119=>722,120=>500,121=>500,122=>444,123=>394,124=>220,125=>394,126=>520, +127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500, +136=>333,137=>1000,138=>556,139=>333,140=>1000,141=>350,142=>667,143=>350,144=>350, +145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000, +154=>389,155=>333,156=>722,157=>350,158=>444,159=>722,160=>250,161=>333,162=>500, +163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>300,171=>500, +172=>570,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333, +181=>556,182=>540,183=>250,184=>333,185=>300,186=>330,187=>500,188=>750,189=>750, +190=>750,191=>500,192=>722,193=>722,194=>722,195=>722,196=>722,197=>722,198=>1000, +199=>722,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389, +208=>722,209=>722,210=>778,211=>778,212=>778,213=>778,214=>778,215=>570,216=>778, +217=>722,218=>722,219=>722,220=>722,221=>722,222=>611,223=>556,224=>500,225=>500, +226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444, +235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500, +244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556, +253=>500,254=>556,255=>500); +?> diff --git a/reporting/fonts/timesbi.php b/reporting/fonts/timesbi.php new file mode 100644 index 00000000..e2190e07 --- /dev/null +++ b/reporting/fonts/timesbi.php @@ -0,0 +1,33 @@ +250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250, +10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250, +20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250, +30=>250,31=>250,32=>250,33=>389,34=>555,35=>500,36=>500,37=>833,38=>778,39=>278, +40=>333,41=>333,42=>500,43=>570,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500, +50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333, +60=>570,61=>570,62=>570,63=>500,64=>832,65=>667,66=>667,67=>667,68=>722,69=>667, +70=>667,71=>722,72=>778,73=>389,74=>500,75=>667,76=>611,77=>889,78=>722,79=>722, +80=>611,81=>722,82=>667,83=>556,84=>611,85=>722,86=>667,87=>889,88=>667,89=>611, +90=>611,91=>333,92=>278,93=>333,94=>570,95=>500,96=>333,97=>500,98=>500,99=>444, +100=>500,101=>444,102=>333,103=>500,104=>556,105=>278,106=>278,107=>500,108=>278, +109=>778,110=>556,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>556, +118=>444,119=>667,120=>500,121=>444,122=>389,123=>348,124=>220,125=>348,126=>570, +127=>350,128=>500,129=>350,130=>333,131=>500,132=>500,133=>1000,134=>500,135=>500, +136=>333,137=>1000,138=>556,139=>333,140=>944,141=>350,142=>611,143=>350,144=>350, +145=>333,146=>333,147=>500,148=>500,149=>350,150=>500,151=>1000,152=>333,153=>1000, +154=>389,155=>333,156=>722,157=>350,158=>389,159=>611,160=>250,161=>389,162=>500, +163=>500,164=>500,165=>500,166=>220,167=>500,168=>333,169=>747,170=>266,171=>500, +172=>606,173=>333,174=>747,175=>333,176=>400,177=>570,178=>300,179=>300,180=>333, +181=>576,182=>500,183=>250,184=>333,185=>300,186=>300,187=>500,188=>750,189=>750, +190=>750,191=>500,192=>667,193=>667,194=>667,195=>667,196=>667,197=>667,198=>944, +199=>667,200=>667,201=>667,202=>667,203=>667,204=>389,205=>389,206=>389,207=>389, +208=>722,209=>722,210=>722,211=>722,212=>722,213=>722,214=>722,215=>570,216=>722, +217=>722,218=>722,219=>722,220=>722,221=>611,222=>611,223=>500,224=>500,225=>500, +226=>500,227=>500,228=>500,229=>500,230=>722,231=>444,232=>444,233=>444,234=>444, +235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>556,242=>500,243=>500, +244=>500,245=>500,246=>500,247=>570,248=>500,249=>556,250=>556,251=>556,252=>556, +253=>444,254=>500,255=>444); +?> diff --git a/reporting/fonts/timesi.php b/reporting/fonts/timesi.php new file mode 100644 index 00000000..19a59739 --- /dev/null +++ b/reporting/fonts/timesi.php @@ -0,0 +1,33 @@ +250,1=>250,2=>250,3=>250,4=>250,5=>250,6=>250,7=>250,8=>250,9=>250, +10=>250,11=>250,12=>250,13=>250,14=>250,15=>250,16=>250,17=>250,18=>250,19=>250, +20=>250,21=>250,22=>250,23=>250,24=>250,25=>250,26=>250,27=>250,28=>250,29=>250, +30=>250,31=>250,32=>250,33=>333,34=>420,35=>500,36=>500,37=>833,38=>778,39=>214, +40=>333,41=>333,42=>500,43=>675,44=>250,45=>333,46=>250,47=>278,48=>500,49=>500, +50=>500,51=>500,52=>500,53=>500,54=>500,55=>500,56=>500,57=>500,58=>333,59=>333, +60=>675,61=>675,62=>675,63=>500,64=>920,65=>611,66=>611,67=>667,68=>722,69=>611, +70=>611,71=>722,72=>722,73=>333,74=>444,75=>667,76=>556,77=>833,78=>667,79=>722, +80=>611,81=>722,82=>611,83=>500,84=>556,85=>722,86=>611,87=>833,88=>611,89=>556, +90=>556,91=>389,92=>278,93=>389,94=>422,95=>500,96=>333,97=>500,98=>500,99=>444, +100=>500,101=>444,102=>278,103=>500,104=>500,105=>278,106=>278,107=>444,108=>278, +109=>722,110=>500,111=>500,112=>500,113=>500,114=>389,115=>389,116=>278,117=>500, +118=>444,119=>667,120=>444,121=>444,122=>389,123=>400,124=>275,125=>400,126=>541, +127=>350,128=>500,129=>350,130=>333,131=>500,132=>556,133=>889,134=>500,135=>500, +136=>333,137=>1000,138=>500,139=>333,140=>944,141=>350,142=>556,143=>350,144=>350, +145=>333,146=>333,147=>556,148=>556,149=>350,150=>500,151=>889,152=>333,153=>980, +154=>389,155=>333,156=>667,157=>350,158=>389,159=>556,160=>250,161=>389,162=>500, +163=>500,164=>500,165=>500,166=>275,167=>500,168=>333,169=>760,170=>276,171=>500, +172=>675,173=>333,174=>760,175=>333,176=>400,177=>675,178=>300,179=>300,180=>333, +181=>500,182=>523,183=>250,184=>333,185=>300,186=>310,187=>500,188=>750,189=>750, +190=>750,191=>500,192=>611,193=>611,194=>611,195=>611,196=>611,197=>611,198=>889, +199=>667,200=>611,201=>611,202=>611,203=>611,204=>333,205=>333,206=>333,207=>333, +208=>722,209=>667,210=>722,211=>722,212=>722,213=>722,214=>722,215=>675,216=>722, +217=>722,218=>722,219=>722,220=>722,221=>556,222=>611,223=>500,224=>500,225=>500, +226=>500,227=>500,228=>500,229=>500,230=>667,231=>444,232=>444,233=>444,234=>444, +235=>444,236=>278,237=>278,238=>278,239=>278,240=>500,241=>500,242=>500,243=>500, +244=>500,245=>500,246=>500,247=>675,248=>500,249=>500,250=>500,251=>500,252=>500, +253=>444,254=>500,255=>444); +?> diff --git a/reporting/fonts/zapfdingbats.php b/reporting/fonts/zapfdingbats.php new file mode 100644 index 00000000..d3b7c56c --- /dev/null +++ b/reporting/fonts/zapfdingbats.php @@ -0,0 +1,32 @@ +0,1=>0,2=>0,3=>0,4=>0,5=>0,6=>0,7=>0,8=>0,9=>0,10=>0,11=>0,12=>0, +13=>0,14=>0,15=>0,16=>0,17=>0,18=>0,19=>0,20=>0,21=>0,22=>0,23=>0,24=>0,25=>0, +26=>0,27=>0,28=>0,29=>0,30=>0,31=>0,32=>278,33=>974,34=>961,35=>974,36=>980, +37=>719,38=>789,39=>790,40=>791,41=>690,42=>960,43=>939,44=>549,45=>855,46=>911, +47=>933,48=>911,49=>945,50=>974,51=>755,52=>846,53=>762,54=>761,55=>571,56=>677, +57=>763,58=>760,59=>759,60=>754,61=>494,62=>552,63=>537,64=>577,65=>692,66=>786, +67=>788,68=>788,69=>790,70=>793,71=>794,72=>816,73=>823,74=>789,75=>841,76=>823, +77=>833,78=>816,79=>831,80=>923,81=>744,82=>723,83=>749,84=>790,85=>792,86=>695, +87=>776,88=>768,89=>792,90=>759,91=>707,92=>708,93=>682,94=>701,95=>826,96=>815, +97=>789,98=>789,99=>707,100=>687,101=>696,102=>689,103=>786,104=>787,105=>713, +106=>791,107=>785,108=>791,109=>873,110=>761,111=>762,112=>762,113=>759,114=>759, +115=>892,116=>892,117=>788,118=>784,119=>438,120=>138,121=>277,122=>415,123=>392, +124=>392,125=>668,126=>668,127=>0,128=>390,129=>390,130=>317,131=>317,132=>276, +133=>276,134=>509,135=>509,136=>410,137=>410,138=>234,139=>234,140=>334,141=>334, +142=>0,143=>0,144=>0,145=>0,146=>0,147=>0,148=>0,149=>0,150=>0,151=>0,152=>0, +153=>0,154=>0,155=>0,156=>0,157=>0,158=>0,159=>0,160=>0,161=>732,162=>544,163=>544, +164=>910,165=>667,166=>760,167=>760,168=>776,169=>595,170=>694,171=>626,172=>788, +173=>788,174=>788,175=>788,176=>788,177=>788,178=>788,179=>788,180=>788,181=>788, +182=>788,183=>788,184=>788,185=>788,186=>788,187=>788,188=>788,189=>788,190=>788, +191=>788,192=>788,193=>788,194=>788,195=>788,196=>788,197=>788,198=>788,199=>788, +200=>788,201=>788,202=>788,203=>788,204=>788,205=>788,206=>788,207=>788,208=>788, +209=>788,210=>788,211=>788,212=>894,213=>838,214=>1016,215=>458,216=>748,217=>924, +218=>748,219=>918,220=>927,221=>928,222=>928,223=>834,224=>873,225=>828,226=>924, +227=>924,228=>917,229=>930,230=>931,231=>463,232=>883,233=>836,234=>836,235=>867, +236=>867,237=>696,238=>696,239=>874,240=>0,241=>874,242=>760,243=>946,244=>771, +245=>865,246=>771,247=>888,248=>967,249=>888,250=>831,251=>873,252=>927,253=>970, +254=>918,255=>0); +?> diff --git a/reporting/includes/Workbook.php b/reporting/includes/Workbook.php index 1f53c2aa..56e4c483 100644 --- a/reporting/includes/Workbook.php +++ b/reporting/includes/Workbook.php @@ -2479,9 +2479,9 @@ class Spreadsheet_Excel_Writer_Parser // Split the range into 2 cell refs if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { - list($cell1, $cell2) = split(':', $range); + list($cell1, $cell2) = preg_split('/:/', $range); } elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { - list($cell1, $cell2) = split('\.\.', $range); + list($cell1, $cell2) = preg_split('/\.\./', $range); } else { // TODO: use real error codes @@ -2521,7 +2521,7 @@ class Spreadsheet_Excel_Writer_Parser $class = 2; // as far as I know, this is magick. // Split the ref at the ! symbol - list($ext_ref, $range) = split('!', $token); + list($ext_ref, $range) = preg_split('/!/', $token); // Convert the external reference part (different for BIFF8) if ($this->_BIFF_version == 0x0500) { @@ -2531,7 +2531,7 @@ class Spreadsheet_Excel_Writer_Parser } // Split the range into 2 cell refs - list($cell1, $cell2) = split(':', $range); + list($cell1, $cell2) = preg_split('/:/', $range); // Convert the cell references if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1)) { @@ -2600,7 +2600,7 @@ class Spreadsheet_Excel_Writer_Parser $class = 2; // as far as I know, this is magick. // Split the ref at the ! symbol - list($ext_ref, $cell) = split('!', $cell); + list($ext_ref, $cell) = preg_split('/!/', $cell); // Convert the external reference part (different for BIFF8) if ($this->_BIFF_version == 0x0500) { @@ -2641,7 +2641,7 @@ class Spreadsheet_Excel_Writer_Parser // Check if there is a sheet range eg., Sheet1:Sheet2. if (preg_match("/:/", $ext_ref)) { - list($sheet_name1, $sheet_name2) = split(':', $ext_ref); + list($sheet_name1, $sheet_name2) = preg_split('/:/', $ext_ref); $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { @@ -2687,7 +2687,7 @@ class Spreadsheet_Excel_Writer_Parser // Check if there is a sheet range eg., Sheet1:Sheet2. if (preg_match("/:/", $ext_ref)) { - list($sheet_name1, $sheet_name2) = split(':', $ext_ref); + list($sheet_name1, $sheet_name2) = preg_split('/:/', $ext_ref); $sheet1 = $this->_getSheetIndex($sheet_name1); if ($sheet1 == -1) { @@ -2986,7 +2986,7 @@ class Spreadsheet_Excel_Writer_Parser default: // if it's a reference if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.') and ($this->_lookahead != '!')) { @@ -2994,39 +2994,39 @@ class Spreadsheet_Excel_Writer_Parser } // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead) and + !preg_match("/[0-9]/",$this->_lookahead) and ($this->_lookahead != ':') and ($this->_lookahead != '.')) { return $token; } // if it's a range (A1:A2) elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // if it's a range (A1..A2) elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2 elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and - !ereg("[0-9]",$this->_lookahead)) + !preg_match("/[0-9]/",$this->_lookahead)) { return $token; } @@ -3038,12 +3038,12 @@ class Spreadsheet_Excel_Writer_Parser return $token; } // If it's a string (of maximum 255 characters) - elseif (ereg("^\"[^\"]{0,255}\"$",$token)) + elseif (preg_match("/^\"[^\"]{0,255}\"$/",$token)) { return $token; } // if it's a function call - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$token) and ($this->_lookahead == "(")) { return $token; } @@ -3258,7 +3258,7 @@ class Spreadsheet_Excel_Writer_Parser return $result; } // if it's a function call - elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token)) + elseif (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/i",$this->_current_token)) { $result = $this->_func(); return $result; @@ -4683,7 +4683,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $row = $match[2]; // Convert base26 column string to number - $chars = split('', $col); + $chars = preg_split('//', $col); $expn = 0; $col = 0; @@ -5401,7 +5401,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // parameters accordingly. // Split the dir name and sheet name (if it exists) /*if (preg_match("/\#/", $url)) { - list($dir_long, $sheet) = split("\#", $url); + list($dir_long, $sheet) = preg_split("/\#/", $url); } else { $dir_long = $url; } @@ -5409,7 +5409,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr if (isset($sheet)) { $link_type |= 0x08; $sheet_len = pack("V", strlen($sheet) + 0x01); - $sheet = join("\0", split('', $sheet)); + $sheet = join("\0", preg_split('//', $sheet)); $sheet .= "\0\0\0"; } else { $sheet_len = ''; @@ -5433,7 +5433,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0"; // Store the long dir name as a wchar string (non-null terminated) - //$dir_long = join("\0", split('', $dir_long)); + //$dir_long = join("\0", preg_split('//', $dir_long)); $dir_long = $dir_long . "\0"; // Pack the lengths of the dir strings @@ -7007,7 +7007,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->Spreadsheet_Excel_Writer_BIFFwriter(); $this->_filename = $filename; - $this->_parser =& new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); + $this->_parser = new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); $this->_1904 = 0; $this->_activesheet = 0; $this->_firstsheet = 0; @@ -7016,7 +7016,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_fileclosed = 0; $this->_biffsize = 0; $this->_sheetname = 'Sheet'; - $this->_tmp_format =& new Spreadsheet_Excel_Writer_Format($this->_BIFF_version); + $this->_tmp_format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version); $this->_worksheets = array(); $this->_sheetnames = array(); $this->_formats = array(); diff --git a/reporting/includes/class.graphic.inc b/reporting/includes/class.graphic.inc index c80f3377..20022f1b 100644 --- a/reporting/includes/class.graphic.inc +++ b/reporting/includes/class.graphic.inc @@ -164,7 +164,7 @@ class graph function display($save="", $border=false) { - $this->legend_exists = (ereg("(5|6)", $this->type)) ? true : false; + $this->legend_exists = (preg_match("/(5|6)/", $this->type)) ? true : false; $this->biggest_graphic_name = (strlen($this->graphic_1) > strlen($this->graphic_2)) ? $this->graphic_1 : $this->graphic_2; $this->height_title = (!empty($this->title)) ? ($this->string_height($this->tsize) + 15) : 0; $this->space_between_bars = ($this->type == 1) ? 40 : 30; @@ -181,7 +181,7 @@ class graph $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width; $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height; - if (count($this->z) && (ereg("(1|2|3|4)", $this->type))) + if (count($this->z) && (preg_match("/(1|2|3|4)/", $this->type))) $this->graphic_2_exists = true; $this->total_parameters = count($this->x); for ($i = 0; $i < $this->total_parameters; $i++) @@ -234,7 +234,7 @@ class graph // Draw axis and background lines for "vertical bars", "dots" and "lines" - if (ereg("^(1|3|4)$", $this->type)) + if (preg_match("/^(1|3|4)$/", $this->type)) { if ($this->legend_exists == true) { @@ -312,7 +312,7 @@ class graph // Draw legend box for "pie" or "donut" - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { $this->draw_legend(); } @@ -404,7 +404,7 @@ class graph /** * Draw graphic: DOTS or LINE */ - else if (ereg("^(3|4)$", $this->type)) + else if (preg_match("/^(3|4)$/", $this->type)) { $x[0] = $this->graphic_area_x1+1; @@ -475,7 +475,7 @@ class graph /** * Draw graphic: PIE or DONUT */ - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { $center_x = ($this->graphic_area_x1 + $this->graphic_area_x2) / 2; $center_y = ($this->graphic_area_y1 + $this->graphic_area_y2) / 2; @@ -702,10 +702,10 @@ class graph // Draw legend values for VERTICAL BARS, HORIZONTAL BARS, DOTS and LINES - if (ereg("^(1|2|3|4)$", $this->type)) + if (preg_match("/^(1|2|3|4)$/", $this->type)) { - $color_1 = (ereg("^(1|2)$", $this->type)) ? $this->color['bars'] : $this->color['line']; - $color_2 = (ereg("^(1|2)$", $this->type)) ? $this->color['bars_2'] : $this->color['line_2']; + $color_1 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars'] : $this->color['line']; + $color_2 = (preg_match("/^(1|2)$/", $this->type)) ? $this->color['bars_2'] : $this->color['line_2']; imagefilledrectangle($this->img, $x, $y, ($x+10), ($y+10), $color_1); imagerectangle($this->img, $x, $y, ($x+10), ($y+10), $this->color['title']); @@ -717,7 +717,7 @@ class graph } // Draw legend values for PIE or DONUT - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { if (!empty($this->axis_x)) { @@ -818,19 +818,19 @@ class graph $this->color['bg_lines'] = imagecolorallocate($this->img, 220, 220, 220); $this->color['bg_legend'] = imagecolorallocate($this->img, 255, 255, 255); - if (ereg("^(1|2)$", $this->type)) + if (preg_match("/^(1|2)$/", $this->type)) { $this->color['bars'] = imagecolorallocate($this->img, 100, 150, 200); $this->color['bars_shadow'] = imagecolorallocate($this->img, 50, 100, 150); $this->color['bars_2'] = imagecolorallocate($this->img, 200, 250, 150); $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 120, 170, 70); } - else if (ereg("^(3|4)$", $this->type)) + else if (preg_match("/^(3|4)$/", $this->type)) { $this->color['line'] = imagecolorallocate($this->img, 100, 150, 200); $this->color['line_2'] = imagecolorallocate($this->img, 230, 100, 100); } - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { $this->color['arc_1'] = imagecolorallocate($this->img, 255, 150, 0); $this->color['arc_2'] = imagecolorallocate($this->img, 150, 0, 255); @@ -858,19 +858,19 @@ class graph $this->color['bg_lines'] = imagecolorallocate($this->img, 100, 100, 100); $this->color['bg_legend'] = imagecolorallocate($this->img, 70, 70, 70); - if (ereg("^(1|2)$", $this->type)) + if (preg_match("/^(1|2)$/", $this->type)) { $this->color['bars'] = imagecolorallocate($this->img, 50, 200, 50); $this->color['bars_shadow'] = imagecolorallocate($this->img, 0, 150, 0); $this->color['bars_2'] = imagecolorallocate($this->img, 255, 255, 255); $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 220, 220, 220); } - else if (ereg("^(3|4)$", $this->type)) + else if (preg_match("/^(3|4)$/", $this->type)) { $this->color['line'] = imagecolorallocate($this->img, 220, 220, 220); $this->color['line_2'] = imagecolorallocate($this->img, 0, 180, 0); } - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { $this->color['arc_1'] = imagecolorallocate($this->img, 255, 255, 255); $this->color['arc_2'] = imagecolorallocate($this->img, 200, 220, 200); @@ -899,19 +899,19 @@ class graph $this->color['bg_lines'] = imagecolorallocate($this->img, 200, 224, 180); $this->color['bg_legend'] = imagecolorallocate($this->img, 230, 230, 200); - if (ereg("^(1|2)$", $this->type)) + if (preg_match("/^(1|2)$/", $this->type)) { $this->color['bars'] = imagecolorallocate($this->img, 255, 170, 80); $this->color['bars_shadow'] = imagecolorallocate($this->img, 200, 120, 30); $this->color['bars_2'] = imagecolorallocate($this->img, 250, 230, 80); $this->color['bars_2_shadow'] = imagecolorallocate($this->img, 180, 150, 0); } - else if (ereg("^(3|4)$", $this->type)) + else if (preg_match("/^(3|4)$/", $this->type)) { $this->color['line'] = imagecolorallocate($this->img, 230, 100, 0); $this->color['line_2'] = imagecolorallocate($this->img, 220, 200, 50); } - else if (ereg("^(5|6)$", $this->type)) + else if (preg_match("/^(5|6)$/", $this->type)) { $this->color['arc_1'] = imagecolorallocate($this->img, 100, 150, 200); $this->color['arc_2'] = imagecolorallocate($this->img, 200, 250, 150); diff --git a/reporting/includes/class.pdf.inc b/reporting/includes/class.pdf.inc index 0fd5aedc..6eae7961 100644 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@ -62,7 +62,7 @@ include_once (dirname(__FILE__).'/tcpdf.php'); class Cpdf extends TCPDF { - function Cpdf($pageSize='A4', $l=array()) + function Cpdf($pageSize='A4', $l=array(), $pageOrientation='P') { if (!isset($l['a_meta_charset'])) $l = array('a_meta_charset' => 'ISO-8859-1', 'a_meta_dir' => 'ltr', 'a_meta_language' => 'en_GB', 'w_page' => 'page'); @@ -70,7 +70,7 @@ class Cpdf extends TCPDF { $uni = ($enc == 'UTF-8' || $enc == 'GB2312' ? true : false); if ($uni) ini_set("memory_limit", "48M"); - $this->TCPDF('P', 'pt', $pageSize, $uni, $enc); + $this->TCPDF($pageOrientation, 'pt', $pageSize, $uni, $enc); $this->setLanguageArray($l); $this->setPrintHeader(false); $this->setPrintFooter(false); @@ -82,16 +82,31 @@ class Cpdf extends TCPDF { $this->cMargin = 0; } - function selectFont($fontname, $style='') + // $fontname should be a standard PDF font (like 'times', 'helvetica' or 'courier') + // or one that's been installed on your system. An empty string can also be used + // which will retain the font currently in use. + // $style is either: + // * a special case string: + // * bold + // * italic + // * or a case-insensitive string where each char represents a style choice + // and you can use more than one or none at all. Possible choices: + // * empty string: regular + // * B: bold + // * I: italic + // * U: underline + // * D: line trough (aka "strike through") + function selectFont($fontname, $style = '') { - if ($fontname != '') - $fontname = basename($fontname); + // Parse the style - check for special cases, otherwise leave as-is if ($style == 'italic') - $type = 'i'; + $style = 'i'; elseif ($style == 'bold') - $type = 'b'; - else - $type = ''; + $style = 'b'; + + // Parse the fontname + if ($fontname != '') + $fontname = basename($fontname); if ($fontname == '') { if ($this->isunicode) @@ -120,7 +135,7 @@ class Cpdf extends TCPDF { } // else use built-in adobe fonts helvetica. } - $this->SetFont($fontname, $type); + $this->SetFont($fontname, $style); } function Header1() @@ -133,17 +148,17 @@ class Cpdf extends TCPDF { function newPage() { - TCPDF::AddPage(); + parent::AddPage(); } - function line($x1,$y1,$x2,$y2) + function line($x1,$y1,$x2,$y2, $style = array()) { - TCPDF::line($x1, $this->h-$y1, $x2, $this->h-$y2); + parent::Line($x1, $this->h-$y1, $x2, $this->h-$y2, $style); } function rectangle($x, $y, $w, $h, $style='', $border_style=array(), $fill_color=array()) { - TCPDF::Rect($x, $this->h-$y, $w, $h, $style, $border_style, $fill_color); + parent::Rect($x, $this->h-$y, $w, $h, $style, $border_style, $fill_color); } @@ -211,12 +226,12 @@ class Cpdf extends TCPDF { */ function ellipse($x0,$y0,$r1,$r2=0,$angle=0,$nSeg=8,$astart=0,$afinish=360,$close=1,$fill=0) { - TCPDF::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg); + parent::Ellipse($x0, $y0, $r1, $r2, $angle, $astart. $afinish, ($close?'C':''), "", "", $nSeg); } function Stream() { - TCPDF::Output('', 'I'); + parent::Output('', 'I'); } function calcTextWrap($txt, $width, $spacebreak=false) @@ -243,7 +258,7 @@ class Cpdf extends TCPDF { return array($txt2, $ret); } - function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $spacebreak=false) + function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $link = NULL, $stretch = 0, $spacebreak=false) { $ret = ""; if (!$this->rtl) @@ -252,47 +267,35 @@ class Cpdf extends TCPDF { $align = 'R'; elseif ($align == 'left') $align = 'L'; + elseif ($align == 'center') + $align = 'C'; + elseif ($align == 'justify') + $align = 'J'; } else $align = 'R'; - $txt = $this->calcTextWrap($txt, $w, $spacebreak); + + // If horizontal scaling was requested, check to see if we're trying to scale + // too much. If so, cut back string first and then scale it. + $maxScaleFactor = 1.4; + if ($stretch == 1 || $stretch == 2) + $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak); + // Wrap text if stretching isn't turned on + else + $txt = $this->calcTextWrap($txt, $w, $spacebreak); $ret = $txt[1]; $txt = $txt[0]; $this->SetXY($xb, $this->h - $yb - $h); - $txt = TCPDF::unhtmlentities($txt); + $txt = parent::unhtmlentities($txt); if ($this->isunicode && $this->encoding != "UTF-8") $txt = iconv($this->encoding, "UTF-8", $txt); - $this->Cell($w, $h, $txt, $border, 0, $align, $fill); + $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link, $stretch); return $ret; } -/** -* sets the colour for stroke operations -*/ - function setStrokeColor($r,$g,$b,$force=0) - { - TCPDF::SetDrawColor($r,$g,$b); - } -/** -* this sets the line drawing style. -* width, is the thickness of the line in user units -* cap is the type of cap to put on the line, values can be 'butt','round','square' -* where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the -* end of the line. -* join can be 'miter', 'round', 'bevel' -* dash is an array which sets the dash pattern, is a series of length values, which are the lengths of the -* on and off dashes. -* (2) represents 2 on, 2 off, 2 on , 2 off ... -* (2,1) is 2 on, 1 off, 2 on, 1 off.. etc -* phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts. -*/ - function setLineStyle($width=1,$cap='',$join='',$dash='',$phase=0) - { - $this->SetLineWidth($width); - } function Text($x, $y, $txt, $stroke=0, $clip=false) { - TCPDF::Text($x,$y, TCPDF::unhtmlentities($txt), $stroke, $clip); + parent::Text($x,$y, parent::unhtmlentities($txt), $stroke, $clip); } } // end of class diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index 0edc595f..d94ffe0c 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -121,6 +121,7 @@ if (isset($linetype)) $doc_Amount = _("Amount"); $doc_TOTAL_INVOICE = $doctype ==10 ? _("TOTAL INVOICE") : _("TOTAL CREDIT"); $doc_TOTAL_ORDER = _("TOTAL ORDER EX VAT"); + $doc_TOTAL_ORDER2 = _("TOTAL ORDER VAT INCL."); $doc_TOTAL_PO = _("TOTAL PO EX VAT"); $doc_TOTAL_DELIVERY = _("TOTAL DELIVERY INCL. VAT"); } diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc index 40853642..d4a725b7 100644 --- a/reporting/includes/doctext2.inc +++ b/reporting/includes/doctext2.inc @@ -120,6 +120,7 @@ if (isset($linetype)) $doc_Amount = "amount"; $doc_TOTAL_INVOICE = $doctype==10 ? "TOTAL INVOICE" : "TOTAL CREDIT"; $doc_TOTAL_ORDER = "TOTAL ORDER EX VAT"; + $doc_TOTAL_ORDER2 = "TOTAL ORDER VAT INCL."; $doc_TOTAL_PO = "TOTAL PO EX VAT"; $doc_TOTAL_DELIVERY = "TOTAL DELIVERY INCL. VAT"; } diff --git a/reporting/includes/excel_report.inc b/reporting/includes/excel_report.inc index f2a36b2f..4fd129b7 100644 --- a/reporting/includes/excel_report.inc +++ b/reporting/includes/excel_report.inc @@ -43,7 +43,9 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook var $row = 9999999; var $y; var $numcols; - + var $excelColWidthFactor; + var $endLine; + var $formatTitle; var $formatDateTime; var $formatDate; @@ -54,7 +56,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook var $sheet; - function FrontReport($title, $filename, $size = 'A4', $fontsize = 9) + function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = 6.5) { global $comp_path, $dateseps, $page_security; if (!$_SESSION["wa_current_user"]->can_access_page($page_security)) @@ -66,10 +68,12 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->size = $size; $this->title = $title; $this->lineHeight = 12; + $this->endLine = 760; $this->fontSize = $fontsize; $this->oldFontSize = 0; $this->y = 1; $this->currency = ''; + $this->excelColWidthFactor = $excelColWidthFactor; $rtl = ($_SESSION['language']->dir == 'rtl'); $this->code = strtolower($_SESSION['language']->encoding); $this->filename = $filename.".xls"; @@ -79,7 +83,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook //$this->setCountry(48); if ($this->code != "iso-8859-1") $this->setVersion(8); // set biff version to 8 (0x0006 internal) - $this->sheet =& $this->addWorksheet($this->title); + $this->sheet =& $this->addWorksheet($this->worksheetNameGenerator($this->title)); if ($this->code != "iso-8859-1") $this->sheet->setInputEncoding($this->code); // set sheet encoding if ($rtl) @@ -128,6 +132,16 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->formatHeaderLeft->setBottom(2); $this->formatHeaderLeft->setBottomColor('gray'); $this->formatHeaderLeft->setAlign('vcenter'); + $this->formatTopHeaderLeft =& $this->addFormat(); + $this->formatTopHeaderLeft->setItalic(); + $this->formatTopHeaderLeft->setTop(2); + $this->formatTopHeaderLeft->setTopColor('gray'); + $this->formatTopHeaderLeft->setAlign('vcenter'); + $this->formatBottomHeaderLeft =& $this->addFormat(); + $this->formatBottomHeaderLeft->setItalic(); + $this->formatBottomHeaderLeft->setBottom(2); + $this->formatBottomHeaderLeft->setBottomColor('gray'); + $this->formatBottomHeaderLeft->setAlign('vcenter'); $this->formatDate->setAlign($rtl ? 'right' : 'left'); $this->formatHeaderRight =& $this->addFormat(); $this->formatHeaderRight->setItalic(); @@ -137,11 +151,38 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->formatHeaderRight->setBottomColor('gray'); $this->formatHeaderRight->setAlign('vcenter'); $this->formatHeaderRight->setAlign('right'); + $this->formatTopHeaderRight =& $this->addFormat(); + $this->formatTopHeaderRight->setItalic(); + $this->formatTopHeaderRight->setTop(2); + $this->formatTopHeaderRight->setTopColor('gray'); + $this->formatTopHeaderRight->setAlign('vcenter'); + $this->formatTopHeaderRight->setAlign('right'); + $this->formatBottomHeaderRight =& $this->addFormat(); + $this->formatBottomHeaderRight->setItalic(); + $this->formatBottomHeaderRight->setBottom(2); + $this->formatBottomHeaderRight->setBottomColor('gray'); + $this->formatBottomHeaderRight->setAlign('vcenter'); + $this->formatBottomHeaderRight->setAlign('right'); $this->formatFooter =& $this->addFormat(); $this->formatFooter->setTop(2); $this->formatFooter->setTopColor('gray'); } + + // Check a given name to see if it's a valid Excel worksheet name, + // and fix if necessary + function worksheetNameGenerator($name) + { + // First, strip out characters which aren't allowed + $illegal_chars = array(':', '\\', '/', '?', '*', '[', ']'); + for ($i = 0; $i < count($illegal_chars); $i++) + $name = str_replace($illegal_chars[$i], '', $name); + // Now, if name is longer than 31 chars, truncate it + if (strlen($name) > 31) + $name = substr($name, 0, 31); + return $name; + } + function NumFormat($dec) { if (!isset($this->formatAmount[$dec])) @@ -162,7 +203,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook return $this->formatAmount[$dec]; } - function Font($style = 'normal') + function Font($fontname = '', $style = 'normal') { } @@ -279,6 +320,168 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook return; } + // Alternate header style - primary differences are for PDFs + function Header3() + { + // Flag to make sure we only print the company name once + $companyNamePrinted = false; + + $this->y = 0; + $tcol = $this->numcols - 1; + $this->sheet->setRow($this->y, 20); + // Title + for ($i = 0; $i < $this->numcols; $i++) + $this->sheet->writeBlank($this->y, $i, $this->formatTitle); + $this->sheet->writeString($this->y, 0, $this->title, $this->formatTitle); + $this->sheet->mergeCells($this->y, 0, $this->y, $tcol); + + // Dimension 1 - optional + // - only print if available and not blank + if (count($this->params) > 3) + if ($this->params[3]['from'] != '') + { + $this->NewLine(); + $str = $this->params[3]['text'] . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $this->sheet->writeString($this->y, 1, $this->params[3]['from'], $this->formatLeft); + // Company Name - at end of this row + if (!$companyNamePrinted) + { + $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft); + $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol); + $companyNamePrinted = true; + } + } + + + // Dimension 2 - optional + // - only print if available and not blank + if (count($this->params) > 4) + if ($this->params[4]['from'] != '') + { + $this->NewLine(); + $str = $this->params[4]['text'] . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $this->sheet->writeString($this->y, 1, $this->params[4]['from'], $this->formatLeft); + // Company Name - at end of this row + if (!$companyNamePrinted) + { + $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft); + $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol); + $companyNamePrinted = true; + } + } + + // Tags - optional + // TBD!!! + + // Report Date - time period covered + // - can specify a range, or just the end date (and the report contents + // should make it obvious what the beginning date is) + $this->NewLine(); + $str = _("Report Date") . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $str = ''; + if ($this->params[1]['from'] != '') + $str = $this->params[1]['from'] . ' - '; + $str .= $this->params[1]['to']; + $this->sheet->writeString($this->y, 1, $str, $this->formatLeft); + // Company Name - at end of this row + if (!$companyNamePrinted) + { + $this->sheet->writeString($this->y, $tcol-1, $this->company['coy_name'], $this->formatLeft); + $this->sheet->mergeCells($this->y, $tcol-1, $this->y, $tcol); + $companyNamePrinted = true; + } + + // Timestamp of when this copy of the report was generated + $this->NewLine(); + $str = _("Generated At") . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $this->sheet->writeString($this->y, 1, Today() . " ".Now(), $this->formatLeft); + + // Name of the user that generated this copy of the report + $this->NewLine(); + $str = _("Generated By") . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $str = $this->user; + $this->sheet->writeString($this->y, 1, $str, $this->formatLeft); + + // Comments - display any user-generated comments for this copy of the report + if ($this->params[0] != '') + { + $this->NewLine(); + $str = _("Comments") . ':'; + $this->sheet->writeString($this->y, 0, $str, $this->formatLeft); + $this->sheet->writeString($this->y, 1, $this->params[0], $this->formatLeft); + } + $this->NewLine(); + + if ($this->headers2 != null) + { + for ($i = 0, $j = 0; $i < $this->numcols; $i++) + { + if ($this->cols2[$j] >= $this->cols[$i] && $this->cols2[$j] <= $this->cols[$i + 1]) + { + if ($this->aligns2[$j] == "right") + $this->sheet->writeString($this->y, $i, $this->headers2[$j], $this->formatTopHeaderRight); + else + $this->sheet->writeString($this->y, $i, $this->headers2[$j], $this->formatTopHeaderLeft); + $j++; + } + else + $this->sheet->writeString($this->y, $i, "", $this->formatTopHeaderLeft); + } + $this->NewLine(); + } + + for ($i = 0; $i < $this->numcols; $i++) + { + if (!isset($this->headers[$i])) + $header = ""; + else + $header = $this->headers[$i]; + if ($this->aligns[$i] == "right") + if ($this->headers2 == null) + $this->sheet->writeString($this->y, $i, $header, $this->formatHeaderRight); + else + $this->sheet->writeString($this->y, $i, $header, $this->formatBottomHeaderRight); + else + if ($this->headers2 == null) + $this->sheet->writeString($this->y, $i, $header, $this->formatHeaderLeft); + else + $this->sheet->writeString($this->y, $i, $header, $this->formatBottomHeaderLeft); + } + $this->NewLine(); + } + + /** + * Format a numeric string date into something nicer looking. + * + * @param string $date Date string to be formatted. + * @param int $input_format Format of the input string. Possible values are:
  • 0: user's default (default)
+ * @param int $output_format Format of the output string. Possible values are:
  • 0: Month (word) Day (numeric), 4-digit Year - Example: January 1, 2000 (default)
  • 1: Month 4-digit Year - Example: January 2000
  • 2: Month Abbreviation 4-digit Year - Example: Jan 2000
+ * @access public + */ + function DatePrettyPrint($date, $input_format = 0, $output_format = 0) + { + if ($date != '') + { + $date = date2sql($date); + $year = (int) (substr($date, 0, 4)); + $month = (int) (substr($date, 5, 2)); + $day = (int) (substr($date, 8, 2)); + if ($output_format == 0) + return(date('F j, Y', mktime(12, 0, 0, $month, $day, $year))); + elseif ($output_format == 1) + return(date('F Y', mktime(12, 0, 0, $month, $day, $year))); + elseif ($output_format == 2) + return(date('M Y', mktime(12, 0, 0, $month, $day, $year))); + } + else + return $date; + } + function AddImage($logo, $x, $y, $w, $h) { return; @@ -294,17 +497,32 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook return; } - function Text($c, $txt, $n=0, $corr=0, $r=0) + function SetFillColor($r, $g, $b) + { + return; + } + + function GetCellPadding() + { + return 0; + } + + function SetCellPadding($pad) + { + return; + } + + function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) { return; } - function TextWrap($xpos, $ypos, $len, $str, $align = 'left') + function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 0) { return; } - function TextCol($c, $n, $txt, $corr=0, $r=0) + function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { if ($this->aligns[$c] == 'right') $this->sheet->writeString($this->y, $c, $txt, $this->formatRight); @@ -314,14 +532,21 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->sheet->mergeCells($this->y, $c, $this->y, $n - 1); } - function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0) + function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false) + { + if (!is_numeric($txt)) + $txt = 0; + $this->sheet->writeNumber($this->y, $c, $txt, $this->NumFormat($dec)); + } + + function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false, $amount_locale = NULL, $amount_format = NULL) { if (!is_numeric($txt)) $txt = 0; $this->sheet->writeNumber($this->y, $c, $txt, $this->NumFormat($dec)); } - function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0) + function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { if (!$conv) $txt = date2sql($txt); @@ -330,23 +555,62 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook $this->sheet->writeNumber($this->y, $c, $date, $this->formatDate); } - function TextCol2($c, $n, $txt, $corr=0, $r=0) + function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { $this->sheet->writeString($this->y, $c, $txt, $this->formatLeft); if ($n - $c > 1) $this->sheet->mergeCells($this->y, $c, $this->y, $n - 1); } - function TextColLines($c, $n, $txt, $corr=0, $r=0) + function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { return; } - function TextWrapLines($c, $width, $txt, $align='left') + function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) { return; } + /** + * Crude text wrap calculator based on PDF version. + */ + function TextWrapCalc($txt, $width, $spacebreak=false) + { + // Assume an average character width + $avg_char_width = 5; + $ret = ""; + $txt2 = $txt; + $w = strlen($txt) * $avg_char_width; + if ($w > $width && $w > 0 && $width != 0) + { + $n = strlen($txt); + $k = intval($n * $width / $w); + if ($k > 0 && $k < $n) + { + $txt2 = substr($txt, 0, $k); + if ($spacebreak && (($pos = strrpos($txt2, " ")) !== false)) + { + $txt2 = substr($txt2, 0, $pos); + $ret = substr($txt, $pos+1); + } + else + $ret = substr($txt, $k); + } + } + return array($txt2, $ret); + } + + function SetLineStyle($style) + { + return; + } + + function SetLineWidth($width) + { + return; + } + function LineTo($from, $row, $to, $row2) { return; @@ -357,7 +621,12 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook return; } - function NewLine($l=1, $np=0) + function UnderlineCell($c, $r = 0, $type = 1, $linewidth = 0, $style = array()) + { + return; + } + + function NewLine($l=1, $np=0, $h=NULL) { $this->y += $l; } @@ -398,7 +667,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook function px2units($px) // XLS app conversion. Not bulletproof. { $excel_column_width_factor = 256; - $unit_offset_length = 6.5; + $unit_offset_length = $this->excelColWidthFactor; return ($px / $unit_offset_length); } diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 03eb81f4..13896dc8 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -42,14 +42,17 @@ class FrontReport extends Cpdf var $headers2; var $aligns2; var $cols2; - var $companyCol; - var $titleCol; var $pageNumber; var $fontSize; var $oldFontSize; var $currency; + var $companyLogoEnable; // select whether to use a company logo graphic in some header templates + var $scaleLogoWidth; + var $footerEnable; // select whether to print a page footer or not + var $footerText; // store user-generated footer text + var $headerFunc; // store the name of the currently selected header function - function FrontReport($title, $filename, $size = 'A4', $fontsize = 9) + function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = NULL) { global $page_security; if (!$_SESSION["wa_current_user"]->can_access_page($page_security)) @@ -58,74 +61,131 @@ class FrontReport extends Cpdf end_page(); exit; } - switch ($size) + // Page margins - if user-specified, use those. Otherwise, use defaults below. + if (isset($margins)) + { + $this->topMargin = $margins['top']; + $this->bottomMargin = $margins['bottom']; + $this->leftMargin = $margins['left']; + $this->rightMargin = $margins['right']; + } + // Page orientation - P: portrait, L: landscape + $orientation = strtoupper($orientation); + // Page size name + switch (strtoupper($size)) { default: case 'A4': - case 'a4': - $this->pageWidth=595; - $this->pageHeight=842; - $this->topMargin=40; - $this->bottomMargin=30; - $this->leftMargin=40; - $this->rightMargin=30; - break; - case 'A4_Landscape': - $this->pageWidth=842; - $this->pageHeight=595; - $this->topMargin=30; - $this->bottomMargin=30; - $this->leftMargin=40; - $this->rightMargin=30; + // Portrait + if ($orientation == 'P') + { + $this->pageWidth=595; + $this->pageHeight=842; + if (!isset($margins)) + { + $this->topMargin=40; + $this->bottomMargin=30; + $this->leftMargin=40; + $this->rightMargin=30; + } + } + // Landscape + else + { + $this->pageWidth=842; + $this->pageHeight=595; + if (!isset($margins)) + { + $this->topMargin=30; + $this->bottomMargin=30; + $this->leftMargin=40; + $this->rightMargin=30; + } + } break; case 'A3': - $this->pageWidth=842; - $this->pageHeight=1190; - $this->topMargin=50; - $this->bottomMargin=50; - $this->leftMargin=50; - $this->rightMargin=40; - break; - case 'A3_landscape': - $this->pageWidth=1190; - $this->pageHeight=842; - $this->topMargin=50; - $this->bottomMargin=50; - $this->leftMargin=50; - $this->rightMargin=40; + // Portrait + if ($orientation == 'P') + { + $this->pageWidth=842; + $this->pageHeight=1190; + if (!isset($margins)) + { + $this->topMargin=50; + $this->bottomMargin=50; + $this->leftMargin=50; + $this->rightMargin=40; + } + } + // Landscape + else + { + $this->pageWidth=1190; + $this->pageHeight=842; + if (!isset($margins)) + { + $this->topMargin=50; + $this->bottomMargin=50; + $this->leftMargin=50; + $this->rightMargin=40; + } + } break; - case 'letter': - case 'Letter': - $this->pageWidth=612; - $this->pageHeight=792; - $this->topMargin=30; - $this->bottomMargin=30; - $this->leftMargin=30; - $this->rightMargin=25; + case 'LETTER': + // Portrait + if ($orientation == 'P') + { + $this->pageWidth=612; + $this->pageHeight=792; + if (!isset($margins)) + { + $this->topMargin=30; + $this->bottomMargin=30; + $this->leftMargin=30; + $this->rightMargin=25; + } + } + // Landscape + else + { + $this->pageWidth=792; + $this->pageHeight=612; + if (!isset($margins)) + { + $this->topMargin=30; + $this->bottomMargin=30; + $this->leftMargin=30; + $this->rightMargin=25; + } + } break; - case 'letter_landscape': - $this->pageWidth=792; - $this->pageHeight=612; - $this->topMargin=30; - $this->bottomMargin=30; - $this->leftMargin=30; - $this->rightMargin=25; - break; - case 'legal': - $this->pageWidth=612; - $this->pageHeight=1008; - $this->topMargin=50; - $this->bottomMargin=40; - $this->leftMargin=30; - $this->rightMargin=25; - break; - case 'legal_landscape': - $this->pageWidth=1008; - $this->pageHeight=612; - $this->topMargin=50; - $this->bottomMargin=40; - $this->leftMargin=30; - $this->rightMargin=25; + case 'LEGAL': + // Portrait + if ($orientation == 'P') + { + $this->pageWidth=612; + $this->pageHeight=1008; + if (!isset($margins)) + { + $this->topMargin=50; + $this->bottomMargin=40; + $this->leftMargin=30; + $this->rightMargin=25; + } + } + // Landscape + else + { + $this->pageWidth=1008; + $this->pageHeight=612; + if (!isset($margins)) + { + $this->topMargin=50; + $this->bottomMargin=40; + $this->leftMargin=30; + $this->rightMargin=25; + } + } break; } $this->size = array(0, 0, $this->pageWidth, $this->pageHeight); @@ -133,28 +193,49 @@ class FrontReport extends Cpdf $this->filename = $filename.".pdf"; $this->pageNumber = 0; $this->endLine = $this->pageWidth - $this->rightMargin; - $this->companyCol = $this->endLine - 150; - $this->titleCol = $this->leftMargin + 100; $this->lineHeight = 12; $this->fontSize = $fontsize; $this->oldFontSize = 0; $this->row = $this->pageHeight - $this->topMargin; $this->currency = ''; + $this->scaleLogoWidth = false; // if Logo, scale on width (else height). + $this->headerFunc = 'Header'; // default to the original header template $rtl = ($_SESSION['language']->dir === 'rtl' ? 'rtl' : 'ltr'); $code = $_SESSION['language']->code; $enc = strtoupper($_SESSION['language']->encoding); // for the language array in class.pdf.inc $l = array('a_meta_charset' => $enc, 'a_meta_dir' => $rtl, 'a_meta_language' => $code, 'w_page' => 'page'); - $this->Cpdf($size, $l); + $this->Cpdf($size, $l, $orientation); } - function Font($style = 'normal') + /* + * Select the font and style to use for following output until + * it's changed again. + * + * $style is either: + * * a special case string (for backwards compatible with older code): + * * bold + * * italic + * * or a case-insensitive string where each char represents a style choice + * and you can use more than one or none at all. Possible choices: + * * empty string: regular + * * B: bold + * * I: italic + * * U: underline + * * D: line trough (aka "strike through") + * $fontname should be a standard PDF font (like 'times', 'helvetica' or 'courier') + * or one that's been installed on your system (see TCPDF docs for details). + * An empty string can also be used which will retain the font currently in use if + * you just want to change the style. + */ + function Font($style = '', $fontname = '') { - $this->selectFont("", $style); + $this->selectFont($fontname, $style); } function Info($params, $cols, $headers, $aligns, - $cols2 = null, $headers2 = null, $aligns2 = null) + $cols2 = null, $headers2 = null, $aligns2 = null, + $companylogoenable = false, $footerenable = false, $footertext = '') { global $app_title, $version, $power_by, $power_url; @@ -185,10 +266,20 @@ class FrontReport extends Cpdf } $this->headers2 = $headers2; $this->aligns2 = $aligns2; + + // Set whether to display company logo in some header templates + $this->companyLogoEnable = $companylogoenable; + + // Store footer settings + $this->footerEnable = $footerenable; + $this->footerText = $footertext; } function Header() { + $companyCol = $this->endLine - 150; + $titleCol = $this->leftMargin + 100; + $this->pageNumber++; if ($this->pageNumber > 1) $this->newPage(); @@ -201,46 +292,46 @@ class FrontReport extends Cpdf $this->fontSize += 4; $this->Font('bold'); - $this->Text($this->leftMargin, $this->title, $this->companyCol); + $this->Text($this->leftMargin, $this->title, $companyCol); $this->Font(); $this->fontSize -= 4; - $this->Text($this->companyCol, $this->company['coy_name']); + $this->Text($companyCol, $this->company['coy_name']); $this->row -= ($this->lineHeight + 4); $str = _("Print Out Date") . ':'; - $this->Text($this->leftMargin, $str, $this->titleCol); + $this->Text($this->leftMargin, $str, $titleCol); $str = Today() . ' ' . Now(); if ($this->company['time_zone']) $str .= ' ' . date('O') . ' GMT'; - $this->Text($this->titleCol, $str, $this->companyCol); - $this->Text($this->companyCol, $this->host); + $this->Text($titleCol, $str, $companyCol); + $this->Text($companyCol, $this->host); $this->NewLine(); $str = _("Fiscal Year") . ':'; - $this->Text($this->leftMargin, $str, $this->titleCol); + $this->Text($this->leftMargin, $str, $titleCol); $str = $this->fiscal_year; - $this->Text($this->titleCol, $str, $this->companyCol); - $this->Text($this->companyCol, $this->user); + $this->Text($titleCol, $str, $companyCol); + $this->Text($companyCol, $this->user); for ($i = 1; $i < count($this->params); $i++) { if ($this->params[$i]['from'] != '') { $this->NewLine(); $str = $this->params[$i]['text'] . ':'; - $this->Text($this->leftMargin, $str, $this->titleCol); + $this->Text($this->leftMargin, $str, $titleCol); $str = $this->params[$i]['from']; if ($this->params[$i]['to'] != '') $str .= " - " . $this->params[$i]['to']; - $this->Text($this->titleCol, $str, $this->companyCol); + $this->Text($titleCol, $str, $companyCol); } } if ($this->params[0] != '') // Comments { $this->NewLine(); $str = _("Comments") . ':'; - $this->Text($this->leftMargin, $str, $this->titleCol); + $this->Text($this->leftMargin, $str, $titleCol); $this->Font('bold'); - $this->Text($this->titleCol, $this->params[0], $this->endLine - 35); + $this->Text($titleCol, $this->params[0], $this->endLine - 35); $this->Font(); } $str = _("Page") . ' ' . $this->pageNumber; @@ -287,6 +378,265 @@ class FrontReport extends Cpdf $this->row = $temp; } + // Alternate header style which also supports a simple footer + function Header3() + { + global $comp_path; + + // Make this header the default for the current report ( used by NewLine() ) + $this->headerFunc = 'Header3'; + + // Turn off cell padding for the main report header, restoring the current setting later + $oldcMargin = $this->cMargin; + $this->SetCellPadding(0); + + // Set some constants which control header item layout + // only set them once or the PHP interpreter gets angry + if ($this->pageNumber == 0) + { + define('COMPANY_WIDTH', 150); + define('LOGO_HEIGHT', 50); + define('LOGO_Y_POS_ADJ_FACTOR', 0.74); + define('LABEL_WIDTH', 80); + define('PAGE_NUM_WIDTH', 60); + define('TITLE_FONT_SIZE', 14); + define('HEADER1_FONT_SIZE', 10); + define('HEADER2_FONT_SIZE', 9); + define('FOOTER_FONT_SIZE', 10); + define('FOOTER_MARGIN', 4); + } + // Set some variables which control header item layout + $companyCol = $this->endLine - COMPANY_WIDTH; + $headerFieldCol = $this->leftMargin + LABEL_WIDTH; + $pageNumCol = $this->endLine - PAGE_NUM_WIDTH; + $footerCol = $this->leftMargin + PAGE_NUM_WIDTH; + $footerRow = $this->bottomMargin - FOOTER_MARGIN; + + // Calling this function generates a new PDF page after the first instance + $this->pageNumber++; + if ($this->pageNumber > 1) + { +// // TODO: experimenting with line drawing to highlight current period +// $this->SetLineWidth(1); +// $this->LineTo($this->cols[3], 33, $this->cols[3], 534); +// $this->LineTo($this->cols[4], 33, $this->cols[4], 534); +// $this->SetLineWidth(0.1); + + $this->newPage(); + } + $this->row = $this->pageHeight - $this->topMargin; + + // Set the color of dividing lines we'll draw + $oldDrawColor = $this->GetDrawColor(); + $this->SetDrawColor(128, 128, 128); + + // Tell TCPDF that we want to use its alias system to track the total number of pages + $this->AliasNbPages(); + + // Footer + if ($this->footerEnable) + { + $this->Line($footerRow, 1); + $prevFontSize = $this->fontSize; + $this->fontSize = FOOTER_FONT_SIZE; + $this->TextWrap($footerCol, $footerRow - ($this->fontSize + 1), + $pageNumCol - $footerCol, $this->footerText, $align = 'center', + $border = 0, $fill = 0, $link = NULL, $stretch = 1); + $this->TextWrap($pageNumCol, $footerRow - ($this->fontSize + 1), + PAGE_NUM_WIDTH, _("Page") . ' ' . $this->pageNumber . '/' . $this->getAliasNbPages(), + $align = 'right', $border = 0, $fill = 0, $link = NULL, $stretch = 1); + $this->fontSize = $prevFontSize; + } + + // + // Header + // + + // Print gray line across the page + $this->Line($this->row + 8, 1); + + $this->NewLine(); + + // Print the report title nice and big + $oldFontSize = $this->fontSize; + $this->fontSize = TITLE_FONT_SIZE; + $this->Font('B'); + $this->Text($this->leftMargin, $this->title, $companyCol); + $this->fontSize = HEADER1_FONT_SIZE; + + // Print company logo if present and requested, or else just print company name + if ($this->companyLogoEnable && ($this->company['coy_logo'] != '')) + { + // Build a string specifying the location of the company logo file + $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo']; + + // Width being zero means that the image will be scaled to the specified height + // keeping its aspect ratio intact. + if ($this->scaleLogoWidth) + $this->AddImage($logo, $companyCol, $this->row, COMPANY_WIDTH, 0); + else + $this->AddImage($logo, $companyCol, $this->row - (LOGO_HEIGHT * LOGO_Y_POS_ADJ_FACTOR), 0, LOGO_HEIGHT); + } + else + $this->Text($companyCol, $this->company['coy_name']); + + // Dimension 1 - optional + // - only print if available and not blank + if (count($this->params) > 3) + if ($this->params[3]['from'] != '') + { + $this->NewLine(1, 0, $this->fontSize + 2); + $str = $this->params[3]['text'] . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = $this->params[3]['from']; + $this->Text($headerFieldCol, $str, $companyCol); + } + + // Dimension 2 - optional + // - only print if available and not blank + if (count($this->params) > 4) + if ($this->params[4]['from'] != '') + { + $this->NewLine(1, 0, $this->fontSize + 2); + $str = $this->params[4]['text'] . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = $this->params[4]['from']; + $this->Text($headerFieldCol, $str, $companyCol); + } + + // Tags - optional + // if present, it's an array of tag names + if (count($this->params) > 5) + if ($this->params[5]['from'] != '') + { + $this->NewLine(1, 0, $this->fontSize + 2); + $str = $this->params[5]['text'] . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = ''; + for ($i = 0; $i < count($this->params[5]['from']); $i++) + { + if($i != 0) + $str .= ', '; + $str .= $this->params[5]['from'][$i]; + } + $this->Text($headerFieldCol, $str, $companyCol); + } + + // Report Date - time period covered + // - can specify a range, or just the end date (and the report contents + // should make it obvious what the beginning date is) + $this->NewLine(1, 0, $this->fontSize + 2); + $str = _("Report Period") . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = ''; + if (isset($this->params[1]['from']) && $this->params[1]['from'] != '') + $str = $this->params[1]['from'] . ' - '; + $str .= $this->params[1]['to']; + $this->Text($headerFieldCol, $str, $companyCol); + + // Turn off Bold + $this->Font(); + + $this->NewLine(1, 0, $this->fontSize + 1); + + // Make the remaining report headings a little less important + $this->fontSize = HEADER2_FONT_SIZE; + + // Timestamp of when this copy of the report was generated + $str = _("Generated At") . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = Today() . ' ' . Now(); + if ($this->company['time_zone']) + $str .= ' ' . date('O') . ' GMT'; + $this->Text($headerFieldCol, $str, $companyCol); + + // Name of the user that generated this copy of the report + $this->NewLine(1, 0, $this->fontSize + 1); + $str = _("Generated By") . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $str = $this->user; + $this->Text($headerFieldCol, $str, $companyCol); + + // Display any user-generated comments for this copy of the report + if ($this->params[0] != '') // Comments + { + $this->NewLine(1, 0, $this->fontSize + 1); + $str = _("Comments") . ':'; + $this->Text($this->leftMargin, $str, $headerFieldCol); + $this->Font('B'); + $this->Text($headerFieldCol, $this->params[0], $companyCol, 0, 0, 'left', 0, 0, $link=NULL, 1); + $this->Font(); + } + + // Add page numbering to header if footer is turned off + if (!$this->footerEnable) + { + $str = _("Page") . ' ' . $this->pageNumber . '/' . $this->getAliasNbPages(); + $this->Text($pageNumCol, $str, 0, 0, 0, 'right', 0, 0, NULL, 1); + } + + // Print gray line across the page + $this->Line($this->row - 5, 1); + + // Restore font size to user-defined size + $this->fontSize = $oldFontSize; + + // restore user-specified cell padding for column headers + $this->SetCellPadding($oldcMargin); + + // scoot down the page a bit + $oldLineHeight = $this->lineHeight; + $this->lineHeight = $this->fontSize + 1; + $this->row -= ($this->lineHeight + 6); + $this->lineHeight = $oldLineHeight; + + // Print the column headers! + $this->Font('I'); + if ($this->headers2 != null) + { + $count = count($this->headers2); + for ($i = 0; $i < $count; $i++) + $this->TextCol2($i, $i + 1, $this->headers2[$i], $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1); + $this->NewLine(); + } + $count = count($this->headers); + for ($i = 0; $i < $count; $i++) + $this->TextCol($i, $i + 1, $this->headers[$i], $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=1); + $this->Font(); + + $this->NewLine(2); + + // restore user-specified draw color + $this->SetDrawColor($oldDrawColor[0], $oldDrawColor[1], $oldDrawColor[2]); + } + + /** + * Format a numeric string date into something nicer looking. + * + * @param string $date Date string to be formatted. + * @param int $input_format Format of the input string. Possible values are:
  • 0: user's default (default)
+ * @param int $output_format Format of the output string. Possible values are:
  • 0: Month (word) Day (numeric), 4-digit Year - Example: January 1, 2000 (default)
  • 1: Month 4-digit Year - Example: January 2000
  • 2: Month Abbreviation 4-digit Year - Example: Jan 2000
+ * @access public + */ + function DatePrettyPrint($date, $input_format = 0, $output_format = 0) + { + if ($date != '') + { + $date = date2sql($date); + $year = (int) (substr($date, 0, 4)); + $month = (int) (substr($date, 5, 2)); + $day = (int) (substr($date, 8, 2)); + if ($output_format == 0) + return(date('F j, Y', mktime(12, 0, 0, $month, $day, $year))); + elseif ($output_format == 1) + return(date('F Y', mktime(12, 0, 0, $month, $day, $year))); + elseif ($output_format == 2) + return(date('M Y', mktime(12, 0, 0, $month, $day, $year))); + } + else + return $date; + } + function AddImage($logo, $x, $y, $w, $h) { if (strpos($logo, ".png") || strpos($logo, ".PNG")) @@ -295,63 +645,118 @@ class FrontReport extends Cpdf $this->addJpegFromFile($logo, $x, $y, $w, $h); } + // Get current draw color setting from TCPDF object; returns array of RGB numbers + function GetDrawColor() + { + // Convert the TCPDF stored DrawColor string into an array of strings + $colorFields = explode(' ', $this->DrawColor); + + // Test last value: G == grayscale, single number; RG == RGB, 3 numbers + if ($colorFields[count($colorFields) - 1] == 'G') + // Convert a grayscale string value to the equivalent RGB value + $drawColor = array((float) $colorFields[0], (float) $colorFields[0], (float) $colorFields[0]); + else + // Convert RGB string values to the a numeric array + $drawColor = array((float) $colorFields[0], (float) $colorFields[1], (float) $colorFields[2]); + + return $drawColor; + } + function SetDrawColor($r, $g, $b) { - $this->setStrokeColor($r, $g, $b); + parent::SetDrawColor($r, $g, $b); } function SetTextColor($r, $g, $b) { - TCPDF::SetTextColor($r, $g, $b); + parent::SetTextColor($r, $g, $b); } - function Text($c, $txt, $n=0, $corr=0, $r=0) + /** + * Set the fill color for table cells. + * @see reporting/includes/TCPDF#SetFillColor($col1, $col2, $col3, $col4) + */ + function SetFillColor($r, $g, $b) + { + parent::SetFillColor($r, $g, $b); + } + + // Get current cell padding setting from TCPDF object + function GetCellPadding() + { + return $this->cMargin; + } + + // Set desired cell padding (aka "cell margin") + // Seems to be just left and right margins... + function SetCellPadding($pad) + { + parent::SetCellPadding($pad); + } + + function Text($c, $txt, $n=0, $corr=0, $r=0, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) { if ($n == 0) $n = $this->pageWidth - $this->rightMargin; - return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, 'left'); + return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, $align, $border, $fill, $link, $stretch); } - function TextWrap($xpos, $ypos, $len, $str, $align = 'left') + function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 0) { if ($this->fontSize != $this->oldFontSize) { $this->SetFontSize($this->fontSize); $this->oldFontSize = $this->fontSize; } - return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align); + return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align, $border, $fill, $link, $stretch); } - function TextCol($c, $n, $txt, $corr=0, $r=0) + function TextCol($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { - return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]); + return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch); } - function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0) + function AmountCol($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false) { - return $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r); + if ($color_red && $txt < 0) + $this->SetTextColor(255, 0, 0); + $ret = $this->TextCol($c, $n, number_format2($txt, $dec), $corr, $r, $border, $fill, $link, $stretch); + if ($color_red && $txt < 0) + $this->SetTextColor(0, 0, 0); + return $ret; } - function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0) + function AmountCol2($c, $n, $txt, $dec=0, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0, $color_red=false, $amount_locale = 'en_US.UTF-8', $amount_format = '%(!.2n') + { + setlocale(LC_MONETARY, $amount_locale); + if ($color_red && $txt < 0) + $this->SetTextColor(255, 0, 0); + $ret = $this->TextCol($c, $n, money_format($amount_format, $txt), $corr, $r, $border, $fill, $link, $stretch); + if ($color_red && $txt < 0) + $this->SetTextColor(0, 0, 0); + return $ret; + } + + function DateCol($c, $n, $txt, $conv=false, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { if ($conv) $txt = sql2date($txt); - return $this->TextCol($c, $n, $txt, $corr, $r); + return $this->TextCol($c, $n, $txt, $corr, $r, $border, $fill, $link, $stretch); } - function TextCol2($c, $n, $txt, $corr=0, $r=0) + function TextCol2($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { - return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c]); + return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c], $border, $fill, $link, $stretch); } - function TextColLines($c, $n, $txt, $corr=0, $r=0) + function TextColLines($c, $n, $txt, $corr=0, $r=0, $border=0, $fill=0, $link=NULL, $stretch=0) { $this->row -= $r; - $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]); + $this->TextWrapLines($this->cols[$c], $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c], $border, $fill, $link, $stretch); } - function TextWrapLines($c, $width, $txt, $align='left') + function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0) { $str = Explode("\n", $txt); for ($i = 0; $i < count($str); $i++) @@ -359,29 +764,117 @@ class FrontReport extends Cpdf $l = $str[$i]; do { - $l = $this->TextWrap($c, $this->row , $width, $l, $align); + $l = $this->TextWrap($c, $this->row , $width, $l, $align, $border, $fill, $link, $stretch); $this->row -= $this->lineHeight; } while ($l != ''); } } + /** + * Expose the underlying calcTextWrap() function in this API. + */ + function TextWrapCalc($txt, $width, $spacebreak=false) + { + return $this->calcTextWrap($txt, $width, $spacebreak); + } + + /** + * Sets the line drawing style. + * + * Takes an associative array as arg so you don't need to specify all values. + * + * Array keys: + * width (float) - the thickness of the line in user units + * cap (string) - the type of cap to put on the line, values can be 'butt','round','square' + * where the diffference between 'square' and 'butt' is that 'square' projects a flat end past the + * end of the line. + * join (string) - can be 'miter', 'round', 'bevel' + * dash (mixed) - Dash pattern. Is 0 (without dash) or string with series of length values, which are the + * lengths of the on and off dashes. For example: "2" represents 2 on, 2 off, 2 on, 2 off, ...; + * "2,1" is 2 on, 1 off, 2 on, 1 off, ... + * phase (integer) - a modifier on the dash pattern which is used to shift the point at which the pattern starts. + * color (array) - draw color. Format: array(GREY), or array(R,G,B) or array(C,M,Y,K). + */ + function SetLineStyle($style) + { + parent::SetLineStyle($style); + } + + /** + * Sets the line drawing width. + */ + function SetLineWidth($width) + { + parent::SetLineWidth($width); + } + function LineTo($from, $row, $to, $row2) { - Cpdf::line($from, $row, $to, $row2); + parent::line($from, $row, $to, $row2); } function Line($row, $height = 0) { - $this->setLineStyle($height + 1); - Cpdf::line($this->pageWidth - $this->rightMargin, $row ,$this->leftMargin, $row); + $oldLineWidth = $this->GetLineWidth(); + $this->SetLineWidth($height + 1); + parent::line($this->pageWidth - $this->rightMargin, $row ,$this->leftMargin, $row); + $this->SetLineWidth($oldLineWidth); } - function NewLine($l=1, $np=0) + /** + * Underlines the contents of a cell, but not the cell padding area. + * Primarily useful for the last line before a "totals" line. + * @param int $c Column number to underline. + * @param int $r Print the underline(s) this number of rows below the current position. Can be negative in order to go up. + * @param int $type Type of underlining to draw. Possible values are:
  • 1: single underline (default)
  • 2: double underline
+ * @param int $linewidth Thickness of the line to draw. Default value of zero will use the current line width defined for this document. + * @param array $style Line style. Array like for {@link SetLineStyle SetLineStyle}. Default value: default line style (empty array). + * @access public + * @see SetLineWidth(), SetDrawColor(), SetLineStyle() + */ + function UnderlineCell($c, $r = 0, $type = 1, $linewidth = 0, $style = array()) + { + // If line width was specified, save current setting so we can reset it + if ($linewidth != 0) + { + $oldLineWidth = $this->GetLineWidth(); + $this->SetLineWidth($linewidth); + } + + // Figure out how far down to move the line based on current font size + // Calculate this because printing underline directly at $this->row goes on top + // of the parts of characters that "hang down", like the bottom of commas & + // lowercase letter 'g', etc. + if ($this->fontSize < 10) + $y_adj = 2; + else + $y_adj = 3; + parent::line($this->cols[$c] + $this->cMargin, $this->row - $r - $y_adj, $this->cols[$c + 1] - $this->cMargin, $this->row - $r - $y_adj, $style); + + // Double underline, far enough below the first underline so as not to overlap + // the first underline (depends on current line thickness (aka "line width") + if ($type == 2) + parent::line($this->cols[$c] + $this->cMargin, $this->row - $r - $y_adj - ($this->GetLineWidth() + 2), $this->cols[$c + 1] - $this->cMargin, $this->row - $r - $y_adj - ($this->GetLineWidth() + 2), $style); + + // If line width was specified, reset it back to the original setting + if ($linewidth != 0) + $this->SetLineWidth($oldLineWidth); + } + + function NewLine($l=1, $np=0, $h = NULL) { - $this->row -= ($l * $this->lineHeight); - if ($this->row < $this->bottomMargin + ($np * $this->lineHeight)) - $this->Header(); + // If the line height wasn't specified, use the current setting + if ($h == NULL) + $h = $this->lineHeight; + + // Move one line down the page + $this->row -= ($l * $h); + // Reset the "current line height" for the new line + $this->curLineHeight = $this->fontSize; + // Check to see if we're at the bottom and should insert a page break + if ($this->row < $this->bottomMargin + ($np * $h)) + $this->{$this->headerFunc}(); // call header template chosen by current report } function End($email=0, $subject=null, $myrow=null, $doctype = 0) diff --git a/reporting/includes/tcpdf.php b/reporting/includes/tcpdf.php index ba54e66a..e30155a4 100644 --- a/reporting/includes/tcpdf.php +++ b/reporting/includes/tcpdf.php @@ -141,7 +141,10 @@ * and * if (!defined("K_RE_PATTERN_ARABIC")) * 4. Parameter $unicode in constructor renamed to $uni. - * 4. Header function renamed to Header1 (due to conflict with FrontReport Header) + * 5. Header function renamed to Header1 (due to conflict with FrontReport Header) + * 6. Line 6190, SetLineWidth (cast of values to avoid problem in PHP 5.2.6 + * 7. Line 6261. ereg replaced by preg_match (with start and end delimiter) + * 8. Lines 8642,9256 and 9348. split replaced by preg_split. * ------------------------------------------------------------------------------- */ if (!defined("K_PATH_FONTS")) @@ -6190,7 +6193,15 @@ if (!class_exists('TCPDF')) { function SetLineWidth($width) { //Set line width $this->LineWidth = $width; - $this->linestyleWidth = sprintf('%.2f w', ($width * $this->k)); + //$this->linestyleWidth = sprintf('%.2f w', ($width * $this->k)); + // FrontAccounting fix + // My PHP 5.2.6 environment gave an "Unsupported operand types" + // error for the multiplication on the next line some of the + // time when this method is called - I debugged and sometimes + // the $width parameter is some sort of weird array. I don't + // understand what's going on, but casting it to a (float) seems + // to "fix" the problem. -Jason Maas, 2009/09/25 + $this->linestyleWidth = sprintf('%.2f w', ((float) $width * (float) $this->k)); $this->_out($this->linestyleWidth); } @@ -6249,7 +6260,7 @@ if (!class_exists('TCPDF')) { if (isset($dash)) { $dash_string = ""; if ($dash) { - if (ereg("^.+,", $dash)) { + if (preg_match("/^.+,/", $dash)) { $tab = explode(",", $dash); } else { $tab = array($dash); @@ -8629,7 +8640,7 @@ if (!class_exists('TCPDF')) { $this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $scale_x, 0, 0, $scale_y, $x1*(1-$scale_x), $y2*(1-$scale_y))); } // handle pc/unix/mac line endings - $lines = split("\r\n|[\r\n]", $data); + $lines = preg_split("/\r\n|[\r\n]/", $data); $u=0; $cnt = count($lines); for ($i=0; $i < $cnt; $i++) { @@ -9243,7 +9254,7 @@ if (!class_exists('TCPDF')) { if (isset($dom[$key]['style']['font-family'])) { // font family if (isset($dom[$key]['style']['font-family'])) { - $fontslist = split(",", strtolower($dom[$key]['style']['font-family'])); + $fontslist = preg_split("/,/", strtolower($dom[$key]['style']['font-family'])); foreach($fontslist as $font) { $font = trim(strtolower($font)); if (in_array($font, $this->fontlist)){ @@ -9335,7 +9346,7 @@ if (!class_exists('TCPDF')) { if ($dom[$key]['value'] == "font") { // font family if (isset($dom[$key]['attribute']['face'])) { - $fontslist = split(",", strtolower($dom[$key]['attribute']['face'])); + $fontslist = preg_split("/,/", strtolower($dom[$key]['attribute']['face'])); foreach($fontslist as $font) { $font = trim(strtolower($font)); if (in_array($font, $this->fontlist)){ diff --git a/reporting/rep108.php b/reporting/rep108.php index 97c4413b..a3519221 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -156,7 +156,7 @@ function print_statements() number_format2($CustomerRecord["Balance"],$dec)); $col = array($rep->cols[0], $rep->cols[0] + 110, $rep->cols[0] + 210, $rep->cols[0] + 310, $rep->cols[0] + 410, $rep->cols[0] + 510); - $rep->row = $rep->bottomMargin + (8 * $rep->lineHeight - 6); + $rep->row = $rep->bottomMargin + (10 * $rep->lineHeight - 6); for ($i = 0; $i < 5; $i++) $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str[$i], 'right'); $rep->NewLine(); diff --git a/reporting/rep109.php b/reporting/rep109.php index 07767415..11349184 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -153,7 +153,10 @@ function print_sales_orders() $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); - $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2); + if ($myrow['tax_included'] == 0) + $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2); + else + $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->Font(); if ($email == 1) diff --git a/reporting/rep111.php b/reporting/rep111.php index a16a1d7f..826089bc 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -137,7 +137,10 @@ function print_sales_quotations() $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); - $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2); + if ($myrow['tax_included'] == 0) + $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2); + else + $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->Font(); if ($email == 1) diff --git a/sales/allocations/customer_allocate.php b/sales/allocations/customer_allocate.php index 058605c6..63a04cdb 100644 --- a/sales/allocations/customer_allocate.php +++ b/sales/allocations/customer_allocate.php @@ -36,7 +36,7 @@ function clear_allocations() unset($_SESSION['alloc']->allocs); unset($_SESSION['alloc']); } - session_register('alloc'); + //session_register('alloc'); } diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 74595a99..cd7299a8 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -136,9 +136,10 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { if (!check_quantities()) { display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity not dispatched on sales order.")); - } elseif(!check_num('ChargeFreightCost', 0)) + } elseif(!check_num('ChargeFreightCost', 0)) { display_error(_("Freight cost cannot be less than zero")); set_focus('ChargeFreightCost'); + } } //----------------------------------------------------------------------------- @@ -194,8 +195,6 @@ function check_data() } if (!check_quantities()) { - display_error(_("Selected quantity cannot be less than quantity invoiced nor more than quantity - not dispatched on sales order.")); return false; } @@ -395,8 +394,12 @@ if ($row['dissallow_invoices'] == 1) display_heading(_("Delivery Items")); div_start('Items'); start_table("$table_style width=80%"); -$th = array(_("Item Code"), _("Item Description"), _("Ordered"), _("Units"), _("Delivered"), + +$new = $_SESSION['Items']->trans_no==0; +$th = array(_("Item Code"), _("Item Description"), + $new ? _("Ordered") : _("Max. delivery"), _("Units"), $new ? _("Delivered") : _("Invoiced"), _("This Delivery"), _("Price"), _("Tax Type"), _("Discount"), _("Total")); + table_header($th); $k = 0; $has_marked = false; diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index b3d5ac96..1ba84ea6 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -100,7 +100,7 @@ class cart global $SysPrefs, $Refs; if (!is_array($trans_no)) $trans_no = array($trans_no); - if ($trans_no[0]) + if ($trans_no[0]) // read old transaction { if ($type == ST_SALESORDER || $type == ST_SALESQUOTE) { // sales order || sales quotation read_sales_order($trans_no[0], $this, $type); @@ -111,7 +111,7 @@ class cart $line->qty_dispatched = $line->quantity - $line->qty_done; } } - } else { // derivative transaction + } else { // other type of sales transaction read_sales_trans($type, $trans_no, $this); if ($this->order_no) { // free hand credit notes have no order_no $sodata = get_sales_order_header($this->order_no, ST_SALESORDER); @@ -121,9 +121,9 @@ class cart $this->delivery_to = $sodata["deliver_to"]; $this->delivery_address = $sodata["delivery_address"]; } + // old derivative transaction edit if (!$view && ($type!=ST_CUSTCREDIT || $this->trans_link!=0)) { $src_type = get_parent_type($type); - $src_details = 0; if ($src_type == ST_SALESORDER) { // get src data from sales_orders $this->src_docs = array( $sodata['order_no']=>$sodata['version']); $srcdetails = get_sales_order_details($this->order_no, ST_SALESORDER); @@ -132,7 +132,6 @@ class cart $srcdetails = get_customer_trans_details($src_type,array_keys($this->src_docs)); } // calculate & save: qtys on other docs and free qtys on src doc - $line_no = 0; for($line_no = 0; $srcline = db_fetch($srcdetails); $line_no++) { $sign = 1; // $type==13 ? 1 : -1; // this is strange debtor_trans atavism $line = &$this->line_items[$line_no]; @@ -141,17 +140,18 @@ class cart $line->qty_old = $line->qty_dispatched = $line->quantity; $line->quantity += $sign * ($srcline['quantity'] - $srcline['qty_done']); // add free qty on src doc } - } else { + } else { // prepare qtys for derivative document entry (not used in display) for($line_no = 0; $line_no < count($this->line_items); $line_no++) { $line = &$this->line_items[$line_no]; $line->src_id = $line->id; // save src line ids for update - $line->qty_dispatched = $line->quantity; + $line->qty_dispatched = $line->quantity - $line->qty_done; } } } - } else { + } else { // new document $this->trans_type = $type; $this->trans_no = 0; + $this->customer_currency = get_company_currency(); // set new sales document defaults here if (get_global_customer() != ALL_TEXT) $this->customer_id = get_global_customer(); diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index febf9332..483f5672 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -186,12 +186,12 @@ function set_document_parent($cart) if (count($cart->src_docs) == 1) { - // if this child document has only one parent - update child link - $del_no = reset(array_keys($cart->src_docs)); + // if this child document has only one parent - update child link + $del_no = reset(array_keys($cart->src_docs)); - $sql = 'UPDATE '.TB_PREF.'debtor_trans SET trans_link = ' . $del_no . - ' WHERE type=".db_escape($cart->trans_type)." AND trans_no='. $inv_no ; - db_query($sql, 'Child document link cannot be updated'); + $sql = 'UPDATE '.TB_PREF.'debtor_trans SET trans_link = ' . $del_no . + ' WHERE type='.db_escape($cart->trans_type).' AND trans_no='. $inv_no ; + db_query($sql, 'Child document link cannot be updated'); } if ($cart->trans_type != ST_SALESINVOICE) diff --git a/update.html b/update.html index 4f7064e3..2580973d 100644 --- a/update.html +++ b/update.html @@ -18,11 +18,11 @@ these files.
  • Upload all the new files. -
  • Look into the file, config.default.php and compare with your own config.php file. You should update the the following in your config.php:

    • Change the $version in your config.php file, about line 59, from "2.X.X" to "2.2".
    • Copy these 2 lines from config.default.php about line 80-82 into config.php about line 80:

      /* Show users online discretetely in the footer */
      $show_users_online = 0;
      Change this to 1 if you want to show users online.
    • Replace the 2 lines about line 110-111 in config.php:

      $table_style     = "cellpadding=3 border=1 bordercolor='#8cacbb' style='border-collapse: collapse'";
      $table_style2     = "cellpadding=3 border=1 bordercolor='#cccccc' style='border-collapse: collapse'";
    • With these 4 lines from config.default.php:

      if (!isset($_SESSION['bordercolor']))
          $_SESSION['bordercolor'] = "#8cacbb";
      $table_style     = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";
      $table_style2     = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";
    • Remove these 2 lines from config.php about line 176-177:

      /* default start-up tab (orders/AP/stock/manuf/proj/GL/system) */
      $def_app = "orders";
    • Copy these 3 lines from config.default.php about line 113-115

      // defalt dateformats and dateseps indexes used before user login

      $dflt_date_fmt = 0;
      $dflt_date_sep = 0;
    • Copy these 2 lines from config.default.php about line 211-212:

      define("ICON_SUBMIT", "ok.gif");        // new in 2.2
      define("ICON_ESCAPE", "escape.png");    // new in 2.2
    • And paste them into config.php about line 209
    • If you use gregorian calendar and have non-workdays on Friday and first day of week = Saturday
      then you  should  set this line in config.php about line  95.
      $date_system = 3;
    • If you want to use FrontAccounting help wiki then set this line in config.php about line 85
      $help_base_url = "http://frontaccounting.net/fawiki?n=Help.";
  • Rename or remove the /install folder (you have already performed the install +
  • Look into the file, config.default.php and compare with your own config.php file. You should update the the following in your config.php:

    • Change the $version in your config.php file, about line 59, from "2.X.X" to "2.2.2".
    • If this is an update from "2.2.X" to "2.2.2" you are done and  should ignore the the rest of the items in this note.
    • Copy these 2 lines from config.default.php about line 80-82 into config.php about line 80:

      /* Show users online discretetely in the footer */
      $show_users_online = 0;
      Change this to 1 if you want to show users online.
    • Replace the 2 lines about line 110-111 in config.php:

      $table_style     = "cellpadding=3 border=1 bordercolor='#8cacbb' style='border-collapse: collapse'";
      $table_style2     = "cellpadding=3 border=1 bordercolor='#cccccc' style='border-collapse: collapse'";
    • With these 4 lines from config.default.php:

      if (!isset($_SESSION['bordercolor']))
          $_SESSION['bordercolor'] = "#8cacbb";
      $table_style     = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";
      $table_style2     = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";
    • Remove these 2 lines from config.php about line 176-177:

      /* default start-up tab (orders/AP/stock/manuf/proj/GL/system) */
      $def_app = "orders";
    • Copy these 3 lines from config.default.php about line 113-115

      // defalt dateformats and dateseps indexes used before user login

      $dflt_date_fmt = 0;
      $dflt_date_sep = 0;
    • Copy these 2 lines from config.default.php about line 211-212:

      define("ICON_SUBMIT", "ok.gif");        // new in 2.2
      define("ICON_ESCAPE", "escape.png");    // new in 2.2
    • And paste them into config.php about line 209
    • If you use gregorian calendar and have non-workdays on Friday and first day of week = Saturday
      then you  should  set this line in config.php about line  95.
      $date_system = 3;
    • If you want to use FrontAccounting help wiki then set this line in config.php about line 85
      $help_base_url = "http://frontaccounting.net/fawiki?n=Help.";
  • Rename or remove the /install folder (you have already performed the install process earlier).
    1. - - - + + +
  • You must immediately