FrontAccounting API Manual
FrontAccounting API Manual
ali syaifudin
API Manual Reference
5/22/2013
When 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
o page
o
end_page
display_error
display_notification
display_heading
display_heading2
display_note
start_form
end_form
start_table
end_table
table_header
start_row
2
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
o
get_js_go_back
get_js_open_window
get_js_date_picker
alert
db_query
db_fetch_row
db_fetch
db_num_rows
db_num_fields
db_insert_id
begin_transaction
commit_transaction
cancel_transaction
Date Functions
o
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
o
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:
$title
The page
title
$no_menu
If true,
no menu
line is
printed.
Set to
true for
popup
windows.
$is_index
If true,
no title
line is
displayed
$onload
If set, the
given
javascript
code is
run on
load.
$js
If set, the
javascript
code is
included
in the
header.
Parameters:
$no_menu
If true,
no power
urls are
printed.
Set to
true for
popup
windows.
$is_index
Not used
at the
moment.
The error
message
string to
be
printed.
$center
If true,
the
message
is
centered.
The
notification
message
string to
be printed.
$center
If 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:
$msg
The
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:
$msg
The
heading
string
to be
printed.
The
10
heading
string to
be
printed.
$br
Number
of break
lines
before
the
message.
$br2
Number
of break
lines
after the
message.
$extra
Extra
values,
style or
class to
be put in
a span.
$sid
$action
$name
function end_form($breaks=0)
11
Number
of
break
lines
inside
the
form
Extra
parameters
ex. style
$padding
The value
of the cell
paddings,
default is 2
$spacing
The 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:
$breaks
Number
12
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:
$labels
An
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:
$param
Parameters
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:
$k
The k
13
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:
$param
function delete_link_cell($param)
Action: Prints a delete link with GET params.
Return value: None
File: /includes/ui/ui_controls.inc
Parameters:
$param
function br($num=1)
Action: Prints break lines, default is 1.
Return value: None
File: /includes/ui/ui_controls.inc
14
Parameters:
$num
Print a
number
of
break
lines,
default
is 1
The URL
that the
user is
forwarded
to.
$params
Optional
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:
$center
The link
is
centered
if value
is true
The
URL-link
$label
The
labelvalue of
the link
$params
The GET
params
to be
added to
the URLlink
$center
If the
link
should
be
centered
(default
true)
The
name
of the
hidden
field.
$value
The
value
of the
hidden
field.
16
The
name of
the
submit
button.
$value
The value
of the
submit
button.
$echo
If this
value is
true the
submit
button is
printed,
otherwise
the HTML
is
returned.
The name
of the
submit
button.
$value
The value
of the
submit
button.
$extra
Parameters
to the TD.
17
The name
of the
submit
button.
$value
The value
of the
submit
button.
$right
If this is
true, an
extra,
empty TD
is printed.
$extra
Parameters
to the TD.
If this is
not null, a
label is
printed in
front of
the
checkbox.
$name
The name
of the
checkbox.
$value
The value
18
of the
checkbox.
$submit_on_change
If this is
true, the
form is
submitted
when
clicking
the
checkbox.
If this is
not null, a
label is
printed in
a TD
before
the
checkbox.
$name
The name
of the
checkbox.
$value
The value
of the
checkbox.
$submit_on_change
If this is
true, the
form is
submitted
when
clicking
the
checkbox.
19
A label is
printed in a
TD.
$params
Parameters
to the TD.
The
amount
to be
printed
in a TD.
$bold
If this
is true,
the
amount
is
printed
in bold.
The
quantity
to be
printed
20
in a TD.
$bold
If this is
true,
the
quantity
is
printed
in bold.
If this is
not null, a
label is
printed in a
TD.
$value
The value
is printed
in a TD.
$params
Parameters
to the label
TD.
$params2
Parameters
to the
value TD.
21
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
$value
If $value is
null and the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$size
If $size is
not empty a
size is set.
$max
If $max is
not empty a
maxlength is
set.
$params
Parameters
to the label
TD.
$post_label
If
$post_label
is not empty
a label is
printed after
the input
box.
$disabled
The value of
$disabled is
printed just
after the
input. Can
be used for
extra
parameters
for the input
box.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
$size
If $size is not
empty a size
is set.
$max
If $max is
not set, the
maxlength is
set to $size.
$init
If $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].
$params
Parameters
to the label
TD.
$post_label
If
$post_label
is not empty
a label is
printed after
the input
box.
23
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
$init
If $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_days
If $init is not
set, you can
add an initial
day value.
Negative
values are
allowed.
$inc_months
If $init is not
set, you can
add an initial
month value.
Negative
values are
allowed.
24
$inc_years
If $init is not
set, you can
add an initial
year value.
Negative
values are
allowed.
$params
Parameters
to the label
TD.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
$init
If $init is
null and the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
Parameters:
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
$init
If $init is
null and the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$params
The
$params to
the $label
TD.
$post_label
The
$post_label
after the
input box.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the input
text box.
26
$init
If $init is
null and the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$params
The
$params to
the $label
TD.
$post_label
The
$post_label
after the
input box.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the textarea
box.
$value
If $value is
null and the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$cols
The width in
27
characters
of the
textarea
box.
$rows
The number
of rows in
the textarea
box.
$params
The
$params to
the $label
TD.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All is
the first
choice.
28
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All is
the first
choice.
$submit_on_chang
e
If true, the
form is
submitted
on change.
29
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$all_option
If true, All is
the first
choice.
$enabled
If true, only
disable_tran
s = 0 are
shown.
$submit_on_chang
e
If true, the
form is
submitted
on change.
30
File: /includes/ui/ui_lists.inc
Parameters:
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All
locations is
the first
choice.
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
31
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
32
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:
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$no_option
If true, an
All
Dimensions
is the first
choise.
$showname
If true, the
dimension
name is
shown.
$showclosed
If true, the
closed
dimensions
are shown
as well.
$showtype
Will only
show the
dimension
type.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All
stock items
is the first
choice.
$submit_on_chang
e
If true, the
form is
submitted
on change.
34
Parameters:
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All
stock bom
items is the
first choice.
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
35
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$all_option
If true, All
stock
manufacture
d items is
the first
choice.
$submit_on_chang
e
If true, the
form is
submitted on
change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
36
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
set.
$all_option
If true, All
stock
purchasable
items is the
first choice.
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
37
$enabled
If true, the
form is
submitted
on change,
else the
listbox is
disabled.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$enabled
If true, the
form is
submitted
on change,
else the
listbox is
disabled.
38
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label is
printed in a
TD.
$name
The name of
the list box.
$selected_id
If $selected_id
is null and the
POST[name] is
not set an
empty value is
39
set, otherwise
the
POST[name]
value is set.
$all_option
If true, All
stock
purchasable
items is the
first choice.
$all_option_nam
e
$submit_on_cha
nge
If true, the
form is
submitted on
change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
] value is
40
set.
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
41
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
43
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
44
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
45
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
46
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$all_option
If true, All is
the first
choice.
47
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:
$label
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$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_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
48
If
$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_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name
of the list
box.
$selected_id
If
$selected_i
d is null
and the
POST[name
] is not set
an empty
value is set,
otherwise
the
49
POST[name
] value is
set.
$skip_bank_account
s
If true, the
bank
accounts
are not
shown.
$show_group
If true, the
bank
account
groups are
shown.
$on_change
If set, the
on_change
value is
printed.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name
] is not set
an empty
value is set,
otherwise
the
POST[name
50
] value is
set.
$name_yes
If set, the
value is
printed, else
'Yes' is
printed.
$name_no
If set, the
value is
printed, else
'No' is
printed.
$submit_on_chang
e
If true, the
form is
submitted
on change.
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
51
If this is not
null, a label
is printed in
a TD.
$name
The name of
the list box.
$selected_id
If
$selected_id
is null and
the
POST[name]
is not set an
empty value
is set,
otherwise
the
POST[name]
value is set.
$from
From value
(included).
$to
To value
(included).
52
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:
$width
The
width of
the
Popup
window.
$height
The
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 Calendar
and 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.
53
Shows
the
message
in a
javascript
alert box.
54
An SQL
statement,
like
SELECT,
INSERT,
UPDATE,
DELETE.
$err_msg
You 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:
$result
The 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.
55
File: /includes/db/connect_db.inc
Parameters:
$result
The 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:
$result
The 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:
$result
The 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.
56
File: /includes/db/connect_db.inc
function begin_transaction
Action: Logs the transactions during a critical operation. Use transactions if you need to
keep several INSERT, DELETE or UPDATE
statements tied together
Return value: None.
File: /includes/db/sql_functions.inc
function commit_transaction
Action: Commits the transactions since begin_transaction. Use transactions if you need to
keep several INSERT, DELETE or UPDATE
statements tied together
Return value: None.
File: /includes/db/sql_functions.inc
function cancel_transaction
Action: Cancels (rolls back) the transactions since begin_transaction. Use transactions if
you need to keep several INSERT, DELETE or UPDATE
statements tied together
Return value: None.
File: /includes/db/sql_functions.inc
57
58
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:
$date
The
formatted
date
59
value to
be
tested.
$convert
You can
test a
nonformatted
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:
$date
The
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
60
Parameters:
$date
The
formatted
date
value.
The
formatted
date
value.
$days
Number
of days to
add.
$days
can be
negative.
The
formatted
date
value.
$months
Number
of
months
to add.
$months
61
can be
negative.
The
formatted
date
value.
$years
Number
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:
$date
The
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:
62
$date
The
formatted
date
value.
The first
formatted
date
value.
$date
2
The
second
formatted
date
value.
63
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:
$number
The
number to
be
formatted.
$decimals
The
number of
decimals.
64
Example Page
<?php
$page_security = 3;
$path_to_root="../..";
include($path_to_root . "/includes/session.inc");
page(_("Sales Persons"));
include($path_to_root . "/includes/ui.inc");
if (isset($_GET['selected_id']))
{
$selected_id = strtoupper($_GET['selected_id']);
}
elseif (isset($_POST['selected_id']))
{
$selected_id = strtoupper($_POST['selected_id']);
}
//----------------------------------------------------------------------------------------------if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM']))
{
//initialise no input errors assumed initially before we test
$input_error = 0;
if (strlen($_POST['salesman_name']) == 0)
{
$input_error = 1;
display_error(_("The sales person name cannot be empty."));
}
if ($input_error != 1)
{
if (isset($selected_id))
{
/*selected_id could also exist if submit had not been clicked
this code would not run in this case cos
submit is false of course see the delete code below*/
$sql = "UPDATE ".TB_PREF."salesman SET salesman_name='" .
$_POST['salesman_name'] . "',
salesman_phone='" . $_POST['salesman_phone'] . "',
salesman_fax='" . $_POST['salesman_fax'] . "',
salesman_email='" . $_POST['salesman_email'] . "'
WHERE salesman_code = '$selected_id'";
}
else
65
}
if (isset($_GET['delete']))
{
//the link to delete a selected record was clicked instead of the
submit button
// PREVENT DELETES IF DEPENDENT RECORDS IN 'debtors_master'
$sql= "SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE
salesman='$selected_id'";
$result = db_query($sql,"check failed");
$myrow = db_fetch_row($result);
if ($myrow[0] > 0)
{
display_error("Cannot delete this sales-person because
branches are set up referring to this sales-person - ".
"first alter the branches concerned.");
}
else
{
$sql="DELETE FROM ".TB_PREF."salesman WHERE
salesman_code='$selected_id'";
db_query($sql,"The sales-person could not be deleted");
meta_forward($_SERVER['PHP_SELF']);
}
hidden('selected_id', $selected_id);
start_table("$table_style2 width=40%");
text_row_ex(_("Sales person name:"), 'salesman_name', 30);
text_row_ex(_("Telephone number:"), 'salesman_phone', 20);
text_row_ex(_("Fax number:"), 'salesman_fax', 20);
text_row_ex(_("Email:"), 'salesman_email', 40);
end_table(1);
submit_add_or_update_center(!isset($selected_id));
end_form();
67
end_page();
?>
68
/report/includes/reporting.inc
Fungsi : menentukan parameter report masing masing modul report
/report/includes/reports_main.php
Fungsi : menambahan report untuk menunjukkan parameter yang digunakan
/report/includes/reports_classes.inc
Menambahkan VAT file : /sales/includes/ui/sales_order_ui.inc, list di deskripsikan di
/includes/ui/ui_list.inc
Penambahan applikasi
Frontaccounting.php
69
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');
.
.
.
function init()
{
//
Includes/access_level.inc
define('SS_SADMIN', 1<<8);
define('SS_SETUP',
2<<8);
define('SS_SPEC',
3<<8);
Includes/systypes.inc
Cart di sediakan di :
Includes/ui/._cart.inc
// site admin
// company level setup
// special administration
Includes/systypes.inc
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");
Includes/types.inc
//
FrontAccounting system transaction types
//
define('ST_JOURNAL', 0);
70
define('ST_BANKPAYMENT', 1);
define('ST_BANKDEPOSIT', 2);
define('ST_BANKTRANSFER', 4);
Includes/sysnames.inc
global $systypes_array, $bank_account_types, $bank_transfer_types,
$payment_person_types, $wo_types_array, $wo_cost_types, $class_types,
$quick_actions, $quick_entry_types, $stock_types, $tag_types;
$systypes_array = array (
ST_JOURNAL => _("Journal Entry"),
ST_BANKPAYMENT => _("Bank Payment"),
71