<?php
# Here we are creating a new invoice.
# The name of the company will be fed to us, so all we have to do is transaction

# Here we define the path to the directory containing our settings
# If you move the settings directory, please make the change in settingspath.inc
include ('settingspath.inc');

# our config file
include("$settingspath/config.inc");

# the function that processes POST variables
include('getpostvars.inc');


# here we send our POST variables off to be processed
$company_id		= getpostvars('company_id', 11);
$day			= getpostvars('day', 2);
$month			= getpostvars('month', 2);
$year			= getpostvars('year', 4);
$today			= getpostvars('today', 5);
# $transaction_id isn't needed unless I'm doing an update session... right?
#$transaction_id	= getpostvars('transaction_id', 11);
#$transaction_date	= getpostvars('transaction_date', 10);
$type_name		= getpostvars('type_name', 20);
$problem		= getpostvars('problem', 4096);
$solution		= getpostvars('solution', 4096);
$technician_id		= getpostvars('technician_id', 12);
$labor_hours		= getpostvars('labor_hours', 16);
$labor_rate		= getpostvars('labor_rate', 16);
# we still aren't using password verification yet
$password		= getpostvars('password', 16);			# shuffle this off to a session variable?
$verified		= getpostvars('verified', 5);
$material_lines		= getpostvars('material_lines', 3);		# this over-writes the initial value set above
$more_material		= getpostvars('more_material', 5);		# set this to add 5 to $lines_of_material


# let's set a couple of other variables
$paid				= 0;


#
# let's set up our database connection
include ("$settingspath/database.inc");

# this is our SQL escaping function
include ('escapesqldata.inc');

#
# the wrapper I wrote to help with database calls
include ('keyvalue.inc');



###############################################################################################
#                                       print header                                          #
###############################################################################################
$title	= 'Create Invoice';
include("$settingspath/header.inc");

###############################################################################################
#                             print the form, or insert the data?                             #
###############################################################################################

if ( ( !($verified == 'true') ) ) {
  # we're still trying to input data, so let's print the form to the user
  include ('createinvoiceform.inc');
} else {
  # we're done with the form, so let's do the DB insert
  include ('createinvoiceinsert.inc');
}

#echo "<P>";
#print_r($_POST);
?>
