frontaccount/0000755000175000017500000000000011404426533013173 5ustar januszjanuszfrontaccount/update.html0000644000175000017500000001733011404426405015345 0ustar januszjanusz FrontAccounting Update
FrontAccounting Update


Important Notes

frontaccount/install/0000755000175000017500000000000011404426503014636 5ustar januszjanuszfrontaccount/install/save.php0000644000175000017500000002534411314437666016331 0ustar januszjanusz Copyright (C) 2004-2007, Ryan Djurovich. The code is released under GPLv3 modified by FrontAcounting, LLC. ***********************************************************************/ error_reporting(E_ALL); ini_set("display_errors", "On"); ini_set("max_execution_time", "180"); // Start a session if(!defined('SESSION_STARTED')) { session_name('ba_session_id'); session_start(); define('SESSION_STARTED', true); } if (!function_exists("_")) { function _($msg) { return $msg; } } // Installer version of display_error function. // function display_error($message) { global $_POST, $path_to_root; if(isset($message) AND $message != '') { // Copy values entered into session so user doesn't have to re-enter everything if(isset($_POST['company_name'])) { $_SESSION['ba_url'] = $_POST['ba_url']; $_SESSION['operating_system'] = isset($_POST['operating_system']); $_SESSION['world_writeable'] = isset($_POST['world_writeable']); $_SESSION['database_host'] = $_POST['database_host']; $_SESSION['database_username'] = $_POST['database_username']; $_SESSION['database_password'] = $_POST['database_password']; $_SESSION['database_name'] = $_POST['database_name']; $_SESSION['demo_data'] = isset($_POST['demo_data']); $_SESSION['table_prefix'] = isset($_POST['table_prefix']); $_SESSION['install_tables'] = isset($_POST['install_tables']); $_SESSION['company_name'] = $_POST['company_name']; $_SESSION['admin_email'] = $_POST['admin_email']; $_SESSION['admin_password'] = $_POST['admin_password']; } // Set the message $_SESSION['message'] = $message; // Specify that session support is enabled $_SESSION['session_support'] = 'Enabled'; // Redirect to first page again and exit @unlink($path_to_root."/config.php"); // remove just created config file header('Location: index.php?sessions_checked=true'); exit(); } } // Function to workout what the default permissions are for files created by the webserver function default_file_mode($temp_dir) { $v = explode(".",PHP_VERSION); $v = $v[0].$v[1]; if($v > 41 && is_writable($temp_dir)) { $filename = $temp_dir.'/test_permissions.txt'; $handle = fopen($filename, 'w'); fwrite($handle, 'This file is to get the default file permissions'); fclose($handle); $default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3); unlink($filename); } else { $default_file_mode = '0777'; } return $default_file_mode; } // Function to workout what the default permissions are for directories created by the webserver function default_dir_mode($temp_dir) { $v = explode(".",PHP_VERSION); $v = $v[0].$v[1]; if ($v > 41 && is_writable($temp_dir)) { $dirname = $temp_dir.'/test_permissions/'; mkdir($dirname); $default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3); rmdir($dirname); } else { $default_dir_mode = '0777'; } return $default_dir_mode; } function add_slashes($input) { if (get_magic_quotes_gpc() || (!is_string($input))) { return $input; } $output = addslashes($input); return $output; } function check_db_error($err_msg, $sql) { return true; } if (isset($_POST['path_to_root'])) $path_to_root = $_POST['path_to_root']; else $path_to_root = ".."; // Begin check to see if form was even submitted // Set error if no post vars found if (!isset($_POST['company_name'])) { display_error('Please fill-in the form below'); } // End check to see if form was even submitted // Begin path and timezone details code // Check if user has entered the installation url if (!isset($_POST['ba_url']) || $_POST['ba_url'] == '') { display_error('Please enter an absolute URL'); } else { $ba_url = $_POST['ba_url']; } // Remove any slashes at the end of the URL if(substr($ba_url, strlen($ba_url) - 1, 1) == "/") { $ba_url = substr($ba_url, 0, strlen($ba_url) - 1); } if(substr($ba_url, strlen($ba_url) - 1, 1) == "\\") { $ba_url = substr($ba_url, 0, strlen($ba_url) - 1); } if(substr($ba_url, strlen($ba_url) - 1, 1) == "/") { $ba_url = substr($ba_url, 0, strlen($ba_url) - 1); } if(substr($ba_url, strlen($ba_url) - 1, 1) == "\\") { $ba_url = substr($ba_url, 0, strlen($ba_url) - 1); } // End path // Begin operating system specific code // Get operating system if (!isset($_POST['operating_system']) || $_POST['operating_system'] != 'linux' && $_POST['operating_system'] != 'windows') { display_error('Please select a valid operating system'); } else { $operating_system = $_POST['operating_system']; } // Work-out file permissions if($operating_system == 'windows') { $file_mode = '0777'; $dir_mode = '0777'; } elseif (isset($_POST['world_writeable']) && $_POST['world_writeable'] == 'true') { $file_mode = '0777'; $dir_mode = '0777'; } else { $file_mode = default_file_mode('../includes'); $dir_mode = default_dir_mode('../includes'); } // End operating system specific code // Begin database details code // Check if user has entered a database host if (!isset($_POST['database_host']) || $_POST['database_host'] == '') { display_error('Please enter a database host name'); } else { $database_host = $_POST['database_host']; } // Check if user has entered a database username if (!isset($_POST['database_username']) || $_POST['database_username'] == '') { display_error('Please enter a database username'); } else { $database_username = $_POST['database_username']; } // Check if user has entered a database password if (!isset($_POST['database_password'])) { display_error('Please enter a database password'); } else { $database_password = $_POST['database_password']; } // Check if user has entered a database name if (!isset($_POST['database_name']) || $_POST['database_name'] == '') { display_error('Please enter a database name'); } else { $database_name = $_POST['database_name']; } // Get table prefix if (isset($_POST['table_prefix']) && $_POST['table_prefix'] == 'true') $table_prefix = "0_"; else $table_prefix = ""; // Find out if the user wants to install tables and data if (isset($_POST['install_tables']) && $_POST['install_tables'] == 'true') { $install_tables = true; } else { $install_tables = false; } // End database details code // Begin company name code // Get company name if (!isset($_POST['company_name']) || $_POST['company_name'] == '') { display_error('Please enter a company name'); } else { $company_name = add_slashes($_POST['company_name']); } // End website company name // Check if the user has entered a correct path if (!file_exists($path_to_root.'/sql/en_US-'.(isset($_POST['demo_data']) ? 'demo':'new').'.sql')) { display_error('It appears the Absolute path that you entered is incorrect'); } // Get admin email and validate it if (!isset($_POST['admin_email']) || $_POST['admin_email'] == '') { display_error('Please enter an email for the Administrator account'); } else { 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']; } else { display_error('Please enter a valid email address for the Administrator account'); } } // Get the two admin passwords entered, and check that they match if (!isset($_POST['admin_password']) || $_POST['admin_password'] == '') { display_error('Please enter a password for the Administrator account'); } else { $admin_password = $_POST['admin_password']; } if (!isset($_POST['admin_repassword']) || $_POST['admin_repassword'] == '') { display_error('Please make sure you re-enter the password for the Administrator account'); } else { $admin_repassword = $_POST['admin_repassword']; } if ($admin_password != $admin_repassword) { display_error('Sorry, the two Administrator account passwords you entered do not match'); } // End admin user details code copy($path_to_root. "/config.default.php", $path_to_root. "/config.php"); include_once($path_to_root . "/includes/db/connect_db.inc"); include_once($path_to_root . "/admin/db/maintenance_db.inc"); if (!file_exists($path_to_root . "/installed_extensions.php")) { $next_extension_id = 1; write_extensions(array()); write_extensions(array(),0); } if (!file_exists($path_to_root . "/lang/installed_languages.inc")) { $installed_languages = array ( 0 => array ('code' => 'en_GB', 'name' => 'English', 'encoding' => 'iso-8859-1')); $dflt_lang = 'en_GB'; write_lang(); } if (file_exists($path_to_root . "/config_db.php")) include_once($path_to_root . "/config_db.php"); else { $def_coy = 0; $tb_pref_counter = 0; $db_connections = array (); } $id = count($db_connections); if ($table_prefix != "" && $id > 0) $table_prefix = $tb_pref_counter . "_"; $db_connections[$id]['name'] = $company_name; $db_connections[$id]['host'] = $database_host; $db_connections[$id]['dbuser'] = $database_username; $db_connections[$id]['dbpassword'] = $database_password; $db_connections[$id]['dbname'] = $database_name; $db_connections[$id]['tbpref'] = $table_prefix; $def_coy = $id; $config_filename = $path_to_root . '/config_db.php'; // Try connecting to database $db = mysql_connect($database_host, $database_username, $database_password); if (!$db) { display_error('Database host name, username and/or password incorrect. MySQL Error:
'.mysql_error()); } else { $result = true; if($install_tables == true) { if (!mysql_select_db($database_name, $db)) { // Try to create the database if (!($result = mysql_query('CREATE DATABASE '.$database_name))) { display_error(_("Cannot create database"). " '$database_name'"); } else $result = mysql_select_db($database_name, $db); } if($result) { $import_filename = $path_to_root.'/sql/en_US-'.(isset($_POST['demo_data']) ? 'demo':'new').'.sql'; db_import($import_filename, $db_connections[$id]); } } else { $result = mysql_select_db($database_name, $db); } if ($result) { $sql = "UPDATE ".$table_prefix."users SET password = '" . md5($admin_password) . "', email = ".db_escape($admin_email)." WHERE user_id = 'admin'"; db_query($sql, "could not update admin account"); $sql = "UPDATE ".$table_prefix."company SET coy_name = ".db_escape($company_name)." WHERE coy_code = 1"; db_query($sql, "could not update company name. Do it manually later in Setup"); $err = write_config_db($table_prefix != ""); if ($err == -1) display_error("Cannot open the configuration file ($config_filename)"); else if ($err == -2) display_error("Cannot write to the configuration file ($config_filename)"); else if ($err == -3) display_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4."); } } session_unset(); session_regenerate_id(); session_destroy(); $_SESSION = array(); header("Location: ".$path_to_root."/index.php"); exit(); ?>frontaccount/install/index.php0000644000175000017500000003572611301263001016457 0ustar januszjanusz Copyright (C) 2004-2007, Ryan Djurovich. The code is released under GPLv3 modified by FrontAcounting, LLC. ***********************************************************************/ error_reporting(E_ALL); ini_set("display_errors", "On"); // Start a session if(!defined('SESSION_STARTED')) { session_name('ba_session_id'); session_start(); define('SESSION_STARTED', true); } // Check if the page has been reloaded if(!isset($_GET['sessions_checked']) || $_GET['sessions_checked'] != 'true') { // Set session variable $_SESSION['session_support'] = 'Enabled'; $_SESSION['message'] = ''; // Reload page header('Location: index.php?sessions_checked=true'); exit(0); } else { // Check if session variable has been saved after reload if(isset($_SESSION['session_support'])) { $session_support = $_SESSION['session_support']; } else { $session_support = 'Disabled'; } } $path_to_root = ".."; //include_once($path_to_root.'/config.php'); $comp_path = $path_to_root."/company"; ?> FrontAccounting Installation Wizard
FrontAccounting Installation Wizard

Welcome to the FrontAccounting Installation Wizard.

Logo
Error: Seems you have FrontAccounting application already installed.
After logging as an admin to first installed company you can:
  • Add more companies using Add/Update Companies under Setup tab;
  • Upgrade FA version using Upgrade Software under Setup tab.
Error:
Enabled') { ?>

Step 1

Please check the following requirements are met before continuing...
Please note: PHP Session Support may appear disabled if your browser does not support cookies.
PHP Version > 4.1.0 4.1) { ?>YesNo PHP Session Support PHP Safe Mode EnabledDisabled
Magic Quotes GPC Enabled'; } else { echo 'Disabled'; } ?> Register Globals Enabled'; } else { echo 'Disabled'; } ?>

Step 2

Please check the following files/folders are writeable before continuing...
config_db.php Writeable'; } elseif(file_exists($path_to_root.'/config_db.php')) { echo 'File Exists'; } else { echo 'Unwriteable'; } ?> modules/ Writeable'; } elseif(!file_exists($path_to_root.'/modules/')) { echo 'Directory Not Found'; } else { echo 'Unwriteable'; } ?>
lang/ Writeable'; } elseif(!file_exists($path_to_root.'/lang/')) { echo 'Directory Not Found'; } else { echo 'Unwriteable'; } ?> Writeable'; } elseif(!file_exists($comp_path)) { echo 'Directory Not Found'; } else { echo 'Unwriteable'; } ?>

Step 3

Please check your path settings...
Absolute URL:

Step 4

Please specify your operating system information below...
Server Operating System: /> Linux/Unix based
/> Windows
/>
(Please note: this is only recommended for testing environments)
Please enter your MySQL database server details below...
Host Name:   Username:
Database Name:   Password: />
Table Prefix ( 0_ ): />   />
      (Please note: May remove existing tables and data)
Fill database with demo data: />
 

Step 5

Please enter the training company name below (you can create your own company later)...
Company Name:

Step 6

Please enter your Administrator account details below...
Username: admin   Password: />
Email: />   Re-Password: />

 

Please note:   FrontAccounting is released under the GNU General Public License. By clicking install, you are accepting the license.
FrontAccounting is released under the GNU General Public License
frontaccount/install/stylesheet.css0000644000175000017500000000212410607534214017543 0ustar januszjanuszbody,td,th,input,textarea { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; } body { background-color: #557799; background-image: url(../admin/interface/background.png); background-repeat: repeat-x; margin: 0px; } form { margin: 0; } .submit { border : solid 1px #CCCCCC; background: #E9ECEF; color : #003366; font-weight : bold; font-size : 11px; padding: 4px; width: 100%; } .content { background-color: #FFFFFF; padding: 15px; height: 350px; width: 750px; text-align: justify; vertical-align: top; } hr { margin: 15px 0px 15px 0px; color: #003366; height: 1px; } h1 { font-size: 13px; color: #336699; margin: 0px 0px 5px 0px; border-bottom: 1px solid #CCCCCC; } h2 { font-size: 12px; color: #336699; text-align: center; margin: 0px 0px 5px 0px; } a:link, a:visited, a:active { color: #003366; text-decoration: none; } a:hover { text-decoration: none; color: #336699; } .bad { color: #FF0000; font-weight: bold; } .good { color: #009900; font-weight: bold; } .note { color: #666666; font-size: 10px; } .hide { display: none; }frontaccount/modules/0000777000175000017500000000000011404426511014643 5ustar januszjanuszfrontaccount/modules/index.php0000644000175000017500000000005310616051254016457 0ustar januszjanusz frontaccount/.htaccess0000644000175000017500000000074211301262777015000 0ustar januszjanusz# These settings are recommended # Maybe you might have problems # with other scripts that needs # register_globals ON php_flag magic_quotes_gpc Off php_flag register_globals Off php_flag session.use_trans_sid Off php_flag magic_quotes_gpc Off php_flag register_globals Off php_flag session.use_trans_sid Off #Sometimes neccessary to add those # #AddType application/x-javascript .js #AddType text/css .css frontaccount/config.default.php0000644000175000017500000001652611404426405016604 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------- // User configurable variables //--------------------------------------------------- /*Show debug messages returned from an error on the page. Debugging info level also determined by settings in PHP.ini if $debug=1 show debugging info, dont show if $debug=0 */ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die("Restricted access"); // Log file for error/warning messages. Should be set to any location // writable by www server. When set to empty string logging is switched off. // Special value 'syslog' can be used for system logger usage (see php manual). //$error_logfile = ''; $error_logfile = dirname(__FILE__).'/tmp/errors.log'; $debug = 1; $show_sql = 0; $go_debug = 0; $pdf_debug = 0; // set $sql_trail to 1 only if you want to perform bugtracking sql trail // Warning: this produces huge amount of data in sql_trail table. // Don't forget switch the option off and flush the table manually after // trail, or your future backup files are overloaded with unneeded data. // $sql_trail = 0; // save all sql queries in sql_trail $select_trail = 0; // track also SELECT queries if ($go_debug == 1) { error_reporting(E_ALL); ini_set("display_errors", "On"); } else { error_reporting(E_USER_WARNING|E_USER_ERROR|E_USER_NOTICE); // ini_alter("error_reporting","E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_PARSE"); ini_set("display_errors", "On"); } if($error_logfile != '') { ini_set("error_log", $error_logfile); ini_set("ignore_repeated_errors", "On"); ini_set("log_errors", "On"); } // Main Title $app_title = "FrontAccounting"; // application version $version = "2.2.10"; // Build for development purposes $build_version = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt")); // Powered by $power_by = "FrontAccounting"; $power_url = "http://frontaccounting.com"; /* use popup windows for views */ $use_popup_windows = 1; /* use date picker for all date fields */ $use_date_picker = 1; /* use Audit Trails in GL */ $use_audit_trail = 0; /* use old style convert (income and expense in BS, PL) */ $use_oldstyle_convert = 0; /* show users online discretely in the footer */ $show_users_online = 0; /* default print destination. 0 = PDF/Printer, 1 = Excel */ $def_print_destination = 0; // Wiki context help configuration // If your help wiki use translated page titles uncomment next line // $old_style_help = 1; // this setting is depreciated and subject to removal in next FA versions // locally installed wiki module // $help_base_url = $path_to_root.'/modules/wiki/index.php?n='._('Help').'.'; // context help feed from frontaccounting.net // $help_base_url = 'http://frontaccounting.com/fawiki/index.php?n=Help.'; // not used $help_base_url = null; /* per user data/cache directory */ $comp_path = $path_to_root.'/company'; /* allow alpha characters in accounts. 0 = numeric, 1 = alpha numeric, 2 = uppercase alpha numeric */ $accounts_alpha = 0; /* Date systems. 0 = traditional, 1 = Jalali used by Iran, nabour countries, Afghanistan and some other Central Asian nations, 2 = Islamic used by other arabic nations. 3 = traditional, but where non-workday is Friday and start of week is Saturday */ $date_system = 0; /* email stock location if order below reorder-level */ $loc_notification = 0; /* print_invoice_no. 0 = print reference number, 1 = print invoice number */ $print_invoice_no = 0; $dateformats = array("MMDDYYYY", "DDMMYYYY", "YYYYMMDD"); $dateseps = array("/", ".", "-", " "); $thoseps = array(",", ".", " "); $decseps = array(".", ","); // defalt dateformats and dateseps indexes used before user login $dflt_date_fmt = 0; $dflt_date_sep = 0; $pagesizes = array("Letter", "A4"); // default PDF pagesize /* Default border and spacing for tables */ /* Should be moved to CSS */ $table_style = "class='tablestyle'"; $table_style2 = "class='tablestyle2'"; /* Accounts Payable */ /* System check to see if quantity charged on purchase invoices exceeds the quantity received. If this parameter is checked the proportion by which the purchase invoice is an overcharge referred to before reporting an error */ $check_qty_charged_vs_del_qty = true; /* System check to see if price charged on purchase invoices exceeds the purchase order price. If this parameter is checked the proportion by which the purchase invoice is an overcharge referred to before reporting an error */ $check_price_charged_vs_order_price = True; $config_allocation_settled_allowance = 0.005; // Internal configurable variables //----------------------------------------------------------------------------------- /* Whether to display the demo login and password or not */ $allow_demo_mode = false; /* for uploaded item pictures */ $pic_width = 80; $pic_height = 50; $max_image_size = 500; /* skin for Business Graphics, 1, 2 or 3 */ $graph_skin = 1; /* Before upgrade from pre-2.2 FA you have to move here your customized security roles definitions. If you have used standard roles, you can simply uncomment following two arrays. After upgrade both arrays need to be deleted or commented out. You may wish to change user roles to new better defined in Users Setup. Old not used roles can be set inactive or deleted. */ /* Standard FA2.1 Security Group definitions $security_headings = array( _("Inquiries"), _("Accountant"), _("System Administrator"), ); $security_groups = array( array(1,2), array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,16), array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20), ); */ //MySQL Backup and Restore Settings if(isset($_SESSION["wa_current_user"])) { define("BACKUP_PATH", $comp_path.'/'.user_company()."/backup/"); } // static js files path $js_path = $path_to_root.'/js/'; // standard external js scripts included in all files $js_static = array('JsHttpRequest.js', 'behaviour.js', 'utils.js', 'inserts.js'); // additional js source included in header $js_lib = $js_userlib = array(); if (!defined('ICON_EDIT')) { define("ICON_EDIT", "edit.gif"); define("ICON_DELETE", "delete.gif"); define("ICON_ADD", "ok.gif"); define("ICON_UPDATE", "ok.gif"); define("ICON_OK", "ok.gif"); define("ICON_CANCEL", "cancel.png"); define("ICON_GL", "gl.png"); define("ICON_PRINT", "print.png"); define("ICON_PDF", "pdf.gif"); define("ICON_DOC", "invoice.gif"); define("ICON_CREDIT", "credit.gif"); define("ICON_RECEIVE", "receive.gif"); define("ICON_DOWN", "download.gif"); define("ICON_MONEY", "money.png"); define("ICON_REMOVE", "remove.png"); define("ICON_REPORT", "report.png"); define("ICON_VIEW", "view.gif"); define("ICON_SUBMIT", "ok.gif"); define("ICON_ESCAPE", "escape.png"); } ?>frontaccount/frontaccounting.php0000644000175000017500000000760211301262777017120 0ustar januszjanusz. ***********************************************************************/ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die("Restricted access"); include_once($path_to_root . '/applications/application.php'); include_once($path_to_root . '/applications/customers.php'); include_once($path_to_root . '/applications/suppliers.php'); include_once($path_to_root . '/applications/inventory.php'); include_once($path_to_root . '/applications/manufacturing.php'); include_once($path_to_root . '/applications/dimensions.php'); include_once($path_to_root . '/applications/generalledger.php'); include_once($path_to_root . '/applications/setup.php'); include_once($path_to_root . '/installed_extensions.php'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $ext) { if ($ext['type'] == 'module') include_once($path_to_root."/".$ext['path']."/".$ext['filename']); } } class front_accounting { var $user; var $settings; var $applications; var $selected_application; // GUI var $menu; //var $renderer; function front_accounting() { //$this->renderer =& new renderer(); } function add_application(&$app) { if ($app->enabled) // skip inactive modules $this->applications[$app->id] = &$app; } function get_application($id) { if (isset($this->applications[$id])) return $this->applications[$id]; return null; } function get_selected_application() { if (isset($this->selected_application)) return $this->applications[$this->selected_application]; foreach ($this->applications as $application) return $application; return null; } function display() { global $path_to_root; include($path_to_root . "/themes/".user_theme()."/renderer.php"); $this->init(); $rend = new renderer(); $rend->wa_header(); //$rend->menu_header($this->menu); $rend->display_applications($this); //$rend->menu_footer($this->menu); $rend->wa_footer(); } function init() { global $installed_extensions, $path_to_root; $this->menu = new menu(_("Main Menu")); $this->menu->add_item(_("Main Menu"), "index.php"); $this->menu->add_item(_("Logout"), "/account/access/logout.php"); $this->applications = array(); $this->add_application(new customers_app()); $this->add_application(new suppliers_app()); $this->add_application(new inventory_app()); $this->add_application(new manufacturing_app()); $this->add_application(new dimensions_app()); $this->add_application(new general_ledger_app()); if (count($installed_extensions) > 0) { // Do not use global array directly here, or you suffer // from buggy php behaviour (unexpected loop break // because of same var usage in class constructor). $extensions = $installed_extensions; foreach ($extensions as $ext) { if (@($ext['active'] && $ext['type'] == 'module')) // supressed warnings before 2.2 upgrade { $_SESSION['get_text']->add_domain($_SESSION['language']->code, $ext['path']."/lang"); $class = $ext['tab']."_app"; if (class_exists($class)) $this->add_application(new $class()); $_SESSION['get_text']->add_domain($_SESSION['language']->code, $path_to_root."/lang"); } } } $this->add_application(new setup_app()); } } ?>frontaccount/access/0000755000175000017500000000000011404426471014435 5ustar januszjanuszfrontaccount/access/timeout.php0000644000175000017500000000231611301266071016630 0ustar januszjanusz. ***********************************************************************/ /* User authentication page popped up after login timeout during ajax call. */ $path_to_root = '..'; $page_security = 'SA_OPEN'; include_once($path_to_root . "/includes/session.inc"); include($path_to_root .'/access/login.php'); if (get_post('SubmitUser') && $_SESSION['wa_current_user']->logged_in()) { // After successfull login repeat last ajax call. // Login form consists all post variables from last ajax call. echo ""; } ?> frontaccount/access/index.php0000644000175000017500000000005310607534205016252 0ustar januszjanusz frontaccount/access/login.php0000644000175000017500000001266311336507275016274 0ustar januszjanusz. ***********************************************************************/ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die(_("Restricted access")); include_once($path_to_root . "/includes/ui.inc"); $js = ""; $js2 = ""; // Display demo user name and password within login form if "$allow_demo_mode" is true if ($allow_demo_mode == true) { $demo_text = _("Login as user: demouser and password: password"); } else { $demo_text = _("Please login here"); } if (!isset($def_coy)) $def_coy = 0; $def_theme = "default"; $login_timeout = $_SESSION["wa_current_user"]->last_act; $title = $login_timeout ? _('Authorization timeout') : $app_title." ".$version." - "._("Login"); $encoding = isset($_SESSION['language']->encoding) ? $_SESSION['language']->encoding : "iso-8859-1"; $rtl = isset($_SESSION['language']->dir) ? $_SESSION['language']->dir : "ltr"; $onload = !$login_timeout ? "onload='defaultCompany()'" : ""; echo "\n"; echo "\n"; echo "$title\n"; echo "\n"; echo " \n"; if (!$login_timeout) { echo $js; } echo $js2; echo "\n"; echo "\n"; echo "
$title
\n"; div_start('_page_body'); br();br(); start_form(false, false, $_SESSION['timeout']['uri'], "loginform"); start_table("class='login'"); start_row(); echo ""; if (!$login_timeout) { // FA logo echo "FrontAccounting"; } else { echo ""._('Authorization timeout').""; } echo "\n"; end_row(); echo "\n"; if (!$login_timeout) table_section_title(_("Version")." $version Build $build_version - "._("Login")); $value = $login_timeout ? $_SESSION['wa_current_user']->loginname : ($allow_demo_mode ? "demouser":""); text_row(_("User name"), "user_name_entry_field", $value, 20, 30); $password = $allow_demo_mode ? "password":""; password_row(_("Password:"), 'password', $password); if ($login_timeout) { hidden('company_login_name', $_SESSION["wa_current_user"]->company); } else { if (isset($_SESSION['wa_current_user']->company)) $coy = $_SESSION['wa_current_user']->company; else $coy = $def_coy; echo ""._("Company")."\n"; start_row(); label_cell($demo_text, "colspan=2 align='center'"); end_row(); }; end_table(1); echo "
\n"; foreach($_SESSION['timeout']['post'] as $p => $val) { // add all request variables to be resend together with login data if (!in_array($p, array('ui_mode', 'user_name_entry_field', 'password', 'SubmitUser', 'company_login_name'))) echo ""; } end_form(1); echo ""; div_end(); echo "\n"; echo ""; if (isset($_SESSION['wa_current_user'])) $date = Today() . " | " . Now(); else $date = date("m/d/Y") . " | " . date("h.i am"); echo "\n"; echo "
$date
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "

\n"; echo "\n"; ?>frontaccount/access/logout.php0000644000175000017500000000302311301262777016460 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_OPEN'; $path_to_root=".."; include($path_to_root . "/includes/session.inc"); include($path_to_root . "/includes/page/header.inc"); page_header(_("Logout"), true, false, '', get_js_png_fix()); echo "
FrontAccounting
 
"; echo _("Thank you for using") . " "; echo "$app_title $version"; echo "
 
"; echo "" . _("Click here to Login Again.") . ""; echo "

\n"; end_page(false, true); session_unset(); session_destroy(); ?> frontaccount/doc/0000755000175000017500000000000011404426475013745 5ustar januszjanuszfrontaccount/doc/license.txt0000644000175000017500000010451411155270677016141 0ustar januszjanusz GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . frontaccount/doc/access_levels.txt0000644000175000017500000001234011301266071017307 0ustar januszjanusz FrontAccounting access control system ===================================== Since version 2.2 FrontAccounting has new, flexible access level control system. In contrast to previous system based on arrays stored in global config.php file, the new system uses per company security_roles tables. This approach makes FrontAccounting finally suitable for multicompany installation involving various types of companies. 1. Security schema ------------------ New access control system uses following concepts: . Security area - elementary fragment of application functionality which is placed under control of access system; . Security role - set of security areas which is accessable for user with some role in company; . Security section - a couple of security areas of similar application grouped together to make roles defining easier. Security areas stored in global $security_areas array have two properties: identifier (in numeric and string form) and description. Description is used only to identify area in security roles editor, while string identifiers are used in various places of source code to be checked against current user permissions. Every security area belongs to one security section, which can be considered as upper level of access control. All defined security sections are stored in global $security_sections array together with descriptions used in roles editor. 2. Access Setup --------------- FrontAccounting since version 2.2 has role based access system. It means that every user defined in a system has assigned role related to his position in company. For any user only security areas which belong to user's role are accesible. To grant access to any security area for any role administrator first have to make accessible also related area's security section. Switching security section off disables access to all related security areas. Security roles predefined in FrontAccounting initial database can be customized or completely rewritten by administrator according to company internal security policy. Some security areas crucial for overall site security are accesible only for administrators of the first installed company, who can be considered as superadmins. All those important areas are grouped in section 0 (System administration), and as of FA 2.2 involve: . Installing/update of companies . Installing/update language message files . Installing/activation system extensions . System upgrades 3. How all it works ------------------- Every user defined in a system has one security role assigned. List of all accesible security areas/sections codes is retrieved from security_roles table on user login, and cached in user session variable for fast checking. Every page in a system has at least one related security area, which is assigned to $page_security global variable at the beginning of the page script. Page access control is performed by check_page_security() call in page() function (used for every displayed page) or by can_access_page() call in FrontReport constructor for all reports. When user has granted access rights to checked security area, selected page is displayed or report generated. Otherwise information message is displayed and page/report generation is aborted. 4. Security extensions ---------------------- FrontAccounting application accepts two forms of functionality additions: extension modules and extension plugins. Both types of extensions can use standard security areas/sections to control access to introduced functionality, or define its own security areas and/or sections. To extend access control system with additional sections/areas, extension need to contain a file were all new extensions are defined. The access control file relative path should be entered during extension install process on Install/Activate Extensions page, or as 'access' property during direct entry in installed_extensions.php file. Every php script using security extensions have to call function add_security_extensions() to make defined extensions active. The call should be placed between session.inc inclusion and page() or FrontReport() call. 5. Example access control configuration file -------------------------------------------- This is content of sample access control file for CRM extension module: The exact values used for security section codes are not very important, as they are rewritten by access control system during integration of access extensions. Therefore numeric values of security sections/areas should never be used directly in the extensions source. Use string representations instead when needed, or values retrieved from $security_areas array. frontaccount/doc/calculate_price.txt0000644000175000017500000000504511301266071017617 0ustar januszjanuszCalculate sales price from standard cost ---------------------------------------- You can have automatic sales price calculation for items that do not have any prices in Sales Prices entered. This works independently from the Base Price List setting, but if the factor is set in the other Sales Type Lists it works together with them. Preparing and operation ----------------------- Go into Setup tab - Company Setup. In the field, Base for auto price calculation, set a Base Price List. In the field, Add Price from Std cost, enter the % that you want to increase from the average standard costs for the items not listed in the Item Price List. If this value is empty there are no automatic price calculations. BE aware that an increase value of 0 will calculate the price to be the same as the Std cost. So to remove the calculation, just empty the field. It will then get an internal value of -1. If the average standard costs is 0, the calculation would result in 0 as well. The field, Round to nearest xxx Cents, will round the calculated result to the nearest Cent entered. If you have 2 decimals in the amounts the value 100 would be divided by the xxx value. If you have 3 decimals in the amounts the value 1000 will be divided by the xxx value. If there is no fraction, the value will be rounded up to the nearest xxx value. If there is a fraction, the value xxx will be subtracted from the value (100-xxx) or (1000-xxx). Let us take an example: ---------------------- Item standard cost = 20.77 Decimals = 2 Value to increase the items with = 70 (%) Round to nearest value = 5 the pow(10, 2) = 100. 100 divided by 5 = 20 and no fraction. Price after increase = 20.77 * (1 + 70 / 100) = 35.309. Rounded to nearest 5 cent value = 35.35; Let us set the Round to nearest value = 95. The value 100 / 95 = 1 and a fraction of 95. The Price will still be calculated to 35.309. Now the value will be rounded to 36.00 and subtracted by (100 - 95) = 35.95. So you see it is very flexible. If you have larger prices you can even round up to nearest 10, 100 by setting the rounding to nearest value = 1000 or 10000. But take care if you have different prices, large prices and small prices. It might not be a good idea to round a value of 10.77 to 100. If there is a base price list set and for instance a factor 0.7 the price list in foreign currencies are calculated as well. And again, if a 'Round to nearest' value is set to other than 1 the foreign prices are rounded in the same way as explained above. This new price calculaton should work with sales kits too. frontaccount/doc/attachments.txt0000644000175000017500000000047511301263000017002 0ustar januszjanuszAttaching documents ------------------- In the Setup tab, Maintenance you can attach scanned documents to transactions. You can do that here, but you can also do it after you have entered a supplier invoice or supplier credit note. There will be a direct link so you don't have to remember the transaction number.frontaccount/doc/bank_reconciliation.txt0000644000175000017500000000310611155270677020507 0ustar januszjanuszBank Reconciliation ------------------- 1. Select the account you want to reconcile. 2. Get your bank statement (from the bank) 3. The first time you reconcile you will need to enter a reconcile date and a start balance... Or 0 for the start balance if it is actually a new account. 4. Enter the end balance from the statement 5. Check entries that match the entries from your bank statement 6. If all entries match, 'Difference' should be 0. If it is, you are done and you have reconciled your account for the period. If you have some transactions unchecked, they will wait for next bank statement to be reconciled. If you have some transactions on bank statement but absent in system, go to the Bank Payments/Deposits and enter missing transactions, then repeat step 5. 7. All checked items are recorded as reconciled in the bank_trans table and the last ending balance and reconciled date is recorded for that account in the bank_accounts table. 8. The next time you reconcile against a bank statement, the ending balance from the last reconciliation is automatically used as the starting balance for this reconciliation.. You enter the ending balance for this reconciliation and repeat steps 5-7 9. If you want for some reason to find transactions reconciled with bank statement on given date select the document date with the selector. If you have a lot of bank statements entered you can skip the bank statement selector and enter date of bank statement in Reconcile Date directly. If there is no bank statement reconciled on given date the selector will display 'New'. frontaccount/doc/2.1_Beta.txt0000644000175000017500000000467111301263000015724 0ustar januszjanuszNews in FrontAccounting 2.1 Beta -------------------------------- Common ------ - Better support for upgrading database changes from early release - Accelerator keys in menues - Grouping listboxes where appropriate - Sortable database paging in inquiries with many records - Better layout in long forms (now double sided). - Preparing for install of menu extensions (not modules) - Document files in doc subdirectory - An inactive field in most 'catalog' tables to prepare for making records inactive. - Option for graphic links instead of text links in tables. - Changed license type to GNU GPL v.3. Stamped in all source files. Sales ----- - Sales documents. Line descriptions can be edited and printing of documents handles multiple line of descriptions. - Point of Sales definitions for better handling of cash sales - Sales Groups for grouping customers. - Recurrent Invoices - Dimensions can be selected on sales delivery and invoices. - Accumulating of shipping costs and legal text on invoices - New printed document layout Purchasing ---------- - New fields in suppliers: phone, fax, tax id, contact and credit limit - Supplier credit notes show only invoices for a period - 'Credit this' link in supplier inquiry - Attachment of scanned documents Items and Inventory ------------------- - Item Kit Sets for order/sales speed up - Foreign Codes registration for barcode scanner entry. Banking and General Ledger -------------------------- - Bank accounts reconciliation - Dimension view now shows balances instead of transactions - Quick Entries (preset GL transactions) in Bank Deposit/Payment, Journal Entry and Supplier invoice/credit - Rewritten tax report and tax inquiry. Bugs fixed in this release -------------------------- All bugs up to release 2.0.7 are fixed in this release too. # [0000097] Can't void freehand customer credit note. # [0000098] Unable issue of credit note for invoice with removed item lines. # [0000099] New line added to inventory transfer/adjustment sometimes overwrites old one. # [0000100] Keep getting left allocated weird results (rounding problems). # [0000102] Credit note was stored without entered shippment cost and comment. # [0000104] minor language updates in a few sales files # Numeric check on class id added. # Bug [0000111] Accounts on Credit Hold can still process delivery notes on sales order and invoicing. # Bug [0000112] It shows invoices as overdue still (in red), even though its been payed and allocated. frontaccount/doc/index.php0000644000175000017500000000005310607722037015560 0ustar januszjanusz frontaccount/doc/quick_entries.txt0000644000175000017500000000656611301263000017343 0ustar januszjanuszQuick Entries ------------- Preparing --------- Go into the Quick Entries on Banking and General Ledger tab, Maintenance. Enter/Modify existing entries. Choose a name for your quick entry and default amount used as a base for calculations. Determine type of entry i.e. page for which the quick entry is designed for. Last two input fields defines default base amount used at the start of calculations, and description of base amount used as remainder during quick entry usage. If you press the Edit link on a Quick Entry you get a new form below where you can edit the sequence of operations performed on base amount (Quick Entry Lines). Every operation defines how the amount posted to selected account is calculated. Currently following type of operations are defined: a) Post constant amount to selected GL account. b) Post percent part of base amount to selected GL account c) Post taxes for selected tax type, using base amount as net value. d) Post taxes for selected tax type, using base amount as value with tax included. e) Post remainder from previous calculations to selected GL acount. After most operations the base amount can be increased, decreased or not changed depending on option selected. For every operation you can also select a dimension(s) if you want to keep track of a dimension. You normally don't need more lines for this quick entry if this is type Phone bill, gazolin or other kind of simple bills. Later on you can create more sophisticated entry lines. If tax should be includes in the base amount you can first select a line 'Tax included, reduce base and select the correct tax type. If more lines with other Tax Types are needed, group them together and use the same action. And a line with 'Remainder' put on the account you want to put the rest on. That's it! Operation --------- In the Bank Payments / Deposits form there are an option for selecting Quick Entries, if you have defined some. After that a list shows up with the quick entries for the respective Payments / deposits and an amount field. Here you enter the base amount for calculations performed during the quick entry to make ready for you. Then press the 'Go' button to enter GL lines. Advanced -------- The quick entries can do a lot more than this simple kind of entry. You can define them to be used in the GL entry form as well by selecting type 'Journal'. Then they will show up in the Journal Entry page. The constraints on negative values has been taken away, so you can create very sophisticated lines. F.i. if you want to post import VAT for something bought overseas, you can enter a VAT line with incoming VAT. This will be the same sign as the amount. You select the 'Post percent part' and enter the percent amount in the amount field, f.i. 9 for 9% VAT. And another line with the outgoing VAT with the same percent and amount (remember to set this as -9 for correct posting). You can also use the 'Post percent part' for depreciations, create fixed amount lines (Post Amount) etc. etc. You can have as many lines as you want or need. Remember nothing is posted before you press the Process button in the bank payments/deposits/journal entry/supplier invoice/credit forms. You can always delete the lines or leave the form and nothing has been performed. You might have entered something wrong on one or more quick entry lines and want to go to Quick Entries again and change something. frontaccount/doc/2.2_Beta.txt0000644000175000017500000000423011301266071015727 0ustar januszjanuszNews in FrontAccounting 2.2 Beta -------------------------------- Common ------ - Quick Entries uses Tax Types instead of Item Tax Types - Support for default buttons with Ctrl-Enter/Escape hotkeys - Arrow navigations in menus - Option to use last document date on subsequent new documents. - Full support for inactive records - Time Zone on Reports - Audit Trail for all operations with Report - Bank Charge field in Customer/Supplier Payment. - New default fields in Company table for Bank Charge, Retained Earnings and Profit/Loss Year. - Direct Allocation of Invoices in Customer/Supplier Payments - New Access Levels/Security Roles system enables fine tunning person access rights. - Item Tax Types moved to Setup module - Default Start-up Tab set by user. - Authorization timeout parameter set in Company preferences Sales ----- - Customer/Supplier Balance Reports now with Open Balance from selected date - Added Sales Quotations, Inquiry and Report Purchasing ---------- - Better support for conversion factor in Purchasing Prices. - Purchasing price can have up to 6 decimals allowing fractions of hundredths in prices. Items and Inventory ------------------- - Item Categories contains default parameters for new items. - Excluded from Sale. Non Sales Items from Categories. - GRN Valuation Report - Automatic price-calculation of Items from Std. Cost (if no prices set on items) - Rounding of prices to nearest XX Cent after calculations. Manufacturing ------------- - Printing/Emailing of Work Orders Dimensions ---------- - Re-opening of Closed dimensions Banking and General Ledger -------------------------- - Closing a fiscal year also closes the balances and brings forward retained earnings - Deleting a fiscal year removes all transactions and convert into relevant Open Balances. - Journal Enquiry - Edition/view of Journal Entries. - Group Sorting by Id in Account Selectors - Default per currency bank accounts (used in reports). The Bank Account selection on documents has been replaced by this. Bugs fixed in this release -------------------------- - Fixed php 5 warnings flood in error log. - All bugs up to release 2.1.6 are fixed in this release too. frontaccount/doc/recurrent_invoice.txt0000644000175000017500000000433711301263000020215 0ustar januszjanuszRecurrent Invoices ------------------ There are two ways of using recurrent invoices. You can either select a group or single customer/branches. If you are going to use groups, start by creating the groups you want to later put on the branches, Fi. Large, Medium and Small Go into the branches. If you want any of a custumers branch to belong to a group, mark it and update the branch. Definition. ----------- You are now ready to make some recurrent invoice definitions, by clicking the 'Recurrent Invoices' in the Sales tab, Maintenance section. The recurrent invoices uses the Template Orders, that are shown under Template Delivery/Template Invoice. First enter a Discription of the item. Select the appropriate template. If this should be adressed to a single customer/branch, select a customer and a branch. If it should be based on a group, set the customer to an empty value and select the group you want to send the recurrent invoices to. Now it is time to consider the interval of the recurrency. If you select days and set the monthly value to 0, it will be due after every days interval. If you select a monthly value, it will be sent on a monthly base and if you select a days value it will be due on that day in the month. A value of -1 would be the last day in the previous month. A monthly value of 3 indicated a due every quarter of a year and 12 every year and so on. The begin date is the date to start the recurrency and end date is the close date of the recurrency. Create and print the recurrent invoices. --------------------------------------- Before creating recurring invoices, check that the price factor in company setup is set. If you have foreign customers the price is automatically calculated. Go to 'Create and Print Recurring Invoices'. The due items are marked and a link 'Create invoices' are there. Pressing this link creates all the invoices belonging to this group or single customer/branch. An info line tells you how many and invoice-numbers that are created. There is also a link to Print the Invoices. That's it. Happy Recurrent Invoicing. PS. If you need more groups on a customer, create new branches with this different group. Maybe call the branch something similar as the group to easily find it.frontaccount/doc/extensions.txt0000644000175000017500000000132711301263000016663 0ustar januszjanuszExtensions to FrontAccounting ----------------------------- We have prepared for installation of Extensions. Like installed modules. In the root directory there is a file, installed_extensions.php. This file contains an array over installed extensions, $installed_extensions. There is an example array in the file. app_file = the application to be put inside the /applications directory name = array key name of the application title = menu title folder = directory where the extension resides. Use same structure inside this as the core extensions. The Extension will be placed as the second last menu, before 'Setup'. At present there is no automatic installation of the extensions. They will have to be done manuelly.frontaccount/doc/sales_quotations.txt0000644000175000017500000000171211301266071020072 0ustar januszjanuszSales Quotations as a separate menu option ------------------------------------------ You can now create Sales Quotations in a separate form. You enter the 'Valid until' date. These Sales Quotations can later be used for creating a Sales Order. There is a new menu choice under Inquiries, Sales Quotation Inquiry. If the 'Valid until' has been passed, the Sales Quotation is not shown. But you can select 'Show All' and all the Sales Quotation inside the period will be shown. In this Inquiry you have the option to look at the entire Quotation, edit the Quotation, print the Quotation and make a Sales Order from the Quotation. The Sales Quotations will not be deleted, so it is possible to use it agan and maybe edit it for use again. The Sales Quotations can however be deleted when editing. And when deleting a fiscal year, the Quotations will be deleted. The Sales Order print out can still be selected to be printed as a Quote should you prefer that. frontaccount/doc/dim_on_invoice.txt0000644000175000017500000000205711301263000017446 0ustar januszjanuszDimensions on sales delivery notes, sales invoices and sales credit notes ------------------------------------------------------------------------- We now have the option to select a dimension on these documents. Here is how it works. If there are 2 levels in company setup, 2 dimension lists are shown with respective types. if 1 level, only one list and of course if none there is no list shown. If there are dimension(s) set on a customer these will be set as default in the dimension(s) lists. If you choose a dimension for your invoice it will overwrite eventually dimension set by item. And the dimension(s) are saved on the cust_trans table. To be used when going from delivery to invoice, so there is a match between the 2 links. These dimension(s) goes to the GL trans. If delivery and there are standard_cost values they will show up on all COGS accounts. If invoicing the dimensions will go to the SALES accounts, so it is easy to monitor a dimension (project or whatever). Credit notes goes the other way round. The same procedure but opposite. frontaccount/manufacturing/0000755000175000017500000000000011404426510016031 5ustar januszjanuszfrontaccount/manufacturing/work_order_release.php0000644000175000017500000000621311301263001022407 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFRELEASE'; $path_to_root = ".."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(800, 500); if ($use_date_picker) $js .= get_js_date_picker(); page(_($help_context = "Work Order Release to Manufacturing"), false, false, "", $js); if (isset($_GET["trans_no"])) { $selected_id = $_GET["trans_no"]; } elseif (isset($_POST["selected_id"])) { $selected_id = $_POST["selected_id"]; } else { display_note("This page must be called with a work order reference"); exit; } //------------------------------------------------------------------------------------ function can_process($myrow) { if ($myrow['released']) { display_error(_("This work order has already been released.")); set_focus('released'); return false; } // make sure item has components if (!has_bom($myrow['stock_id'])) { display_error(_("This Work Order cannot be released. The selected item to manufacture does not have a bom.")); set_focus('stock_id'); return false; } return true; } //------------------------------------------------------------------------------------ if (isset($_POST['release'])) { release_work_order($selected_id, $_POST['released_date'], $_POST['memo_']); display_notification(_("The work order has been released to manufacturing.")); display_note(get_trans_view_str(ST_WORKORDER, $selected_id, _("View this Work Order"))); hyperlink_no_params("search_work_orders.php", _("Select another &work order")); $Ajax->activate('_page_body'); end_page(); exit; } //------------------------------------------------------------------------------------ start_form(); $myrow = get_work_order($selected_id); $_POST['released'] = $myrow["released"]; $_POST['memo_'] = ""; if (can_process($myrow)) { start_table($table_style2); label_row(_("Work Order #:"), $selected_id); label_row(_("Work Order Reference:"), $myrow["wo_ref"]); date_row(_("Released Date") . ":", 'released_date'); textarea_row(_("Memo:"), 'memo_', $_POST['memo_'], 40, 5); end_table(1); submit_center('release', _("Release Work Order"), true, '', 'default'); hidden('selected_id', $selected_id); hidden('stock_id', $myrow['stock_id']); } end_form(); end_page(); ?>frontaccount/manufacturing/view/0000755000175000017500000000000011404426511017004 5ustar januszjanuszfrontaccount/manufacturing/view/wo_production_view.php0000644000175000017500000000516311301263001023434 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFTRANSVIEW'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); page(_($help_context = "View Work Order Production"), true, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); //------------------------------------------------------------------------------------------------- if ($_GET['trans_no'] != "") { $wo_production = $_GET['trans_no']; } //------------------------------------------------------------------------------------------------- function display_wo_production($prod_id) { global $table_style; $myrow = get_work_order_produce($prod_id); br(1); start_table($table_style); $th = array(_("Production #"), _("Reference"), _("For Work Order #"), _("Item"), _("Quantity Manufactured"), _("Date")); table_header($th); start_row(); label_cell($myrow["id"]); label_cell($myrow["reference"]); label_cell(get_trans_view_str(ST_WORKORDER,$myrow["workorder_id"])); label_cell($myrow["stock_id"] . " - " . $myrow["StockDescription"]); qty_cell($myrow["quantity"], false, get_qty_dec($myrow["stock_id"])); label_cell(sql2date($myrow["date_"])); end_row(); comments_display_row(ST_MANURECEIVE, $prod_id); end_table(1); is_voided_display(ST_MANURECEIVE, $prod_id, _("This production has been voided.")); } //------------------------------------------------------------------------------------------------- display_heading($systypes_array[ST_MANURECEIVE] . " # " . $wo_production); display_wo_production($wo_production); //------------------------------------------------------------------------------------------------- br(2); end_page(true); ?> frontaccount/manufacturing/view/index.php0000644000175000017500000000005310607534224020627 0ustar januszjanusz frontaccount/manufacturing/view/wo_issue_view.php0000644000175000017500000000730011301263001022371 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFTRANSVIEW'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); page(_($help_context = "View Work Order Issue"), true, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); //------------------------------------------------------------------------------------------------- if ($_GET['trans_no'] != "") { $wo_issue_no = $_GET['trans_no']; } //------------------------------------------------------------------------------------------------- function display_wo_issue($issue_no) { global $table_style; $myrow = get_work_order_issue($issue_no); br(1); start_table($table_style); $th = array(_("Issue #"), _("Reference"), _("For Work Order #"), _("Item"), _("From Location"), _("To Work Centre"), _("Date of Issue")); table_header($th); start_row(); label_cell($myrow["issue_no"]); label_cell($myrow["reference"]); label_cell(get_trans_view_str(ST_WORKORDER,$myrow["workorder_id"])); label_cell($myrow["stock_id"] . " - " . $myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreName"]); label_cell(sql2date($myrow["issue_date"])); end_row(); comments_display_row(28, $issue_no); end_table(1); is_voided_display(28, $issue_no, _("This issue has been voided.")); } //------------------------------------------------------------------------------------------------- function display_wo_issue_details($issue_no) { global $table_style; $result = get_work_order_issue_details($issue_no); if (db_num_rows($result) == 0) { display_note(_("There are no items for this issue.")); } else { start_table($table_style); $th = array(_("Component"), _("Quantity"), _("Units")); table_header($th); $j = 1; $k = 0; //row colour counter $total_cost = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["stock_id"] . " - " . $myrow["description"]); qty_cell($myrow["qty_issued"], false, get_qty_dec($myrow["stock_id"])); label_cell($myrow["units"]); end_row();; $j++; If ($j == 12) { $j = 1; table_header($th); }//end of page full new headings if }//end of while end_table(); } } //------------------------------------------------------------------------------------------------- display_heading($systypes_array[ST_MANUISSUE] . " # " . $wo_issue_no); display_wo_issue($wo_issue_no); display_heading2(_("Items for this Issue")); display_wo_issue_details($wo_issue_no); //------------------------------------------------------------------------------------------------- echo "
"; end_page(true); ?> frontaccount/manufacturing/view/work_order_view.php0000644000175000017500000000514111301263001022712 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFTRANSVIEW'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(800, 500); page(_($help_context = "View Work Order"), true, false, "", $js); //------------------------------------------------------------------------------------------------- $woid = 0; if ($_GET['trans_no'] != "") { $woid = $_GET['trans_no']; } display_heading($systypes_array[ST_WORKORDER] . " # " . $woid); br(1); $myrow = get_work_order($woid); if ($myrow["type"] == WO_ADVANCED) display_wo_details($woid, true); else display_wo_details_quick($woid, true); echo "
"; // display the WO requirements br(1); if ($myrow["released"] == false) { display_heading2(_("BOM for item:") . " " . $myrow["StockItemName"]); display_bom($myrow["stock_id"]); } else { display_heading2(_("Work Order Requirements")); display_wo_requirements($woid, $myrow["units_reqd"]); if ($myrow["type"] == WO_ADVANCED) { echo "
"; display_heading2(_("Issues")); display_wo_issues($woid); echo ""; display_heading2(_("Productions")); display_wo_productions($woid); echo ""; display_heading2(_("Additional Costs")); display_wo_payments($woid); echo "
"; } else { echo "
"; display_heading2(_("Additional Costs")); display_wo_payments($woid); echo "
"; } } echo "
"; is_voided_display(ST_WORKORDER, $woid, _("This work order has been voided.")); end_page(true); ?> frontaccount/manufacturing/index.php0000644000175000017500000000005310607534223017654 0ustar januszjanusz frontaccount/manufacturing/manage/0000755000175000017500000000000011404426510017261 5ustar januszjanuszfrontaccount/manufacturing/manage/bom_edit.php0000644000175000017500000002213411301263001021544 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_BOM'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); page(_($help_context = "Bill Of Materials")); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); check_db_has_bom_stock_items(_("There are no manufactured or kit items defined in the system.")); check_db_has_workcentres(_("There are no work centres defined in the system. BOMs require at least one work centre be defined.")); simple_page_mode(true); $selected_component = $selected_id; //-------------------------------------------------------------------------------------------------- //if (isset($_GET["NewItem"])) //{ // $_POST['stock_id'] = $_GET["NewItem"]; //} if (isset($_GET['stock_id'])) { $_POST['stock_id'] = $_GET['stock_id']; $selected_parent = $_GET['stock_id']; } /* selected_parent could come from a post or a get */ /*if (isset($_GET["selected_parent"])) { $selected_parent = $_GET["selected_parent"]; } else if (isset($_POST["selected_parent"])) { $selected_parent = $_POST["selected_parent"]; } */ /* selected_component could also come from a post or a get */ /*if (isset($_GET["selected_component"])) { $selected_component = $_GET["selected_component"]; } else { $selected_component = get_post("selected_component", -1); } */ //-------------------------------------------------------------------------------------------------- function check_for_recursive_bom($ultimate_parent, $component_to_check) { /* returns true ie 1 if the bom contains the parent part as a component ie the bom is recursive otherwise false ie 0 */ $sql = "SELECT component FROM ".TB_PREF."bom WHERE parent=".db_escape($component_to_check); $result = db_query($sql,"could not check recursive bom"); if ($result != 0) { while ($myrow = db_fetch_row($result)) { if ($myrow[0] == $ultimate_parent) { return 1; } if (check_for_recursive_bom($ultimate_parent, $myrow[0])) { return 1; } } //(while loop) } //end if $result is true return 0; } //end of function check_for_recursive_bom //-------------------------------------------------------------------------------------------------- function display_bom_items($selected_parent) { global $table_style; $result = get_bom($selected_parent); div_start('bom'); start_table("$table_style width=60%"); $th = array(_("Code"), _("Description"), _("Location"), _("Work Centre"), _("Quantity"), _("Units"),'',''); table_header($th); $k = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["component"]); label_cell($myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreDescription"]); qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"])); label_cell($myrow["units"]); edit_button_cell("Edit".$myrow['id'], _("Edit")); delete_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); div_end(); } //-------------------------------------------------------------------------------------------------- function on_submit($selected_parent, $selected_component=-1) { if (!check_num('quantity', 0)) { display_error(_("The quantity entered must be numeric and greater than zero.")); set_focus('quantity'); return; } if ($selected_component != -1) { $sql = "UPDATE ".TB_PREF."bom SET workcentre_added=".db_escape($_POST['workcentre_added']) . ",loc_code=".db_escape($_POST['loc_code']) . ", quantity= " . input_num('quantity') . " WHERE parent=".db_escape($selected_parent) . " AND id=".db_escape($selected_component); check_db_error("Could not update this bom component", $sql); db_query($sql,"could not update bom"); display_notification(_('Selected component has been updated')); $Mode = 'RESET'; } else { /*Selected component is null cos no item selected on first time round so must be adding a record must be Submitting new entries in the new component form */ //need to check not recursive bom component of itself! if (!check_for_recursive_bom($selected_parent, $_POST['component'])) { /*Now check to see that the component is not already on the bom */ $sql = "SELECT component FROM ".TB_PREF."bom WHERE parent=".db_escape($selected_parent)." AND component=".db_escape($_POST['component']) . " AND workcentre_added=".db_escape($_POST['workcentre_added']) . " AND loc_code=".db_escape($_POST['loc_code']); $result = db_query($sql,"check failed"); if (db_num_rows($result) == 0) { $sql = "INSERT INTO ".TB_PREF."bom (parent, component, workcentre_added, loc_code, quantity) VALUES (".db_escape($selected_parent).", ".db_escape($_POST['component']) . "," .db_escape($_POST['workcentre_added']) . ", ".db_escape($_POST['loc_code']) . ", " . input_num('quantity') . ")"; db_query($sql,"check failed"); display_notification(_("A new component part has been added to the bill of material for this item.")); $Mode = 'RESET'; } else { /*The component must already be on the bom */ display_error(_("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom.")); } } //end of if its not a recursive bom else { display_error(_("The selected component is a parent of the current item. Recursive BOMs are not allowed.")); } } } //-------------------------------------------------------------------------------------------------- if ($Mode == 'Delete') { $sql = "DELETE FROM ".TB_PREF."bom WHERE id=".db_escape($selected_id); db_query($sql,"Could not delete this bom components"); display_notification(_("The component item has been deleted from this bom")); $Mode = 'RESET'; } if ($Mode == 'RESET') { $selected_id = -1; unset($_POST['quantity']); } //-------------------------------------------------------------------------------------------------- start_form(); start_form(false, true); start_table("class='tablestyle_noborder'"); stock_manufactured_items_list_row(_("Select a manufacturable item:"), 'stock_id', null, false, true); if (list_updated('stock_id')) $Ajax->activate('_page_body'); end_table(); br(); end_form(); //-------------------------------------------------------------------------------------------------- if (get_post('stock_id') != '') { //Parent Item selected so display bom or edit component $selected_parent = $_POST['stock_id']; if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') on_submit($selected_parent, $selected_id); //-------------------------------------------------------------------------------------- start_form(); display_bom_items($selected_parent); //-------------------------------------------------------------------------------------- echo '
'; start_table($table_style2); if ($selected_id != -1) { if ($Mode == 'Edit') { //editing a selected component from the link to the line item $sql = "SELECT ".TB_PREF."bom.*,".TB_PREF."stock_master.description FROM " .TB_PREF."bom,".TB_PREF."stock_master WHERE id=".db_escape($selected_id)." AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.component"; $result = db_query($sql, "could not get bom"); $myrow = db_fetch($result); $_POST['loc_code'] = $myrow["loc_code"]; $_POST['component'] = $myrow["component"]; // by Tom Moulton $_POST['workcentre_added'] = $myrow["workcentre_added"]; $_POST['quantity'] = number_format2($myrow["quantity"], get_qty_dec($myrow["component"])); label_row(_("Component:"), $myrow["component"] . " - " . $myrow["description"]); } hidden('selected_id', $selected_id); } else { start_row(); label_cell(_("Component:")); echo ""; echo stock_component_items_list('component', $selected_parent, null, false, true); if (get_post('_component_update')) { $Ajax->activate('quantity'); } echo ""; end_row(); } hidden('stock_id', $selected_parent); locations_list_row(_("Location to Draw From:"), 'loc_code', null); workcenter_list_row(_("Work Centre Added:"), 'workcentre_added', null); $dec = get_qty_dec(get_post('component')); $_POST['quantity'] = number_format2(input_num('quantity',1), $dec); qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); } // ---------------------------------------------------------------------------------- end_page(); ?> frontaccount/manufacturing/manage/index.php0000644000175000017500000000005310607534224021105 0ustar januszjanusz frontaccount/manufacturing/manage/work_centres.php0000644000175000017500000001030611301263001022465 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_WORKCENTRES'; $path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); page(_($help_context = "Work Centres")); include($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include($path_to_root . "/includes/ui.inc"); simple_page_mode(true); //----------------------------------------------------------------------------------- if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test $input_error = 0; if (strlen($_POST['name']) == 0) { $input_error = 1; display_error(_("The work centre name cannot be empty.")); set_focus('name'); } if ($input_error != 1) { if ($selected_id != -1) { update_work_centre($selected_id, $_POST['name'], $_POST['description']); display_notification(_('Selected work center has been updated')); } else { add_work_centre($_POST['name'], $_POST['description']); display_notification(_('New work center has been added')); } $Mode = 'RESET'; } } //----------------------------------------------------------------------------------- function can_delete($selected_id) { $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE workcentre_added=".db_escape($selected_id); $result = db_query($sql, "check can delete work centre"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(_("Cannot delete this work centre because BOMs have been created referring to it.")); return false; } $sql= "SELECT COUNT(*) FROM ".TB_PREF."wo_requirements WHERE workcentre=".db_escape($selected_id); $result = db_query($sql, "check can delete work centre"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(_("Cannot delete this work centre because work order requirements have been created referring to it.")); return false; } return true; } //----------------------------------------------------------------------------------- if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_work_centre($selected_id); display_notification(_('Selected work center has been deleted')); } $Mode = 'RESET'; } if ($Mode == 'RESET') { $selected_id = -1; $sav = get_post('show_inactive'); unset($_POST); $_POST['show_inactive'] = $sav; } //----------------------------------------------------------------------------------- $result = get_all_work_centres(check_value('show_inactive')); start_form(); start_table("$table_style width=50%"); $th = array(_("Name"), _("description"), "", ""); inactive_control_column($th); table_header($th); $k = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["name"]); label_cell($myrow["description"]); inactive_control_cell($myrow["id"], $myrow["inactive"], 'workcentres', 'id'); edit_button_cell("Edit".$myrow['id'], _("Edit")); delete_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } inactive_control_row($th); end_table(1); //----------------------------------------------------------------------------------- start_table($table_style2); if ($selected_id != -1) { if ($Mode == 'Edit') { //editing an existing status code $myrow = get_work_centre($selected_id); $_POST['name'] = $myrow["name"]; $_POST['description'] = $myrow["description"]; } hidden('selected_id', $selected_id); } text_row_ex(_("Name:"), 'name', 40); text_row_ex(_("Description:"), 'description', 50); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'both'); end_form(); //------------------------------------------------------------------------------------ end_page(); ?> frontaccount/manufacturing/includes/0000755000175000017500000000000011404426510017637 5ustar januszjanuszfrontaccount/manufacturing/includes/work_order_issue_ui.inc0000644000175000017500000001220311301263001024400 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/ui/items_cart.inc"); //-------------------------------------------------------------------------------- function add_to_issue(&$order, $new_item, $new_item_qty, $standard_cost) { if ($order->find_cart_item($new_item)) display_error(_("For Part :") . $new_item . " " . "This item is already on this issue. You can change the quantity issued of the existing line if necessary."); else $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost); } //--------------------------------------------------------------------------------- function display_issue_items($title, &$order) { global $table_style, $path_to_root; display_heading($title); div_start('items_table'); start_table("$table_style width=80% colspan=7"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Unit Cost"), ''); if ( count($order->line_items)) $th[] = ''; table_header($th); // $total = 0; $k = 0; //row colour counter $id = find_submit('Edit'); foreach ($order->line_items as $line_no=>$stock_item) { // $total += ($stock_item->standard_cost * $stock_item->quantity); if ($id != $line_no) { alt_table_row_color($k); view_stock_status_cell($stock_item->stock_id); label_cell($stock_item->item_description); qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id)); label_cell($stock_item->units); amount_cell($stock_item->standard_cost); // amount_cell($stock_item->standard_cost * $stock_item->quantity); edit_button_cell("Edit$line_no", _("Edit"), _('Edit document line')); delete_button_cell("Delete$line_no", _("Delete"), _('Remove line from document')); end_row(); } else { issue_edit_item_controls($order, $line_no); } } if ($id == -1) issue_edit_item_controls($order); // label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right"); end_table(); div_end(); } //--------------------------------------------------------------------------------- function issue_edit_item_controls(&$order, $line_no=-1) { global $Ajax; start_row(); $id = find_submit('Edit'); if ($line_no != -1 && $line_no == $id) { $_POST['stock_id'] = $order->line_items[$id]->stock_id; $_POST['qty'] = qty_format($order->line_items[$id]->quantity, $order->line_items[$id]->stock_id, $dec); $_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost); $_POST['units'] = $order->line_items[$id]->units; hidden('stock_id', $_POST['stock_id']); label_cell($_POST['stock_id']); label_cell($order->line_items[$id]->item_description); $Ajax->activate('items_table'); } else { $wo_details = get_work_order($_SESSION['issue_items']->order_id); stock_component_items_list_cells(null, 'stock_id', $wo_details["stock_id"], null, false, true); if (list_updated('stock_id')) { $Ajax->activate('units'); $Ajax->activate('qty'); $Ajax->activate('std_cost'); } $item_info = get_item_edit_info($_POST['stock_id']); $dec = $item_info["decimals"]; $_POST['qty'] = number_format2(0, $dec); $_POST['std_cost'] = price_format($item_info["standard_cost"]); $_POST['units'] = $item_info["units"]; } qty_cells(null, 'qty', $_POST['qty'], null, null, $dec); label_cell($_POST['units'], '', 'units'); amount_cells(null, 'std_cost', $_POST['std_cost']); if ($id != -1) { button_cell('UpdateItem', _("Update"), _('Confirm changes'), ICON_UPDATE); button_cell('CancelItemChanges', _("Cancel"), _('Cancel changes'), ICON_CANCEL); hidden('LineNo', $line_no); set_focus('qty'); } else { submit_cells('AddItem', _("Add Item"), "colspan=2", _('Add new item to document'), true); } end_row(); } //--------------------------------------------------------------------------------- function issue_options_controls() { global $Refs; echo "
"; start_table(); ref_row(_("Reference:"), 'ref', '', $Refs->get_next(28)); if (!isset($_POST['IssueType'])) $_POST['IssueType'] = 0; yesno_list_row(_("Type:"), 'IssueType', $_POST['IssueType'], _("Return Items to Location"), _("Issue Items to Work order")); locations_list_row(_("From Location:"), 'Location'); workcenter_list_row(_("To Work Centre:"), 'WorkCentre'); date_row(_("Issue Date:"), 'date_'); textarea_row(_("Memo"), 'memo_', null, 50, 3); end_table(1); } //--------------------------------------------------------------------------------- ?>frontaccount/manufacturing/includes/manufacturing_ui.inc0000644000175000017500000002275311301263001023671 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/ui.inc"); //-------------------------------------------------------------------------------------- function display_bom($item_check) { global $table_style; $result = get_bom($item_check); if (db_num_rows($result) == 0) { display_note(_("The bill of material for this item is empty."), 0, 1); } else { start_table($table_style); $th = array(_("Component"), _("Description"), _("Work Centre"), _("From Location"), _("Quantity"), _("Unit Cost"), _("Total Cost")); table_header($th); $j = 1; $k = 0; //row colour counter $total_cost = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["component"]); label_cell($myrow["description"]); label_cell($myrow["WorkCentreDescription"]); label_cell($myrow["location_name"]); qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"])); amount_cell($myrow["standard_cost"]); amount_cell($myrow["ComponentCost"]); end_row(); $total_cost += $myrow["ComponentCost"]; $j++; If ($j == 12) { $j = 1; table_header($th); }//end of page full new headings if }//end of while label_row("" . _("Total Cost") . "", "" . number_format2($total_cost,user_price_dec()) ."", "colspan=6 align=right", "nowrap align=right"); end_table(); } } //-------------------------------------------------------------------------------------- function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null) { global $table_style, $SysPrefs; $result = get_wo_requirements($woid); if (db_num_rows($result) == 0) { display_note(_("There are no Requirements for this Order."), 1, 0); } else { start_table("$table_style width=80%"); $th = array(_("Component"), _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand")); table_header($th); $k = 0; //row colour counter $has_marked = false; if ($date == null) $date = Today(); while ($myrow = db_fetch($result)) { $qoh = 0; $show_qoh = true; // if it's a non-stock item (eg. service) don't show qoh if (!has_stock_holding($myrow["mb_flag"])) $show_qoh = false; if ($show_qoh) $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date); if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) && !$SysPrefs->allow_negative_stock()) { // oops, we don't have enough of one of the component items start_row("class='stockmankobg'"); $has_marked = true; } else alt_table_row_color($k); if (user_show_codes()) label_cell($myrow["stock_id"]. " - " . $myrow["description"]); else label_cell($myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreDescription"]); $dec = get_qty_dec($myrow["stock_id"]); qty_cell($myrow["units_req"], false, $dec); qty_cell($myrow["units_req"] * $quantity, false, $dec); qty_cell($myrow["units_issued"], false, $dec); if ($show_qoh) qty_cell($qoh, false, $dec); else label_cell(""); end_row(); } end_table(); if ($has_marked) display_note(_("Marked items have insufficient quantities in stock."), 0, 0, "class='red'"); } } //-------------------------------------------------------------------------------------- function display_wo_productions($woid) { global $path_to_root, $table_style; $result = get_work_order_productions($woid); if (db_num_rows($result) == 0) { display_note(_("There are no Productions for this Order."), 1, 1); } else { start_table($table_style); $th = array(_("#"), _("Reference"), _("Date"), _("Quantity")); table_header($th); $k = 0; //row colour counter $total_qty = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); $total_qty += $myrow['quantity']; label_cell(get_trans_view_str(29, $myrow["id"])); label_cell($myrow['reference']); label_cell(sql2date($myrow["date_"])); qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference'])); end_row(); }//end of while label_row(_("Total"), number_format2($total_qty,user_qty_dec()), "colspan=3", "nowrap align=right"); end_table(); } } //-------------------------------------------------------------------------------------- function display_wo_issues($woid) { global $path_to_root, $table_style; $result = get_work_order_issues($woid); if (db_num_rows($result) == 0) { display_note(_("There are no Issues for this Order."), 0, 1); } else { start_table($table_style); $th = array(_("#"), _("Reference"), _("Date")); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell(get_trans_view_str(28, $myrow["issue_no"])); label_cell($myrow['reference']); label_cell(sql2date($myrow["issue_date"])); end_row(); } end_table(); } } //-------------------------------------------------------------------------------------- function display_wo_payments($woid) { global $path_to_root, $table_style, $wo_cost_types; //$result = get_bank_trans(null, null, PT_WORKORDER, $woid); $result = get_gl_wo_cost_trans($woid); if (db_num_rows($result) == 0) { display_note(_("There are no additional costs for this Order."), 0, 1); } else { start_table($table_style); $th = array(_("#"), _("Type"), _("Date"), _("Amount")); table_header($th); $k = 0; //row colour counter while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell(get_gl_view_str(ST_WORKORDER, $myrow["type_no"], $myrow["type_no"])); label_cell($wo_cost_types[$myrow['person_id']]); $date = sql2date($myrow["tran_date"]); label_cell($date); amount_cell(-($myrow['amount'])); end_row(); } end_table(); } } //-------------------------------------------------------------------------------------- function display_wo_details($woid, $suppress_view_link=false) { global $table_style, $wo_types_array; $myrow = get_work_order($woid); if (strlen($myrow[0]) == 0) { display_note(_("The work order number sent is not valid.")); exit; } start_table("$table_style width=80%"); if ($myrow["released"] == true) $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"), _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"), _("Released Date"), _("Manufactured")); else $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"), _("Into Location"), _("Date"), _("Required By"), _("Quantity Required")); table_header($th); start_row(); if ($suppress_view_link) label_cell($myrow["id"]); else label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"])); label_cell($myrow["wo_ref"]); label_cell($wo_types_array[$myrow["type"]]); view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]); label_cell($myrow["location_name"]); label_cell(sql2date($myrow["date_"])); label_cell(sql2date($myrow["required_by"])); $dec = get_qty_dec($myrow["stock_id"]); qty_cell($myrow["units_reqd"], false, $dec); if ($myrow["released"] == true) { label_cell(sql2date($myrow["released_date"])); qty_cell($myrow["units_issued"], false, $dec); } end_row(); comments_display_row(ST_WORKORDER, $woid); end_table(); if ($myrow["closed"] == true) { display_note(_("This work order is closed.")); } } //-------------------------------------------------------------------------------------- function display_wo_details_quick($woid, $suppress_view_link=false) { global $table_style, $wo_types_array; $myrow = get_work_order($woid); if (strlen($myrow[0]) == 0) { display_note(_("The work order number sent is not valid.")); exit; } start_table("$table_style width=80%"); $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"), _("Into Location"), _("Date"), _("Quantity")); table_header($th); start_row(); if ($suppress_view_link) label_cell($myrow["id"]); else label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"])); label_cell($myrow["wo_ref"]); label_cell($wo_types_array[$myrow["type"]]); view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]); label_cell($myrow["location_name"]); label_cell(sql2date($myrow["date_"])); qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"])); end_row(); comments_display_row(ST_WORKORDER, $woid); end_table(); if ($myrow["closed"] == true) { display_note(_("This work order is closed.")); } } ?>frontaccount/manufacturing/includes/index.php0000644000175000017500000000005310607534223021462 0ustar januszjanusz frontaccount/manufacturing/includes/manufacturing_db.inc0000644000175000017500000000220511155256064023651 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/manufacturing/includes/db/work_centres_db.inc"); include_once($path_to_root . "/manufacturing/includes/db/work_orders_db.inc"); include_once($path_to_root . "/manufacturing/includes/db/work_orders_quick_db.inc"); include_once($path_to_root . "/manufacturing/includes/db/work_order_issues_db.inc"); include_once($path_to_root . "/manufacturing/includes/db/work_order_produce_items_db.inc"); include_once($path_to_root . "/manufacturing/includes/db/work_order_requirements_db.inc"); ?>frontaccount/manufacturing/includes/db/0000755000175000017500000000000011404426510020224 5ustar januszjanuszfrontaccount/manufacturing/includes/db/work_order_requirements_db.inc0000644000175000017500000000604411342502410026343 0ustar januszjanusz. ***********************************************************************/ function get_wo_requirements($woid) { $sql = "SELECT ".TB_PREF."wo_requirements.*, ".TB_PREF."stock_master.description, ".TB_PREF."stock_master.mb_flag, ".TB_PREF."locations.location_name, ".TB_PREF."workcentres.name AS WorkCentreDescription FROM (".TB_PREF."wo_requirements, ".TB_PREF."locations, " .TB_PREF."workcentres) INNER JOIN ".TB_PREF."stock_master ON ".TB_PREF."wo_requirements.stock_id = ".TB_PREF."stock_master.stock_id WHERE workorder_id=".db_escape($woid)." AND ".TB_PREF."locations.loc_code = ".TB_PREF."wo_requirements.loc_code AND ".TB_PREF."workcentres.id=workcentre"; return db_query($sql, "The work order requirements could not be retrieved"); } //-------------------------------------------------------------------------------------- function create_wo_requirements($woid, $stock_id) { // create Work Order Requirements based on the bom $result = get_bom($stock_id); while ($myrow = db_fetch($result)) { $sql = "INSERT INTO ".TB_PREF."wo_requirements (workorder_id, stock_id, workcentre, units_req, loc_code) VALUES (".db_escape($woid).", '" . $myrow["component"] . "', '" . $myrow["workcentre_added"] . "', '" . $myrow["quantity"] . "', '" . $myrow["loc_code"] . "')"; db_query($sql, "The work order requirements could not be added"); } } //-------------------------------------------------------------------------------------- function delete_wo_requirements($woid) { $sql="DELETE FROM ".TB_PREF."wo_requirements WHERE workorder_id=".db_escape($woid); db_query($sql,"The work order requirements could not be deleted"); } //-------------------------------------------------------------------------------------- function update_wo_requirement_issued($woid, $stock_id, $quantity) { $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = units_issued + ".db_escape($quantity)." WHERE workorder_id = ".db_escape($woid)." AND stock_id = ".db_escape($stock_id); db_query($sql, "The work requirements issued quantity couldn't be updated"); } //-------------------------------------------------------------------------------------- function void_wo_requirements($woid) { $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = 0 WHERE workorder_id = " .db_escape($woid); db_query($sql, "The work requirements issued quantity couldn't be voided"); } //-------------------------------------------------------------------------------------- ?>frontaccount/manufacturing/includes/db/work_orders_quick_db.inc0000644000175000017500000001535411342502410025123 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------------------------------------------- function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc) { global $Refs; begin_transaction(); // if unassembling, reverse the stock movements if ($type == WO_UNASSEMBLY) $units_reqd = -$units_reqd; add_material_cost($stock_id, $units_reqd, $date_); $date = date2sql($date_); if (!isset($costs) || ($costs == "")) $costs = 0; add_overhead_cost($stock_id, $units_reqd, $date_, $costs); if (!isset($labour) || ($labour == "")) $labour = 0; add_labour_cost($stock_id, $units_reqd, $date_, $labour); $sql = "INSERT INTO ".TB_PREF."workorders (wo_ref, loc_code, units_reqd, units_issued, stock_id, type, additional_costs, date_, released_date, required_by, released, closed) VALUES (".db_escape($wo_ref).", ".db_escape($loc_code).", ".db_escape($units_reqd) .", ".db_escape($units_reqd).", ".db_escape($stock_id).", ".db_escape($type).", ".db_escape($costs).", '$date', '$date', '$date', 1, 1)"; db_query($sql, "could not add work order"); $woid = db_insert_id(); //-------------------------------------------------------------------------- // create Work Order Requirements based on the bom $result = get_bom($stock_id); while ($bom_item = db_fetch($result)) { $unit_quantity = $bom_item["quantity"]; $item_quantity = $bom_item["quantity"] * $units_reqd; $sql = "INSERT INTO ".TB_PREF."wo_requirements (workorder_id, stock_id, workcentre, units_req, units_issued, loc_code) VALUES ($woid, " . "'" . $bom_item["component"] . "'" . ", '". $bom_item["workcentre_added"] . "', $unit_quantity, $item_quantity, '" . $bom_item["loc_code"] . "')"; db_query($sql, "The work order requirements could not be added"); // insert a -ve stock move for each item add_stock_move(ST_WORKORDER, $bom_item["component"], $woid, $bom_item["loc_code"], $date_, $wo_ref, -$item_quantity, 0); } // ------------------------------------------------------------------------- // insert a +ve stock move for the item being manufactured add_stock_move(ST_WORKORDER, $stock_id, $woid, $loc_code, $date_, $wo_ref, $units_reqd, 0); // ------------------------------------------------------------------------- work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, 0, $costs, $cr_acc, $labour, $cr_lab_acc); // ------------------------------------------------------------------------- add_comments(ST_WORKORDER, $woid, $date_, $memo_); $Refs->save(ST_WORKORDER, $woid, $wo_ref); add_audit_trail(ST_WORKORDER, $woid, $date_,_("Quick production.")); commit_transaction(); return $woid; } //-------------------------------------------------------------------------------------- function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=0, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="") { global $wo_cost_types; $result = get_bom($stock_id); // credit all the components $total_cost = 0; while ($bom_item = db_fetch($result)) { $bom_accounts = get_stock_gl_code($bom_item["component"]); $bom_cost = $bom_item["ComponentCost"] * $units_reqd; if ($advanced) { update_wo_requirement_issued($woid, $bom_item['component'], $bom_item["quantity"] * $units_reqd); // insert a -ve stock move for each item add_stock_move(ST_MANURECEIVE, $bom_item["component"], $advanced, $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, 0); } $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $bom_accounts["inventory_account"], 0, 0, null, -$bom_cost); } if ($advanced) { // also take the additional issues $res = get_additional_issues($woid); $wo = get_work_order($woid); $issue_total = 0; while ($item = db_fetch($res)) { $standard_cost = get_standard_cost($item['stock_id']); $issue_cost = $standard_cost * $item['qty_issued'] * $units_reqd / $wo['units_reqd']; $issue = get_stock_gl_code($item['stock_id']); $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], 0, 0, null, -$issue_cost); $issue_total += $issue_cost; } if ($issue_total != 0) add_issue_cost($stock_id, $units_reqd, $date_, $issue_total); $lcost = get_gl_wo_cost($woid, WO_LABOUR); add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']); $ocost = get_gl_wo_cost($woid, WO_OVERHEAD); add_overhead_cost($stock_id, $units_reqd, $date_, $ocost * $units_reqd / $wo['units_reqd']); } // credit additional costs $item_accounts = get_stock_gl_code($stock_id); if ($costs != 0.0) { add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_acc, 0, 0, $wo_cost_types[WO_OVERHEAD], -$costs, PT_WORKORDER, WO_OVERHEAD); $is_bank_to = is_bank_account($cr_acc); if ($is_bank_to) { add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "", $date_, -$costs, PT_WORKORDER, WO_OVERHEAD, get_company_currency(), "Cannot insert a destination bank transaction"); } add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"], $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_OVERHEAD], $costs, PT_WORKORDER, WO_OVERHEAD); } if ($labour != 0.0) { add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_lab_acc, 0, 0, $wo_cost_types[WO_LABOUR], -$labour, PT_WORKORDER, WO_LABOUR); $is_bank_to = is_bank_account($cr_lab_acc); if ($is_bank_to) { add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "", $date_, -$labour, PT_WORKORDER, WO_LABOUR, get_company_currency(), "Cannot insert a destination bank transaction"); } add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"], $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_LABOUR], $labour, PT_WORKORDER, WO_LABOUR); } // debit total components $total_cost add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["inventory_account"], 0, 0, null, -$total_cost); } //-------------------------------------------------------------------------------------- ?>frontaccount/manufacturing/includes/db/work_order_produce_items_db.inc0000644000175000017500000001024511342502410026460 0ustar januszjanusz. ***********************************************************************/ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo) { global $Refs; begin_transaction(); $details = get_work_order($woid); if (strlen($details[0]) == 0) { echo _("The order number sent is not valid."); exit; } if (work_order_is_closed($woid)) { display_error("UNEXPECTED : Producing Items for a closed Work Order"); cancel_transaction(); exit; } $date = date2sql($date_); $sql = "INSERT INTO ".TB_PREF."wo_manufacture (workorder_id, reference, quantity, date_) VALUES (".db_escape($woid).", ".db_escape($ref).", ".db_escape($quantity) .", '$date')"; db_query($sql,"A work order manufacture could not be added"); $id = db_insert_id(); // ------------------------------------------------------------------------- work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id); // ------------------------------------------------------------------------- // insert a +ve stock move for the item being manufactured // negative means "unproduce" or unassemble add_stock_move(ST_MANURECEIVE, $details["stock_id"], $id, $details["loc_code"], $date_, $memo_, $quantity, 0); // update wo quantity and close wo if requested work_order_update_finished_quantity($woid, $quantity, $close_wo); if ($memo_) add_comments(ST_MANURECEIVE, $id, $date_, $memo_); $Refs->save(ST_MANURECEIVE, $id, $ref); add_audit_trail(ST_MANURECEIVE, $id, $date_, _("Production.")); commit_transaction(); } //-------------------------------------------------------------------------------------------- function get_work_order_produce($id) { $sql = "SELECT ".TB_PREF."wo_manufacture.*,".TB_PREF."workorders.stock_id, " .TB_PREF."stock_master.description AS StockDescription FROM ".TB_PREF."wo_manufacture, ".TB_PREF."workorders, ".TB_PREF."stock_master WHERE ".TB_PREF."wo_manufacture.workorder_id=".TB_PREF."workorders.id AND ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id AND ".TB_PREF."wo_manufacture.id=".db_escape($id); $result = db_query($sql, "The work order production could not be retrieved"); return db_fetch($result); } //-------------------------------------------------------------------------------------- function get_work_order_productions($woid) { $sql = "SELECT * FROM ".TB_PREF."wo_manufacture WHERE workorder_id=" .db_escape($woid)." ORDER BY id"; return db_query($sql, "The work order issues could not be retrieved"); } //-------------------------------------------------------------------------------------- function exists_work_order_produce($id) { $sql = "SELECT id FROM ".TB_PREF."wo_manufacture WHERE id=".db_escape($id); $result = db_query($sql, "Cannot retreive a wo production"); return (db_num_rows($result) > 0); } //-------------------------------------------------------------------------------------------- function void_work_order_produce($type_no) { begin_transaction(); $row = get_work_order_produce($type_no); // deduct the quantity of this production from the parent work order work_order_update_finished_quantity($row["workorder_id"], -$row["quantity"]); work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no); // clear the production record $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".db_escape($type_no); db_query($sql, "Cannot void a wo production"); // void all related stock moves void_stock_move(ST_MANURECEIVE, $type_no); // void any related gl trans void_gl_trans(ST_MANURECEIVE, $type_no, true); commit_transaction(); } ?>frontaccount/manufacturing/includes/db/index.php0000644000175000017500000000005310607534223022047 0ustar januszjanusz frontaccount/manufacturing/includes/db/work_centres_db.inc0000644000175000017500000000323211301263001024057 0ustar januszjanusz. ***********************************************************************/ function add_work_centre($name, $description) { $sql = "INSERT INTO ".TB_PREF."workcentres (name, description) VALUES (".db_escape($name).",".db_escape($description).")"; db_query($sql, "could not add work centre"); } function update_work_centre($type_id, $name, $description) { $sql = "UPDATE ".TB_PREF."workcentres SET name=".db_escape($name).", description=".db_escape($description)." WHERE id=".db_escape($type_id); db_query($sql, "could not update work centre"); } function get_all_work_centres($all=false) { $sql = "SELECT * FROM ".TB_PREF."workcentres"; if (!$all) $sql .= " WHERE !inactive"; return db_query($sql, "could not get all work centres"); } function get_work_centre($type_id) { $sql = "SELECT * FROM ".TB_PREF."workcentres WHERE id=".db_escape($type_id); $result = db_query($sql, "could not get work centre"); return db_fetch($result); } function delete_work_centre($type_id) { $sql="DELETE FROM ".TB_PREF."workcentres WHERE id=".db_escape($type_id); db_query($sql, "could not delete work centre"); } ?>frontaccount/manufacturing/includes/db/work_order_issues_db.inc0000644000175000017500000001242211301263001025123 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------------------------------------------- function add_work_order_issue($woid, $ref, $to_work_order, $items, $location, $workcentre, $date_, $memo_) { global $Refs; begin_transaction(); $details = get_work_order($woid); if (strlen($details[0]) == 0) { echo _("The order number sent is not valid."); cancel_transaction(); exit; } if (work_order_is_closed($woid)) { display_error("UNEXPECTED : Issuing items for a closed Work Order"); cancel_transaction(); exit; } // insert the actual issue $sql = "INSERT INTO ".TB_PREF."wo_issues (workorder_id, reference, issue_date, loc_code, workcentre_id) VALUES (".db_escape($woid).", ".db_escape($ref).", '" . date2sql($date_) . "', ".db_escape($location).", ".db_escape($workcentre).")"; db_query($sql,"The work order issue could not be added"); $number = db_insert_id(); foreach ($items as $item) { if ($to_work_order) $item->quantity = -$item->quantity; // insert a -ve stock move for each item add_stock_move(ST_MANUISSUE, $item->stock_id, $number, $location, $date_, $memo_, -$item->quantity, 0); $sql = "INSERT INTO ".TB_PREF."wo_issue_items (issue_id, stock_id, qty_issued) VALUES (".db_escape($number).", ".db_escape($item->stock_id).", " .db_escape($item->quantity).")"; db_query($sql,"A work order issue item could not be added"); } if ($memo_) add_comments(ST_MANUISSUE, $number, $date_, $memo_); $Refs->save(ST_MANUISSUE, $number, $ref); add_audit_trail(ST_MANUISSUE, $number, $date_); commit_transaction(); } //-------------------------------------------------------------------------------------- function get_work_order_issues($woid) { $sql = "SELECT * FROM ".TB_PREF."wo_issues WHERE workorder_id=".db_escape($woid) ." ORDER BY issue_no"; return db_query($sql, "The work order issues could not be retrieved"); } function get_additional_issues($woid) { $sql = "SELECT ".TB_PREF."wo_issues.*, ".TB_PREF."wo_issue_items.* FROM ".TB_PREF."wo_issues, ".TB_PREF."wo_issue_items WHERE ".TB_PREF."wo_issues.issue_no=".TB_PREF."wo_issue_items.issue_id AND ".TB_PREF."wo_issues.workorder_id=".db_escape($woid) ." ORDER BY ".TB_PREF."wo_issue_items.id"; return db_query($sql, "The work order issues could not be retrieved"); } //-------------------------------------------------------------------------------------- function get_work_order_issue($issue_no) { $sql = "SELECT DISTINCT ".TB_PREF."wo_issues.*, ".TB_PREF."workorders.stock_id, ".TB_PREF."stock_master.description, ".TB_PREF."locations.location_name, " .TB_PREF."workcentres.name AS WorkCentreName FROM ".TB_PREF."wo_issues, ".TB_PREF."workorders, ".TB_PREF."stock_master, " .TB_PREF."locations, ".TB_PREF."workcentres WHERE issue_no=".db_escape($issue_no)." AND ".TB_PREF."workorders.id = ".TB_PREF."wo_issues.workorder_id AND ".TB_PREF."locations.loc_code = ".TB_PREF."wo_issues.loc_code AND ".TB_PREF."workcentres.id = ".TB_PREF."wo_issues.workcentre_id AND ".TB_PREF."stock_master.stock_id = ".TB_PREF."workorders.stock_id"; $result = db_query($sql, "A work order issue could not be retrieved"); return db_fetch($result); } //-------------------------------------------------------------------------------------- function get_work_order_issue_details($issue_no) { $sql = "SELECT ".TB_PREF."wo_issue_items.*," .TB_PREF."stock_master.description, ".TB_PREF."stock_master.units FROM ".TB_PREF."wo_issue_items, ".TB_PREF."stock_master WHERE issue_id=".db_escape($issue_no)." AND ".TB_PREF."stock_master.stock_id=".TB_PREF."wo_issue_items.stock_id ORDER BY ".TB_PREF."wo_issue_items.id"; return db_query($sql, "The work order issue items could not be retrieved"); } //-------------------------------------------------------------------------------------- function exists_work_order_issue($issue_no) { $sql = "SELECT issue_no FROM ".TB_PREF."wo_issues WHERE issue_no=".db_escape($issue_no); $result = db_query($sql, "Cannot retreive a wo issue"); return (db_num_rows($result) > 0); } //-------------------------------------------------------------------------------------- function void_work_order_issue($type_no) { begin_transaction(); // void the actual issue items and their quantities $sql = "UPDATE ".TB_PREF."wo_issue_items Set qty_issued = 0 WHERE issue_id=" .db_escape($type_no); db_query($sql,"A work order issue item could not be voided"); // void all related stock moves void_stock_move(ST_MANUISSUE, $type_no); // void any related gl trans void_gl_trans(ST_MANUISSUE, $type_no, true); commit_transaction(); } //-------------------------------------------------------------------------------------- ?>frontaccount/manufacturing/includes/db/work_orders_db.inc0000644000175000017500000003226411342502410023726 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------------------------------------------- function add_material_cost($stock_id, $qty, $date_) { $m_cost = 0; $result = get_bom($stock_id); while ($bom_item = db_fetch($result)) { $standard_cost = get_standard_cost($bom_item['component']); $m_cost += ($bom_item['quantity'] * $standard_cost); } $dec = user_price_dec(); price_decimal_format($m_cost, $dec); $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id = " .db_escape($stock_id); $result = db_query($sql); $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; $qoh = get_qoh_on_date($stock_id, null, $date_); if ($qoh < 0) $qoh = 0; if ($qoh + $qty != 0) $material_cost = ($qoh * $material_cost + $qty * $m_cost) / ($qoh + $qty); $material_cost = round2($material_cost, $dec); $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); } function add_overhead_cost($stock_id, $qty, $date_, $costs) { $dec = user_price_dec(); price_decimal_format($costs, $dec); if ($qty != 0) $costs /= $qty; $sql = "SELECT overhead_cost FROM ".TB_PREF."stock_master WHERE stock_id = " .db_escape($stock_id); $result = db_query($sql); $myrow = db_fetch($result); $overhead_cost = $myrow['overhead_cost']; $qoh = get_qoh_on_date($stock_id, null, $date_); if ($qoh < 0) $qoh = 0; if ($qoh + $qty != 0) $overhead_cost = ($qoh * $overhead_cost + $qty * $costs) / ($qoh + $qty); $overhead_cost = round2($overhead_cost, $dec); $sql = "UPDATE ".TB_PREF."stock_master SET overhead_cost=".db_escape($overhead_cost)." WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); } function add_labour_cost($stock_id, $qty, $date_, $costs) { $dec = user_price_dec(); price_decimal_format($costs, $dec); if ($qty != 0) $costs /= $qty; $sql = "SELECT labour_cost FROM ".TB_PREF."stock_master WHERE stock_id = " .db_escape($stock_id); $result = db_query($sql); $myrow = db_fetch($result); $labour_cost = $myrow['labour_cost']; $qoh = get_qoh_on_date($stock_id, null, $date_); if ($qoh < 0) $qoh = 0; if ($qoh + $qty != 0) $labour_cost = ($qoh * $labour_cost + $qty * $costs) / ($qoh + $qty); $labour_cost = round2($labour_cost, $dec); $sql = "UPDATE ".TB_PREF."stock_master SET labour_cost=".db_escape($labour_cost)." WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); } function add_issue_cost($stock_id, $qty, $date_, $costs) { if ($qty != 0) $costs /= $qty; $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id = " .db_escape($stock_id); $result = db_query($sql); $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; $dec = user_price_dec(); price_decimal_format($material_cost, $dec); $qoh = get_qoh_on_date($stock_id, null, $date_); if ($qoh < 0) $qoh = 0; if ($qoh + $qty != 0) $material_cost = ($qty * $costs) / ($qoh + $qty); $material_cost = round2($material_cost, $dec); $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=material_cost+" .db_escape($material_cost) ." WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); } function add_work_order($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $required_by, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc) { global $Refs; if (!($type == WO_ADVANCED)) return add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type, $date_, $memo_, $costs, $cr_acc, $labour, $cr_lab_acc); begin_transaction(); add_material_cost($stock_id, $units_reqd, $date_); $date = date2sql($date_); $required = date2sql($required_by); $sql = "INSERT INTO ".TB_PREF."workorders (wo_ref, loc_code, units_reqd, stock_id, type, date_, required_by) VALUES (".db_escape($wo_ref).", ".db_escape($loc_code).", " .db_escape($units_reqd).", ".db_escape($stock_id).", ".db_escape($type).", '$date', ".db_escape($required).")"; db_query($sql, "could not add work order"); $woid = db_insert_id(); add_comments(ST_WORKORDER, $woid, $required_by, $memo_); $Refs->save(ST_WORKORDER, $woid, $wo_ref); add_audit_trail(ST_WORKORDER, $woid, $date_); commit_transaction(); return $woid; } //-------------------------------------------------------------------------------------- function update_work_order($woid, $loc_code, $units_reqd, $stock_id, $date_, $required_by, $memo_) { begin_transaction(); add_material_cost($_POST['old_stk_id'], -$_POST['old_qty'], $date_); add_material_cost($stock_id, $units_reqd, $date_); $date = date2sql($date_); $required = date2sql($required_by); $sql = "UPDATE ".TB_PREF."workorders SET loc_code=".db_escape($loc_code).", units_reqd=".db_escape($units_reqd).", stock_id=".db_escape($stock_id).", required_by=".db_escape($required).", date_='$date' WHERE id = ".db_escape($woid); db_query($sql, "could not update work order"); update_comments(ST_WORKORDER, $woid, null, $memo_); add_audit_trail(ST_WORKORDER, $woid, $date_, _("Updated.")); commit_transaction(); } function delete_work_order($woid) { begin_transaction(); add_material_cost($_POST['stock_id'], -$_POST['quantity'], $_POST['date_']); // delete the work order requirements delete_wo_requirements($woid); // delete the actual work order $sql = "DELETE FROM ".TB_PREF."workorders WHERE id=".db_escape($woid); db_query($sql,"The work order could not be deleted"); delete_comments(ST_WORKORDER, $woid); add_audit_trail(ST_WORKORDER, $woid, $_POST['date_'], _("Canceled.")); commit_transaction(); } //-------------------------------------------------------------------------------------- function get_work_order($woid, $allow_null=false) { $sql = "SELECT ".TB_PREF."workorders.*, ".TB_PREF."stock_master.description As StockItemName, ".TB_PREF."locations.location_name, ".TB_PREF."locations.delivery_address FROM ".TB_PREF."workorders, ".TB_PREF."stock_master, ".TB_PREF."locations WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id AND ".TB_PREF."locations.loc_code=".TB_PREF."workorders.loc_code AND ".TB_PREF."workorders.id=".db_escape($woid)." GROUP BY ".TB_PREF."workorders.id"; $result = db_query($sql, "The work order issues could not be retrieved"); if (!$allow_null && db_num_rows($result) == 0) display_db_error("Could not find work order $woid", $sql); return db_fetch($result); } //-------------------------------------------------------------------------------------- function work_order_has_productions($woid) { $sql = "SELECT COUNT(*) FROM ".TB_PREF."wo_manufacture WHERE workorder_id=".db_escape($woid); $result = db_query($sql, "query work order for productions"); $myrow = db_fetch_row($result); return ($myrow[0] > 0); } //-------------------------------------------------------------------------------------- function work_order_has_issues($woid) { $sql = "SELECT COUNT(*) FROM ".TB_PREF."wo_issues WHERE workorder_id=".db_escape($woid); $result = db_query($sql, "query work order for issues"); $myrow = db_fetch_row($result); return ($myrow[0] > 0); } //-------------------------------------------------------------------------------------- function work_order_has_payments($woid) { $result = get_gl_wo_cost_trans($woid); return (db_num_rows($result) != 0); } //-------------------------------------------------------------------------------------- function release_work_order($woid, $releaseDate, $memo_) { begin_transaction(); $myrow = get_work_order($woid); $stock_id = $myrow["stock_id"]; $date = date2sql($releaseDate); $sql = "UPDATE ".TB_PREF."workorders SET released_date='$date', released=1 WHERE id = ".db_escape($woid); db_query($sql, "could not release work order"); // create Work Order Requirements based on the bom create_wo_requirements($woid, $stock_id); add_comments(ST_WORKORDER, $woid, $releaseDate, $memo_); add_audit_trail(ST_WORKORDER, $woid, $releaseDate,_("Released.")); commit_transaction(); } //-------------------------------------------------------------------------------------- function close_work_order($woid) { $sql = "UPDATE ".TB_PREF."workorders SET closed=1 WHERE id = ".db_escape($woid); db_query($sql, "could not close work order"); } //-------------------------------------------------------------------------------------- function work_order_is_closed($woid) { $sql = "SELECT closed FROM ".TB_PREF."workorders WHERE id = ".db_escape($woid); $result = db_query($sql, "could not query work order"); $row = db_fetch_row($result); return ($row[0] > 0); } //-------------------------------------------------------------------------------------- function work_order_update_finished_quantity($woid, $quantity, $force_close=0) { $sql = "UPDATE ".TB_PREF."workorders SET units_issued = units_issued + ".db_escape($quantity).", closed = ((units_issued >= units_reqd) OR ".db_escape($force_close).") WHERE id = ".db_escape($woid); db_query($sql, "The work order issued quantity couldn't be updated"); } //-------------------------------------------------------------------------------------- function void_work_order($woid) { begin_transaction(); $work_order = get_work_order($woid); if (!($work_order["type"] == WO_ADVANCED)) { $date = sql2date($work_order['date_']); $qty = $work_order['units_reqd']; add_material_cost($work_order['stock_id'], -$qty, $date); // remove avg. cost for qty $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost if ($cost != 0) add_labour_cost($work_order['stock_id'], -$qty, $date, $cost); $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost if ($cost != 0) add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost); $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = " .db_escape($woid); db_query($sql, "The work order couldn't be voided"); // void all related stock moves void_stock_move(ST_WORKORDER, $woid); // void any related gl trans void_gl_trans(ST_WORKORDER, $woid, true); // clear the requirements units received void_wo_requirements($woid); } else { // void everything inside the work order : issues, productions, payments $date = sql2date($work_order['date_']); add_material_cost($work_order['stock_id'], -$work_order['units_reqd'], $date); // remove avg. cost for qty $result = get_work_order_productions($woid); // check the produced quantity $qty = 0; while ($row = db_fetch($result)) { $qty += $row['quantity']; // clear the production record $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".$$row['id']; db_query($sql, "Cannot void a wo production"); void_stock_move(ST_MANURECEIVE, $row['id']); // and void the stock moves; } $result = get_additional_issues($woid); // check the issued quantities $cost = 0; $issue_no = 0; while ($row = db_fetch($result)) { $std_cost = get_standard_cost($row['stock_id']); $icost = $std_cost * $row['qty_issued']; $cost += $icost; if ($issue_no == 0) $issue_no = $row['issue_no']; // void the actual issue items and their quantities $sql = "UPDATE ".TB_PREF."wo_issue_items SET qty_issued = 0 WHERE issue_id=" .db_escape($row['id']); db_query($sql,"A work order issue item could not be voided"); } if ($issue_no != 0) void_stock_move(ST_MANUISSUE, $issue_no); // and void the stock moves if ($cost != 0) add_issue_cost($work_order['stock_id'], -$qty, $date, $cost); $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost if ($cost != 0) add_labour_cost($work_order['stock_id'], -$qty, $date, $cost); $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost if ($cost != 0) add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost); $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = " .db_escape($woid); db_query($sql, "The work order couldn't be voided"); // void all related stock moves void_stock_move(ST_WORKORDER, $woid); // void any related gl trans void_gl_trans(ST_WORKORDER, $woid, true); // clear the requirements units received void_wo_requirements($woid); } commit_transaction(); } //-------------------------------------------------------------------------------------- function get_gl_wo_cost($woid, $cost_type) { $cost = 0; $result = get_gl_wo_cost_trans($woid, $cost_type); while ($row = db_fetch($result)) $cost += -$row['amount']; return $cost; } ?>frontaccount/manufacturing/search_work_orders.php0000644000175000017500000001473011301263001022422 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFTRANSVIEW'; $path_to_root = ".."; include($path_to_root . "/includes/db_pager.inc"); include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(800, 500); if (isset($_GET['outstanding_only']) && ($_GET['outstanding_only'] == true)) { // curently outstanding simply means not closed $outstanding_only = 1; page(_($help_context = "Search Outstanding Work Orders"), false, false, "", $js); } else { $outstanding_only = 0; page(_($help_context = "Search Work Orders"), false, false, "", $js); } //----------------------------------------------------------------------------------- // Ajax updates // if (get_post('SearchOrders')) { $Ajax->activate('orders_tbl'); } elseif (get_post('_OrderNumber_changed')) { $disable = get_post('OrderNumber') !== ''; $Ajax->addDisable(true, 'StockLocation', $disable); $Ajax->addDisable(true, 'OverdueOnly', $disable); $Ajax->addDisable(true, 'OpenOnly', $disable); $Ajax->addDisable(true, 'SelectedStockItem', $disable); if ($disable) { set_focus('OrderNumber'); } else set_focus('StockLocation'); $Ajax->activate('orders_tbl'); } //-------------------------------------------------------------------------------------- if (isset($_GET["stock_id"])) $_POST['SelectedStockItem'] = $_GET["stock_id"]; //-------------------------------------------------------------------------------------- start_form(false, false, $_SERVER['PHP_SELF'] ."?outstanding_only=$outstanding_only"); start_table("class='tablestyle_noborder'"); start_row(); ref_cells(_("Reference:"), 'OrderNumber', '',null, '', true); locations_list_cells(_("at Location:"), 'StockLocation', null, true); check_cells( _("Only Overdue:"), 'OverdueOnly', null); if ($outstanding_only==0) check_cells( _("Only Open:"), 'OpenOnly', null); stock_manufactured_items_list_cells(_("for item:"), 'SelectedStockItem', null, true); submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default'); end_row(); end_table(); //----------------------------------------------------------------------------- function check_overdue($row) { return (!$row["closed"] && date_diff2(Today(), sql2date($row["required_by"]), "d") > 0); } function view_link($dummy, $order_no) { return get_trans_view_str(ST_WORKORDER, $order_no); } function view_stock($row) { return view_stock_status($row["stock_id"], $row["description"], false); } function wo_type_name($dummy, $type) { global $wo_types_array; return $wo_types_array[$type]; } function edit_link($row) { return $row['closed'] ? ''._('Closed').'' : pager_link(_("Edit"), "/manufacturing/work_order_entry.php?trans_no=" . $row["id"], ICON_EDIT); } function release_link($row) { return $row["closed"] ? '' : ($row["released"]==0 ? pager_link(_('Release'), "/manufacturing/work_order_release.php?trans_no=" . $row["id"]) : pager_link(_('Issue'), "/manufacturing/work_order_issue.php?trans_no=" .$row["id"])); } function produce_link($row) { return $row["closed"] || !$row["released"] ? '' : pager_link(_('Produce'), "/manufacturing/work_order_add_finished.php?trans_no=" .$row["id"]); } function costs_link($row) { /* return $row["closed"] || !$row["released"] ? '' : pager_link(_('Costs'), "/gl/gl_bank.php?NewPayment=1&PayType=" .PT_WORKORDER. "&PayPerson=" .$row["id"]); */ return $row["closed"] || !$row["released"] ? '' : pager_link(_('Costs'), "/manufacturing/work_order_costs.php?trans_no=" .$row["id"]); } function view_gl_link($row) { if ($row['closed'] == 0) return ''; return get_gl_view_str(ST_WORKORDER, $row['id']); } function dec_amount($row, $amount) { return number_format2($amount, $row['decimals']); } $sql = "SELECT workorder.id, workorder.wo_ref, workorder.type, location.location_name, item.description, workorder.units_reqd, workorder.units_issued, workorder.date_, workorder.required_by, workorder.released_date, workorder.closed, workorder.released, workorder.stock_id, unit.decimals FROM ".TB_PREF."workorders as workorder," .TB_PREF."stock_master as item," .TB_PREF."item_units as unit," .TB_PREF."locations as location WHERE workorder.stock_id=item.stock_id AND workorder.loc_code=location.loc_code AND item.units=unit.abbr"; if (check_value('OpenOnly') || $outstanding_only != 0) { $sql .= " AND workorder.closed=0"; } if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != $all_items) { $sql .= " AND workorder.loc_code=".db_escape($_POST['StockLocation']); } if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "") { $sql .= " AND workorder.wo_ref LIKE ".db_escape('%'.$_POST['OrderNumber'].'%'); } if (isset($_POST['SelectedStockItem']) && $_POST['SelectedStockItem'] != $all_items) { $sql .= " AND workorder.stock_id=".db_escape($_POST['SelectedStockItem']); } if (check_value('OverdueOnly')) { $Today = date2sql(Today()); $sql .= " AND workorder.required_by < '$Today' "; } $cols = array( _("#") => array('fun'=>'view_link'), _("Reference"), // viewlink 2 ? _("Type") => array('fun'=>'wo_type_name'), _("Location"), _("Item") => array('fun'=>'view_stock'), _("Required") => array('fun'=>'dec_amount', 'align'=>'right'), _("Manufactured") => array('fun'=>'dec_amount', 'align'=>'right'), _("Date") => 'date', _("Required By") => array('type'=>'date', 'ord'=>''), array('insert'=>true, 'fun'=> 'edit_link'), array('insert'=>true, 'fun'=> 'release_link'), array('insert'=>true, 'fun'=> 'produce_link'), array('insert'=>true, 'fun'=> 'costs_link'), array('insert'=>true, 'fun'=> 'view_gl_link') ); $table =& new_db_pager('orders_tbl', $sql, $cols); $table->set_marker('check_overdue', _("Marked orders are overdue.")); $table->width = "90%"; display_db_pager($table); end_form(); end_page(); ?> frontaccount/manufacturing/work_order_entry.php0000644000175000017500000003400111301263001022124 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_WORKORDERENTRY'; $path_to_root = ".."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); if ($use_date_picker) $js .= get_js_date_picker(); page(_($help_context = "Work Order Entry"), false, false, "", $js); check_db_has_manufacturable_items(_("There are no manufacturable items defined in the system.")); check_db_has_locations(("There are no inventory locations defined in the system.")); //--------------------------------------------------------------------------------------- if (isset($_GET['trans_no'])) { $selected_id = $_GET['trans_no']; } elseif(isset($_POST['selected_id'])) { $selected_id = $_POST['selected_id']; } //--------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) { $id = $_GET['AddedID']; $stype = ST_WORKORDER; display_notification_centered(_("The work order been added.")); display_note(get_trans_view_str($stype, $id, _("View this Work Order"))); if ($_GET['type'] != WO_ADVANCED) { include_once($path_to_root . "/reporting/includes/reporting.inc"); $ar = array('PARAM_0' => $id, 'PARAM_1' => $id, 'PARAM_2' => 0); display_note(print_link(_("Print this Work Order"), 409, $ar), 1); $ar['PARAM_2'] = 1; display_note(print_link(_("Email this Work Order"), 409, $ar), 1); display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1); $ar = array('PARAM_0' => $_GET['date'], 'PARAM_1' => $_GET['date'], 'PARAM_2' => $stype); display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1); } safe_exit(); } //--------------------------------------------------------------------------------------- if (isset($_GET['UpdatedID'])) { $id = $_GET['UpdatedID']; display_notification_centered(_("The work order been updated.")); safe_exit(); } //--------------------------------------------------------------------------------------- if (isset($_GET['DeletedID'])) { $id = $_GET['DeletedID']; display_notification_centered(_("Work order has been deleted.")); safe_exit(); } //--------------------------------------------------------------------------------------- if (isset($_GET['ClosedID'])) { $id = $_GET['ClosedID']; display_notification_centered(_("This work order has been closed. There can be no more issues against it.") . " #$id"); safe_exit(); } //--------------------------------------------------------------------------------------- function safe_exit() { global $path_to_root; hyperlink_no_params("", _("Enter a new work order")); hyperlink_no_params("search_work_orders.php", _("Select an existing work order")); display_footer_exit(); } //------------------------------------------------------------------------------------- if (!isset($_POST['date_'])) { $_POST['date_'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['date_'])) $_POST['date_'] = end_fiscalyear(); } function can_process() { global $selected_id, $SysPrefs, $Refs; if (!isset($selected_id)) { if (!$Refs->is_valid($_POST['wo_ref'])) { display_error(_("You must enter a reference.")); set_focus('wo_ref'); return false; } if (!is_new_reference($_POST['wo_ref'], ST_WORKORDER)) { display_error(_("The entered reference is already in use.")); set_focus('wo_ref'); return false; } } if (!check_num('quantity', 0)) { display_error( _("The quantity entered is invalid or less than zero.")); set_focus('quantity'); return false; } if (!is_date($_POST['date_'])) { display_error( _("The date entered is in an invalid format.")); set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); return false; } // only check bom and quantites if quick assembly if (!($_POST['type'] == WO_ADVANCED)) { if (!has_bom($_POST['stock_id'])) { display_error(_("The selected item to manufacture does not have a bom.")); set_focus('stock_id'); return false; } if ($_POST['Labour'] == "") $_POST['Labour'] = price_format(0); if (!check_num('Labour', 0)) { display_error( _("The labour cost entered is invalid or less than zero.")); set_focus('Labour'); return false; } if ($_POST['Costs'] == "") $_POST['Costs'] = price_format(0); if (!check_num('Costs', 0)) { display_error( _("The cost entered is invalid or less than zero.")); set_focus('Costs'); return false; } if (!$SysPrefs->allow_negative_stock()) { if ($_POST['type'] == WO_ASSEMBLY) { // check bom if assembling $result = get_bom($_POST['stock_id']); while ($bom_item = db_fetch($result)) { if (has_stock_holding($bom_item["ResourceType"])) { $quantity = $bom_item["quantity"] * input_num('quantity'); $qoh = get_qoh_on_date($bom_item["component"], $bom_item["loc_code"], $_POST['date_']); if (-$quantity + $qoh < 0) { display_error(_("The work order cannot be processed because there is an insufficient quantity for component:") . " " . $bom_item["component"] . " - " . $bom_item["description"] . ". " . _("Location:") . " " . $bom_item["location_name"]); set_focus('quantity'); return false; } } } } elseif ($_POST['type'] == WO_UNASSEMBLY) { // if unassembling, check item to unassemble $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['StockLocation'], $_POST['date_']); if (-input_num('quantity') + $qoh < 0) { display_error(_("The selected item cannot be unassembled because there is insufficient stock.")); return false; } } } } else { if (!is_date($_POST['RequDate'])) { set_focus('RequDate'); display_error( _("The date entered is in an invalid format.")); return false; } //elseif (!is_date_in_fiscalyear($_POST['RequDate'])) //{ // display_error(_("The entered date is not in fiscal year.")); // return false; //} if (isset($selected_id)) { $myrow = get_work_order($selected_id, true); if ($_POST['units_issued'] > input_num('quantity')) { set_focus('quantity'); display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order.")); return false; } } } return true; } //------------------------------------------------------------------------------------- if (isset($_POST['ADD_ITEM']) && can_process()) { if (!isset($_POST['cr_acc'])) $_POST['cr_acc'] = ""; if (!isset($_POST['cr_lab_acc'])) $_POST['cr_lab_acc'] = ""; $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['type'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_'], input_num('Costs'), $_POST['cr_acc'], input_num('Labour'), $_POST['cr_lab_acc']); new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$id&type=".$_POST['type']."&date=".$_POST['date_']); } //------------------------------------------------------------------------------------- if (isset($_POST['UPDATE_ITEM']) && can_process()) { update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']); new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id"); } //-------------------------------------------------------------------------------------- if (isset($_POST['delete'])) { //the link to delete a selected record was clicked instead of the submit button $cancel_delete = false; // can't delete it there are productions or issues if (work_order_has_productions($selected_id) || work_order_has_issues($selected_id) || work_order_has_payments($selected_id)) { display_error(_("This work order cannot be deleted because it has already been processed.")); $cancel_delete = true; } if ($cancel_delete == false) { //ie not cancelled the delete as a result of above tests // delete the actual work order delete_work_order($selected_id); meta_forward($_SERVER['PHP_SELF'], "DeletedID=$selected_id"); } } //------------------------------------------------------------------------------------- if (isset($_POST['close'])) { // update the closed flag in the work order close_work_order($selected_id); meta_forward($_SERVER['PHP_SELF'], "ClosedID=$selected_id"); } //------------------------------------------------------------------------------------- if (get_post('_type_update')) { $Ajax->activate('_page_body'); } //------------------------------------------------------------------------------------- start_form(); start_table($table_style2); $existing_comments = ""; $dec = 0; if (isset($selected_id)) { $myrow = get_work_order($selected_id); if (strlen($myrow[0]) == 0) { echo _("The order number sent is not valid."); safe_exit(); } // if it's a closed work order can't edit it if ($myrow["closed"] == 1) { echo "
"; display_error(_("This work order is closed and cannot be edited.")); safe_exit(); } $_POST['wo_ref'] = $myrow["wo_ref"]; $_POST['stock_id'] = $myrow["stock_id"]; $_POST['quantity'] = qty_format($myrow["units_reqd"], $_POST['stock_id'], $dec); $_POST['StockLocation'] = $myrow["loc_code"]; $_POST['released'] = $myrow["released"]; $_POST['closed'] = $myrow["closed"]; $_POST['type'] = $myrow["type"]; $_POST['date_'] = sql2date($myrow["date_"]); $_POST['RequDate'] = sql2date($myrow["required_by"]); $_POST['released_date'] = sql2date($myrow["released_date"]); $_POST['memo_'] = ""; $_POST['units_issued'] = $myrow["units_issued"]; $_POST['Costs'] = price_format($myrow["additional_costs"]); $_POST['memo_'] = get_comments_string(ST_WORKORDER, $selected_id); hidden('wo_ref', $_POST['wo_ref']); hidden('units_issued', $_POST['units_issued']); hidden('released', $_POST['released']); hidden('released_date', $_POST['released_date']); hidden('selected_id', $selected_id); hidden('old_qty', $myrow["units_reqd"]); hidden('old_stk_id', $myrow["stock_id"]); label_row(_("Reference:"), $_POST['wo_ref']); label_row(_("Type:"), $wo_types_array[$_POST['type']]); hidden('type', $myrow["type"]); } else { $_POST['units_issued'] = $_POST['released'] = 0; ref_row(_("Reference:"), 'wo_ref', '', $Refs->get_next(ST_WORKORDER)); wo_types_list_row(_("Type:"), 'type', null); } if (get_post('released')) { hidden('stock_id', $_POST['stock_id']); hidden('StockLocation', $_POST['StockLocation']); hidden('type', $_POST['type']); label_row(_("Item:"), $myrow["StockItemName"]); label_row(_("Destination Location:"), $myrow["location_name"]); } else { stock_manufactured_items_list_row(_("Item:"), 'stock_id', null, false, true); if (list_updated('stock_id')) $Ajax->activate('quantity'); locations_list_row(_("Destination Location:"), 'StockLocation', null); } if (!isset($_POST['quantity'])) $_POST['quantity'] = qty_format(1, $_POST['stock_id'], $dec); else $_POST['quantity'] = qty_format($_POST['quantity'], $_POST['stock_id'], $dec); if (get_post('type') == WO_ADVANCED) { qty_row(_("Quantity Required:"), 'quantity', null, null, null, $dec); if ($_POST['released']) label_row(_("Quantity Manufactured:"), number_format($_POST['units_issued'], get_qty_dec($_POST['stock_id']))); date_row(_("Date") . ":", 'date_', '', true); date_row(_("Date Required By") . ":", 'RequDate', '', null, $SysPrefs->default_wo_required_by()); } else { qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); date_row(_("Date") . ":", 'date_', '', true); hidden('RequDate', ''); $sql = "SELECT DISTINCT account_code FROM ".TB_PREF."bank_accounts"; $rs = db_query($sql,"could not get bank accounts"); $r = db_fetch_row($rs); if (!isset($_POST['Labour'])) { $_POST['Labour'] = price_format(0); $_POST['cr_lab_acc'] = $r[0]; } amount_row($wo_cost_types[WO_LABOUR], 'Labour'); gl_all_accounts_list_row(_("Credit Labour Account"), 'cr_lab_acc', null); if (!isset($_POST['Costs'])) { $_POST['Costs'] = price_format(0); $_POST['cr_acc'] = $r[0]; } amount_row($wo_cost_types[WO_OVERHEAD], 'Costs'); gl_all_accounts_list_row(_("Credit Overhead Account"), 'cr_acc', null); } if (get_post('released')) label_row(_("Released On:"),$_POST['released_date']); textarea_row(_("Memo:"), 'memo_', null, 40, 5); end_table(1); if (isset($selected_id)) { echo ""; submit_cells('UPDATE_ITEM', _("Update"), '', _('Save changes to work order'), 'default'); if (get_post('released')) { submit_cells('close', _("Close This Work Order"),'','',true); } submit_cells('delete', _("Delete This Work Order"),'','',true); echo "
"; } else { submit_center('ADD_ITEM', _("Add Workorder"), true, '', 'default'); } end_form(); end_page(); ?>frontaccount/manufacturing/work_order_costs.php0000644000175000017500000001245511301263001022127 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_WORKORDERCOST'; $path_to_root = ".."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/gl/includes/db/gl_db_bank_trans.inc"); include_once($path_to_root . "/includes/db/inventory_db.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); if ($use_date_picker) $js .= get_js_date_picker(); page(_($help_context = "Work Order Additional Costs"), false, false, "", $js); if (isset($_GET['trans_no']) && $_GET['trans_no'] != "") { $_POST['selected_id'] = $_GET['trans_no']; } //-------------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) { $id = $_GET['AddedID']; $stype = ST_WORKORDER; display_notification(_("The additional cost has been entered.")); display_note(get_trans_view_str($stype, $id, _("View this Work Order"))); display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1); hyperlink_params("work_order_costs.php", _("Enter another additional cost."), "trans_no=$id"); hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process")); end_page(); exit; } //-------------------------------------------------------------------------------------------------- $wo_details = get_work_order($_POST['selected_id']); if (strlen($wo_details[0]) == 0) { display_error(_("The order number sent is not valid.")); exit; } //-------------------------------------------------------------------------------------------------- function can_process() { global $wo_details; if (!check_num('costs', 0)) { display_error(_("The amount entered is not a valid number or less then zero.")); set_focus('costs'); return false; } if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); return false; } if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) { display_error(_("The additional cost date cannot be before the release date of the work order.")); set_focus('date_'); return false; } return true; } //-------------------------------------------------------------------------------------------------- if (isset($_POST['process']) && can_process() == true) { begin_transaction(); add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['cr_acc'], 0, 0, $wo_cost_types[$_POST['PaymentType']], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType']); $is_bank_to = is_bank_account($_POST['cr_acc']); if ($is_bank_to) { add_bank_trans(ST_WORKORDER, $_POST['selected_id'], $is_bank_to, "", $_POST['date_'], -input_num('costs'), PT_WORKORDER, $_POST['PaymentType'], get_company_currency(), "Cannot insert a destination bank transaction"); } add_gl_trans_std_cost(ST_WORKORDER, $_POST['selected_id'], $_POST['date_'], $_POST['db_acc'], $_POST['dim1'], $_POST['dim2'], $wo_cost_types[$_POST['PaymentType']], input_num('costs'), PT_WORKORDER, $_POST['PaymentType']); commit_transaction(); meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']); } //------------------------------------------------------------------------------------- display_wo_details($_POST['selected_id']); //------------------------------------------------------------------------------------- start_form(); hidden('selected_id', $_POST['selected_id']); //hidden('WOReqQuantity', $_POST['WOReqQuantity']); start_table($table_style2); br(); yesno_list_row(_("Type:"), 'PaymentType', null, $wo_cost_types[WO_OVERHEAD], $wo_cost_types[WO_LABOUR]); date_row(_("Date:"), 'date_'); $item_accounts = get_stock_gl_code($wo_details['stock_id']); $_POST['db_acc'] = $item_accounts['assembly_account']; $sql = "SELECT DISTINCT account_code FROM ".TB_PREF."bank_accounts"; $rs = db_query($sql,"could not get bank accounts"); $r = db_fetch_row($rs); $_POST['cr_acc'] = $r[0]; amount_row(_("Additional Costs:"), 'costs'); gl_all_accounts_list_row(_("Debit Account"), 'db_acc', null); gl_all_accounts_list_row(_("Credit Account"), 'cr_acc', null); end_table(1); hidden('dim1', $item_accounts["dimension_id"]); hidden('dim2', $item_accounts["dimension2_id"]); submit_center('process', _("Process Additional Cost"), true, '', true); end_form(); end_page(); ?>frontaccount/manufacturing/inquiry/0000755000175000017500000000000011404426510017531 5ustar januszjanuszfrontaccount/manufacturing/inquiry/bom_cost_inquiry.php0000644000175000017500000000323011301263001023613 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_WORKORDERCOST'; $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); page(_($help_context = "Costed Bill Of Material Inquiry")); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/banking.inc"); include_once($path_to_root . "/includes/data_checks.inc"); check_db_has_bom_stock_items(_("There are no manufactured or kit items defined in the system.")); if (isset($_GET['stock_id'])) { $_POST['stock_id'] = $_GET['stock_id']; } if (list_updated('stock_id')) $Ajax->activate('_page_body'); start_form(false, true); start_table("class='tablestyle_noborder'"); stock_manufactured_items_list_row(_("Select a manufacturable item:"), 'stock_id', null, false, true); end_table(); br(); display_heading(_("All Costs Are In:") . " " . get_company_currency()); display_bom($_POST['stock_id']); end_form(); end_page(); ?> frontaccount/manufacturing/inquiry/index.php0000644000175000017500000000005310607534224021355 0ustar januszjanusz frontaccount/manufacturing/inquiry/where_used_inquiry.php0000644000175000017500000000436011301263001024145 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_WORKORDERANALYTIC'; $path_to_root = "../.."; include($path_to_root . "/includes/db_pager.inc"); include($path_to_root . "/includes/session.inc"); page(_($help_context = "Inventory Item Where Used Inquiry")); include($path_to_root . "/includes/ui.inc"); check_db_has_stock_items(_("There are no items defined in the system.")); start_form(false, true); if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); echo "
" . _("Select an item to display its parent item(s).") . " "; echo stock_items_list('stock_id', $_POST['stock_id'], false, true); echo "
"; set_global_stock_item($_POST['stock_id']); //----------------------------------------------------------------------------- function select_link($row) { return pager_link( $row["parent"]. " - " . $row["description"], "/manufacturing/manage/bom_edit.php?stock_id=" . $row["parent"]); } $sql = "SELECT bom.parent, workcentre.name As WorkCentreName, location.location_name, bom.quantity, parent.description FROM ".TB_PREF."bom as bom, " .TB_PREF."stock_master as parent, " .TB_PREF."workcentres as workcentre, " .TB_PREF."locations as location WHERE bom.parent = parent.stock_id AND bom.workcentre_added = workcentre.id AND bom.loc_code = location.loc_code AND bom.component=".db_escape($_POST['stock_id']); $cols = array( _("Parent Item") => array('fun'=>'select_link'), _("Work Centre"), _("Location"), _("Quantity Required") ); $table =& new_db_pager('usage_table', $sql, $cols); $table->width = "80%"; display_db_pager($table); end_form(); end_page(); ?>frontaccount/manufacturing/work_order_issue.php0000644000175000017500000001470611301263001022125 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFISSUE'; $path_to_root = ".."; include_once($path_to_root . "/includes/ui/items_cart.inc"); include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); include_once($path_to_root . "/manufacturing/includes/work_order_issue_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(800, 500); if ($use_date_picker) $js .= get_js_date_picker(); page(_($help_context = "Issue Items to Work Order"), false, false, "", $js); //----------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) { display_notification(_("The work order issue has been entered.")); display_note(get_trans_view_str(ST_WORKORDER, $_GET['AddedID'], _("View this Work Order"))); hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process")); display_footer_exit(); } //-------------------------------------------------------------------------------------------------- function line_start_focus() { global $Ajax; $Ajax->activate('items_table'); set_focus('_stock_id_edit'); } //-------------------------------------------------------------------------------------------------- function handle_new_order() { if (isset($_SESSION['issue_items'])) { $_SESSION['issue_items']->clear_items(); unset ($_SESSION['issue_items']); } Session_register("issue_items"); $_SESSION['issue_items'] = new items_cart(28); $_SESSION['issue_items']->order_id = $_GET['trans_no']; } //----------------------------------------------------------------------------------------------- function can_process() { global $Refs; if (!is_date($_POST['date_'])) { display_error(_("The entered date for the issue is invalid.")); set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 28)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } $failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']); if ($failed_item != -1) { display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") . " " . $failed_item->stock_id . " - " . $failed_item->item_description); return false; } return true; } if (isset($_POST['Process']) && can_process()) { // if failed, returns a stockID $failed_data = add_work_order_issue($_SESSION['issue_items']->order_id, $_POST['ref'], $_POST['IssueType'], $_SESSION['issue_items']->line_items, $_POST['Location'], $_POST['WorkCentre'], $_POST['date_'], $_POST['memo_']); if ($failed_data != null) { display_error(_("The process cannot be completed because there is an insufficient total quantity for a component.") . "
" . _("Component is :"). $failed_data[0] . "
" . _("From location :"). $failed_data[1] . "
"); } else { meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_SESSION['issue_items']->order_id); } } /*end of process credit note */ //----------------------------------------------------------------------------------------------- function check_item_data() { if (!check_num('qty', 0)) { display_error(_("The quantity entered is negative or invalid.")); set_focus('qty'); return false; } if (!check_num('std_cost', 0)) { display_error(_("The entered standard cost is negative or invalid.")); set_focus('std_cost'); return false; } return true; } //----------------------------------------------------------------------------------------------- function handle_update_item() { if($_POST['UpdateItem'] != "" && check_item_data()) { $id = $_POST['LineNo']; $_SESSION['issue_items']->update_cart_item($id, input_num('qty'), input_num('std_cost')); } line_start_focus(); } //----------------------------------------------------------------------------------------------- function handle_delete_item($id) { $_SESSION['issue_items']->remove_from_cart($id); line_start_focus(); } //----------------------------------------------------------------------------------------------- function handle_new_item() { if (!check_item_data()) return; add_to_issue($_SESSION['issue_items'], $_POST['stock_id'], input_num('qty'), input_num('std_cost')); line_start_focus(); } //----------------------------------------------------------------------------------------------- $id = find_submit('Delete'); if ($id != -1) handle_delete_item($id); if (isset($_POST['AddItem'])) handle_new_item(); if (isset($_POST['UpdateItem'])) handle_update_item(); if (isset($_POST['CancelItemChanges'])) { line_start_focus(); } //----------------------------------------------------------------------------------------------- if (isset($_GET['trans_no'])) { handle_new_order(); } //----------------------------------------------------------------------------------------------- display_wo_details($_SESSION['issue_items']->order_id); echo "
"; start_form(); start_table("$table_style width=90%", 10); echo ""; display_issue_items(_("Items to Issue"), $_SESSION['issue_items']); issue_options_controls(); echo ""; end_table(); submit_center('Process', _("Process Issue"), true, '', 'default'); end_form(); //------------------------------------------------------------------------------------------------ end_page(); ?> frontaccount/manufacturing/work_order_add_finished.php0000644000175000017500000001525111341535706023414 0ustar januszjanusz. ***********************************************************************/ $page_security = 'SA_MANUFRECEIVE'; $path_to_root = ".."; include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/gl/includes/db/gl_db_bank_trans.inc"); include_once($path_to_root . "/includes/db/inventory_db.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc"); $js = ""; if ($use_popup_windows) $js .= get_js_open_window(900, 500); if ($use_date_picker) $js .= get_js_date_picker(); page(_($help_context = "Produce or Unassemble Finished Items From Work Order"), false, false, "", $js); if (isset($_GET['trans_no']) && $_GET['trans_no'] != "") { $_POST['selected_id'] = $_GET['trans_no']; } //-------------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) { include_once($path_to_root . "/reporting/includes/reporting.inc"); $id = $_GET['AddedID']; $stype = ST_WORKORDER; display_notification(_("The manufacturing process has been entered.")); display_note(get_trans_view_str($stype, $id, _("View this Work Order"))); display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1); $ar = array('PARAM_0' => $_GET['date'], 'PARAM_1' => $_GET['date'], 'PARAM_2' => $stype); display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1); hyperlink_no_params("search_work_orders.php", _("Select another &Work Order to Process")); end_page(); exit; } //-------------------------------------------------------------------------------------------------- $wo_details = get_work_order($_POST['selected_id']); if (strlen($wo_details[0]) == 0) { display_error(_("The order number sent is not valid.")); exit; } //-------------------------------------------------------------------------------------------------- function can_process() { global $wo_details, $SysPrefs, $Refs; if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 29)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!check_num('quantity', 0)) { display_error(_("The quantity entered is not a valid number or less then zero.")); set_focus('quantity'); return false; } if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('date_'); return false; } if (date_diff2(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) { display_error(_("The production date cannot be before the release date of the work order.")); set_focus('date_'); return false; } // if unassembling we need to check the qoh if (($_POST['ProductionType'] == 0) && !$SysPrefs->allow_negative_stock()) { $wo_details = get_work_order($_POST['selected_id']); $qoh = get_qoh_on_date($wo_details["stock_id"], $wo_details["loc_code"], $_POST['date_']); if (-input_num('quantity') + $qoh < 0) { display_error(_("The unassembling cannot be processed because there is insufficient stock.")); set_focus('quantity'); return false; } } // if production we need to check the qoh of the wo requirements if (($_POST['ProductionType'] == 1) && !$SysPrefs->allow_negative_stock()) { $err = false; $result = get_wo_requirements($_POST['selected_id']); while ($row = db_fetch($result)) { if ($row['mb_flag'] == 'D') // service, non stock continue; $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $_POST['date_']); if ($qoh - $row['units_req'] * input_num('quantity') < 0) { display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") . " " . $row['stock_id'] . " - " . $row['description']); $err = true; } } if ($err) { set_focus('quantity'); return false; } } return true; } //-------------------------------------------------------------------------------------------------- if ((isset($_POST['Process']) || isset($_POST['ProcessAndClose'])) && can_process() == true) { $close_wo = 0; if (isset($_POST['ProcessAndClose']) && ($_POST['ProcessAndClose']!="")) $close_wo = 1; // if unassembling, negate quantity if ($_POST['ProductionType'] == 0) $_POST['quantity'] = -$_POST['quantity']; $id = work_order_produce($_POST['selected_id'], $_POST['ref'], input_num('quantity'), $_POST['date_'], $_POST['memo_'], $close_wo); meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']."&date=".$_POST['date_']); } //------------------------------------------------------------------------------------- display_wo_details($_POST['selected_id']); //------------------------------------------------------------------------------------- start_form(); hidden('selected_id', $_POST['selected_id']); //hidden('WOReqQuantity', $_POST['WOReqQuantity']); $dec = get_qty_dec($wo_details["stock_id"]); if (!isset($_POST['quantity']) || $_POST['quantity'] == '') $_POST['quantity'] = qty_format(max($wo_details["units_reqd"] - $wo_details["units_issued"], 0), $wo_details["stock_id"], $dec); start_table($table_style2); br(); ref_row(_("Reference:"), 'ref', '', $Refs->get_next(29)); if (!isset($_POST['ProductionType'])) $_POST['ProductionType'] = 1; yesno_list_row(_("Type:"), 'ProductionType', $_POST['ProductionType'], _("Produce Finished Items"), _("Return Items to Work Order")); small_qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); date_row(_("Date:"), 'date_'); textarea_row(_("Memo:"), 'memo_', null, 40, 3); end_table(1); submit_center_first('Process', _("Process"), '', 'default'); submit_center_last('ProcessAndClose', _("Process And Close Order"), '', true); end_form(); end_page(); ?>frontaccount/applications/0000755000175000017500000000000011404426473015664 5ustar januszjanuszfrontaccount/applications/generalledger.php0000644000175000017500000000736511332146406021203 0ustar januszjanusz. ***********************************************************************/ class general_ledger_app extends application { function general_ledger_app() { global $installed_extensions; $this->application("GL", _($this->help_context = "&Banking and General Ledger")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("&Payments"), "gl/gl_bank.php?NewPayment=Yes", 'SA_PAYMENT'); $this->add_lapp_function(0, _("&Deposits"), "gl/gl_bank.php?NewDeposit=Yes", 'SA_DEPOSIT'); $this->add_lapp_function(0, _("Bank Account &Transfers"), "gl/bank_transfer.php?", 'SA_BANKTRANSFER'); $this->add_rapp_function(0, _("&Journal Entry"), "gl/gl_journal.php?NewJournal=Yes", 'SA_JOURNALENTRY'); $this->add_rapp_function(0, _("&Budget Entry"), "gl/gl_budget.php?", 'SA_BUDGETENTRY'); $this->add_rapp_function(0, _("&Reconcile Bank Account"), "gl/bank_account_reconcile.php?", 'SA_RECONCILE'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("&Journal Inquiry"), "gl/inquiry/journal_inquiry.php?", 'SA_GLANALYTIC'); $this->add_lapp_function(1, _("GL &Inquiry"), "gl/inquiry/gl_account_inquiry.php?", 'SA_GLTRANSVIEW'); $this->add_lapp_function(1, _("Bank Account &Inquiry"), "gl/inquiry/bank_inquiry.php?", 'SA_BANKTRANSVIEW'); $this->add_lapp_function(1, _("Ta&x Inquiry"), "gl/inquiry/tax_inquiry.php?", 'SA_TAXREP'); $this->add_rapp_function(1, _("Trial &Balance"), "gl/inquiry/gl_trial_balance.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("Balance &Sheet Drilldown"), "gl/inquiry/balance_sheet.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("&Profit and Loss Drilldown"), "gl/inquiry/profit_loss.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("Banking &Reports"), "reporting/reports_main.php?Class=5", 'SA_BANKREP'); $this->add_rapp_function(1, _("General Ledger &Reports"), "reporting/reports_main.php?Class=6", 'SA_GLREP'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Bank &Accounts"), "gl/manage/bank_accounts.php?", 'SA_BANKACCOUNT'); $this->add_lapp_function(2, _("&Quick Entries"), "gl/manage/gl_quick_entries.php?", 'SA_QUICKENTRY'); $this->add_lapp_function(2, _("Account &Tags"), "admin/tags.php?type=account", 'SA_GLACCOUNTTAGS'); $this->add_lapp_function(2, "",""); $this->add_lapp_function(2, _("&Currencies"), "gl/manage/currencies.php?", 'SA_CURRENCY'); $this->add_lapp_function(2, _("&Exchange Rates"), "gl/manage/exchange_rates.php?", 'SA_EXCHANGERATE'); $this->add_rapp_function(2, _("&GL Accounts"), "gl/manage/gl_accounts.php?", 'SA_GLACCOUNT'); $this->add_rapp_function(2, _("GL Account &Groups"), "gl/manage/gl_account_types.php?", 'SA_GLACCOUNTGROUP'); $this->add_rapp_function(2, _("GL Account &Classes"), "gl/manage/gl_account_classes.php?", 'SA_GLACCOUNTCLASS'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "GL") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/customers.php0000644000175000017500000001066011301263000020401 0ustar januszjanusz. ***********************************************************************/ class customers_app extends application { function customers_app() { global $installed_extensions; $this->application("orders", _($this->help_context = "&Sales")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Sales &Quotation Entry"), "sales/sales_order_entry.php?NewQuotation=Yes", 'SA_SALESQUOTE'); $this->add_lapp_function(0, _("Sales &Order Entry"), "sales/sales_order_entry.php?NewOrder=Yes", 'SA_SALESORDER'); $this->add_lapp_function(0, _("Direct &Delivery"), "sales/sales_order_entry.php?NewDelivery=0", 'SA_SALESDELIVERY'); $this->add_lapp_function(0, _("Direct &Invoice"), "sales/sales_order_entry.php?NewInvoice=0", 'SA_SALESINVOICE'); $this->add_lapp_function(0, "",""); $this->add_lapp_function(0, _("&Delivery Against Sales Orders"), "sales/inquiry/sales_orders_view.php?OutstandingOnly=1", 'SA_SALESDELIVERY'); $this->add_lapp_function(0, _("&Invoice Against Sales Delivery"), "sales/inquiry/sales_deliveries_view.php?OutstandingOnly=1", 'SA_SALESINVOICE'); $this->add_rapp_function(0, _("&Template Delivery"), "sales/inquiry/sales_orders_view.php?DeliveryTemplates=Yes", 'SA_SALESDELIVERY'); $this->add_rapp_function(0, _("&Template Invoice"), "sales/inquiry/sales_orders_view.php?InvoiceTemplates=Yes", 'SA_SALESINVOICE'); $this->add_rapp_function(0, _("&Create and Print Recurrent Invoices"), "sales/create_recurrent_invoices.php?", 'SA_SALESINVOICE'); $this->add_rapp_function(0, "",""); $this->add_rapp_function(0, _("Customer &Payments"), "sales/customer_payments.php?", 'SA_SALESPAYMNT'); $this->add_rapp_function(0, _("Customer &Credit Notes"), "sales/credit_note_entry.php?NewCredit=Yes", 'SA_SALESCREDIT'); $this->add_rapp_function(0, _("&Allocate Customer Payments or Credit Notes"), "sales/allocations/customer_allocation_main.php?", 'SA_SALESALLOC'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Sales Quotation I&nquiry"), "sales/inquiry/sales_orders_view.php?type=32", 'SA_SALESTRANSVIEW'); $this->add_lapp_function(1, _("Sales Order &Inquiry"), "sales/inquiry/sales_orders_view.php?type=30", 'SA_SALESTRANSVIEW'); $this->add_lapp_function(1, _("Customer Transaction &Inquiry"), "sales/inquiry/customer_inquiry.php?", 'SA_SALESTRANSVIEW'); $this->add_lapp_function(1, "",""); $this->add_lapp_function(1, _("Customer Allocation &Inquiry"), "sales/inquiry/customer_allocation_inquiry.php?", 'SA_SALESALLOC'); $this->add_rapp_function(1, _("Customer and Sales &Reports"), "reporting/reports_main.php?Class=0", 'SA_SALESTRANSVIEW'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Add and Manage &Customers"), "sales/manage/customers.php?", 'SA_CUSTOMER'); $this->add_lapp_function(2, _("Customer &Branches"), "sales/manage/customer_branches.php?", 'SA_CUSTOMER'); $this->add_lapp_function(2, _("Sales &Groups"), "sales/manage/sales_groups.php?", 'SA_SALESGROUP'); $this->add_lapp_function(2, _("Recurrent &Invoices"), "sales/manage/recurrent_invoices.php?", 'SA_SRECURRENT'); $this->add_rapp_function(2, _("Sales T&ypes"), "sales/manage/sales_types.php?", 'SA_SALESTYPES'); $this->add_rapp_function(2, _("Sales &Persons"), "sales/manage/sales_people.php?", 'SA_SALESMAN'); $this->add_rapp_function(2, _("Sales &Areas"), "sales/manage/sales_areas.php?", 'SA_SALESAREA'); $this->add_rapp_function(2, _("Credit &Status Setup"), "sales/manage/credit_status.php?", 'SA_CRSTATUS'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "orders") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/suppliers.php0000644000175000017500000000537011301263000020405 0ustar januszjanusz. ***********************************************************************/ class suppliers_app extends application { function suppliers_app() { global $installed_extensions; $this->application("AP", _($this->help_context = "&Purchases")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Purchase &Order Entry"), "purchasing/po_entry_items.php?NewOrder=Yes", 'SA_PURCHASEORDER'); $this->add_lapp_function(0, _("&Outstanding Purchase Orders Maintenance"), "purchasing/inquiry/po_search.php?", 'SA_SUPPTRANSVIEW'); $this->add_rapp_function(0, _("&Payments to Suppliers"), "purchasing/supplier_payment.php?", 'SA_SUPPLIERPAYMNT'); $this->add_rapp_function(0, "",""); $this->add_rapp_function(0, _("Supplier &Invoices"), "purchasing/supplier_invoice.php?New=1", 'SA_SUPPLIERINVOICE'); $this->add_rapp_function(0, _("Supplier &Credit Notes"), "purchasing/supplier_credit.php?New=1", 'SA_SUPPLIERCREDIT'); $this->add_rapp_function(0, _("&Allocate Supplier Payments or Credit Notes"), "purchasing/allocations/supplier_allocation_main.php?", 'SA_SUPPLIERALLOC'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Purchase Orders &Inquiry"), "purchasing/inquiry/po_search_completed.php?", 'SA_SUPPTRANSVIEW'); $this->add_lapp_function(1, _("Supplier Transaction &Inquiry"), "purchasing/inquiry/supplier_inquiry.php?", 'SA_SUPPTRANSVIEW'); $this->add_lapp_function(1, "",""); $this->add_lapp_function(1, _("Supplier Allocation &Inquiry"), "purchasing/inquiry/supplier_allocation_inquiry.php?", 'SA_SUPPLIERALLOC'); $this->add_rapp_function(1, _("Supplier and Purchasing &Reports"), "reporting/reports_main.php?Class=1", 'SA_SUPPTRANSVIEW'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Suppliers"), "purchasing/manage/suppliers.php?", 'SA_SUPPLIER'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "AP") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/index.php0000644000175000017500000000005310607534206017500 0ustar januszjanusz frontaccount/applications/manufacturing.php0000644000175000017500000000442711301263000021224 0ustar januszjanusz. ***********************************************************************/ class manufacturing_app extends application { function manufacturing_app() { global $installed_extensions; $this->application("manuf", _($this->help_context = "&Manufacturing")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Work &Order Entry"), "manufacturing/work_order_entry.php?", 'SA_WORKORDERENTRY'); $this->add_lapp_function(0, _("&Outstanding Work Orders"), "manufacturing/search_work_orders.php?outstanding_only=1", 'SA_MANUFTRANSVIEW'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Costed Bill Of Material Inquiry"), "manufacturing/inquiry/bom_cost_inquiry.php?", 'SA_WORKORDERCOST'); $this->add_lapp_function(1, _("Inventory Item Where Used &Inquiry"), "manufacturing/inquiry/where_used_inquiry.php?", 'SA_WORKORDERANALYTIC'); $this->add_lapp_function(1, _("Work Order &Inquiry"), "manufacturing/search_work_orders.php?", 'SA_MANUFTRANSVIEW'); $this->add_rapp_function(1, _("Manufacturing &Reports"), "reporting/reports_main.php?Class=3", 'SA_MANUFTRANSVIEW'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Bills Of Material"), "manufacturing/manage/bom_edit.php?", 'SA_BOM'); $this->add_lapp_function(2, _("&Work Centres"), "manufacturing/manage/work_centres.php?", 'SA_WORKCENTRES'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "manuf") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/application.php0000644000175000017500000000545011301263000020661 0ustar januszjanusz. ***********************************************************************/ class menu_item { var $label; var $link; function menu_item($label, $link) { $this->label = $label; $this->link = $link; } } class menu { var $title; var $items; function menu($title) { $this->title = $title; $this->items = array(); } function add_item($label, $link) { $item = new menu_item($label,$link); array_push($this->items,$item); return $item; } } class app_function { var $label; var $link; var $access; function app_function($label,$link,$access='SA_OPEN') { $this->label = $label; $this->link = $link; $this->access = $access; } } class module { var $name; var $icon; var $lappfunctions; var $rappfunctions; function module($name,$icon = null) { $this->name = $name; $this->icon = $icon; $this->lappfunctions = array(); $this->rappfunctions = array(); } function add_lapp_function($label,$link="",$access='SA_OPEN') { $appfunction = new app_function($label,$link,$access); //array_push($this->lappfunctions,$appfunction); $this->lappfunctions[] = $appfunction; return $appfunction; } function add_rapp_function($label,$link="",$access='SA_OPEN') { $appfunction = new app_function($label,$link,$access); //array_push($this->rappfunctions,$appfunction); $this->rappfunctions[] = $appfunction; return $appfunction; } } class application { var $id; var $name; var $help_context; var $modules; var $enabled; function application($id, $name, $enabled=true) { $this->id = $id; $this->name = $name; $this->enabled = $enabled; $this->modules = array(); } function add_module($name, $icon = null) { $module = new module($name,$icon); //array_push($this->modules,$module); $this->modules[] = $module; return $module; } function add_lapp_function($level, $label,$link="",$access='SA_OPEN') { $this->modules[$level]->lappfunctions[] = new app_function($label, $link, $access); } function add_rapp_function($level, $label,$link="",$access='SA_OPEN') { $this->modules[$level]->rappfunctions[] = new app_function($label, $link, $access); } } ?>frontaccount/applications/inventory.php0000644000175000017500000000617011301263000020413 0ustar januszjanusz. ***********************************************************************/ class inventory_app extends application { function inventory_app() { global $installed_extensions; $this->application("stock", _($this->help_context = "&Items and Inventory")); $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Inventory Location &Transfers"), "inventory/transfers.php?NewTransfer=1", 'SA_LOCATIONTRANSFER'); $this->add_lapp_function(0, _("Inventory &Adjustments"), "inventory/adjustments.php?NewAdjustment=1", 'SA_INVENTORYADJUSTMENT'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Inventory Item &Movements"), "inventory/inquiry/stock_movements.php?", 'SA_ITEMSTRANSVIEW'); $this->add_lapp_function(1, _("Inventory Item &Status"), "inventory/inquiry/stock_status.php?", 'SA_ITEMSSTATVIEW'); $this->add_rapp_function(1, _("Inventory &Reports"), "reporting/reports_main.php?Class=2", 'SA_ITEMSTRANSVIEW'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Items"), "inventory/manage/items.php?", 'SA_ITEM'); $this->add_lapp_function(2, _("&Foreign Item Codes"), "inventory/manage/item_codes.php?", 'SA_FORITEMCODE'); $this->add_lapp_function(2, _("Sales &Kits"), "inventory/manage/sales_kits.php?", 'SA_SALESKIT'); $this->add_lapp_function(2, _("Item &Categories"), "inventory/manage/item_categories.php?", 'SA_ITEMCATEGORY'); $this->add_lapp_function(2, _("Inventory &Locations"), "inventory/manage/locations.php?", 'SA_INVENTORYLOCATION'); $this->add_rapp_function(2, _("Inventory &Movement Types"), "inventory/manage/movement_types.php?", 'SA_INVENTORYMOVETYPE'); $this->add_rapp_function(2, _("&Units of Measure"), "inventory/manage/item_units.php?", 'SA_UOM'); $this->add_rapp_function(2, _("&Reorder Levels"), "inventory/reorder_level.php?", 'SA_REORDER'); $this->add_module(_("Pricing and Costs")); $this->add_lapp_function(3, _("Sales &Pricing"), "inventory/prices.php?", 'SA_SALESPRICE'); $this->add_lapp_function(3, _("Purchasing &Pricing"), "inventory/purchasing_data.php?", 'SA_PURCHASEPRICING'); $this->add_rapp_function(3, _("Standard &Costs"), "inventory/cost_update.php?", 'SA_STANDARDCOST'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "stock") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/setup.php0000644000175000017500000000727411307746313017547 0ustar januszjanusz. ***********************************************************************/ class setup_app extends application { function setup_app() { global $installed_extensions; $this->application("system", _($this->help_context = "S&etup")); $this->add_module(_("Company Setup")); $this->add_lapp_function(0, _("&Company Setup"), "admin/company_preferences.php?", 'SA_SETUPCOMPANY'); $this->add_lapp_function(0, _("&User Accounts Setup"), "admin/users.php?", 'SA_USERS'); $this->add_lapp_function(0, _("&Access Setup"), "admin/security_roles.php?", 'SA_SECROLES'); $this->add_lapp_function(0, _("&Display Setup"), "admin/display_prefs.php?", 'SA_SETUPDISPLAY'); $this->add_lapp_function(0, _("&Forms Setup"), "admin/forms_setup.php?", 'SA_FORMSETUP'); $this->add_rapp_function(0, _("&Taxes"), "taxes/tax_types.php?", 'SA_TAXRATES'); $this->add_rapp_function(0, _("Tax &Groups"), "taxes/tax_groups.php?", 'SA_TAXGROUPS'); $this->add_rapp_function(0, _("Item Ta&x Types"), "taxes/item_tax_types.php?", 'SA_ITEMTAXTYPE'); $this->add_rapp_function(0, _("System and &General GL Setup"), "admin/gl_setup.php?", 'SA_GLSETUP'); $this->add_rapp_function(0, _("&Fiscal Years"), "admin/fiscalyears.php?", 'SA_FISCALYEARS'); $this->add_rapp_function(0, _("&Print Profiles"), "admin/print_profiles.php?", 'SA_PRINTPROFILE'); $this->add_module(_("Miscellaneous")); $this->add_lapp_function(1, _("Pa&yment Terms"), "admin/payment_terms.php?", 'SA_PAYTERMS'); $this->add_lapp_function(1, _("Shi&pping Company"), "admin/shipping_companies.php?", 'SA_SHIPPING'); $this->add_rapp_function(1, _("&Points of Sale"), "sales/manage/sales_points.php?", 'SA_POSSETUP'); $this->add_rapp_function(1, _("&Printers"), "admin/printers.php?", 'SA_PRINTERS'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Void a Transaction"), "admin/void_transaction.php?", 'SA_VOIDTRANSACTION'); $this->add_lapp_function(2, _("View or &Print Transactions"), "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"), "admin/create_coy.php?", 'SA_CREATECOMPANY'); $this->add_rapp_function(2, _("Install/Update &Languages"), "admin/inst_lang.php?", 'SA_CREATELANGUAGE'); $this->add_rapp_function(2, _("Install/Activate &Extensions"), "admin/inst_module.php?", 'SA_CREATEMODULES'); $this->add_rapp_function(2, _("Software &Upgrade"), "admin/inst_upgrade.php?", 'SA_SOFTWAREUPGRADE'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "system") $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } ?>frontaccount/applications/dimensions.php0000644000175000017500000000374111301263000020527 0ustar januszjanusz. ***********************************************************************/ class dimensions_app extends application { function dimensions_app() { global $installed_extensions; $dim = get_company_pref('use_dimension'); $this->application("proj", _($this->help_context = "&Dimensions"), $dim); if ($dim > 0) { $this->add_module(_("Transactions")); $this->add_lapp_function(0, _("Dimension &Entry"), "dimensions/dimension_entry.php?", 'SA_DIMENSION'); $this->add_lapp_function(0, _("&Outstanding Dimensions"), "dimensions/inquiry/search_dimensions.php?outstanding_only=1", 'SA_DIMTRANSVIEW'); $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Dimension &Inquiry"), "dimensions/inquiry/search_dimensions.php?", 'SA_DIMTRANSVIEW'); $this->add_rapp_function(1, _("Dimension &Reports"), "reporting/reports_main.php?Class=4", 'SA_DIMENSIONREP'); $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Dimension &Tags"), "admin/tags.php?type=dimension", 'SA_DIMTAGS'); if (count($installed_extensions) > 0) { foreach ($installed_extensions as $mod) { if (@$mod['active'] && $mod['type'] == 'plugin' && $mod["tab"] == "proj") { $this->add_rapp_function(2, $mod["title"], "modules/".$mod["path"]."/".$mod["filename"]."?", isset($mod["access"]) ? $mod["access"] : 'SA_OPEN' ); } } } } } } ?>frontaccount/tmp/0000777000175000017500000000000011404426533013777 5ustar januszjanuszfrontaccount/tmp/index.php0000644000175000017500000000005310607722116015611 0ustar januszjanusz frontaccount/index.php0000644000175000017500000000201111301262777015011 0ustar januszjanusz. ***********************************************************************/ $path_to_root="."; if (!file_exists($path_to_root.'/config.php')) header("Location: ".$path_to_root."/install/index.php"); $page_security = 'SA_OPEN'; ini_set('xdebug.auto_trace',1); include_once("includes/session.inc"); add_access_extensions(); $app = &$_SESSION["App"]; if (isset($_GET['application'])) $app->selected_application = $_GET['application']; $app->display(); ?>frontaccount/includes/0000755000175000017500000000000011404426501014774 5ustar januszjanuszfrontaccount/includes/types.inc0000644000175000017500000002050211327260142016633 0ustar januszjanusz. ***********************************************************************/ //---------------------------------------------------------------------------------- // FrontAccounting system transaction types // define('ST_JOURNAL', 0); define('ST_BANKPAYMENT', 1); define('ST_BANKDEPOSIT', 2); define('ST_BANKTRANSFER', 4); define('ST_SALESINVOICE', 10); define('ST_CUSTCREDIT', 11); define('ST_CUSTPAYMENT', 12); define('ST_CUSTDELIVERY', 13); define('ST_LOCTRANSFER', 16); define('ST_INVADJUST', 17); define('ST_PURCHORDER', 18); define('ST_SUPPINVOICE', 20); define('ST_SUPPCREDIT', 21); define('ST_SUPPAYMENT', 22); define('ST_SUPPRECEIVE', 25); define('ST_WORKORDER', 26); define('ST_MANUISSUE', 28); define('ST_MANURECEIVE', 29); define('ST_SALESORDER', 30); define('ST_SALESQUOTE', 32); define('ST_COSTUPDATE', 35); define('ST_DIMENSION', 40); // Don't include these defines in the $systypes_array. // They are used for documents only. define ('ST_STATEMENT', 91); define ('ST_CHEQUE', 92); $systypes_array = array ( ST_JOURNAL => _("Journal Entry"), ST_BANKPAYMENT => _("Bank Payment"), ST_BANKDEPOSIT => _("Bank Deposit"), ST_BANKTRANSFER => _("Funds Transfer"), ST_SALESINVOICE => _("Sales Invoice"), ST_CUSTCREDIT => _("Customer Credit Note"), ST_CUSTPAYMENT => _("Customer Payment"), ST_CUSTDELIVERY => _("Delivery Note"), ST_LOCTRANSFER => _("Location Transfer"), ST_INVADJUST => _("Inventory Adjustment"), ST_PURCHORDER => _("Purchase Order"), ST_SUPPINVOICE => _("Supplier Invoice"), ST_SUPPCREDIT => _("Supplier Credit Note"), ST_SUPPAYMENT => _("Supplier Payment"), ST_SUPPRECEIVE => _("Purchase Order Delivery"), ST_WORKORDER => _("Work Order"), ST_MANUISSUE => _("Work Order Issue"), ST_MANURECEIVE => _("Work Order Production"), ST_SALESORDER => _("Sales Order"), ST_SALESQUOTE => _("Sales Quotation"), ST_COSTUPDATE => _("Cost Update"), ST_DIMENSION => _("Dimension") ); //---------------------------------------------------------------------------------- // Bank transaction types // define('BT_TRANSFER', 0); define('BT_CHEQUE', 1); define('BT_CREDIT', 2); define('BT_CASH', 3); $bank_account_types = array ( BT_TRANSFER => _("Savings Account"), _("Chequing Account"), _("Credit Account"), _("Cash Account") ); $bank_transfer_types = array( BT_TRANSFER => _("Transfer"), _("Cheque"), _("Credit"), _("Cash") ); include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include_once($path_to_root . "/purchasing/includes/purchasing_db.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/dimensions/includes/dimensions_db.inc"); //---------------------------------------------------------------------------------- // Payment types // define('PT_MISC', 0); define('PT_WORKORDER', 1); define('PT_CUSTOMER', 2); define('PT_SUPPLIER', 3); define('PT_QUICKENTRY', 4); define('PT_DIMESION', 5); $payment_person_types = array ( PT_MISC => _("Miscellaneous"), _("Work Order"), _("Customer"), _("Supplier"), _("Quick Entry") ); function payment_person_currency($type, $person_id) { switch ($type) { case PT_MISC : case PT_QUICKENTRY : case PT_WORKORDER : return get_company_currency(); case PT_CUSTOMER : return get_customer_currency($person_id); case PT_SUPPLIER : return get_supplier_currency($person_id); default : return get_company_currency(); } } function payment_person_name($type, $person_id, $full=true) { global $payment_person_types; switch ($type) { case PT_MISC : return $person_id; case PT_QUICKENTRY : $qe = get_quick_entry($person_id); return ($full ? $payment_person_types[$type] . " ":"") . $qe["description"]; case PT_WORKORDER : global $wo_cost_types; return $wo_cost_types[$person_id]; case PT_CUSTOMER : return ($full ?$payment_person_types[$type] . " ":"") . get_customer_name($person_id); case PT_SUPPLIER : return ($full ? $payment_person_types[$type] . " ":"") . get_supplier_name($person_id); default : //DisplayDBerror("Invalid type sent to person_name"); //return; return ''; } } function payment_person_has_items($type) { switch ($type) { case PT_MISC : return true; case PT_QUICKENTRY : return db_has_quick_entries(); case PT_WORKORDER : // 070305 changed to open workorders JH return db_has_open_workorders(); case PT_CUSTOMER : return db_has_customers(); case PT_SUPPLIER : return db_has_suppliers(); default : display_db_error("Invalid type sent to has_items", ""); return false; } } //---------------------------------------------------------------------------------- // Manufacturing types // define('WO_ASSEMBLY', 0); define('WO_UNASSEMBLY', 1); define('WO_ADVANCED', 2); $wo_types_array = array ( WO_ASSEMBLY => _("Assemble"), WO_UNASSEMBLY => _("Unassemble"), WO_ADVANCED => _("Advanced Manufacture") ); define('WO_LABOUR', 0); define('WO_OVERHEAD', 1); $wo_cost_types = array( WO_LABOUR => _("Labour Cost"), WO_OVERHEAD => _("Overhead Cost"), ); //---------------------------------------------------------------------------------- // GL account classes // define('CL_NONE', 0); // for backward compatibility define('CL_ASSETS', 1); define('CL_LIABILITIES', 2); define('CL_EQUITY', 3); define('CL_INCOME', 4); define('CL_COGS', 5); define('CL_EXPENSE', 6); $class_types = array( CL_ASSETS => _("Assets"), CL_LIABILITIES => _("Liabilities"), CL_EQUITY => _("Equity"), CL_INCOME => _("Income"), CL_COGS => _("Cost of Goods Sold"), CL_EXPENSE => _("Expense"), ); function get_class_type_convert($ctype) { global $use_oldstyle_convert; if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1) return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1); else return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1); } //---------------------------------------------------------------------------------- // Quick entry types // $quick_actions = array( '=' => _('Remainder'), // post current base amount to GL account 'a' => _('Amount'), // post amount to GL account 'a+' => _('Amount, increase base'), // post amount to GL account and increase base 'a-' => _('Amount, reduce base'), // post amount to GL account and reduce base '%' => _('% amount of base'), // store acc*amount% to GL account '%+' => _('% amount of base, increase base'), // ditto & increase base amount '%-' => _('% amount of base, reduce base'), // ditto & reduce base amount 'T' => _('Taxes added'), // post taxes calculated on base amount 'T+' => _('Taxes added, increase base'), // ditto & increase base amount 'T-' => _('Taxes added, reduce base'), // ditto & reduce base amount 't' => _('Taxes included'), // post taxes calculated on base amount 't+' => _('Taxes included, increase base'), // ditto & increase base amount 't-' => _('Taxes included, reduce base') // ditto & reduce base amount ); define('QE_PAYMENT', '1'); define('QE_DEPOSIT', '2'); define('QE_JOURNAL', '3'); define('QE_SUPPINV', '4'); $quick_entry_types = array( QE_DEPOSIT => _("Bank Deposit"), QE_PAYMENT => _("Bank Payment"), QE_JOURNAL => _("Journal Entry"), QE_SUPPINV => _("Supplier Invoice/Credit") ); //---------------------------------------------------------------------------------- // Special option values for various list selectors. // define('ANY_TEXT', ''); define('ANY_NUMERIC', -1); define('ALL_TEXT', ''); define('ALL_NUMERIC', -1); //---------------------------------------------------------------------------------- // Types of stock items $stock_types = array( 'M' => _("Manufactured"), 'B' => _("Purchased"), 'D' => _("Service") ); //---------------------------------------------------------------------------------- define('TAG_ACCOUNT', 1); define('TAG_DIMENSION', 2); $tag_types = array ( TAG_ACCOUNT => _("Account"), TAG_DIMENSION => _("Dimension") ); ?>frontaccount/includes/session.inc0000644000175000017500000002010611372504101017146 0ustar januszjanusz. ***********************************************************************/ function output_html($text) { global $before_box, $Ajax, $messages; // Fatal errors are not send to error_handler, // so we must check the output if ($text && preg_match('/\bFatal error(<.*?>)?:(.*)/i', $text, $m)) { $Ajax->aCommands = array(); // Don't update page via ajax on errors $text = preg_replace('/\bFatal error(<.*?>)?:(.*)/i','', $text); $messages[] = array(E_ERROR, $m[2], null, null); } $Ajax->run(); return in_ajax() ? fmt_errors() : ($before_box.fmt_errors().$text); } //---------------------------------------------------------------------------------------- function kill_login() { session_unset(); session_destroy(); } //---------------------------------------------------------------------------------------- function login_fail() { global $path_to_root; header("HTTP/1.1 401 Authorization Required"); echo "


" . _("Incorrect Password") . "

"; echo "" . _("The user and password combination is not valid for the system.") . "

"; echo _("If you are not an authorized user, please contact your system administrator to obtain an account to enable you to use the system."); echo "
" . _("Try again") . ""; echo "
"; kill_login(); die(); } //---------------------------------------------------------------------------------------- function check_page_security($page_security) { if (!$_SESSION["wa_current_user"]->check_user_access()) { // notification after upgrade from pre-2.2 version $msg = $_SESSION["wa_current_user"]->old_db ? _("Security settings have not been defined for your user account.") . "
" . _("Please contact your system administrator.") : _("Please remove \$security_groups and \$security_headings arrays from config.php file!"); display_error($msg); end_page(); kill_login(); exit; } if (!$_SESSION["wa_current_user"]->can_access_page($page_security)) { echo "



"; echo _("The security settings on your account do not permit you to access this function"); echo ""; echo "



"; end_page(); exit; } } /* Helper function for setting page security level depeding on GET start variable and/or some value stored in session variable. Before the call $page_security should be set to default page_security value. */ function set_page_security($value=null, $trans = array(), $gtrans = array()) { global $page_security; // first check is this is not start page call foreach($gtrans as $key => $area) if (isset($_GET[$key])) { $page_security = $area; return; } // then check session value if (isset($trans[$value])) { $page_security = $trans[$value]; return; } } //----------------------------------------------------------------------------- // Removing magic quotes from nested arrays/variables // function strip_quotes($data) { if(get_magic_quotes_gpc()) { if(is_array($data)) { foreach($data as $k => $v) { $data[$k] = strip_quotes($data[$k]); } } else return stripslashes($data); } return $data; } //============================================================================ // // function login_timeout() { // skip timeout on logout page if ($_SESSION["wa_current_user"]->logged) { $tout = $_SESSION["wa_current_user"]->timeout; if ($tout && (time() > $_SESSION["wa_current_user"]->last_act + $tout)) { $_SESSION["wa_current_user"]->logged = false; } $_SESSION["wa_current_user"]->last_act = time(); } } //============================================================================ if (!isset($path_to_root)) { $path_to_root = "."; } // Prevent register_globals vulnerability if (isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die("Restricted access"); include_once($path_to_root . "/includes/current_user.inc"); include_once($path_to_root . "/frontaccounting.php"); include_once($path_to_root . "/admin/db/security_db.inc"); include_once($path_to_root . "/includes/lang/language.php"); include_once($path_to_root . "/config_db.php"); include_once($path_to_root . "/includes/ajax.inc"); include_once($path_to_root . "/includes/ui/ui_msgs.inc"); /* Uncomment the setting below when using FA on shared hosting to avoid unexpeced session timeouts. Make sure this directory exists and is writable! */ //ini_set('session.save_path', dirname(__FILE__).'/../tmp/'); ini_set('session.gc_maxlifetime', 36000); // 10hrs session_name('FA'.md5(dirname(__FILE__))); session_start(); // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks header("Cache-control: private"); get_text_init(); // Page Initialisation if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language')) { $l = array_search_value($dflt_lang, $installed_languages, 'code'); $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'], isset($l['rtl']) ? 'rtl' : 'ltr'); } $_SESSION['language']->set_language($_SESSION['language']->code); // include $Hooks object if locale file exists if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) { include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"); $Hooks = new Hooks(); } include_once($path_to_root . "/includes/access_levels.inc"); include_once($path_to_root . "/config.php"); include_once($path_to_root . "/includes/main.inc"); // Ajax communication object $Ajax = new Ajax(); // js/php validation rules container $Validate = array(); // bindings for editors $Editors = array(); // page help. Currently help for function keys. $Pagehelp = array(); $SysPrefs = new sys_prefs(); $Refs = new references(); // intercept all output to destroy it in case of ajax call register_shutdown_function('end_flush'); ob_start('output_html',0); // colect all error msgs set_error_handler('error_handler' /*, errtypes */); if (!isset($_SESSION["wa_current_user"])) $_SESSION["wa_current_user"] = new current_user(); // logout.php is the only page we should have always // accessable regardless of access level and current login status. if (strstr($_SERVER['PHP_SELF'], 'logout.php') == false){ login_timeout(); if (!$_SESSION["wa_current_user"]->logged_in()) { // Show login screen if (!isset($_POST["user_name_entry_field"]) or $_POST["user_name_entry_field"] == "") { // strip ajax marker from uri, to force synchronous page reload $_SESSION['timeout'] = array( 'uri'=>preg_replace('/JsHttpRequest=(?:(\d+)-)?([^&]+)/s', '', @$_SERVER['REQUEST_URI']), 'post' => $_POST); include($path_to_root . "/access/login.php"); if (in_ajax()) $Ajax->activate('_page_body'); exit; } else { $succeed = isset($db_connections[$_POST["company_login_name"]]) && $_SESSION["wa_current_user"]->login($_POST["company_login_name"], $_POST["user_name_entry_field"], md5($_POST["password"])); // select full vs fallback ui mode on login $_SESSION["wa_current_user"]->ui_mode = $_POST['ui_mode']; if (!$succeed) { // Incorrect password login_fail(); } $lang = &$_SESSION['language']; $lang->set_language($_SESSION['language']->code); } } else set_global_connection(); if (!$_SESSION["wa_current_user"]->old_db) include_once($path_to_root . '/company/'.user_company().'/installed_extensions.php'); if (!isset($_SESSION["App"])) { $_SESSION["App"] = new front_accounting(); $_SESSION["App"]->init(); } } // POST vars cleanup needed for direct reuse. // We quote all values later with db_escape() before db update. $_POST = strip_quotes($_POST); ?>frontaccount/includes/current_user.inc0000644000175000017500000003253411401655703020223 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/prefs/userprefs.inc"); //-------------------------------------------------------------------------- class current_user { var $user; var $loginname; var $username; var $name; var $company; var $pos; var $access; var $timeout; var $last_act; var $role_set = false; var $old_db; var $logged; var $ui_mode = 0; var $prefs; function current_user() { global $def_coy; $this->loginname = $this->username = $this->name = ""; $this->company = isset($def_coy)? $def_coy : 0; $this->logged = false; $this->prefs = new user_prefs(); } function logged_in() { return $this->logged; } function set_company($company) { $this->company = $company; } function login($company, $loginname, $password) { global $security_areas, $security_groups, $security_headings, $path_to_root; $this->set_company($company); $this->logged = false; $Auth_Result = get_user_for_login($loginname, $password); if (db_num_rows($Auth_Result) > 0) { $myrow = db_fetch($Auth_Result); $this->old_db = isset($myrow["full_access"]); if (! @$myrow["inactive"]) { if ($this->old_db) { // Transition code: // db was not yet upgraded after source update to v.2.2 // give enough access for admin user to continue upgrade if (!isset($security_groups) || !isset($security_headings)) { echo "


"; echo _('Before software upgrade you have to include old $security_groups and $security_headings arrays from old config.php file to the new one.'); echo '
'.""._("Back").""; echo "


"; exit; } $this->access = $myrow["full_access"]; if (in_array(20, $security_groups[$this->access])) // temporary access for admin users $this->role_set[] = $security_areas['SA_SOFTWAREUPGRADE'][0]; else { echo "


"; echo _('System is available for site admin only until full database upgrade'); echo "

"; exit; } } else { $this->role_set = array(); $this->access = $myrow["role_id"]; // store area codes available for current user role $role = get_security_role($this->access); if (!$role) return false; foreach( $role['areas'] as $code ) // filter only area codes for enabled security sections if (in_array($code&~0xff, $role['sections'])) $this->role_set[] = $code; } $this->name = $myrow["real_name"]; $this->pos = $myrow["pos"]; $this->loginname = $loginname; $this->username = $this->loginname; $this->prefs = new user_prefs($myrow); $this->user = @$myrow["id"]; update_user_visitdate($this->username); $this->logged = true; $this->last_act = time(); $this->timeout = session_timeout(); } } return $this->logged; } function check_user_access() { global $security_groups; if ($this->old_db) { // notification after upgrade from pre-2.2 version return isset($security_groups) && is_array(@$security_groups[$this->access]); } else return !isset($security_groups) && is_array($this->role_set); } function can_access($page_level) { global $security_groups, $security_areas; if (isset($security_groups)) { return $this->company == 0 && in_array(20, $security_groups[$this->access]); } if ($page_level === 'SA_OPEN') return true; if ($page_level === 'SA_DENIED' || $page_level === '') return false; $code = $security_areas[$page_level][0]; // only first registered company has site admin privileges return $code && in_array($code, $this->role_set) && ($this->company == 0 || (($code&~0xff) != SS_SADMIN)); } function can_access_page($page_level) { return $this->can_access($page_level); } function get_db_connection($id=-1) { global $db_connections; $connection = $db_connections[$id == -1 ? $this->company : $id]; //print_r($connection); $db = mysql_connect($connection["host"] , $connection["dbuser"], $connection["dbpassword"]); mysql_select_db($connection["dbname"],$db); if (!defined('TB_PREF')) define('TB_PREF', $connection["tbpref"]); return $db; } function update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab) { global $allow_demo_mode; $user = array( 'prices_dec' => $price_dec, 'qty_dec' => $qty_dec, 'rates_dec' => $exrate_dec, 'percent_dec' => $percent_dec, 'show_gl' => $showgl, 'show_codes' => $showcodes, 'date_format' => $date_format, 'date_sep' => $date_sep, 'tho_sep' => $tho_sep, 'dec_sep' => $dec_sep, 'theme' => $theme, 'page_size' => $pagesize, 'show_hints' => $show_hints, 'print_profile' => $profile, 'rep_popup' => $rep_popup, 'query_size' => $query_size, 'graphic_links' => $graphic_links, 'language' => $lang, 'sticky_doc_date' => $stickydate, 'startup_tab' => $startup_tab ); if(!$allow_demo_mode) { update_user_display_prefs($this->user, $price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab); } $this->prefs = new user_prefs(get_user($this->user)); } } //-------------------------------------------------------------------------- function round2($number, $decimals=0) { $delta = ($number < 0 ? -.0000000001 : .0000000001); return round($number+$delta, $decimals); } function number_format2($number, $decimals=0) { global $thoseps, $decseps; $tsep = $thoseps[$_SESSION["wa_current_user"]->prefs->tho_sep()]; $dsep = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()]; //return number_format($number, $decimals, $dsep, $tsep); $delta = ($number < 0 ? -.0000000001 : .0000000001); return number_format($number+$delta, $decimals, $dsep, $tsep); } // // Current ui mode. // function fallback_mode() { return $_SESSION["wa_current_user"]->ui_mode==0; } function price_format($number) { return number_format2($number, $_SESSION["wa_current_user"]->prefs->price_dec()); } function price_decimal_format($number, &$dec) { $dec = user_price_dec(); $str = strval($number); $pos = strpos($str, '.'); if ($pos !== false) { $len = strlen(substr($str, $pos + 1)); if ($len > $dec) $dec = $len; } 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) { $dec = get_qty_dec($stock_id); return number_format2($number, $dec); } // and get_qty_dec function get_qty_dec($stock_id=null) { global $path_to_root; include_once($path_to_root."/inventory/includes/db/items_units_db.inc"); if ($stock_id != null) $dec = get_unit_dec($stock_id); if ($stock_id == null || $dec == -1 || $dec == null) $dec = $_SESSION["wa_current_user"]->prefs->qty_dec(); return $dec; } //------------------------------------------------------------------- function exrate_format($number) { return number_format2($number, $_SESSION["wa_current_user"]->prefs->exrate_dec()); } function percent_format($number) { return number_format2($number, $_SESSION["wa_current_user"]->prefs->percent_dec()); } function user_numeric($input) { global $decseps, $thoseps; $num = trim($input); $sep = $thoseps[user_tho_sep()]; if ($sep!='') $num = str_replace( $sep, '', $num); $sep = $decseps[user_dec_sep()]; if ($sep!='.') $num = str_replace( $sep, '.', $num); if (!is_numeric($num)) return false; $num = (float)$num; if ($num == (int)$num) return (int)$num; else return $num; } function user_company() { return $_SESSION["wa_current_user"]->company; } function user_pos() { return $_SESSION["wa_current_user"]->pos; } function user_language() { return $_SESSION["wa_current_user"]->prefs->language(); } function user_qty_dec() { return $_SESSION["wa_current_user"]->prefs->qty_dec(); } function user_price_dec() { return $_SESSION["wa_current_user"]->prefs->price_dec(); } function user_exrate_dec() { return $_SESSION["wa_current_user"]->prefs->exrate_dec(); } function user_percent_dec() { return $_SESSION["wa_current_user"]->prefs->percent_dec(); } function user_show_gl_info() { return $_SESSION["wa_current_user"]->prefs->show_gl_info(); } function user_show_codes() { return $_SESSION["wa_current_user"]->prefs->show_codes(); } function user_date_format() { return $_SESSION["wa_current_user"]->prefs->date_format(); } function user_date_display() { return $_SESSION["wa_current_user"]->prefs->date_display(); } function user_date_sep() { return $_SESSION["wa_current_user"]->prefs->date_sep(); } function user_tho_sep() { return $_SESSION["wa_current_user"]->prefs->tho_sep(); } function user_dec_sep() { return $_SESSION["wa_current_user"]->prefs->dec_sep(); } function user_theme() { return $_SESSION["wa_current_user"]->prefs->get_theme(); } function user_pagesize() { return $_SESSION["wa_current_user"]->prefs->get_pagesize(); } function user_hints() { return $_SESSION["wa_current_user"]->prefs->show_hints(); } function user_print_profile() { return $_SESSION["wa_current_user"]->prefs->print_profile(); } function user_rep_popup() { return $_SESSION["wa_current_user"]->prefs->rep_popup(); } function user_query_size() { return $_SESSION["wa_current_user"]->prefs->query_size(); } function user_graphic_links() { return $_SESSION["wa_current_user"]->prefs->graphic_links(); } function sticky_doc_date() { return $_SESSION["wa_current_user"]->prefs->sticky_date(); } function user_startup_tab() { return $_SESSION["wa_current_user"]->prefs->start_up_tab(); } function set_user_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab) { $_SESSION["wa_current_user"]->update_prefs($price_dec, $qty_dec, $exrate_dec, $percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep, $dec_sep, $theme, $pagesize, $show_hints, $print_profile, $rep_popup, $query_size, $graphic_links, $lang, $stickydate, $startup_tab); } function add_user_js_data() { global $path_to_root, $thoseps, $decseps, $date_system, $dateseps; $ts = $thoseps[user_tho_sep()]; $ds = $decseps[user_dec_sep()]; $js = "\n" . "var user = {\n" . "theme: '". $path_to_root . '/themes/'. user_theme().'/'."',\n" . "loadtxt: '"._('Requesting data...')."',\n" . "date: '".Today()."',\n" // server date . "datesys: ".$date_system.",\n" . "datefmt: ".user_date_format().",\n" . "datesep: '".$dateseps[user_date_sep()]."',\n" . "ts: '$ts',\n" . "ds: '$ds',\n" . "pdec : " . user_price_dec() . "}\n"; add_js_source($js); } //-------------------------------------------------------------------------- function session_timeout() { $tout = @get_company_pref('login_tout'); // mask warning for db ver. 2.2 return $tout ? $tout : ini_get('session.gc_maxlifetime'); } //----------------------------------------------------------------------------- // Inserts $elements into $array at position $index. // $elements is list of any objects // function array_insert(&$array, $index, $elements) { if (!is_array($elements)) $elements = array($elements); $head = array_splice($array, 0, $index); $array = array_merge($head, $elements, $array); } function array_remove(&$array, $index, $len=1) { array_splice($array, $index, $len); } function array_substitute(&$array, $index, $len, $elements) { array_splice($array, $index, $len); array_insert($array, $index, $elements); } function array_append(&$array, $elements) { foreach($elements as $key => $el) { if(is_int($key)) $array[] = $el; else $array[$key] = $el; } } function array_search_value($needle, $haystack, $valuekey=null) { foreach($haystack as $key => $value) { $val = isset($valuekey) ? $value[$valuekey] : $value; if ($needle == $val){ return $value; } } return null; } function array_search_key($needle, $haystack, $valuekey=null) { foreach($haystack as $key => $value) { $val = isset($valuekey) ? $value[$valuekey] : $value; if ($needle == $val){ return $key; } } return null; } ?>frontaccount/includes/index.php0000644000175000017500000000005310607534212016615 0ustar januszjanusz frontaccount/includes/main.inc0000644000175000017500000001631511333113201016410 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/db/connect_db.inc"); include_once($path_to_root . "/includes/errors.inc"); include_once($path_to_root . "/includes/types.inc"); include_once($path_to_root . "/includes/systypes.inc"); include_once($path_to_root . "/includes/references.inc"); include_once($path_to_root . "/includes/prefs/sysprefs.inc"); include_once($path_to_root . "/includes/db/comments_db.inc"); include_once($path_to_root . "/includes/db/sql_functions.inc"); include_once($path_to_root . "/includes/db/audit_trail_db.inc"); //include_once($path_to_root . "/includes/validation.inc"); include_once($path_to_root . "/admin/db/users_db.inc"); include_once($path_to_root . "/includes/ui/ui_view.inc"); include_once($path_to_root . "/includes/ui/ui_controls.inc"); function page($title, $no_menu=false, $is_index=false, $onload="", $js="", $script_only=false) { global $path_to_root, $page_security; $hide_menu = $no_menu; include($path_to_root . "/includes/page/header.inc"); page_header($title, $no_menu, $is_index, $onload, $js); check_page_security($page_security); // error_box(); if($script_only) { echo ''; div_start('_page_body', null, true); } else { div_start('_page_body'); // whole page content for ajax reloading } } function end_page($no_menu=false, $is_index=false, $hide_back_link=false) { global $path_to_root; if (!$is_index && !$hide_back_link && function_exists('hyperlink_back')) hyperlink_back(true, $no_menu); div_end(); // end of _page_body section include($path_to_root . "/includes/page/footer.inc"); page_footer($no_menu, $is_index, $hide_back_link); } function flush_dir($path, $wipe = false) { $dir = opendir($path); while(false !== ($fname = readdir($dir))) { if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue; if(is_dir($path.'/'.$fname)) { flush_dir($path.'/'.$fname, $wipe); if ($wipe) @rmdir($path.'/'.$fname); } else @unlink($path.'/'.$fname); } } function cache_js_file($fpath, $text) { global $go_debug; if(!$go_debug) $text = js_compress($text); $file = fopen($fpath, 'w'); if (!$file) return false; if (!fwrite($file, $text)) return false; return fclose($file); } function add_js_file($filename) { global $js_static; $search = array_search($filename, $js_static); if ($search === false || $search === null) // php>4.2.0 returns null $js_static[] = $filename; } function add_js_ufile($filename) { global $js_userlib; $search = array_search($filename, $js_userlib); if ($search === false || $search === null) // php>4.2.0 returns null $js_userlib[] = $filename; } function add_js_source($text) { global $js_lib; $search = array_search($text, $js_lib); if ($search === false || $search === null) // php>4.2.0 returns null $js_lib[] = $text; } /** * Compresses the Javascript code for more efficient delivery. * copyright (c) 2005 by Jared White & J. Max Wilson * http://www.xajaxproject.org * Added removing comments from output. * Warning: Fails on RegExp with quotes - use new RegExp() in this case. */ function js_compress($sJS) { //remove windows cariage returns $sJS = str_replace("\r","",$sJS); //array to store replaced literal strings $literal_strings = array(); //explode the string into lines $lines = explode("\n",$sJS); //loop through all the lines, building a new string at the same time as removing literal strings $clean = ""; $inComment = false; $literal = ""; $inQuote = false; $escaped = false; $quoteChar = ""; for($i=0;$ifrontaccount/includes/systypes.inc0000644000175000017500000001065211305331032017370 0ustar januszjanusz. ***********************************************************************/ //----------------------------------------------------------------------------------------- // Returns next transaction number. // Used only for transactions stored in tables without autoincremented key. // function get_next_trans_no ($trans_type){ $st = get_systype_db_info($trans_type); if (!($st && $st[0] && $st[2])) { // this is in fact internal error condition. display_error('Internal error: invalid type passed to get_next_trans_no()'); return 0; } $sql = "SELECT MAX(`$st[2]`) FROM $st[0]"; if ($st[1] != null) $sql .= " WHERE `$st[1]`=$trans_type"; $result = db_query($sql,"The next transaction number for $trans_type could not be retrieved"); $myrow = db_fetch_row($result); return $myrow[0] + 1; } //----------------------------------------------------------------------------- function get_systype_db_info($type) { switch ($type) { case ST_JOURNAL : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date"); case ST_BANKPAYMENT : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); case ST_BANKDEPOSIT : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); case 3 : return null; case ST_BANKTRANSFER : return array("".TB_PREF."bank_trans", "type", "trans_no", "ref", "trans_date"); case ST_SALESINVOICE : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); case ST_CUSTCREDIT : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); case ST_CUSTPAYMENT : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); case ST_CUSTDELIVERY : return array("".TB_PREF."debtor_trans", "type", "trans_no", "reference", "tran_date"); case ST_LOCTRANSFER : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); case ST_INVADJUST : return array("".TB_PREF."stock_moves", "type", "trans_no", "reference", "tran_date"); case ST_PURCHORDER : return array("".TB_PREF."purch_orders", null, "order_no", "reference", "tran_date"); case ST_SUPPINVOICE : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); case ST_SUPPCREDIT : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); case ST_SUPPAYMENT : return array("".TB_PREF."supp_trans", "type", "trans_no", "reference", "tran_date"); case ST_SUPPRECEIVE : return array("".TB_PREF."grn_batch", null, "id", "reference", "delivery_date"); case ST_WORKORDER : return array("".TB_PREF."workorders", null, "id", "wo_ref", "released_date"); case ST_MANUISSUE : return array("".TB_PREF."wo_issues", null, "issue_no", "reference", "issue_date"); case ST_MANURECEIVE : return array("".TB_PREF."wo_manufacture", null, "id", "reference", "date_"); case ST_SALESORDER : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); case 31 : return array("".TB_PREF."service_orders", null, "order_no", "cust_ref", "date"); case ST_SALESQUOTE : return array("".TB_PREF."sales_orders", "trans_type", "order_no", "reference", "ord_date"); case ST_DIMENSION : return array("".TB_PREF."dimensions", null, "id", "reference", "date_"); case ST_COSTUPDATE : return array("".TB_PREF."gl_trans", "type", "type_no", null, "tran_date"); } display_db_error("invalid type ($type) sent to get_systype_db_info", "", true); } function get_systypes() { $sql = "SELECT * FROM ".TB_PREF."sys_types"; $result = db_query($sql, "could not query systypes table"); return $result; } ?>frontaccount/includes/ajax.inc0000644000175000017500000001044111155256063016421 0ustar januszjanusz. ***********************************************************************/ require_once($path_to_root. "/includes/JsHttpRequest.php"); class Ajax extends JsHttpRequest { var $aCommands = array(); var $triggers = array(); function Ajax() { $this->JsHttpRequest($_SESSION['language']->encoding); } // // This function is used in ctrl routines to activate // update of ajaxified html element selected by given name/id. // function activate($trigname) { if (in_ajax()) { $this->triggers[$trigname] = true; } } // // Javascript clientside redirection. // This is the last command added to reponse (if any). // function redirect($url) { if(in_ajax()) { $this->_addCommand(true, array('n'=>'rd'), absolute_url($url)); $this->run(); } } // // Popup window (target=_blank) // function popup($url) { $this->_addCommand(true, array('n'=>'pu'), absolute_url($url)); } // // Adds an executable Javascript code. // function addScript($trigger, $sJS) { $this->_addCommand($trigger, array('n'=>'js'),$sJS); return $this; } // // Assign target attribute with data. // function addAssign($trigger, $sTarget,$sAttribute,$sData) { $this->_addCommand($trigger, array('n'=>'as','t'=>$sTarget,'p'=>$sAttribute),$sData); return $this; } // // Updates input element or label with data. // function addUpdate($trigger, $sTarget, $sData) { $this->_addCommand($trigger, array('n'=>'up','t'=>$sTarget),$sData); return $this; } // // Set disable state of element. // function addDisable($trigger, $sTarget, $sData=true) { $this->_addCommand($trigger, array('n'=>'di','t'=>$sTarget),$sData); return $this; } // // Set state of element to enabled. // function addEnable($trigger, $sTarget, $sData=true) { $this->_addCommand($trigger, array('n'=>'di','t'=>$sTarget), !$sData); return $this; } // // Set current focus. // function addFocus($trigger, $sTarget) { $this->_addCommand($trigger, array('n'=>'fc'),$sTarget); return $this; } // // Internal procedure adding command to response. // function _addCommand($trigger, $aAttributes, $mData) { if ($this->isActive() && ($trigger !== false)) { // display_error('adding '.$trigger.':'.htmlentities($mData)); $aAttributes['why'] = $trigger; $aAttributes['data'] = $mData; $this->aCommands[] = $aAttributes; } } /* * Register binds function with ajax call parameter function register($trigger, $function) { if (isset($_REQUEST[$trigger])) { $function(&$this); } } */ function run() { if (!$this->isActive()) return; // remove not active commands foreach ($this->aCommands as $idx => $com) { // If we should reload whole page content ignore all commands but the update. // This is page repost equivalent, although header and footer are not reloaded. if ($com['why'] !== true && !isset($this->triggers[$com['why']])) { unset($this->aCommands[$idx]); // display_error('unset '.$com['t']); } else if($com['n'] == 'up' && $com['t'] == '_page_body') { $cmds = array($com); foreach( $this->aCommands as $k=> $cmd) { if ($cmd['n'] == 'fc') { // save focus $cmds[] = $cmd; break; } } $this->aCommands = $cmds; break; } } // display_error('Activate:'.htmlentities(print_r($this->triggers, true))); // display_error('Commands :'.htmlentities(print_r($this->aCommands, true))); $GLOBALS['_RESULT'] = $this->aCommands; // exit(); } } function in_ajax() { global $Ajax; return $Ajax->isActive(); } // Returns absolute path of relative $url. To be used in ajax calls // for proper redirection from any referer page. // function absolute_url($url) { return strpos($url, '..')===0 ? dirname($_SERVER['PHP_SELF']).'/'.$url : $url; } ?> frontaccount/includes/references.inc0000644000175000017500000000611311321036147017612 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/db/references_db.inc"); class references { function save($type, $id, $reference) { add_reference($type, $id, $reference); if ($reference != 'auto') $this->save_last($reference, $type); } function get($type, $id) { return get_reference($type, $id); } function delete($type, $id) { delete_reference($type, $id); } function update($type, $id, $reference) { update_reference($type, $id, $reference); if ($reference != 'auto') $this->save_last($reference, $type); } function exists($type, $reference) { return (find_reference($type, $reference) != null); } function save_last($reference, $type) { $next = $this->increment($reference); save_next_reference($type, $next); } function get_next($type) { return get_next_reference($type); } //------------------------------------ function is_valid($reference) { return strlen(trim($reference)) > 0; } function increment($reference) { // New method done by Pete. So f.i. WA036 will increment to WA037 and so on. // If $reference contains at least one group of digits, // extract first didgits group and add 1, then put all together. // NB. preg_match returns 1 if the regex matches completely // also $result[0] holds entire string, 1 the first captured, 2 the 2nd etc. // if (preg_match('/^(\D*?)(\d+)(.*)/', $reference, $result) == 1) { list($all, $prefix, $number, $postfix) = $result; $dig_count = strlen($number); // How many digits? eg. 0003 = 4 $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes $nextval = sprintf($fmt, intval($number + 1)); // Add one on, and put prefix back on return $prefix.$nextval.$postfix; } else return $reference; } //------------------------------------ } //---------------------------------------------------------------------------- function is_new_reference($ref, $type) { $db_info = get_systype_db_info($type); $db_name = $db_info[0]; $db_type = $db_info[1]; $db_ref = $db_info[3]; if ($db_ref != null) { $sql = "SELECT $db_ref FROM $db_name WHERE $db_ref='$ref'"; if ($db_type != null) $sql .= " AND $db_type=$type"; $result = db_query($sql, "could not test for unique reference"); return (db_num_rows($result) == 0); } // it's a type that doesn't use references - shouldn't be calling here, but say yes anyways return true; } ?>frontaccount/includes/data_checks.inc0000644000175000017500000002302211324164600017717 0ustar januszjanusz. ***********************************************************************/ function db_has_customers() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."debtors_master"); } function check_db_has_customers($msg) { global $path_to_root; if (!db_has_customers()) { display_error($msg, true); end_page(); exit; } } function db_has_currencies() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."currencies"); } function check_db_has_currencies($msg) { global $path_to_root; if (!db_has_currencies()) { display_error($msg, true); end_page(); exit; } } function db_has_sales_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."sales_types"); } function check_db_has_sales_types($msg) { global $path_to_root; if (!db_has_sales_types()) { display_error($msg, true); end_page(); exit; } } function db_has_item_tax_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."item_tax_types"); } function check_db_has_item_tax_types($msg) { global $path_to_root; if (!db_has_item_tax_types()) { display_error($msg, true); end_page(); exit; } } function db_has_tax_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_types"); } function check_db_has_tax_types($msg) { global $path_to_root; if (!db_has_tax_types()) { display_error($msg, true); end_page(); exit; } } function db_has_tax_groups() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tax_groups"); } function check_db_has_tax_groups($msg) { global $path_to_root; if (!db_has_tax_groups()) { display_error($msg, true); end_page(); exit; } } function db_has_movement_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."movement_types"); } function check_db_has_movement_types($msg) { global $path_to_root; if (!db_has_movement_types()) { display_error($msg, true); end_page(); exit; } } function db_customer_has_branches($customer_id) { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch " ."WHERE debtor_no='$customer_id'"); } function db_has_customer_branches() { return check_empty_result("SELECT COUNT(*) FROM " .TB_PREF."cust_branch WHERE !inactive"); } function check_db_has_customer_branches($msg) { global $path_to_root; if (!db_has_customer_branches()) { display_error($msg, true); end_page(); exit; } } function db_has_sales_people() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."salesman"); } function check_db_has_sales_people($msg) { global $path_to_root; if (!db_has_sales_people()) { display_error($msg, true); end_page(); exit; } } function db_has_sales_areas() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."areas"); } function check_db_has_sales_areas($msg) { global $path_to_root; if (!db_has_sales_areas()) { display_error($msg, true); end_page(); exit; } } function db_has_shippers() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."shippers"); } function check_db_has_shippers($msg) { global $path_to_root; if (!db_has_shippers()) { display_error($msg, true); end_page(); exit; } } function db_has_open_workorders() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders WHERE closed=0"); } function db_has_workorders() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workorders"); } function check_db_has_workorders($msg) { global $path_to_root; if (!db_has_workorders()) { display_error($msg, true); end_page(); exit; } } function db_has_open_dimensions() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions WHERE closed=0"); } function db_has_dimensions() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."dimensions"); } function check_db_has_dimensions($msg) { global $path_to_root; if (!db_has_dimensions()) { display_error($msg, true); end_page(); exit; } } function db_has_suppliers() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."suppliers"); } function check_db_has_suppliers($msg) { global $path_to_root; if (!db_has_suppliers()) { display_error($msg, true); end_page(); exit; } } function db_has_stock_items() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master"); } function check_db_has_stock_items($msg) { global $path_to_root; if (!db_has_stock_items()) { display_error($msg, true); end_page(); exit; } } function db_has_bom_stock_items() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag='M'"); } function check_db_has_bom_stock_items($msg) { global $path_to_root; if (!db_has_bom_stock_items()) { display_error($msg, true); end_page(); exit; } } function db_has_manufacturable_items() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M')"); } function check_db_has_manufacturable_items($msg) { global $path_to_root; if (!db_has_manufacturable_items()) { display_error($msg, true); end_page(); exit; } } function db_has_purchasable_items() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='M'"); } function check_db_has_purchasable_items($msg) { global $path_to_root; if (!db_has_purchasable_items()) { display_error($msg, true); end_page(); exit; } } function db_has_costable_items() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='D'"); } function check_db_has_costable_items($msg) { global $path_to_root; if (!db_has_costable_items()) { display_error($msg, true); end_page(); exit; } } function db_has_stock_categories() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_category"); } function check_db_has_stock_categories($msg) { global $path_to_root; if (!db_has_stock_categories()) { display_error($msg, true); end_page(); exit; } } function db_has_workcentres() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."workcentres"); } function check_db_has_workcentres($msg) { global $path_to_root; if (!db_has_workcentres()) { display_error($msg, true); end_page(); exit; } } function db_has_locations() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."locations"); } function check_db_has_locations($msg) { global $path_to_root; if (!db_has_locations()) { display_error($msg, true); end_page(); exit; } } function db_has_bank_accounts() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_accounts"); } function check_db_has_bank_accounts($msg) { global $path_to_root; if (!db_has_bank_accounts()) { display_error($msg, true); end_page(); exit; } } function db_has_cash_accounts() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."bank_accounts WHERE account_type=3"); } function db_has_gl_accounts() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_master"); } function db_has_gl_account_groups() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."chart_types"); } function check_db_has_gl_account_groups($msg) { global $path_to_root; if (!db_has_gl_account_groups()) { display_error($msg, true); end_page(); exit; } } function db_has_quick_entries() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries"); } function db_has_tags($type) { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."tags WHERE type=$type"); } function check_db_has_tags($type, $msg) { global $path_to_root; if (!db_has_tags($type)) { display_error($msg, true); end_page(); exit; } } function check_empty_result($sql) { $result = db_query($sql, "could not do check empty query"); $myrow = db_fetch_row($result); return $myrow[0] > 0; } // // Integer input check // Return 1 if number has proper form and is within range // function check_int($postname, $min=null, $max=null) { if(!isset($_POST[$postname])) return 0; $num = input_num($postname); if(!is_int($num)) return 0; if (isset($min) && ($num<$min)) return 0; if (isset($max) && ($num>$max)) return 0; return 1; } // // Numeric input check. // Return 1 if number has proper form and is within range // Empty/not defined fields are defaulted to $dflt value. // function check_num($postname, $min=null, $max=null, $dflt=0) { if(!isset($_POST[$postname])) return 0; $num = input_num($postname, $dflt); if ($num === false || $num === null) return 0; if (isset($min) && ($num<$min)) return 0; if (isset($max) && ($num>$max)) return 0; return 1; } ?>frontaccount/includes/db/0000755000175000017500000000000011404426500015360 5ustar januszjanuszfrontaccount/includes/db/comments_db.inc0000644000175000017500000000452011301263000020334 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------------------------------------------------------- function get_comments($type, $type_no) { $sql = "SELECT * FROM ".TB_PREF."comments WHERE type=" .db_escape($type)." AND id=".db_escape($type_no); return db_query($sql, "could not query comments transaction table"); } //-------------------------------------------------------------------------------------------------- function add_comments($type, $type_no, $date_, $memo_) { if ($memo_ != null && $memo_ != "") { $date = date2sql($date_); $sql = "INSERT INTO ".TB_PREF."comments (type, id, date_, memo_) VALUES (".db_escape($type).", ".db_escape($type_no) .", '$date', ".db_escape($memo_).")"; db_query($sql, "could not add comments transaction entry"); } } //-------------------------------------------------------------------------------------------------- function update_comments($type, $id, $date_, $memo_) { if ($date_ == null) { delete_comments($type, $id); add_comments($type, $id, Today(), $memo_); } else { $date = date2sql($date_); $sql = "UPDATE ".TB_PREF."comments SET memo_=".db_escape($memo_) ." WHERE type=".db_escape($type)." AND id=".db_escape($id) ." AND date_='$date'"; db_query($sql, "could not update comments"); } } //-------------------------------------------------------------------------------------------------- function delete_comments($type, $type_no) { $sql = "DELETE FROM ".TB_PREF."comments WHERE type=".db_escape($type) ." AND id=".db_escape($type_no); db_query($sql, "could not delete from comments transaction table"); } //-------------------------------------------------------------------------------------------------- ?>frontaccount/includes/db/index.php0000644000175000017500000000005310607534213017203 0ustar januszjanusz frontaccount/includes/db/sql_functions.inc0000644000175000017500000000254611301263000020737 0ustar januszjanusz. ***********************************************************************/ // // General database functions common for all modules. // //------------------------------------------------------------------- function begin_transaction() { db_query("BEGIN", "could not start a transaction"); } function commit_transaction() { db_query("COMMIT", "could not commit a transaction"); } function cancel_transaction() { db_query("ROLLBACK", "could not cancel a transaction"); } //----------------------------------------------------------------------------- // Update record activity status. // function update_record_status($id, $status, $table, $key) { $sql = "UPDATE ".TB_PREF.$table." SET inactive = " . db_escape($status)." WHERE $key=".db_escape($id); db_query($sql, "Can't update record status"); } ?> frontaccount/includes/db/manufacturing_db.inc0000644000175000017500000002061511334544506021400 0ustar januszjanusz. ***********************************************************************/ //---------------------------------------------------------------------------------------- function get_demand_qty($stock_id, $location) { $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - " .TB_PREF."sales_order_details.qty_sent) AS QtyDemand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders WHERE ".TB_PREF."sales_order_details.order_no=" .TB_PREF."sales_orders.order_no AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." AND ".TB_PREF."sales_orders.trans_type=".TB_PREF."sales_order_details.trans_type AND "; if ($location != "") $sql .= TB_PREF."sales_orders.from_stk_loc =".db_escape($location)." AND "; $sql .= TB_PREF."sales_order_details.stk_code = ".db_escape($stock_id); $result = db_query($sql,"No transactions were returned"); $row = db_fetch($result); if ($row === false) return 0; return $row['QtyDemand']; } $bom_list = array(); $qoh_stock = NULL; function load_stock_levels($location) { global $qoh_stock; $date = date2sql(Today()); $sql = "SELECT stock_id, SUM(qty) FROM ".TB_PREF."stock_moves WHERE tran_date <= '$date'"; if ($location != '') $sql .= " AND loc_code = ".db_escape($location); $sql .= " GROUP BY stock_id"; $result = db_query($sql, "QOH calulcation failed"); while ($row = db_fetch($result)) { $qoh_stock[$row[0]] = $row[1]; } } // recursion fixed by Tom Moulton. Max 10 recursion levels. function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level=0) { global $bom_list, $qoh_stock; $demand = 0.0; if ($level > 10) { display_warning("BOM Too many Manufacturing levels deep $level"); return $demand; } // Load all stock levels (stock moves) into $qoh_stock if ($qoh_stock == NULL) { $qoh_stock = array(); load_stock_levels($location); } $stock_qty = $qoh_stock[$stock_id]; if ($stock_qty == NULL) $stock_qty = 0; if ($qty <= $stock_qty) return $demand; $bom = @$bom_list[$stock_id]; if ($bom == NULL) { $sql = "SELECT parent, component, quantity FROM " .TB_PREF."bom WHERE parent = ".db_escape($stock_id); if ($location != "") $sql .= " AND loc_code = ".db_escape($location); $result = db_query($sql, "Could not search bom"); $bom = array(); // Even if we get no results, remember that fact $bom[] = array($stock_id, '', 0); while ($row = db_fetch_row($result)) { $bom[] = array($row[0], $row[1], $row[2]); } db_free_result($result); $bom_list[$stock_id] = $bom; } $len = count($bom); $i = 0; while ($i < $len) { $row = $bom[$i]; $i++; // Ignore the dummy entry if ($row[1] == '') continue; $q = $qty * $row[2]; if ($row[1] == $demand_id) $demand += $q; $demand += stock_demand_manufacture($row[1], $q, $demand_id, $location, $level+1); } return $demand; } // recursion fixed by Tom Moulton function get_demand_asm_qty($stock_id, $location) { $demand_qty = 0.0; $sql = "SELECT ".TB_PREF."sales_order_details.stk_code, SUM(".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent) AS Demmand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders, ".TB_PREF."stock_master WHERE ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." AND ".TB_PREF."sales_orders.trans_type=".TB_PREF."sales_order_details.trans_type AND "; if ($location != "") $sql .= TB_PREF."sales_orders.from_stk_loc =".db_escape($location)." AND "; $sql .= TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND ".TB_PREF."stock_master.stock_id=".TB_PREF."sales_order_details.stk_code AND (".TB_PREF."stock_master.mb_flag='M' OR ".TB_PREF."stock_master.mb_flag='A') GROUP BY ".TB_PREF."sales_order_details.stk_code"; $result = db_query($sql, "No transactions were returned"); while ($row = db_fetch_row($result)) { $demand_qty += stock_demand_manufacture($row[0], $row[1], $stock_id, $location); } return $demand_qty; } function get_on_porder_qty($stock_id, $location) { $sql = "SELECT SUM(".TB_PREF."purch_order_details.quantity_ordered - " .TB_PREF."purch_order_details.quantity_received) AS qoo FROM ".TB_PREF."purch_order_details INNER JOIN " .TB_PREF."purch_orders ON ".TB_PREF."purch_order_details.order_no=".TB_PREF."purch_orders.order_no WHERE ".TB_PREF."purch_order_details.item_code=".db_escape($stock_id)." "; if ($location != "") $sql .= "AND ".TB_PREF."purch_orders.into_stock_location=".db_escape($location)." "; $sql .= "AND ".TB_PREF."purch_order_details.item_code=".db_escape($stock_id); $qoo_result = db_query($sql,"could not receive quantity on order for item"); if (db_num_rows($qoo_result) == 1) { $qoo_row = db_fetch_row($qoo_result); $qoo = $qoo_row[0]; } else { $qoo = 0; } return $qoo; } function get_on_worder_qty($stock_id, $location) { $sql = "SELECT SUM((".TB_PREF."workorders.units_reqd-".TB_PREF."workorders.units_issued) * (".TB_PREF."wo_requirements.units_req-".TB_PREF."wo_requirements.units_issued)) AS qoo FROM ".TB_PREF."wo_requirements INNER JOIN ".TB_PREF."workorders ON ".TB_PREF."wo_requirements.workorder_id=".TB_PREF."workorders.id WHERE ".TB_PREF."wo_requirements.stock_id=".db_escape($stock_id)." "; if ($location != "") $sql .= "AND ".TB_PREF."wo_requirements.loc_code=".db_escape($location)." "; $sql .= "AND ".TB_PREF."workorders.released=1"; $qoo_result = db_query($sql,"could not receive quantity on order for item"); if (db_num_rows($qoo_result) == 1) { $qoo_row = db_fetch_row($qoo_result); $qoo = $qoo_row[0]; } else $qoo = 0.0; $flag = get_mb_flag($stock_id); if ($flag == 'A' || $flag == 'M') { $sql = "SELECT SUM((".TB_PREF."workorders.units_reqd-".TB_PREF."workorders.units_issued)) AS qoo FROM ".TB_PREF."workorders WHERE ".TB_PREF."workorders.stock_id=".db_escape($stock_id)." "; if ($location != "") $sql .= "AND ".TB_PREF."workorders.loc_code=".db_escape($location)." "; $sql .= "AND ".TB_PREF."workorders.released=1"; $qoo_result = db_query($sql,"could not receive quantity on order for item"); if (db_num_rows($qoo_result) == 1) { $qoo_row = db_fetch_row($qoo_result); $qoo += $qoo_row[0]; } } return $qoo; } function get_mb_flag($stock_id) { $sql = "SELECT mb_flag FROM ".TB_PREF."stock_master WHERE stock_id = " .db_escape($stock_id); $result = db_query($sql, "retreive mb_flag from item"); if (db_num_rows($result) == 0) return -1; $myrow = db_fetch_row($result); return $myrow[0]; } //-------------------------------------------------------------------------------------- function get_bom($item) { $sql = "SELECT ".TB_PREF."bom.*, ".TB_PREF."locations.location_name, ".TB_PREF."workcentres.name AS WorkCentreDescription, ".TB_PREF."stock_master.description, ".TB_PREF."stock_master.mb_flag AS ResourceType, ".TB_PREF."stock_master.material_cost+ ".TB_PREF."stock_master.labour_cost+".TB_PREF."stock_master.overhead_cost AS standard_cost, units, ".TB_PREF."bom.quantity * (".TB_PREF."stock_master.material_cost+ ".TB_PREF."stock_master.labour_cost+ ".TB_PREF."stock_master.overhead_cost) AS ComponentCost FROM (".TB_PREF."workcentres, ".TB_PREF."locations, ".TB_PREF."bom) INNER JOIN ".TB_PREF."stock_master ON ".TB_PREF."bom.component = ".TB_PREF."stock_master.stock_id WHERE ".TB_PREF."bom.parent = ".db_escape($item)." AND ".TB_PREF."workcentres.id=".TB_PREF."bom.workcentre_added AND ".TB_PREF."bom.loc_code = ".TB_PREF."locations.loc_code ORDER BY ".TB_PREF."bom.id"; return db_query($sql, "The bill of material could not be retrieved"); } //-------------------------------------------------------------------------------------- function has_bom($item) { $result = get_bom($item); return (db_num_rows($result) != 0); } //-------------------------------------------------------------------------------------- ?> frontaccount/includes/db/inventory_db.inc0000644000175000017500000002124211334532136020563 0ustar januszjanusz. ***********************************************************************/ function get_qoh_on_date($stock_id, $location=null, $date_=null, $exclude=0) { if ($date_ == null) $date_ = Today(); $date = date2sql($date_); $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id)." AND tran_date <= '$date'"; if ($location != null) $sql .= " AND loc_code = ".db_escape($location); $result = db_query($sql, "QOH calulcation failed"); $myrow = db_fetch_row($result); if ($exclude > 0) { $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id) ." AND type=".db_escape($exclude) ." AND tran_date = '$date'"; $result = db_query($sql, "QOH calulcation failed"); $myrow2 = db_fetch_row($result); if ($myrow2 !== false) $myrow[0] -= $myrow2[0]; } return $myrow[0]; } //-------------------------------------------------------------------------------------- function get_item_edit_info($stock_id) { $sql = "SELECT material_cost + labour_cost + overhead_cost AS standard_cost, units, decimals FROM ".TB_PREF."stock_master,".TB_PREF."item_units WHERE stock_id=".db_escape($stock_id) ." AND ".TB_PREF."stock_master.units=".TB_PREF."item_units.abbr"; $result = db_query($sql, "The standard cost cannot be retrieved"); return db_fetch($result); } //-------------------------------------------------------------------------------------- function get_standard_cost($stock_id) { $sql = "SELECT IF(s.mb_flag='D', 0, material_cost + labour_cost + overhead_cost) AS std_cost FROM ".TB_PREF."stock_master s WHERE stock_id=".db_escape($stock_id); $result = db_query($sql, "The standard cost cannot be retrieved"); $myrow = db_fetch_row($result); return $myrow[0]; } //-------------------------------------------------------------------------------------- function is_inventory_item($stock_id) { $sql = "SELECT stock_id FROM ".TB_PREF."stock_master WHERE stock_id=".db_escape($stock_id)." AND mb_flag <> 'D'"; $result = db_query($sql, "Cannot query is inventory item or not"); return db_num_rows($result) > 0; } //------------------------------------------------------------------- function last_negative_stock_begin_date($stock_id, $to) { $to = date2sql($to); $sql ="SET @q = 0"; db_query($sql); $sql = "SET @flag = 0"; db_query($sql); $sql = "SELECT SUM(qty), @q:= @q + qty, IF(@q < 0 AND @flag=0, @flag:=1,@flag:=0), IF(@q < 0 AND @flag=1, tran_date,'') AS begin_date FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id)." AND tran_date<='$to' AND qty <> 0 GROUP BY stock_id ORDER BY tran_date"; $result = db_query($sql, "The dstock moves could not be retrieved"); $row = db_fetch_row($result); return $row[3]; } //------------------------------------------------------------------- function get_deliveries_between($stock_id, $from, $to) { $from = date2sql($from); $to = date2sql($to); $sql = "SELECT SUM(-qty), SUM(-qty*standard_cost) FROM ".TB_PREF."stock_moves WHERE type=".ST_CUSTDELIVERY." AND stock_id=".db_escape($stock_id)." AND tran_date>='$from' AND tran_date<='$to' GROUP BY stock_id"; $result = db_query($sql, "The deliveries could not be updated"); return db_fetch_row($result); } //------------------------------------------------------------------- function adjust_deliveries($stock_id, $material_cost, $to) { if (!is_inventory_item($stock_id)) return; $from = last_negative_stock_begin_date($stock_id, $to); if ($from == false || $from == "") return; $from = sql2date($from); $row = get_deliveries_between($stock_id, $from, $to); if ($row == false) return; $old_cost = $row[1]; $new_cost = $row[0] * $material_cost; $diff = $new_cost - $old_cost; if ($diff != 0) { $update_no = get_next_trans_no(ST_COSTUPDATE); if (!is_date_in_fiscalyear($to)) $to = end_fiscalyear(); $stock_gl_code = get_stock_gl_code($stock_id); $memo_ = _("Cost was ") . $old_cost . _(" changed to ") . $new_cost . _(" for item ")."'$stock_id'"; add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $to, $stock_gl_code["cogs_account"], $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, $diff); add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $to, $stock_gl_code["inventory_account"], 0, 0, $memo_, -$diff); add_audit_trail(ST_COSTUPDATE, $update_no, $to); } } function get_stock_gl_code($stock_id) { /*Gets the GL Codes relevant to the item account */ $sql = "SELECT inventory_account, cogs_account, adjustment_account, sales_account, assembly_account, dimension_id, dimension2_id FROM ".TB_PREF."stock_master WHERE stock_id = ".db_escape($stock_id); $get = db_query($sql,"retreive stock gl code"); return db_fetch($get); } //-------------------------------------------------------------------------------------- // $date_ - display / non-sql date // $std_cost - in HOME currency // $show_or_hide - wil this move be visible in reports, etc // $price - in $person_id's currency function add_stock_move($type, $stock_id, $trans_no, $location, $date_, $reference, $quantity, $std_cost, $person_id=0, $show_or_hide=1, $price=0, $discount_percent=0, $error_msg="") { // do not add a stock move if it's a non-inventory item if (!is_inventory_item($stock_id)) return null; $date = date2sql($date_); $sql = "INSERT INTO ".TB_PREF."stock_moves (stock_id, trans_no, type, loc_code, tran_date, person_id, reference, qty, standard_cost, visible, price, discount_percent) VALUES (".db_escape($stock_id) .", ".db_escape($trans_no).", ".db_escape($type) .", ".db_escape($location).", '$date', " .db_escape($person_id).", ".db_escape($reference).", " .db_escape($quantity).", ".db_escape($std_cost)."," .db_escape($show_or_hide).", ".db_escape($price).", " .db_escape($discount_percent).")"; if ($error_msg == "") $error_msg = "The stock movement record cannot be inserted"; db_query($sql, $error_msg); return db_insert_id(); } function update_stock_move_pid($type, $stock_id, $from, $to, $pid, $cost) { $from = date2sql($from); $to = date2sql($to); $sql = "UPDATE ".TB_PREF."stock_moves SET standard_cost=".db_escape($cost) ." WHERE type=".db_escape($type) ." AND stock_id=".db_escape($stock_id) ." AND tran_date>='$from' AND tran_date<='$to' AND person_id = ".db_escape($pid); db_query($sql, "The stock movement standard_cost cannot be updated"); } //-------------------------------------------------------------------------------------------------- function get_stock_moves($type, $type_no, $visible=false) { $sql = "SELECT ".TB_PREF."stock_moves.*, ".TB_PREF."stock_master.description, " .TB_PREF."stock_master.units,".TB_PREF."locations.location_name," .TB_PREF."stock_master.material_cost + " .TB_PREF."stock_master.labour_cost + " .TB_PREF."stock_master.overhead_cost AS FixedStandardCost FROM ".TB_PREF."stock_moves,".TB_PREF."locations,".TB_PREF."stock_master WHERE ".TB_PREF."stock_moves.stock_id = ".TB_PREF."stock_master.stock_id AND ".TB_PREF."locations.loc_code=".TB_PREF."stock_moves.loc_code AND type=".db_escape($type)." AND trans_no=".db_escape($type_no)." ORDER BY trans_id"; if ($visible) $sql .= " AND ".TB_PREF."stock_moves.visible=1"; return db_query($sql, "Could not get stock moves"); } //-------------------------------------------------------------------------------------------------- function void_stock_move($type, $type_no) { $sql = "UPDATE ".TB_PREF."stock_moves SET qty=0, price=0, discount_percent=0, standard_cost=0 WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no); db_query($sql, "Could not void stock moves"); } //-------------------------------------------------------------------------------------------------- function get_location_name($loc_code) { $sql = "SELECT location_name FROM ".TB_PREF."locations WHERE loc_code=" .db_escape($loc_code); $result = db_query($sql, "could not retreive the location name for $loc_code"); if (db_num_rows($result) == 1) { $row = db_fetch_row($result); return $row[0]; } display_db_error("could not retreive the location name for $loc_code", $sql, true); } //-------------------------------------------------------------------------------------------------- ?>frontaccount/includes/db/connect_db.inc0000644000175000017500000000665211301263000020150 0ustar januszjanusz. ***********************************************************************/ function set_global_connection() { global $db; $db = $_SESSION["wa_current_user"]->get_db_connection(); } $db_duplicate_error_code = 1062; //DB wrapper functions to change only once for whole application function db_query($sql, $err_msg=null) { global $db, $show_sql, $sql_trail, $select_trail, $go_debug; if ($show_sql) { echo "SQL.."; echo "
";
		echo $sql;
		echo "
\n"; } $result = mysql_query($sql, $db); if($sql_trail) { if ($select_trail || (strstr($sql, 'SELECT') === false)) { mysql_query( "INSERT INTO ".TB_PREF."sql_trail (`sql`, `result`, `msg`) VALUES(".db_escape($sql).",".($result ? 1 : 0).", ".db_escape($err_msg).")", $db); } } if ($err_msg != null || $go_debug) { $exit = $err_msg != null; if (function_exists('xdebug_call_file')) check_db_error('
At file '.xdebug_call_file().':'.xdebug_call_line().':
'.$err_msg, $sql, $exit); else check_db_error($err_msg, $sql, $exit); } return $result; } function db_fetch_row ($result) { return mysql_fetch_row($result); } function db_fetch_assoc ($result) { return mysql_fetch_assoc($result); } function db_fetch ($result) { return mysql_fetch_array($result); } function db_seek (&$result,$record) { return mysql_data_seek($result, $record); } function db_free_result ($result) { if ($result) mysql_free_result($result); } function db_num_rows ($result) { return mysql_num_rows($result); } function db_num_fields ($result) { return mysql_num_fields($result); } function db_escape($value = "", $nullify = false) { $value = @html_entity_decode($value, ENT_QUOTES, $_SESSION['language']->encoding); $value = @htmlspecialchars($value, ENT_QUOTES, $_SESSION['language']->encoding); //reset default if second parameter is skipped $nullify = ($nullify === null) ? (false) : ($nullify); //check for null/unset/empty strings if ((!isset($value)) || (is_null($value)) || ($value === "")) { $value = ($nullify) ? ("NULL") : ("''"); } else { if (is_string($value)) { //value is a string and should be quoted; determine best method based on available extensions if (function_exists('mysql_real_escape_string')) { $value = "'" . mysql_real_escape_string($value) . "'"; } else { $value = "'" . mysql_escape_string($value) . "'"; } } else if (!is_numeric($value)) { //value is not a string nor numeric display_error("ERROR: incorrect data type send to sql query"); echo '

'; exit(); } } return $value; } function db_error_no () { global $db; return mysql_errno($db); } function db_error_msg($conn) { return mysql_error($conn); } function db_insert_id() { global $db; return mysql_insert_id($db); } function db_num_affected_rows() { global $db; return mysql_affected_rows($db); } ?> frontaccount/includes/db/references_db.inc0000644000175000017500000000606011301263000020631 0ustar januszjanusz. ***********************************************************************/ //-------------------------------------------------------------------------------------------------- function get_reference($type, $id) { $sql = "SELECT * FROM ".TB_PREF."refs WHERE type=".db_escape($type)." AND id=".db_escape($id); $result = db_query($sql, "could not query reference table"); $row = db_fetch($result); return $row['reference']; } //-------------------------------------------------------------------------------------------------- function add_reference($type, $id, $reference) { $sql = "INSERT INTO ".TB_PREF."refs (type, id, reference) VALUES (".db_escape($type).", ".db_escape($id).", " . db_escape(trim($reference)) . ")"; db_query($sql, "could not add reference entry"); } //-------------------------------------------------------------------------------------------------- function update_reference($type, $id, $reference) { $sql = "UPDATE ".TB_PREF."refs SET reference=".db_escape($reference) ." WHERE type=".db_escape($type)." AND id=".db_escape($id); db_query($sql, "could not update reference entry"); } //-------------------------------------------------------------------------------------------------- function delete_reference($type, $id) { $sql = "DELETE FROM ".TB_PREF."refs WHERE type=$type AND id=".db_escape($id); return db_query($sql, "could not delete from reference table"); } //-------------------------------------------------------------------------------------------------- function find_reference($type, $reference) { $sql = "SELECT id FROM ".TB_PREF."refs WHERE type=".db_escape($type) ." AND reference=".db_escape($reference); $result = db_query($sql, "could not query reference table"); return (db_num_rows($result) > 0); } //-------------------------------------------------------------------------------------------------- function save_next_reference($type, $reference) { $sql = "UPDATE ".TB_PREF."sys_types SET next_reference=" . db_escape(trim($reference)) . " WHERE type_id = ".db_escape($type); db_query($sql, "The next transaction ref for $type could not be updated"); } //-------------------------------------------------------------------------------------------------- function get_next_reference($type) { $sql = "SELECT next_reference FROM ".TB_PREF."sys_types WHERE type_id = ".db_escape($type); $result = db_query($sql,"The last transaction ref for $type could not be retreived"); $row = db_fetch_row($result); return $row[0]; } ?>frontaccount/includes/db/audit_trail_db.inc0000644000175000017500000001034411301266071021024 0ustar januszjanusz. ***********************************************************************/ function add_audit_trail($trans_type, $trans_no, $trans_date, $descr='') { $sql = "INSERT INTO ".TB_PREF."audit_trail" . " (type, trans_no, user, fiscal_year, gl_date, description, gl_seq) VALUES(".db_escape($trans_type).", ".db_escape($trans_no)."," . $_SESSION["wa_current_user"]->user. "," . get_company_pref('f_year') ."," . "'". date2sql($trans_date) ."'," . db_escape($descr). ", 0)"; db_query($sql, "Cannot add audit info"); // all audit records beside latest one should have gl_seq set to NULL // to avoid need for subqueries (not existing in MySQL 3) all over the code $sql = "UPDATE ".TB_PREF."audit_trail SET gl_seq = NULL" . " WHERE type=".db_escape($trans_type)." AND trans_no=" .db_escape($trans_no)." AND id!=".db_insert_id(); db_query($sql, "Cannot update audit gl_seq"); } function get_audit_trail_all($trans_type, $trans_no) { $sql = "SELECT * FROM ".TB_PREF."audit_trail" ." WHERE type=".db_escape($trans_type)." AND trans_no=" .db_escape($trans_no); return db_query($sql, "Cannot get all audit info for transaction"); } function get_audit_trail_last($trans_type, $trans_no) { $sql = "SELECT * FROM ".TB_PREF."audit_trail" ." WHERE type=".db_escape($trans_type). " AND trans_no=".db_escape($trans_no)." AND NOT ISNULL(gl_seq)"; $res = db_query($sql, "Cannot get last audit info for transaction"); if ($res) $row = db_fetch($res); return $row; } /* Confirm and close for edition all transactions up to date $todate, and reindex journal. */ function close_transactions($todate) { $errors = 0; $sql = "SELECT DISTINCT a.id, a.gl_date, a.fiscal_year" ." FROM ".TB_PREF."gl_trans gl" ." LEFT JOIN ". TB_PREF."audit_trail a ON (gl.type=a.type AND gl.type_no=a.trans_no)" . " WHERE gl_date<='". date2sql($todate) ."'" . " AND NOT ISNULL(gl_seq)" . " ORDER BY a.fiscal_year, a.gl_date, a.id"; $result = db_query($sql, "Cannot select transactions for closing"); if (db_num_rows($result)) { $last_year = 0; while ($row = db_fetch($result)) { if ($row['fiscal_year'] == null) { $errors = 1; continue; } if ($last_year != $row['fiscal_year']) { $last_year = $row['fiscal_year']; $counter = 1; // reset counter on fiscal year change } else $counter++; $sql2 = "UPDATE ".TB_PREF."audit_trail SET" . " gl_seq=$counter" . " WHERE id=".$row['id']; db_query($sql2, "Cannot reindex journal"); } } if ($errors) display_warning(_("Some transactions journal GL postings were not indexed due to lack of audit trail record.")); } /* Reopen all transactions for edition up from date $fromdate */ function open_transactions($fromdate) { $sql = "SELECT a.id, a.gl_date, a.fiscal_year" ." FROM ".TB_PREF."gl_trans gl" ." LEFT JOIN ". TB_PREF."audit_trail a ON (gl.type=a.type AND gl.type_no=a.trans_no)" . " WHERE gl_date>='". date2sql($fromdate) ."'" . " AND !ISNULL(gl_seq)" . " ORDER BY a.fiscal_year, a.gl_date, a.id"; $result = db_query($sql, "Cannot select transactions for openning"); if (db_num_rows($result)) { $last_year = 0; while ($row = db_fetch($result)) { if ($row['fiscal_year'] == null) { continue; } $sql2 = "UPDATE ".TB_PREF."audit_trail SET" . " gl_seq=0" . " WHERE id=".$row['id']; db_query($sql2, "Cannot clear journal order"); } } } /* Closed transactions have gl_seq number assigned. */ function is_closed_trans($type, $trans_no) { $sql = "SELECT gl_seq FROM ".TB_PREF."audit_trail" . " WHERE type=".db_escape($type) ." AND trans_no=".db_escape($trans_no) ." AND gl_seq>0"; $res = db_query($sql, "Cannot check transaction"); return db_num_rows($res); } ?> frontaccount/includes/manufacturing.inc0000644000175000017500000000211411155256063020337 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/db/manufacturing_db.inc"); function is_manufactured($mb_flag) { return ($mb_flag == 'M'); } function is_purchased($mb_flag) { return ($mb_flag == 'B'); } function is_service($mb_flag) { return ($mb_flag == 'D'); } function has_stock_holding($mb_flag) { return is_purchased($mb_flag) || is_manufactured($mb_flag); } //-------------------------------------------------------------------------------------- ?> frontaccount/includes/ui.inc0000644000175000017500000000204511155256063016114 0ustar januszjanusz. ***********************************************************************/ include_once($path_to_root . "/includes/ui/ui_lists.inc"); include_once($path_to_root . "/includes/ui/ui_controls.inc"); include_once($path_to_root . "/includes/ui/ui_input.inc"); include_once($path_to_root . "/includes/ui/ui_msgs.inc"); include_once($path_to_root . "/includes/ui/ui_globals.inc"); include_once($path_to_root . "/includes/ui/ui_view.inc"); include_once($path_to_root . "/includes/data_checks.inc"); ?>frontaccount/includes/access_levels.inc0000644000175000017500000003170011340506311020300 0ustar januszjanusz. ***********************************************************************/ /* Security sections groups various areas on both functionality and privilege levels. Often analytic inquires are available only for management, and configuration for administration or management staff. This is why we have those three section type inside near every FA module. Section codes 0-99 are reserved for core FA functionalities. Every security section can contain up to 256 different areas. External modules can extend security roles system by adding rows to $security_sections and $security_areas using section codes >=100. Security areas and sections created by extension modules/plugins have dynamically assigned 3-byte integer codes. The highest byte is zero for sections/areas defined in this file, and extid+1 for those defined by extensions */ define('SS_SADMIN', 1<<8); // site admin define('SS_SETUP', 2<<8); // company level setup define('SS_SPEC', 3<<8); // special administration define('SS_SALES_C',11<<8); // configuration define('SS_SALES', 12<<8); // transactions define('SS_SALES_A',13<<8); // analytic functions/reports/inquires define('SS_PURCH_C',21<<8); define('SS_PURCH', 22<<8); define('SS_PURCH_A',23<<8); define('SS_ITEMS_C',31<<8); define('SS_ITEMS', 32<<8); define('SS_ITEMS_A',33<<8); define('SS_MANUF_C',41<<8); define('SS_MANUF', 42<<8); define('SS_MANUF_A',43<<8); define('SS_DIM_C', 51<<8); define('SS_DIM', 52<<8); define('SS_DIM_A', 53<<8); define('SS_GL_C', 61<<8); define('SS_GL', 62<<8); define('SS_GL_A', 63<<8); $security_sections = array( SS_SADMIN => _("System administration"), SS_SETUP => _("Company setup"), SS_SPEC => _("Special maintenance"), SS_SALES_C => _("Sales configuration"), SS_SALES => _("Sales transactions"), SS_SALES_A => _("Sales related reports"), SS_PURCH_C => _("Purchase configuration"), SS_PURCH => _("Purchase transactions"), SS_PURCH_A => _("Purchase analytics"), SS_ITEMS_C => _("Inventory configuration"), SS_ITEMS => _("Inventory operations"), SS_ITEMS_A => _("Inventory analytics"), SS_MANUF_C => _("Manufacturing configuration"), SS_MANUF => _("Manufacturing transations"), SS_MANUF_A => _("Manufacturing analytics"), SS_DIM_C => _("Dimensions configuration"), SS_DIM => _("Dimensions"), SS_GL_C => _("Banking & GL configuration"), SS_GL => _("Banking & GL transactions"), SS_GL_A => _("Banking & GL analytics") ); /* This table stores security areas available in FA. Key is area identifier used to check user rights, values are codes stored for each role in security_roles table and description used in roles editor. Set of allowed access areas codes is retrieved during user login from security_roles table, and cached in user profile. Special value 'SA_OPEN' is used for publicly available pages like login/logout. */ $security_areas =array( // // Site administration // 'SA_CREATECOMPANY' =>array(SS_SADMIN|1, _("Install/update companies")), 'SA_CREATELANGUAGE' => array(SS_SADMIN|2, _("Install/update languages")), 'SA_CREATEMODULES' => array(SS_SADMIN|3, _("Install/upgrade modules")), 'SA_SOFTWAREUPGRADE' => array(SS_SADMIN|4, _("Software upgrades")), // // Company setup // 'SA_SETUPCOMPANY' => array(SS_SETUP|1, _("Company parameters")), 'SA_SECROLES' => array(SS_SETUP|2, _("Access levels edition")), 'SA_USERS' => array(SS_SETUP|3, _("Users setup")), 'SA_POSSETUP' => array(SS_SETUP|4, _("Point of sales definitions")), 'SA_PRINTERS' => array(SS_SETUP|5, _("Printers configuration")), 'SA_PRINTPROFILE' => array(SS_SETUP|6, _("Print profiles")), 'SA_PAYTERMS' => array(SS_SETUP|7, _("Payment terms")), 'SA_SHIPPING' => array(SS_SETUP|8, _("Shipping ways")), 'SA_CRSTATUS' => array(SS_SETUP|9, _("Credit status definitions changes")), 'SA_INVENTORYLOCATION' => array(SS_SETUP|10, _("Inventory locations changes")), 'SA_INVENTORYMOVETYPE' => array(SS_SETUP|11, _("Inventory movement types")), 'SA_WORKCENTRES' => array(SS_SETUP|12, _("Manufacture work centres")), 'SA_FORMSETUP' => array(SS_SETUP|13, _("Forms setup")), // // Special and common functions // 'SA_VOIDTRANSACTION' => array(SS_SPEC|1, _("Voiding transactions")), 'SA_BACKUP' => array(SS_SPEC|2, _("Database backup/restore")), 'SA_VIEWPRINTTRANSACTION' => array(SS_SPEC|3, _("Common view/print transactions interface")), 'SA_ATTACHDOCUMENT' => array(SS_SPEC|4, _("Attaching documents")), 'SA_SETUPDISPLAY' => array(SS_SPEC|5, _("Display preferences")), //??? 'SA_CHGPASSWD' => array(SS_SPEC|6, _("Password changes")), //??? // // Sales related functionality // 'SA_SALESTYPES' => array(SS_SALES_C|1, _("Sales types")), 'SA_SALESPRICE' => array(SS_SALES_C|2, _("Sales prices edition")), 'SA_SALESMAN' => array(SS_SALES_C|3, _("Sales staff maintenance")), 'SA_SALESAREA' => array(SS_SALES_C|4, _("Sales areas maintenance")), 'SA_SALESGROUP' => array(SS_SALES_C|5, _("Sales groups changes")), 'SA_STEMPLATE' => array(SS_SALES_C|6, _("Sales templates")), 'SA_SRECURRENT' => array(SS_SALES_C|7, _("Recurrent invoices definitions")), 'SA_SALESTRANSVIEW' => array(SS_SALES|1, _("Sales transactions view")), 'SA_CUSTOMER' => array(SS_SALES|2, _("Sales customer and branches changes")), 'SA_SALESQUOTE' => array(SS_SALES|10, _("Sales quotations")), 'SA_SALESORDER' => array(SS_SALES|3, _("Sales orders edition")), 'SA_SALESDELIVERY' => array(SS_SALES|4, _("Sales deliveries edition")), 'SA_SALESINVOICE' => array(SS_SALES|5, _("Sales invoices edition")), 'SA_SALESCREDITINV' => array(SS_SALES|6, _("Sales credit notes against invoice")), 'SA_SALESCREDIT' => array(SS_SALES|7, _("Sales freehand credit notes")), 'SA_SALESPAYMNT' => array(SS_SALES|8, _("Customer payments entry")), 'SA_SALESALLOC' => array(SS_SALES|9, _("Customer payments allocation")), 'SA_SALESANALYTIC' => array(SS_SALES_A|1, _("Sales analytical reports")), 'SA_SALESBULKREP' => array(SS_SALES_A|2, _("Sales document bulk reports")), 'SA_PRICEREP' => array(SS_SALES_A|3, _("Sales prices listing")), 'SA_SALESMANREP' => array(SS_SALES_A|4, _("Sales staff listing")), 'SA_CUSTBULKREP' => array(SS_SALES_A|5, _("Customer bulk listing")), 'SA_CUSTSTATREP' => array(SS_SALES_A|6, _("Customer status report")), 'SA_CUSTPAYMREP' => array(SS_SALES_A|7, _("Customer payments report")), // // Purchase related functions // 'SA_PURCHASEPRICING' => array(SS_PURCH_C|1, _("Purchase price changes")), 'SA_SUPPTRANSVIEW' => array(SS_PURCH|1, _("Supplier transactions view")), 'SA_SUPPLIER' => array(SS_PURCH|2, _("Suppliers changes")), 'SA_PURCHASEORDER' => array(SS_PURCH|3, _("Purchase order entry")), 'SA_GRN' => array(SS_PURCH|4, _("Purchase receive")), 'SA_SUPPLIERINVOICE' => array(SS_PURCH|5, _("Supplier invoices")), 'SA_GRNDELETE' => array(SS_PURCH|9, _("Deleting GRN items during invoice entry")), 'SA_SUPPLIERCREDIT' => array(SS_PURCH|6, _("Supplier credit notes")), 'SA_SUPPLIERPAYMNT' => array(SS_PURCH|7, _("Supplier payments")), 'SA_SUPPLIERALLOC' => array(SS_PURCH|8, _("Supplier payments allocations")), 'SA_SUPPLIERANALYTIC' => array(SS_PURCH_A|1, _("Supplier analytical reports")), 'SA_SUPPBULKREP' => array(SS_PURCH_A|2, _("Supplier document bulk reports")), 'SA_SUPPPAYMREP' => array(SS_PURCH_A|3, _("Supplier payments report")), // // Inventory // 'SA_ITEM' => array(SS_ITEMS_C|1, _("Stock items add/edit")), 'SA_SALESKIT' => array(SS_ITEMS_C|2, _("Sales kits")), 'SA_ITEMCATEGORY' => array(SS_ITEMS_C|3, _("Item categories")), 'SA_UOM' => array(SS_ITEMS_C|4, _("Units of measure")), 'SA_ITEMSSTATVIEW' => array(SS_ITEMS|1, _("Stock status view")), 'SA_ITEMSTRANSVIEW' => array(SS_ITEMS|2, _("Stock transactions view")), 'SA_FORITEMCODE' => array(SS_ITEMS|3, _("Foreign item codes entry")), 'SA_LOCATIONTRANSFER' => array(SS_ITEMS|4, _("Inventory location transfers")), 'SA_INVENTORYADJUSTMENT' => array(SS_ITEMS|5, _("Inventory adjustments")), 'SA_REORDER' => array(SS_ITEMS_A|1, _("Reorder levels")), 'SA_ITEMSANALYTIC' => array(SS_ITEMS_A|2, _("Items analytical reports and inquiries")), 'SA_ITEMSVALREP' => array(SS_ITEMS_A|3, _("Inventory valuation report")), // // Manufacturing module // 'SA_BOM' => array(SS_MANUF_C|1, _("Bill of Materials")), 'SA_MANUFTRANSVIEW' => array(SS_MANUF|1, _("Manufacturing operations view")), 'SA_WORKORDERENTRY' => array(SS_MANUF|2, _("Work order entry")), 'SA_MANUFISSUE' => array(SS_MANUF|3, _("Material issues entry")), 'SA_MANUFRECEIVE' => array(SS_MANUF|4, _("Final product receive")), 'SA_MANUFRELEASE' => array(SS_MANUF|5, _("Work order releases")), 'SA_WORKORDERANALYTIC' => array(SS_MANUF_A|1, _("Work order analytical reports and inquiries")), 'SA_WORKORDERCOST' => array(SS_MANUF_A|2, _("Manufacturing cost inquiry")), 'SA_MANUFBULKREP' => array(SS_MANUF_A|3, _("Work order bulk reports")), 'SA_BOMREP' => array(SS_MANUF_A|4, _("Bill of materials reports")), // // Dimensions // 'SA_DIMTAGS' => array(SS_DIM_C|1, _("Dimension tags")), 'SA_DIMTRANSVIEW' => array(SS_DIM|1, _("Dimension view")), 'SA_DIMENSION' => array(SS_DIM|2, _("Dimension entry")), 'SA_DIMENSIONREP' => array(SS_DIM|3, _("Dimension reports")), // // Banking and General Ledger // 'SA_ITEMTAXTYPE' => array(SS_GL_C|1, _("Item tax type definitions")), 'SA_GLACCOUNT' => array(SS_GL_C|2, _("GL accounts edition")), 'SA_GLACCOUNTGROUP' => array(SS_GL_C|3, _("GL account groups")), 'SA_GLACCOUNTCLASS' => array(SS_GL_C|4, _("GL account classes")), 'SA_QUICKENTRY' => array(SS_GL_C|5, _("Quick GL entry definitions")), 'SA_CURRENCY' => array(SS_GL_C|6, _("Currencies")), 'SA_BANKACCOUNT' => array(SS_GL_C|7, _("Bank accounts")), 'SA_TAXRATES' => array(SS_GL_C|8, _("Tax rates")), 'SA_TAXGROUPS' => array(SS_GL_C|12, _("Tax groups")), 'SA_FISCALYEARS' => array(SS_GL_C|9, _("Fiscal years maintenance")), 'SA_GLSETUP' => array(SS_GL_C|10, _("Company GL setup")), 'SA_GLACCOUNTTAGS' => array(SS_GL_C|11, _("GL Account tags")), 'SA_BANKTRANSVIEW' => array(SS_GL|1, _("Bank transactions view")), 'SA_GLTRANSVIEW' => array(SS_GL|2, _("GL postings view")), 'SA_EXCHANGERATE' => array(SS_GL|3, _("Exchange rate table changes")), 'SA_PAYMENT' => array(SS_GL|4, _("Bank payments")), 'SA_DEPOSIT' => array(SS_GL|5, _("Bank deposits")), 'SA_BANKTRANSFER' => array(SS_GL|6, _("Bank account transfers")), 'SA_RECONCILE' => array(SS_GL|7, _("Bank reconciliation")), 'SA_JOURNALENTRY' => array(SS_GL|8, _("Manual journal entries")), 'SA_BANKJOURNAL' => array(SS_GL|11, _("Journal entries to bank related accounts")), 'SA_BUDGETENTRY' => array(SS_GL|9, _("Budget edition")), 'SA_STANDARDCOST' => array(SS_GL|10, _("Item standard costs")), 'SA_GLANALYTIC' => array(SS_GL_A|1, _("GL analytical reports and inquiries")), 'SA_TAXREP' => array(SS_GL_A|2, _("Tax reports and inquiries")), 'SA_BANKREP' => array(SS_GL_A|3, _("Bank reports and inquiries")), 'SA_GLREP' => array(SS_GL_A|4, _("GL reports and inquiries")), ); /* This function should be called whenever we want to extend core access level system with new security areas and/or sections i.e.: . on any page with non-standard security areas . in security roles editor The call should be placed between session.inc inclusion and page() call. Up to 155 security sections and 155 security areas for any extension can be installed. */ function add_access_extensions() { global $security_areas, $security_sections, $installed_extensions; foreach($installed_extensions as $extid => $ext) { $scode = 100; $acode = 100; $accext = get_access_extensions($extid); $extsections = $accext[1]; $extareas = $accext[0]; $extcode = $extid<<16; $trans = array(); foreach($extsections as $code =>$name) { $trans[$code] = $scode<<8; // reassign section codes $security_sections[$trans[$code]|$extcode] = $name; $scode++; } foreach($extareas as $code => $area) { $section = $area[0]&0xff00; // extension modules: // if area belongs to nonstandard section // use translated section codes and // preserve lower part of area code if (isset($trans[$section])) { $section = $trans[$section]; } // otherwise assign next available // area code >99 $area[0] = $extcode | $section | ($acode++); $security_areas[$code] = $area; } } } /* Helper function to retrieve extension access definitions in isolated environment. */ function get_access_extensions($id) { global $path_to_root, $installed_extensions; $ext = $installed_extensions[$id]; $security_sections = $security_areas = array(); if (isset($ext['acc_file'])) include($path_to_root.($ext['type'] == 'plugin' ? '/modules/':'/').$ext['path'].'/'.$ext['acc_file']); return array($security_areas, $security_sections); } ?>frontaccount/includes/db_pager.inc0000644000175000017500000003132411314437666017253 0ustar januszjanusz. ***********************************************************************/ // // Controler part of database table pager with column sort. // To display actual html object call display_db_pager($name) inside // any form. // // View definition you will find in the following file: include_once($path_to_root."/includes/ui/db_pager_view.inc"); class db_pager { var $sql; var $name; var $columns; // column definitions (head, type, order) var $marker; // marker check function var $marker_txt; var $marker_class; var $notice_class; var $width; // table width (default '95%') var $header_fun; // additional row between title and body var $header_class; var $footer_fun; var $footer_class; var $data = array(); var $curr_page, $max_page, $last_page, $prev_page, $next_page, $first_page; var $page_len, $rec_count; var $select, $where, $from, $group, $order; var $extra_where; var $ready = false; // this var is false after change in sql before first // and before first query. var $inactive_ctrl = false; var $main_tbl; // table and key field name for inactive ctrl and edit/delete links var $key; // key field name // db_pager constructor // accepts $sql like 'SELECT ...[FROM ...][WHERE ...][GROUP ...][ORDER ...]' // $name is base name for pager controls function db_pager($sql, $name, $table = null, $page_len=0) { global $table_style; $this->width = "95%"; if ($page_len == 0) $page_len = user_query_size(); $this->name = $name; $this->page_len = $page_len; $this->set_sql($sql); } // // Parse base sql select query. // function set_sql($sql) { if ($sql != $this->sql) { $this->sql = $sql; $this->ready = false; $parts = preg_split('/\sORDER\s*BY\s/si', $sql, 2); if(count($parts) == 2) { $sql = $parts[0]; $this->order = $parts[1]; } $parts = preg_split('/\sGROUP\s*BY\s/si', $sql, 2); if(count($parts) == 2) { $sql = $parts[0]; $this->group = $parts[1]; } $parts = preg_split('/\sWHERE\s/si', $sql, 2); if(count($parts) == 2) { $sql = $parts[0]; $this->where = $parts[1]; } $parts = preg_split('/\sFROM\s/si', $sql, 2); if(count($parts) == 2) { $sql = $parts[0]; $this->from = $parts[1]; } $this->select = $sql; } } // // Set additional constraint on record set // function set_where($where = null) { if ($where) { if (!is_array($where)) $where = array($where); if (count($where) == count($this->extra_where) && !count(array_diff($this->extra_where, $where))) return; } $this->extra_where = $where; $this->ready = false; } // // Set query result page // function change_page($page=null) { $this->set_page($page); $this->query(); return true; } // // Change sort column direction // in order asc->desc->none->asc // function sort_table($col) { $ord = $this->columns[$col]['ord']; $ord = ($ord == '') ? 'asc' : (($ord == 'asc') ? 'desc' : ''); $this->columns[$col]['ord'] = $ord; $this->set_page(1); $this->query(); return true; } // // Query database // function query() { global $Ajax; $Ajax->activate("_{$this->name}_span"); $this->data = array(); if (!$this->_init()) return false; if ($this->rec_count == 0) return true; $sql = $this->_sql_gen(false); $result = db_query($sql, 'Error browsing database: '.$sql ); if ($result) { // setting field names for subsequent queries $c = 0; // add result field names to column defs for // col value retrieve and sort purposes $cnt = min(mysql_num_fields($result), count($this->columns)); for ($c = $i = 0; $c < $cnt; $c++) { if (!(isset($this->columns[$c]['insert']) && $this->columns[$c]['insert'])) { // if (!@($this->columns[$c]['type']=='skip')) $this->columns[$c]['name']= mysql_field_name($result, $i); if (!@($this->columns[$c]['type']=='insert')) $i++; } } while ($row = db_fetch_assoc($result)) { $this->data[] = $row; } } else return false; return true; } // // Calculates page numbers for html controls. // function set_page($to) { switch($to) { case 'next': $page = $this->curr_page+1; break; case 'prev': $page = $this->curr_page-1; break; case 'last': $page = $this->last_page; break; default: if (is_numeric($to)) { $page = $to; break; } case 'first': $page = 1; break; } if ($page < 1) $page = 1; $max = $this->max_page; if ($page > $max) $page = $max; $this->curr_page = $page; $this->next_page = ($page < $max) ? $page+1 : null; $this->prev_page = ($page > 1) ? ($page-1) : null; $this->last_page = ($page < $max) ? $max : null; $this->first_page = ($page != 1) ? 1: null; } // // Set column definitions // $flds: array( fldname1, fldname2=>type,...) function set_columns($flds) { $this->columns = array(); if (!is_array($flds)) { $flds = array($flds); } foreach ($flds as $colnum=>$coldef) { if (is_string($colnum)) { // 'colname'=>params $h = $colnum; $c = $coldef; } else { // n=>params if (is_array($coldef)) { $h = ''; $c = $coldef; } else { $h = $coldef; $c = 'text'; } } if (is_string($c)) // params is simple column type $c = array('type'=>$c); if (!isset($c['type'])) $c['type'] = 'text'; switch($c['type']) { case 'inactive': $this->inactive_ctrl = true; case 'insert': default: $c['head'] = $h; break; case 'skip': // skip the column (no header) unset($c['head']); break; } $this->columns[] = $c; } } // // Generate db query from base sql // $count==false - for current page data retrieval // $count==true - for total records count // function _sql_gen($count=false) { $select = $this->select; $from = $this->from; $where = $this->where; $group = $this->group; $order = $this->order; if(count($this->extra_where)) { $where .= ($where=='' ? '' : ' AND ') .implode( $this->extra_where, ' AND '); } if ($where) $where = " WHERE ($where)"; if ($count) { $group = $group == '' ? "*" : "DISTINCT $group"; return "SELECT COUNT($group) FROM $from $where"; } $sql = "$select FROM $from $where"; if ($group) $sql.= " GROUP BY $group"; $ord = array(); foreach ($this->columns as $col) { if (isset($col['ord'])) { if ( $col['ord'] != '' && isset($col['name'])) { $ord[] = $col['name'] .' '. $col['ord']; } } } if (count($ord)) { $sql .= " ORDER BY " . implode($ord, ','); } else { if($order) $sql .= " ORDER BY $order"; // original base query order } $page_len = $this->page_len; $offset = ($this->curr_page - 1) * $page_len; $sql .= " LIMIT $offset, $page_len"; return $sql; } // // Initialization after changing record set // function _init() { global $go_debug; if ($this->ready == false ) { $sql = $this->_sql_gen(true); $result = db_query($sql, 'Error reading record set'); if ($result == false) return false; $row = db_fetch_row($result); $this->rec_count = $row[0]; $this->max_page = $this->page_len ? ceil($this->rec_count/$this->page_len) : 0; if ($go_debug) { // FIX - need column name parsing, but for now: // check if field names are set explicite in col def // for all initially ordered columns foreach ($this->columns as $col) { if (isset($col['ord']) && $col['ord'] != '' && !isset($col['name'])) { display_warning("Result field names must be set for all intially ordered db_pager columns."); } } } $this->set_page(1); $this->ready = true; } return true; } // // Set current page in response to user control. // function select_records() { global $Ajax; $page = find_submit($this->name.'_page_', false); $sort = find_submit($this->name.'_sort_', true); if ($page) { $this->change_page($page); if ($page == 'next' && !$this->next_page || $page == 'last' && !$this->last_page) set_focus($this->name.'_page_prev'); if ($page == 'prev' && !$this->prev_page || $page == 'first' && !$this->first_page) set_focus($this->name.'_page_next'); } elseif ($sort != -1) { $this->sort_table($sort); } else $this->query(); } // // Set check function to mark some rows. // function set_marker($func, $notice='', $markercl='overduebg', $msgclass='overduefg' ) { $this->marker = $func; $this->marker_txt = $notice; $this->marker_class = $markercl; $this->notice_class = $msgclass; } // // Set handler to display additional row between titles and pager body. // Return array of column contents. // function set_header($func, $headercl='inquirybg') { $this->header_fun = $func; $this->header_class = $headercl; } // // Set handler to display additional row between pager body and navibar. // Return array of column contents. // function set_footer($func, $footercl='inquirybg') { $this->footer_fun = $func; $this->footer_class = $footercl; } // // Setter for table editors with inactive cell control. // function set_inactive_ctrl($table, $key) { $this->inactive_ctrl = array('table'=>$table, 'key'=>$key); } // // Helper for display inactive control cells // function inactive_control_cell(&$row) { if ($this->inactive_ctrl) { // return inactive_control_cell($row[$this->inactive_ctrl['key']], // $row['inactive'], $this->inactive_ctrl['table'], // $this->inactive_ctrl['key']); global $Ajax; $key = $this->key ? $this->key : $this->columns[0]['name']; // TODO - support for complex keys $id = $row[$key]; $table = $this->main_tbl; $name = "Inactive". $id; $value = $row['inactive'] ? 1:0; if (check_value('show_inactive')) { if (isset($_POST['LInact'][$id]) && (get_post('_Inactive'.$id.'_update') || get_post('Update')) && (check_value('Inactive'.$id) != $value)) { update_record_status($id, !$value, $table, $key); $value = !$value; } echo ''. checkbox(null, $name, $value, true, '', "align='center'") . hidden("LInact[$id]", $value, false) . ''; } } else return ''; } }; //----------------------------------------------------------------------------- // Creates new db_pager $_SESSION object on first page call. // Retrieves from $_SESSION var on subsequent $_POST calls // // $name - base name for pager controls and $_SESSION object name // $sql - base sql for data inquiry. Order of fields implies // pager columns order. // $coldef - array of column definitions. Example definitions // Column with title 'User name' and default text format: // 'User name' // Skipped field from sql query. Data for the field is not displayed: // 'dummy' => 'skip' // Column without title, data retrieved form row data with function func(): // array('fun'=>'func') // Inserted column with title 'Some', formated with function rowfun(). // formated as date: // 'Some' => array('type'=>'date, 'insert'=>true, 'fun'=>'rowfun') // Column with name 'Another', formatted as date, // sortable with ascending start order (available orders: asc,desc, ''). // 'Another' => array('type'=>'date', 'ord'=>'asc') // // All available column format types you will find in db_pager_view.inc file. // If query result has more fields than count($coldef), rest of data is ignored // during display, but can be used in format handlers for 'spec' and 'insert' // type columns. function &new_db_pager($name, $sql, $coldef, $table = null, $key = null, $page_len = 0) { if (isset($_SESSION[$name]) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SESSION[$name]->sql != $sql)) { 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]->main_tbl = $table; $_SESSION[$name]->key = $key; $_SESSION[$name]->set_sql($sql); $_SESSION[$name]->set_columns($coldef); } return $_SESSION[$name]; } // // Force pager initialization. // function refresh_pager($name) { if (isset($_SESSION[$name])) $_SESSION[$name]->ready = false; } ?>frontaccount/includes/ui/0000755000175000017500000000000011404426503015413 5ustar januszjanuszfrontaccount/includes/ui/ui_controls.inc0000644000175000017500000002716011336507275020466 0ustar januszjanusz. ***********************************************************************/ function get_post($name, $dflt='') { return ((!isset($_POST[$name]) || $_POST[$name] === '') ? $dflt : $_POST[$name]); } //--------------------------------------------------------------------------------- function start_form($multi=false, $dummy=false, $action="", $name="") { // $dummy - leaved for compatibility with 2.0 API if ($name != "") $name = "name='$name'"; if ($action == "") $action = $_SERVER['PHP_SELF']; if ($multi) echo "
\n"; else echo "\n"; } //--------------------------------------------------------------------------------- function end_form($breaks=0) { if ($breaks) br($breaks); echo "\n"; echo "
\n"; } function start_table($extra="", $padding='2', $spacing='0') { echo "
\n"; } function end_table($breaks=0) { echo "
\n"; if ($breaks) br($breaks); } function start_outer_table($extra="", $padding='2', $spacing='0', $br=false) { if ($br) br(); start_table($extra, $padding, $spacing); echo "\n"; // outer table } function table_section($number=1, $width=false) { if ($number > 1) { echo "\n"; $width = ($width ? "width=$width" : ""); //echo "\n"; // outer table echo "\n"; // outer table } echo "\n"; } function end_outer_table($breaks=0, $close_table=true) { if ($close_table) echo "
\n"; echo "\n"; end_table($breaks); } // // outer table spacer // function vertical_space($params='') { echo ""; } function meta_forward($forward_to, $params="") { global $Ajax; echo "\n"; echo "

" . _("You should automatically be forwarded."); echo " " . _("If this does not happen") . " " . "" . _("click here") . " " . _("to continue") . ".

\n"; if ($params !='') $params = '?'.$params; $Ajax->redirect($forward_to.$params); exit; } //----------------------------------------------------------------------------------- // Find and replace hotkey marker. // if $clean == true marker is removed and clean label is returned // (for use in wiki help system), otherwise result is array of label // with underlined hotkey letter and access property string. // function access_string($label, $clean=false) { $access = ''; $slices = array(); if (preg_match('/(.*)&([a-zA-Z0-9])(.*)/', $label, $slices)) { $label = $clean ? $slices[1].$slices[2].$slices[3] : $slices[1].''.$slices[2].''.$slices[3]; $access = " accesskey='".strtoupper($slices[2])."'"; } $label = str_replace( '&&', '&', $label); return $clean ? $label : array($label, $access); } function hyperlink_back($center=true, $no_menu=true) { if ($center) echo "
"; start_table("width=20%"); start_row(); if ($no_menu) echo ""._("Print")."\n"; echo "".($no_menu ? _("Close") : _("Back"))."\n"; end_row(); end_table(); if ($center) echo "
"; echo "
"; } function hyperlink_no_params($target, $label, $center=true) { $id = default_focus(); $pars = access_string($label); if ($target == '') $target = $_SERVER['PHP_SELF']; if ($center) echo "
"; echo "$pars[0]\n"; if ($center) echo "
"; } function hyperlink_no_params_td($target, $label) { echo ""; hyperlink_no_params($target, $label); echo "\n"; } function viewer_link($label, $url='', $class='', $id='', $icon=null) { global $path_to_root; if ($class != '') $class = " class='$class'"; if ($id != '') $class = " id='$id'"; if ($url != "") { $pars = access_string($label); if (user_graphic_links() && $icon) $pars[0] = set_icon($icon, $pars[0]); $preview_str = "$pars[0]"; } else $preview_str = $label; return $preview_str; } function menu_link($url, $label, $id=null) { $id = default_focus($id); $pars = access_string($label); return "$pars[0]"; } function submenu_option($title, $url, $id=null) { global $path_to_root; display_note(menu_link($path_to_root . $url, $title, $id), 0, 1); } function submenu_view($title, $type, $number, $id=null) { display_note(get_trans_view_str($type, $number, $title, false, 'menu_option', $id), 0, 1); } function submenu_print($title, $type, $number, $id=null, $email=0, $extra=0) { display_note(print_document_link($number, $title, true, $type, false, 'menu_option', $id, $email, $extra), 0, 1); } //----------------------------------------------------------------------------------- function hyperlink_params($target, $label, $params, $center=true) { $id = default_focus(); $pars = access_string($label); if ($target == '') $target = $_SERVER['PHP_SELF']; if ($center) echo "
"; echo "$pars[0]\n"; if ($center) echo "
"; } function hyperlink_params_td($target, $label, $params) { echo ""; hyperlink_params($target, $label, $params, false); echo "\n"; } //----------------------------------------------------------------------------------- function hyperlink_params_separate($target, $label, $params, $center=false) { $id = default_focus(); $pars = access_string($label); if ($center) echo "
"; echo "$pars[0]\n"; if ($center) echo "
"; } function hyperlink_params_separate_td($target, $label, $params) { echo ""; hyperlink_params_separate($target, $label, $params); echo "\n"; } //-------------------------------------------------------------------------------------------------- function alt_table_row_color(&$k) { if ($k == 1) { echo "\n"; $k = 0; } else { echo "\n"; $k++; } } function table_section_title($msg, $colspan=2) { echo "$msg\n"; } function table_header($labels, $params='') { start_row(); foreach ($labels as $label) labelheader_cell($label, $params); end_row(); } //----------------------------------------------------------------------------------- function start_row($param="") { if ($param != "") echo "\n"; else echo "\n"; } function end_row() { echo "\n"; } function br($num=1) { for ($i = 0; $i < $num; $i++) echo "
"; } $ajax_divs = array(); function div_start($id='', $trigger=null, $non_ajax=false) { global $ajax_divs; if ($non_ajax) { // div for non-ajax elements array_push($ajax_divs, array($id, null)); echo "