
FUNCTION check_if_reserved (w_rese)
This function is used to check if argument given (or part of the argument)
is an SQL reserved word.
Function returns TRUE if argument is reseved word, or FALSE as default.

FUNCTION check_auth_level(a_auth_level)
This function check if logged user has authorization to execute an action.
Allowed authorization levels are:
    LOGON, STAFF_READ, STAFF_WRITE, CUSTOMER_READ, CUSTOMER_WRITE
    INVOICE_READ, INVOICE_WRITE, PRODUCT_READ, PRODUCT_WRITE
If user is allowed to execute action this function returns TRUE. 
Default return code is FALSE.
Authorization level is acquired from   allowed   table.

FUNCTION customer_type_add(w_short_type, w_long_type)
Function is used to add customer type. 
Both arguments are written to   customer_type   table (if specified type
does not exist in table.
New customer type is retrieved from ctype_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION customer_type_update(w_short_type_old, w_short_type, w_long_type)
Function is used to update records in customer_type table if
w_short_type_old record is found in table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION customer_type_delete(w_customer_type, should_delete)
Function is used to delete specified type record from customer_type_table.
Flag should_delete specifies:
   MARK   - sets deleted flag on record
   DELETE - realy delete specified record
   CHECK  - check if deletion is allowed   
Function returns 0 as default, and 1 if an error occoures.

FUNCTION customer_status_add(w_short_status, w_long_status)
Function is used to add customer status records in customer_status table.
Records are added only if specified record does not exist in customer_status
table.
New customer type is retrieved from cs_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION customer_status_update(w_short_status_old, w_short_status, w_long_status)
Function is used to update records in customer_status table if
w_short_status_old record exists in table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION customer_status_delete(w_customer_status, should_delete)
Function is used to delete specified status record from customer status table.
Flag should_delete specifies:
   MARK   - sets deleted flag on record
   DELETE - realy delete specified record
   CHECK  - check if deletion is allowed   
Function returns 0 as default, and 1 if an error occoures.

FUNCTION telephone_add(w_email, telephone_no, fax_no)
Function adds telephone and fax_no into telephone table if specified records
dont already exist. Records primary key is users e-mail.
New telephone_no is retrieved from telephone_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION telephone_update(w_email, w_telephone, w_fax)
Updates telephone and fax numbers for specifed users e-mail.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION telephone_delete(w_status_no, should_delete)
Function is used to delete specified telephone record from telephone table.
Flag should_delete specifies:
   MARK   - sets deleted flag on record
   DELETE - realy delete specified record
   CHECK  - check if deletion is allowed   
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_status_add(status_txt, status_note)
Function is used to add order status records in order_status table.
Records are added only if specified record does not exist in order_status table.
New order_status_no is retrieved from order_status_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_status_update(w_short_status_old, w_short_status, w_long_status)
Function is used to update records in order_status table if
w_short_status_old record exists in table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_status_delete(order_no, should_delete)
Function is used to delete specified status record from order_status table.
Flag should_delete specifies:
   MARK   - sets deleted flag on record
   DELETE - realy delete specified record
   CHECK  - check if deletion is allowed   
Function returns 0 as default, and 1 if an error occoures.

FUNCTION renewal_period_add(renewal_stxt, renewal_txt, renewal_date)
Function is used to add renewal period record in renewal_period table if
specified record does not exist in database.
New renewal_no is retrieved from renewal_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION renewal_period_update(renewal_no, renewal_stxt, renewal_txt)
Function is used to update renewal period record in renewal_period table if
record number is renewal_no.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION renewal_period_delete(delete_no, real_delete)
IF real_delete flag is set to MARK than this fuinction just sests deleted
flag for records whose no is delete_no.
If real_delete flag is set to DELELTE than records whose numbers are equal
to delete_no are realy deleted from database. 
Function returns 0 as default, and 1 if an error occoures.

FUNCTION address_add(w_email, street1, street_2, street_3, city, postcode
                     county, country)
Function adds customer address into address table. Address is added to table
only if customer exists in customer table and if address is unique for
specified customer.
New address_no is retrieved from address_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION address_update(w_email, street1, street_2, street_3, city, postcode
                        county, country)
Function updates address table with specified arguments for specified
customer.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION address_delete(delete_no, should_delete)
Function deletes specified record from address table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_type_add(w_short_type, w_long_type)
Function adds new card type to card_type table if specified type
(w_short_type) does not already exist in database.
New card_type_no is retrieved from ct_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_type_update(w_short_type_old, w_short_type, w_long_type)
Function is used to update card type record in card_type table if
w_short_type_old is matched in card_type table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_type_delete(delete_no, should_delete)
Function deletes specified record from card_type table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_name_add(w_short_name, w_long_name)
Function adds card name to card_name table. Card is added to table only if
specified w_short_name doesn't already exist card_name table.
New card number is retrieved from card_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_name_update(w_short_name_old, w_short_name, w_long_name)
Updates record in card_name table if w_short_name_old is matched.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION card_name_delete(delete_no, should_delete)
Function deletes specified record from card_name table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION payment_type_add(type_short, type_full)
Function adds payment_type to payment_type table if type_short is not
matched in table.
New payment number is retrieved from pt_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION payment_type_update(type_no, type_short, type_full)
Updates record in payment_type table if type_no exists in payment_type table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION payment_type_delete(delete_no, should_delete)
Function deletes specified record from card_name table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION contactinfo_add(status_short, status_full)
Function adds status data to contactinfo table if status specified in
status_short argument does not exist in contactinfo table.
New sequence number is generated in cs_no sequence.
Function returns 0 as default, or 1 if an error occoures.

FUNCTION contactinfo_update(status_no, status_short, status_full)
Updates contactinfo table with specified arguments if status_no is matched
in contactinfo table.
Function returns 0 as default, or 1 if an error occoures.

FUNCTION contactinfo_delete(delete_no, should_delete)
Function deletes specified record from contactinfo table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION last_action()
Updates staff table with current date and time. 
This is used for auto-logoff feature.

FUNCTION user_logon(w_user, w_pass)
Function first check if user is authorized to LOGON.
If user is authorized password is checked and if password matches user is
logged to system.
Users last access to system is updated (last_action function).
Function returns three strings concatenated with ',' (comma)

       w_name  - Users name and second name
       w_lac   - last_Access time
       a_level - Users authorization 

FUNCTION user_logoff(w_snick)
If user is allowed to LOGON, logoff procedure is started.
Function returns time elapsed from users logon.

FUNCTION customer_data_add(w_email, w_status, w_type, w_domain, w_cust_name
                           w_cust_surname, w_organization, w_contact, 
                           w_password, w_discount)
Function adds all customer data fields to customer table if customer with
specified e_mail address already does not exist in table.
Status_no is retrieved from customer_status table.
Type_no is retrieved from customer_type table.
Domain_no is retrieved from domains table.
staff_no is retrieved from staff table.
Sequence is retrieved from customer_no sequence.
Function returns 0 as default, or 1 if an error occoures.

FUNCTION customer_data_update(w_customer_no, w_email, w_status, w_type,
                              w_domain, w_cust_name, w_cust_surname,
                              w_organization, w_contact, w_password,
                              w_discount)
Function updates customers data in customer table if w_customer_no is
matched in table.
Function returns 0 as default, or 1 if an error occoures.

FUNCTION customer_data_delete(w_email, should_delete)
Function is used to delete customer records from customers table.
Allowed should_delete flags:
   MARK    - sets deleted flags on specified customer
   DELETE  - deletes specified records on specified customer
Data is marked/deleted in following tables: customer_card, telephone,
address, customer.
Function returns 0 if action is executed or 1 if an error occoures.

FUNCTION customer_card_add(w_email, w_card_name, w_card_type, w_name
                           w_expire, w_card_number)
Function is used for adding card data for specified customer (w_email).
All card data are added to customer_card table if card does not already exist
in table.
Card type is fetched from  card_type table.
Sequence used is ccard_no.
Function returns 0 as default or 1 if an error occoures.

FUNCTION customer_card_update(w_ccard_no, w_email, w_card_name, w_card_type,
                              w_name, w_expire, w_card_number)
Function updates fields for specified card (w_ccard_no) for specified user
(w_email) in customer card table.
Function returns 0 as default or 1 if an error occoures.

FUNCTION customer_card_delete(w_ccard_no, should_delete)
Function deletes specified record from customer_card table if should_delete
flag is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected.
IF CHECK flag is selected function checks if card is allowed to be deleted.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_data_add(w_domain, w_name, w_short_desc, w_desc)
Function adds product data to products table for specified domain.
Data is added only if w_name is not matched in products table.
Sequence used is product_no.
If everything was done correctly till this moment empty product table
is created.
Function returns 0 as default or 1 if an error occoures.

FUNCTION product_data_update(w_domain, w_name_old, w_name, w_short_desc, w_desc)
Function updates data in products table if w_name_old product exists for
domain w_domain.
Function returns 0 as default or 1 if an error occoures.

FUNCTION product_data_delete(delete_no, should_delete)
Function deletes specified record from products table if should_delete flag
is set to DELETE, or just changes deleted flag to TRUE if MARK flag is
selected. 
Data is marked/deleted in tables  product_description and products.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_column_add(w_product_name, w_index, w_cn, w_type, 
                            w_short_desc, w_desc, w_default, w_range)
Function is used to add columns to product_description. 
All columns have name (w_cn), type (w_type), short and long description,
default value and range.
Only users who have PRODUCT_WRITE authorization can add product_description.
Column names are first checked if they are reserved, and if column names are
not reserved and don't already exist they are added to database.
After this product table is recreated!
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_column_update(w_product_name, w_old_column_name, w_index,
			       w_cn, w_type, w_short_desc, w_desc, w_default, w_range)
Function is used to change product_description if user has PRODUCT_WRITE authority.
If w_old_column_name is found in table, data is updated and product table is
recreated.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_table_recreate(w_product)
This function is called from other functions (product_column_add,
product_column_update and product_column_delete) to create (or recreate)
individual product tables. Data is read from product_description table for
specified product (w_product). String a_output contains SQL CREATE statement
which is used to create product table.
After table creation permissions are given to users on created table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_column_delete(w_product, w_column, should_delete)
Function deletes specified record from product_description table if
should_delete flag is set to DELETE, or just changes deleted flag to TRUE
if MARK flag is selected. 
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_column_swap(w_product_name, w_column_name_1, w_column_name_2)
Function is used to change position indexes on specified columns (e.g. to 
change order of apperance of specified product columns.
Only users with PRODUCT_WRITE authority can execute this function.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_data_add(w_domain, w_name, w_short_desc, w_desc, w_visible,
                          w_visible)
Function used to add general package data. Requires PRODUCT_WRITE authority.
Data is addes to package_definition table. 
New package_id is acqured from package_no sequence.
Function returns 0 as default, and 1 if an error occoures.
 
FUNCTION package_data_update(w_name_old, w_name, w_short_desc, w_desc,
                             w_visible, w_visible)
Function is used to update data in package_definition table. Requires same 
authorization level as package_data_add function (PRODUCT_WRITE).
Package is updated only if w_name_old is matched in package_definition
table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_data_delete(delete_no, should_delete)
Function is used to delete specified package from package_definition table.
Requires PRODUCT_WRITE authority for logged user.
Function deletes data from package_definition table if should_delete flag is 
set to DELETE, or just changes deleted flag to TRUE if MARK flag is selected. 
Function deletes data from tables package_definition and package_consists_of.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_product_add(w_package_name, w_product_name, w_quantity)
Function is used to add individual products to already defined packages.
Requires PRODUCT_WRITE authority.
Function arguments w_product_name and w_quantity are inserted to
package_consists_of table if w_product_name is not matched in table.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_product_update(w_package_name, w_old_product_name, 
                                w_product_name, w_quantity)
Function is used to update products in package_consists_of table.
Requires PRODUCT_WRITE authority for logged user.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_product_delete(w_package_name, w_product_name, should_delete)
Function is used to delete specified product (w_product_name) from 
package (w_package_name).
Product is deleted if should delete is set to DELETE, or just marked as deleted
if should_delete is set to MARK.
If should_delete is set to CHECK function than first checkes if product can
be deleted and dan executes deletion or marking.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION price_add(price, price_once, price_monthly, price_quarterly, 
                   price_yearly, price_biyearly)
Function adds new price data to price table. This data is later referenced
from other tables. Requires PRODUCT_WRITE authority.
New price_id is acquired from price_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION price_update(n_price_no, price, price_once, price_monthly,
                      price_quarterly, price_yearly, price_biyearly)
Function is used to update price data for specified w_price_no.
Requires PRODUCT_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION price_delete(delete_no, should_delete)
Function is used to delete specified price data from database.
Data can be deleted from price table id should_delete flag is set to DELETE,
or just marked as deleted if should_delete is set to MARK.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_price_add(w_product_name, price, price_once, price_monthly,
                           price_quarterly, price_yearly, price_biyearly)
Function adds new price data (calling price_add function) and than adds data
to products table referencing this price.
Requires PRODUCT_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_price_update(w_product_name, n_price_no, price, price_once, price_monthly,
                              price_quarterly, price_yearly, price_biyearly)
Function is used to update price data for specified product w_product_name.
Requires PRODUCT_WRITE authority.
Price position is first read from products table, and than updated using
price_update function.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_price_delete(delete_no, should_delete)
Function is used to delete specified product price data from database.
Data can be deleted from price table if should_delete flag is set to DELETE,
or just marked as deleted if should_delete is set to MARK.
Function deletes/marks data in tables products and price.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_price_add(w_package_name, price, price_once, price_monthly,
                           price_quarterly, price_yearly, price_biyearly)
Function adds new price data (calling price_add function) and than adds data
to package_definiton table referencing this price.
Requires PRODUCT_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_price_update(w_package_name, n_price_no, price, price_once, price_monthly,
                              price_quarterly, price_yearly, price_biyearly)
Function is used to update price data for specified package w_package_name.
Requires PRODUCT_WRITE authority.
Price position is first read from package_definition table, and than updated 
using price_update function.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_price_delete(delete_no, should_delete)
Function is used to delete specified package price data from database.
Data can be deleted from package_definition table if should_delete flag is 
set to DELETE, or just marked as deleted if should_delete is set to MARK.
Function deletes/marks data in tables package_definition and price.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION product_renewal_select(w_product_name, w_renewal_period)
Function adds data about selected renewal period for specified product w_product_name.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION package_renewal_select(w_package_name, w_renewal_period)
Function adds data about selected renewal period for specified package w_package_name.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_data_add(w_email, w_domain, w_status, w_discount,
                        w_description, w_note, w_contact, w_invisible)
Function is used to add general data about order. Orders are added accordig
to logged on users w_email.
Requires INVOICE_WRITE authority.
Next order_id is selected from order_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_data_update(w_order, w_domain, w_status, w_discount,
                           w_description, w_note, w_contact, w_invisible)
Updates specified order (w_order) data according to passed arguments to this
function.
Requires INVOICE_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_data_delete(delete_no, should_delete)
Function is used to delete specified order data (delete_no) from table.
Requires INVOICE_WRITE authority.
According to should_delete flag DELETE/MARK this function DELETES/MARKS data
in tables order_consists_of and orders.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_item_add(w_order_no, w_type, w_data_no, w_quantity, w_price_no)
Function is used to add individual items to specified orders (w_order_no).
Requires INVOICE_WRITE AUTHORITY.
Data is inserted to order_consists_of table.
Function is used to add data to specified order (w_order_no). 
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_item_update(w_order_no, w_type, w_old_data_no, w_data_no,
                           w_quantity, w_price_no)
Function is used to update selected item in order_consists_of table.
Requires INVOICE_WRITE authority.
Function is used to add data to specified order (w_order_no). 
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_item_delete(w_order_no, w_delete_no, w_delete_type,
                           should_delete)
Function is used to delete specified item (w_delete_no) from order (w_order_no)
Requires INVOICE_WRITE authority.
According to should_delete flag DELETE/MARK this function DELETES/MARKS data
in table order_consists_of.
Function is used to add data to specified order (w_order_no). 
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_product_add(w_order_no, w_product_name, w_quantity)
Function is used to add product with name (w_product_name) into order
(w_order_no).
Requires INVOICE_WRITE authority.
Product is added to database using order_item_add function with type
specified as ''product'';
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_product_update(w_order_no, w_old_product_name, w_product_name, w_quantity)
Function updates product_data (w_old_product_no) in specified order
(w_order_no) using order_item_update function with type set to ''product'';
Requires INVOICE_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_product_delete(w_order_no, w_product_name, should_delete)
Function deletes specified product (w_product_name) from order (w_order_no)
using order_item_delete function if product is found in this order.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_package_add(w_order_no, w_package_name, w_quantity)
Function is used to add package with name (w_package_name) into order
(w_order_no).
Requires INVOICE_WRITE authority.
Package is added to database using order_item_add function with type
specified as ''package'';
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_package_update(w_order_no, w_old_package_name, w_package_name, w_quantity)
Function updates package_data (w_old_package_no) in specified order
(w_order_no) using order_item_update function with type set to ''package'';
Requires INVOICE_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_package_delete(w_order_no, w_package_name, should_delete)
Function deletes specified package (w_package_name) from order (w_order_no)
using order_item_delete function if package is found in this order.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION invoice_add(w_invoice_no, w_issue_no, w_amount, w_status, w_renewal, 
                     w_to_print, w_payed, w_payed_date)
Function is used to add general invoice data to database.
Requires INVOICE_WRITE authority for logged user.
Next order number is selected from invoice_no sequence.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION invoice_update(w_invoice_no, w_issue_no, w_amount, w_status, w_renewal,
                        w_to_print, w_payed, w_payed_date)
Function is used to update invoice data for invoice with nuber (w_invoice_no)
Requires INVOICE_WRITE authority for logged user.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION invoice_delete(delete_no, should_delete)
Function is used to delete specified invoice (delete_no).
Requires INVOICE_WRITE authority for logged user.
According to should_delete flag DELETE/MARK this function DELETES/MARKS data.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION order_renewal_select(w_order_name, w_renewal_period)
Function adds data about selected renewal period for specified order w_order_name.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION get_max_renewal(w_order_no)
Function calculates maximal renewal rate for products and packages 
in specified order (w_order_no).
Function returns calculated maximal renewal.

FUNCTION calculate_adequate_price(w_order_no)
Function calculates price for products and packages in specified order
(w_order_no).
Function returns calculated price.

FUNCTION invoice_status_add(w_short_status, w_long_status)
FUNCTION is used to add new invoice status.
Requires INVOICE_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION invoice_status_update(w_short_status_old, w_short_status, w_long_status)
Function is used to update existing invoice_status.
Requires INVOICE_WRITE authority.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION invoice_status_delete(w_status_no, should_delete)
Function is used to delete specified invoice_status.
Status is deleted if should delete is set to DELETE, or just marked as deleted
if should_delete is set to MARK.
If should_delete is set to CHECK function than first checkes if status can
be deleted (if it is not referenced in any invoices).
Function returns 0 as default, and 1 if an error occoures.

FUNCTION staff_add(w_staff_nick, w_password, w_domain, w_name, w_telephone,
                   w_telephone, w_email, w_manager, w_auth_level)
Function requires STAFF_WRITE authority and is used to add new staff members
for specified domain.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION staff_update(w_staff_nick_old, w_staff_nick, w_password, w_domain,
                      w_name, w_telephone, w_telephone, w_email, w_manager, 
                      w_auth_level)
Function requires STAFF_WRITE authority and is used to update existing staff 
member.
Function returns 0 as default, and 1 if an error occoures.

FUNCTION staff_delete(w_staff_nick, should_delete)
Function requires STAFF_WRITE authority and is used to delete selected user
from staff table. 
Function returns 0 as default, and 1 if an error occoures.

