+ All Categories
Home > Documents > FrontAccounting API Manual 2

FrontAccounting API Manual 2

Date post: 22-Nov-2015
Category:
Upload: mas-gembul
View: 148 times
Download: 2 times
Share this document with a friend
Popular Tags:
133
Front Accounting 5/22/2013 m. ali syaifudin API Manual Reference
Transcript

Front Accounting

FrontAccounting API Manual5Table of Contents5UI Functions9function page($title, $no_menu=false, $is_index=false, $onload="", $js="")9function end_page($no_menu=false, $is_index=false)9function display_error($msg, $center=true)10function display_notification($msg, $center=true)10function display_heading($msg)11function display_heading2($msg)11function display_note($msg, $br=0, $br2=0, $extra="")11function start_form($multi=false, $sid=false, $action="", $name="")12function end_form($breaks=0)12function start_table($extra="", $padding='2', $spacing='0')13function end_table($breaks=0)13function table_header($labels)14function start_row($param="")14function alt_table_row_color(&$k)14function end_row()15function edit_link_cell($param)15function delete_link_cell($param)15function br($num=1)15function meta_forward($forward_to, $params="")16function hyperlink_back($center=true)16function hyperlink_params($target, $label, $params, $center=true)16function hidden($name, $value)17function submit($name, $value, $echo=true)17function submit_cells($name, $value, $extra="")18function submit_row($name, $value, $right=true, $extra="")18function check($label, $name, $value, $submit_on_change=false)19function check_cells($label, $name, $value, $submit_on_change=false)20function check_row($label, $name, $value, $submit_on_change=false)20function label_cell($label, $params="")20function amount_cell($label, $bold=false)21function qty_cell($label, $bold=false)21function label_cells($label, $value, $params="", $params2="")22function label_row($label, $value, $params="", $params2="")22function text_cells($label, $name, $value, $size="", $max="", $params="", $post_label="", $disabled="")22function text_row($label, $name, $value, $size, $max, $params="", $post_label="")22function text_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null)23function text_row_ex($label, $name, $size, $max=null, $value=null, $params=null, $post_label=null)23function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)25function date_row($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)25function percent_row($label, $name, $init=null)26function amount_cells($label, $name, $init=null, $params=null, $post_label=null)26function amount_row($label, $name, $init=null, $params=null, $post_label=null)26function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null)27function textarea_cells($label, $name, $value, $cols, $rows, $params="")28function textarea_row($label, $name, $value, $cols, $rows, $params="")28function supplier_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)29function supplier_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)29function customer_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)30function customer_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)30function customer_branches_list_cells($label, $name, $selected_id, $all_option=false, $enabled=true, $submit_on_change=false)31function customer_branches_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)31function locations_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)32function locations_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)32function currencies_list_cells($label, $name, $selected_id)32function currencies_list_row($label, $name, $selected_id)32function fiscalyears_list_cells($label, $name, $selected_id)33function fiscalyears_list_row($label, $name, $selected_id)33function dimensions_list_cells($label, $name, $selected_id, $no_option=false, $showname=null, $showclosed=false, $showtype=0)34function dimensions_list_row($label, $name, $selected_id, $no_option=false, $showname=null, $showclosed=false, $showtype=0)34function stock_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)35function stock_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)35function stock_bom_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)36function stock_bom_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)36function stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)37function stock_manufactured_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)37function stock_purchasable_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)38function stock_purchasable_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)38function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)38function stock_units_list_row($label, $name, $selected_id, $enabled=true)39function stock_categories_list_cells($label, $name, $selected_id)40function stock_categories_list_row($label, $name, $selected_id)40function tax_type_list_cells($label, $name, $selected_id, $all_option=false, $all_option_name=null, $submit_on_change=false)41function tax_type_list_row($label, $name, $selected_id, $all_option=false, $all_option_name=null, $submit_on_change=false)41function tax_groups_list_cells($label, $name, $selected_id, $submit_on_change=false)41function tax_groups_list_row($label, $name, $selected_id, $submit_on_change=false)41function item_tax_types_list_cells($label, $name, $selected_id)42function item_tax_types_list_row($label, $name, $selected_id)42function shippers_list_cells($label, $name, $selected_id)43function shippers_list_row($label, $name, $selected_id)43function sales_persons_list_cells($label, $name, $selected_id)43function sales_persons_list_row($label, $name, $selected_id)43function sales_areas_list_cells($label, $name, $selected_id)44function sales_areas_list_row($label, $name, $selected_id)44function workorders_list_cells($label, $name, $selected_id)45function workorders_list_row($label, $name, $selected_id)45function payment_terms_list_cells($label, $name, $selected_id)45function payment_terms_list_row($label, $name, $selected_id)45function credit_status_list_cells($label, $name, $selected_id)46function credit_status_list_row($label, $name, $selected_id)46function sales_types_list_cells($label, $name, $selected_id)47function sales_types_list_row($label, $name, $selected_id)47function movements_types_list_cells($label, $name, $selected_id)47function movement_types_list_row($label, $name, $selected_id)47function bank_trans_types_list_cells($label, $name, $selected_id)48function bank_trans_types_list_row($label, $name, $selected_id)48function workcenter_list_cells($label, $name, $selected_id, $all_option=false)48function workcenter_list_row($label, $name, $selected_id, $all_option=false)48function bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change=false)49function bank_accounts_list_row($label, $name, $selected_id, $submit_on_change=false)49function class_list_cells($label, $name, $selected_id, $submit_on_change=false)50function class_list_row($label, $name, $selected_id, $submit_on_change=false)50function gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts=false, $show_group=false, $on_change="")51function gl_all_accounts_list_row($label, $name, $selected_id, $skip_bank_accounts=false, $show_group=false, $on_change="")51function yesno_list_cells($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)52function yesno_list_row($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)52function languages_list_cells($label, $name, $selected_id)53function languages_list_row($label, $name, $selected_id)53function number_list_cells($label, $name, $selected_id, $from, $to)53function number_list_row($label, $name, $selected_id, $from, $to)53Javascript Functions55function get_js_go_back()55function get_js_open_window($width, $height)55function get_js_date_picker()55function alert($msg)55Database Functions (low level)57function db_query($sql, $err_msg)57function db_fetch_row($result)57function db_fetch($result)57function db_num_rows($result)58function db_num_fields($result)58function db_insert_id()58function begin_transaction59function commit_transaction59function cancel_transaction59Database Functions (high level)60Date functions61function is_date($date_)61function today()61function now()61function is_date_in_fiscalyear($date, $convert=false)61function begin_fiscalyear()62function end_fiscalyear()62function begin_month($date)62function end_month($date)62function add_days($date, $days)63function add_months($date, $months)63function add_years($date, $years)64function sql2date($date)64function date2sql($date)64function date1_greater_date2($date1, $date2)65Formatting Functions66function number_format2($number, $decimals=0)66Example Page67

FrontAccounting API ManualCopyright 2007 by JH Global Consulting LLCWhen you are changing something inside FrontAccounting or you are writing an add-on module you typically need an overview over the functions you can use to get your changes/modules to look the same way as FrontAccounting. You will need some database routines, some UI routines when creating forms for adapting data from your user, some routines for displaying the data to the user. You will also need some date conversions functions, amount formatting functions that automatically follow the underlying settings for FrontAccounting.The functions presented here are only a small selection of the functions inside FrontAccounting. They are the most commonly used, however, please have a closer look inside the referenced files. Even for understanding the behavior of the functions it is a good idea to study the routines carefully. Table of Contents UI Functions page end_page display_error display_notification display_heading display_heading2 display_note start_form end_form start_table end_table table_header start_row alt_table_row_color end_row edit_link_cell delete_link_cell br meta_forward hyperlink_back hyperlink_params hidden submit submit_cells submit_row check check_cells check_row label_cell amount_cell qty_cell label_cells label_row text_cells text_cells_ex text_row text_row_ex date_cells date_row percent_row amount_cells amount_row small_amount_cells textarea_cells textarea_row supplier_list_cells supplier_list_row customer_list_cells customer_list_row customer_branches_list_cells customer_branches_list_row locations_list_cells locations_list_row currencies_list_cells currencies_list_row fiscalyears_list_cells fiscalyears_list_row dimensions_list_cells dimensions_list_row stock_items_list_cells stock_items_list_row stock_bom_items_list_cells stock_bom_items_list_row stock_manufactured_items_list_cells stock_manufactured_items_list_row stock_purchasable_items_list_cells stock_purchasable_items_list_row stock_item_types_list_row stock_units_list_row stock_categories_list_cells stock_categories_list_row tax_types_list_cells tax_types_list_row tax_groups_list_cells tax_groups_list_row item_tax_types_list_cells item_tax_types_list_row shippers_list_cells shippers_list_row sales_persons_list_cells sales_persons_list_row sales_areas_list_cells sales_areas_list_row workorders_list_cells workorders_list_row payment_terms_list_cells payment_terms_list_row credit_status_list_cells credit_status_list_row sales_types_list_cells sales_types_list_row movements_types_list_cells movement_types_list_row bank_trans_types_list_cells bank_trans_types_list_row workcenter_list_cells workcenter_list_row bank_accounts_list_cells bank_accounts_list_row class_list_cells class_list_row gl_all_accounts_list_cells gl_all_accounts_list_row yesno_list_cells yesno_list_row languages_list_cells languages_list_row number_list_cells number_list_row Javascript Functions get_js_go_back get_js_open_window get_js_date_picker alert Database Functions (low level) db_query db_fetch_row db_fetch db_num_rows db_num_fields db_insert_id begin_transaction commit_transaction cancel_transaction Database Functions (high level) Date Functions is_date today now is_date_in_fiscalyear begin_fiscalyear end_fiscalyear begin_month end_month add_days add_months add_years sql2date date2sql date1_greater_date2 Formatting Functions number_format2 Example Page

UI Functions

function page($title, $no_menu=false, $is_index=false, $onload="", $js="")Action: Prints the page title and the header of the page.

Return value: None

File: /includes/main.inc

Parameters:$titleThe page title

$no_menuIf true, no menu line is printed. Set to true for popup windows.

$is_indexIf true, no title line is displayed

$onloadIf set, the given javascript code is run on load.

$jsIf set, the javascript code is included in the header.

function end_page($no_menu=false, $is_index=false)Action: Prints the page footer of the page.

Return value: None

File: /includes/main.inc

Parameters:$no_menuIf true, no power urls are printed. Set to true for popup windows.

$is_indexNot used at the moment.

function display_error($msg, $center=true)Action: Prints an error string in bold and with bgcolor #ffcccc, optional centered.

Return value: None

File: /includes/ui/ui_msg.inc

Parameters:$msgThe error message string to be printed.

$centerIf true, the message is centered.

function display_notification($msg, $center=true)Action: Prints a notifications string in bold and with bgcolor #ccffcc, optional centered.

Return value: None

File: /includes/ui/ui_msg.inc

Parameters:$msgThe notification message string to be printed.

$centerIf true, the message is centered.

function display_heading($msg)Action: Prints a centered heading string in bold.

Return value: None

File: /includes/ui/ui_msg.inc

Parameters:$msgThe heading string to be printed.

function display_heading2($msg)Action: Prints a centered alternative heading string in bold.

Return value: None

File: /includes/ui/ui_msg.inc

Parameters:$msgThe heading string to be printed.

function display_note($msg, $br=0, $br2=0, $extra="")Action: Prints a centered note in normal text with optional break lines before and after.

Return value: None

File: /includes/ui/ui_msg.inc

Parameters:$msgThe heading string to be printed.

$brNumber of break lines before the message.

$br2Number of break lines after the message.

$extraExtra values, style or class to be put in a span.

function start_form($multi=false, $sid=false, $action="", $name="")Action: Prints the start of a form.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$multitrue = fields for uploading, false = normal form

$sidtrue = SID (session id) is included in the action, false = nothing is included

$actionThe action URL when submitted. Empty string = $_SERVER['PHP_SELF']

$nameThe name of the form.

function end_form($breaks=0)Action: Prints the end of the form.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$breaksNumber of break lines inside the form

function start_table($extra="", $padding='2', $spacing='0')Action: Prints the start of a centered table.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$extraExtra parameters ex. style

$paddingThe value of the cell paddings, default is 2

$spacingThe value of the cell spacing, default is 2

function end_table($breaks=0)Action: Prints the end of a centered table.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$breaksNumber of break lines after the table

function table_header($labels)Action: Prints the table headers from an array of labels.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$labelsAn array of labels for the table header

function start_row($param="")Action: Prints the start of a table row.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$paramParameters to the table row (tr)

function alt_table_row_color(&$k)Action: Prints the start of a table row and with alternative background colors.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$kThe k value of the row. Set this value to 0 before the loop.

function end_row()Action: Prints the end of a table row.

Return value: None

File: /includes/ui/ui_controls.inc

function edit_link_cell($param)Action: Prints an edit link with GET params.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$paramPrints the GET params that is added to the $_SERVER['PHP_SELF'].

function delete_link_cell($param)Action: Prints a delete link with GET params.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$paramPrints the GET params that is added to the $_SERVER['PHP_SELF'].

function br($num=1)Action: Prints break lines, default is 1.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$numPrint a number of break lines, default is 1

function meta_forward($forward_to, $params="")Action: Prints the HTML for forwarding the user to another URL.

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$forward_toThe URL that the user is forwarded to.

$paramsOptional parameters (GET) added to the URL

function hyperlink_back($center=true)Action: Prints a back link

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$centerThe link is centered if value is true

function hyperlink_params($target, $label, $params, $center=true)Action: Prints a link and a label with GET parameters

Return value: None

File: /includes/ui/ui_controls.inc

Parameters:$targetThe URL-link

$labelThe label-value of the link

$paramsThe GET params to be added to the URL-link

$centerIf the link should be centered (default true)

function hidden($name, $value)Action: Prints an input type hidden with name and value.

Return value: None

File: /includes/ui/ui_input.inc

Parameters:$nameThe name of the hidden field.

$valueThe value of the hidden field.

function submit($name, $value, $echo=true)Action: Prints a submit button or returns a string with name and value and optional printed.

Return value: If $echo is false the entire html string is returned instead.

File: /includes/ui/ui_input.inc

Parameters:$nameThe name of the submit button.

$valueThe value of the submit button.

$echoIf this value is true the submit button is printed, otherwise the HTML is returned.

function submit_cells($name, $value, $extra="")Action: Prints a submit button inside a TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$nameThe name of the submit button.

$valueThe value of the submit button.

$extraParameters to the TD.

function submit_row($name, $value, $right=true, $extra="")Action: Prints a submit button inside a TR-TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$nameThe name of the submit button.

$valueThe value of the submit button.

$rightIf this is true, an extra, empty TD is printed.

$extraParameters to the TD.

function check($label, $name, $value, $submit_on_change=false)Action: Prints a checkbox with an optional label.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in front of the checkbox.

$nameThe name of the checkbox.

$valueThe value of the checkbox.

$submit_on_changeIf this is true, the form is submitted when clicking the checkbox.

function check_cells($label, $name, $value, $submit_on_change=false)function check_row($label, $name, $value, $submit_on_change=false)Action: Prints a checkbox with an optional label inside a TD or TR-TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD before the checkbox.

$nameThe name of the checkbox.

$valueThe value of the checkbox.

$submit_on_changeIf this is true, the form is submitted when clicking the checkbox.

function label_cell($label, $params="")Action: Prints a label (text) inside a TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelA label is printed in a TD.

$paramsParameters to the TD.

function amount_cell($label, $bold=false)Action: Prints a user formatted, right aligned amount inside a TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelThe amount to be printed in a TD.

$boldIf this is true, the amount is printed in bold.

function qty_cell($label, $bold=false)Action: Prints a user formatted, right aligned quantity inside a TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelThe quantity to be printed in a TD.

$boldIf this is true, the quantity is printed in bold.

function label_cells($label, $value, $params="", $params2="")function label_row($label, $value, $params="", $params2="")Action: Prints a value (text) inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$valueThe value is printed in a TD.

$paramsParameters to the label TD.

$params2Parameters to the value TD.

function text_cells($label, $name, $value, $size="", $max="", $params="", $post_label="", $disabled="")function text_row($label, $name, $value, $size, $max, $params="", $post_label="")Action: Prints an input text box inside a TD or TR-TD with an optional label TD and optional post label and optional disabled.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$valueIf $value is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$sizeIf $size is not empty a size is set.

$maxIf $max is not empty a maxlength is set.

$paramsParameters to the label TD.

$post_labelIf $post_label is not empty a label is printed after the input box.

$disabledThe value of $disabled is printed just after the input. Can be used for extra parameters for the input box.

function text_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null)function text_row_ex($label, $name, $size, $max=null, $value=null, $params=null, $post_label=null)Action: Like text_cells, but if $init is not null, the POST[name] is set to $init, otherwise POST[name] is set to an empty string. The value is set to POST[name].

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$sizeIf $size is not empty a size is set.

$maxIf $max is not set, the maxlength is set to $size.

$initIf $init is not set, the POST[name] is set to $init, otherwise POST[name] is set to an empty string. The value is set to POST[name].

$paramsParameters to the label TD.

$post_labelIf $post_label is not empty a label is printed after the input box.

function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)function date_row($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)Action: Like text_cells, but if $init is not null, the POST[name] is set to $init, otherwise POST[name] is set to today's date. The value is set to POST[name]. The date values are user formatted. If the global variable, $use_date_picker, is seta date picker is is placed after the input box, where you can alter the date values.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$initIf $init is not set, the POST[name] is set to $init, otherwise POST[name] is set to today's date. The value is set to POST[name].

$inc_daysIf $init is not set, you can add an initial day value. Negative values are allowed.

$inc_monthsIf $init is not set, you can add an initial month value. Negative values are allowed.

$inc_yearsIf $init is not set, you can add an initial year value. Negative values are allowed.

$paramsParameters to the label TD.

function percent_row($label, $name, $init=null)Action: Prints a percent input text box, with a '%' label after, inside a TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$initIf $init is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function amount_cells($label, $name, $init=null, $params=null, $post_label=null)function amount_row($label, $name, $init=null, $params=null, $post_label=null)Action: Prints an amount input text box (max 15 digits) inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$initIf $init is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$paramsThe $params to the $label TD.

$post_labelThe $post_label after the input box.

function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null)Action: Prints an small amount input text box (max 12 digits) inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the input text box.

$initIf $init is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$paramsThe $params to the $label TD.

$post_labelThe $post_label after the input box.

function textarea_cells($label, $name, $value, $cols, $rows, $params="")function textarea_row($label, $name, $value, $cols, $rows, $params="")Action: Prints a multi line text box inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_input.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the textarea box.

$valueIf $value is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$colsThe width in characters of the textarea box.

$rowsThe number of rows in the textarea box.

$paramsThe $params to the $label TD.

function supplier_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function supplier_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a supplier listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function customer_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function customer_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a customer listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function customer_branches_list_cells($label, $name, $selected_id, $all_option=false, $enabled=true, $submit_on_change=false)function customer_branches_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a customer branch listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All is the first choice.

$enabledIf true, only disable_trans = 0 are shown.

$submit_on_changeIf true, the form is submitted on change.

function locations_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function locations_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a locations listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All locations is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function currencies_list_cells($label, $name, $selected_id)function currencies_list_row($label, $name, $selected_id)Action: Prints a currencies listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function fiscalyears_list_cells($label, $name, $selected_id)function fiscalyears_list_row($label, $name, $selected_id)Action: Prints a fiscal years listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function dimensions_list_cells($label, $name, $selected_id, $no_option=false, $showname=null, $showclosed=false, $showtype=0)function dimensions_list_row($label, $name, $selected_id, $no_option=false, $showname=null, $showclosed=false, $showtype=0)Action: Prints a dimensions listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$no_optionIf true, an All Dimensions is the first choise.

$shownameIf true, the dimension name is shown.

$showclosedIf true, the closed dimensions are shown as well.

$showtypeWill only show the dimension type.

function stock_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function stock_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a stock items listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All stock items is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function stock_bom_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function stock_bom_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a stock bom (bill of material) items listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All stock bom items is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function stock_manufactured_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function stock_manufactured_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a stock manufactured items listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All stock manufactured items is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function stock_purchasable_items_list_cells($label, $name, $selected_id, $all_option=false, $submit_on_change=false)function stock_purchasable_items_list_row($label, $name, $selected_id, $all_option=false, $submit_on_change=false)Action: Prints a stock purchasable items listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All stock purchasable items is the first choice.

$submit_on_changeIf true, the form is submitted on change.

function stock_item_types_list_row($label, $name, $selected_id, $enabled=true)Action: Prints a stock item types listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$enabledIf true, the form is submitted on change, else the listbox is disabled.

function stock_units_list_row($label, $name, $selected_id, $enabled=true)Action: Prints a stock units listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$enabledIf true, the form is submitted on change, else the listbox is disabled.

function stock_categories_list_cells($label, $name, $selected_id)function stock_categories_list_row($label, $name, $selected_id)Action: Prints a stock categories listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function tax_type_list_cells($label, $name, $selected_id, $all_option=false, $all_option_name=null, $submit_on_change=false)function tax_type_list_row($label, $name, $selected_id, $all_option=false, $all_option_name=null, $submit_on_change=false)Action: Prints a tax type listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All stock purchasable items is the first choice.

$all_option_nameIf not null, the $all_option_name is printed.

$submit_on_changeIf true, the form is submitted on change.

function tax_groups_list_cells($label, $name, $selected_id, $submit_on_change=false)function tax_groups_list_row($label, $name, $selected_id, $submit_on_change=false)Action: Prints a tax type listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$submit_on_changeIf true, the form is submitted on change.

function item_tax_types_list_cells($label, $name, $selected_id)function item_tax_types_list_row($label, $name, $selected_id)Action: Prints an item tax types listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function shippers_list_cells($label, $name, $selected_id)function shippers_list_row($label, $name, $selected_id)Action: Prints a shippers listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function sales_persons_list_cells($label, $name, $selected_id)function sales_persons_list_row($label, $name, $selected_id)Action: Prints a sales persons listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function sales_areas_list_cells($label, $name, $selected_id)function sales_areas_list_row($label, $name, $selected_id)Action: Prints a sales areas listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function workorders_list_cells($label, $name, $selected_id)function workorders_list_row($label, $name, $selected_id)Action: Prints a workorders listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function payment_terms_list_cells($label, $name, $selected_id)function payment_terms_list_row($label, $name, $selected_id)Action: Prints a payment terms listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function credit_status_list_cells($label, $name, $selected_id)function credit_status_list_row($label, $name, $selected_id)Action: Prints a credit status listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function sales_types_list_cells($label, $name, $selected_id)function sales_types_list_row($label, $name, $selected_id)Action: Prints a sales types listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function movements_types_list_cells($label, $name, $selected_id)function movement_types_list_row($label, $name, $selected_id)Action: Prints a movements types listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function bank_trans_types_list_cells($label, $name, $selected_id)function bank_trans_types_list_row($label, $name, $selected_id)Action: Prints a bank transaction types listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function workcenter_list_cells($label, $name, $selected_id, $all_option=false)function workcenter_list_row($label, $name, $selected_id, $all_option=false)Action: Prints a workcenter listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$all_optionIf true, All is the first choice.

function bank_accounts_list_cells($label, $name, $selected_id, $submit_on_change=false)function bank_accounts_list_row($label, $name, $selected_id, $submit_on_change=false)Action: Prints a bank accounts listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$submit_on_changeIf true, the form is submitted on change.

function class_list_cells($label, $name, $selected_id, $submit_on_change=false)function class_list_row($label, $name, $selected_id, $submit_on_change=false)Action: Prints an account class listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$submit_on_changeIf true, the form is submitted on change.

function gl_all_accounts_list_cells($label, $name, $selected_id, $skip_bank_accounts=false, $show_group=false, $on_change="")function gl_all_accounts_list_row($label, $name, $selected_id, $skip_bank_accounts=false, $show_group=false, $on_change="")Action: Prints an account class listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$skip_bank_accountsIf true, the bank accounts are not shown.

$show_groupIf true, the bank account groups are shown.

$on_changeIf set, the on_change value is printed.

function yesno_list_cells($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)function yesno_list_row($label, $name, $selected_id, $name_yes="", $name_no="", $submit_on_change=false)Action: Prints a yesno listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$name_yesIf set, the value is printed, else 'Yes' is printed.

$name_noIf set, the value is printed, else 'No' is printed.

$submit_on_changeIf true, the form is submitted on change.

function languages_list_cells($label, $name, $selected_id)function languages_list_row($label, $name, $selected_id)Action: Prints a languages listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

function number_list_cells($label, $name, $selected_id, $from, $to)function number_list_row($label, $name, $selected_id, $from, $to)Action: Prints a numbered listbox inside a TD or TR-TD with an optional label TD.

Return value: None.

File: /includes/ui/ui_lists.inc

Parameters:$labelIf this is not null, a label is printed in a TD.

$nameThe name of the list box.

$selected_idIf $selected_id is null and the POST[name] is not set an empty value is set, otherwise the POST[name] value is set.

$fromFrom value (included).

$toTo value (included).

Javascript Functions

function get_js_go_back()Action: Gets Javascript code for a 'Back' link. Popups are closed, normal windows are going back.

Return value: Javascript code.

File: /includes/ui/ui_view.inc

function get_js_open_window($width, $height)Action: Gets Javascript code for a centered Popup window.

Return value: Javascript code.

File: /includes/ui/ui_view.inc

Parameters:$widthThe width of the Popup window.

$heightThe height of the Popup window.

function get_js_date_picker()Action: Gets Javascript code for a date picker. If the global variable $use_date_picker is set, this code is needed.If the global variable $date_system is set to 0, the Gregorian Calendar is used. A value of 1 will show the Jalali Calendarand a value of 2 will show the Islamic Calendar.

Return value: Javascript code.

File: /includes/ui/ui_view.inc

function alert($msg)Action: Prints Javascript code for an alert popup. Can be used as a debugging feature.

Return value: None.

File: /includes/ui/ui_view.inc

Parameters:$msgShows the message in a javascript alert box.

Database Functions (low level)

function db_query($sql, $err_msg)Action: Send an SQL statement to MySql server.

Return value: A result set.

File: /includes/db/connect_db.inc

Parameters:$sqlAn SQL statement, like SELECT, INSERT, UPDATE, DELETE.

$err_msgYou can supply an error message if the action fails.

function db_fetch_row($result)Action: Fetches the next row array from the result set in db_query.

Return value: A row array that is numeric, i.e. $row[0], $row[1] ans so on.

File: /includes/db/connect_db.inc

Parameters:$resultThe result set returned from db_query.

function db_fetch($result)Action: Fetches the next row array from the result set in db_query.

Return value: A row array that is field based, i.e. $row['id'], $row['name'] ans so on.

File: /includes/db/connect_db.inc

Parameters:$resultThe result set returned from db_query.

function db_num_rows($result)Action: Fetches the number of rows in the result set in db_query.

Return value: A number of rows in the result set.

File: /includes/db/connect_db.inc

Parameters:$resultThe result set returned from db_query.

function db_num_fields($result)Action: Fetches the number of fields in the result set in db_query.

Return value: A number of fields in the result set.

File: /includes/db/connect_db.inc

Parameters:$resultThe result set returned from db_query.

function db_insert_id()Action: Gets the inserted id from the last INSERT INTO statement.

Return value: The inserted id value.

File: /includes/db/connect_db.inc

function begin_transactionAction: Logs the transactions during a critical operation. Use transactions if you need to keep several INSERT, DELETE or UPDATEstatements tied together

Return value: None.

File: /includes/db/sql_functions.inc

function commit_transactionAction: Commits the transactions since begin_transaction. Use transactions if you need to keep several INSERT, DELETE or UPDATEstatements tied together

Return value: None.

File: /includes/db/sql_functions.inc

function cancel_transactionAction: Cancels (rolls back) the transactions since begin_transaction. Use transactions if you need to keep several INSERT, DELETE or UPDATEstatements tied together

Return value: None.

File: /includes/db/sql_functions.inc

Database Functions (high level)

Date functions

function is_date($date_)Action: Checks if $date_ is a valid date based on the current formatting.

Return value: True if $date_ is a valid date, otherwise false.

File: /includes/date_functions.inc

Parameters:$date_The formatted date value to be tested.

function today()Action: Returns a formatted date value based on the current setting.

Return value: Returns a formatted date value based on the current setting.

File: /includes/date_functions.inc

function now()Action: Returns a formatted time value based on the current setting.

Return value: Returns a formatted time value based on the current setting.

File: /includes/date_functions.inc

function is_date_in_fiscalyear($date, $convert=false)Action: Checks if $date is inside the current fiscal year.

Return value: True if $date is inside the current fiscal year, otherwise false.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value to be tested.

$convertYou can test a non-formatted SQL value directly if this value is true.

function begin_fiscalyear()Action: Returns the formatted beginning date of the current fiscal year.

Return value: Returns the formatted beginning date of the current fiscal year.

File: /includes/date_functions.inc

function end_fiscalyear()Action: Returns the formatted ending date of the current fiscal year.

Return value: Returns the formatted ending date of the current fiscal year.

File: /includes/date_functions.inc

function begin_month($date)Action: Returns the formatted first day of the month based on the $date value.

Return value: Returns the formatted first day of the month based on the $date value.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

function end_month($date)Action: Returns the formatted last day of the month based on the $date value.

Return value: Returns the formatted last day of the month based on the $date value.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

function add_days($date, $days)Action: Returns the formatted new date after adding $days. $days can be negative.

Return value: Returns the formatted new date after adding $days. $days can be negative.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

$daysNumber of days to add. $days can be negative.

function add_months($date, $months)Action: Returns the formatted new date after adding $months. $months can be negative.

Return value: Returns the formatted new date after adding $months. $months can be negative.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

$monthsNumber of months to add. $months can be negative.

function add_years($date, $years)Action: Returns the formatted new date after adding $years. $years can be negative.

Return value: Returns the formatted new date after adding $years. $years can be negative.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

$yearsNumber of years to add. $years can be negative.

function sql2date($date)Action: Returns the formatted date from the MySql date value YYYY/MM/DD.

Return value: Returns the formatted date from the MySql date value YYYY/MM/DD.

File: /includes/date_functions.inc

Parameters:$dateThe MySql date value.

function date2sql($date)Action: Returns the MySql date value YYYY/MM/DD from the formatted date.

Return value: Returns the MySql date value YYYY/MM/DD from the formatted date.

File: /includes/date_functions.inc

Parameters:$dateThe formatted date value.

function date1_greater_date2($date1, $date2)Action: Returns true if the formatted $date1 value is greater than the formatted $date2 value.

Return value: Returns true if the formatted $date1 value is greater than the formatted $date2 value.

File: /includes/date_functions.inc

Parameters:$date1The first formatted date value.

$date2The second formatted date value.

Formatting Functions

function number_format2($number, $decimals=0)Action: Returns the formatted number value, based on the current user settings.

Return value: Returns the formatted number value, based on the current user settings.

File: /includes/current_user.inc

Parameters:$numberThe number to be formatted.

$decimalsThe number of decimals.

Example Page


Recommended