From: Steve Sutton Date: Thu, 10 Nov 2016 16:19:53 +0000 (-0500) Subject: First sources X-Git-Tag: v1.0.0~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=622bc3b6433a17045de2b3a592916fc0177fea7a;p=prog%2Fws0%2FRegistrations_V3.git First sources Initializing git repo for the copy of Registrations_V3 that was on ws0. --- 622bc3b6433a17045de2b3a592916fc0177fea7a diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..ff03bf3 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +#Nothing Here diff --git a/admin/Views/admin.html b/admin/Views/admin.html new file mode 100644 index 0000000..5fde85d --- /dev/null +++ b/admin/Views/admin.html @@ -0,0 +1,33 @@ + + + + {cust_name} Administration + + + + + + + + + +
+ + {application}
+

+ {menu} + +

+
{message}
+

+ + + {body} + +

+

 

+


+
+ + diff --git a/admin/Views/edit_attendees.html b/admin/Views/edit_attendees.html new file mode 100644 index 0000000..ff12af4 --- /dev/null +++ b/admin/Views/edit_attendees.html @@ -0,0 +1,84 @@ + + + Edit {attendeesTermCap} + + +
+

Your request was not submitted. Please check the following items.

+
+
    + +
  • {text}
  • + +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
Reg #: {reg_id}
Date Submittted: {date_entered}
Name: {lname}, {fname}
Status: {status}
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Activity: {regname}
{attendeesTermCap} 
+ +   Delete this {attendeeTerm}: +
 Date of Birth: Parent/Guardian:
 Emergency Contact: Emergency Phone:
 Brief Medical History:
 Alergies/Medications:
+
 
+ +
+ diff --git a/admin/Views/form_edit_test.html b/admin/Views/form_edit_test.html new file mode 100644 index 0000000..548e654 --- /dev/null +++ b/admin/Views/form_edit_test.html @@ -0,0 +1,43 @@ + + + {cust_name} Administration + + + + + + + + + + + + + + +
+
{cust_name}
+ Magic Form Builder
+

+

+ +

The form submission was invalid because:

{problem}

+

+

+ + {form_data} + {magic_form} +

+ * Required fields

+ +

+ +

 

+


+
+ + \ No newline at end of file diff --git a/admin/Views/form_edit_test_result.html b/admin/Views/form_edit_test_result.html new file mode 100644 index 0000000..b8a2491 --- /dev/null +++ b/admin/Views/form_edit_test_result.html @@ -0,0 +1,41 @@ + + + {cust_name} Administration + + + + + + + + + + + + + + +
+
{cust_name}
+ Magic Form Builder
+

+

+

The form submission was invalid because:

{problem}

+

{return_data}{form_data}
+

 

+

Results


{html}

+ + Total value of selected options = {total_value}

+ +


+

 

+ CSV export


{csv}

+

 

+


+
+ + \ No newline at end of file diff --git a/admin/Views/registrations_cc_confirmation.html b/admin/Views/registrations_cc_confirmation.html new file mode 100644 index 0000000..9f30f90 --- /dev/null +++ b/admin/Views/registrations_cc_confirmation.html @@ -0,0 +1,33 @@ + + + + + + + + + +
+ + + + + + + + + + + + + + +
{registrationTermCap}: {checkout_type}
{registrationTermCap} #:  {request_numb}
+ Thank you for your {registrationTerm}.
+ This confirms payment. Please print this page. +
 

{html_summary}
 

{cust_name}
{cust_address}
{cust_city}, {cust_state} {cust_zip}
{cust_phone}
+
+ + + + diff --git a/admin/Views/report_by_activity.html b/admin/Views/report_by_activity.html new file mode 100644 index 0000000..8762d76 --- /dev/null +++ b/admin/Views/report_by_activity.html @@ -0,0 +1,55 @@ + + + + {cust_name} Reports + + + + + + + +
+ {application} - {cust_name} +
+ + + +

[Printable Report]

+

+

+ Send by E-Mail to: +
+

+ + +
+ {date_time} + Report by Activity +
+ + + + + + + + + + +{report_body} + +
+ + + + + + +
Total Activities:{total_activities}Total {attendingTermCap}:{total_attendees}
 
+ + + + + + diff --git a/admin/Views/report_by_activity_Body_Attendee.html b/admin/Views/report_by_activity_Body_Attendee.html new file mode 100644 index 0000000..87b8e8a --- /dev/null +++ b/admin/Views/report_by_activity_Body_Attendee.html @@ -0,0 +1,60 @@ + + + {attendee} + {status_text} + {phone} + {desired_date} + {email} + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + +
   Date of Birth:{dob}Guardian:{guardian}
   Emergency Contact:{emer_contact}Emergency Phone:{emer_phone}
   Medical history:{med_history}
   Allergy Meds:{allergy_med}
+ + + + + + + + + + + + + + + +
 {indent}{title}:  {value}
+ + + + + diff --git a/admin/Views/report_by_activity_Body_Foot.html b/admin/Views/report_by_activity_Body_Foot.html new file mode 100644 index 0000000..1d736ac --- /dev/null +++ b/admin/Views/report_by_activity_Body_Foot.html @@ -0,0 +1,8 @@ + + + + + + +   + diff --git a/admin/Views/report_by_activity_Body_Head.html b/admin/Views/report_by_activity_Body_Head.html new file mode 100644 index 0000000..8b4f432 --- /dev/null +++ b/admin/Views/report_by_activity_Body_Head.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/Views/report_by_attendee_csv.html b/admin/Views/report_by_attendee_csv.html new file mode 100644 index 0000000..e0ee8cd --- /dev/null +++ b/admin/Views/report_by_attendee_csv.html @@ -0,0 +1,3 @@ +"{attendeeTermCap}","Activity","Phone","PayMethod","Status","Desired Date","DOB","Guardian","Contact","Contact Phone","Med History","Allergy Meds","{title}" +{report_body} +"Total {attendeesTermCap}","{total_attendees}" diff --git a/admin/Views/report_by_attendee_csv_Body.html b/admin/Views/report_by_attendee_csv_Body.html new file mode 100644 index 0000000..7d64221 --- /dev/null +++ b/admin/Views/report_by_attendee_csv_Body.html @@ -0,0 +1 @@ +"{attendee}","{activity}","{phone}","{pay_type}","{status_text}","{desired_date}","{dob}","{guardian}","{emer_contact}","{emer_phone}","{med_history}","{allergy_med}","{value}" diff --git a/admin/Views/report_by_registration.html b/admin/Views/report_by_registration.html new file mode 100644 index 0000000..3193ef3 --- /dev/null +++ b/admin/Views/report_by_registration.html @@ -0,0 +1,55 @@ + + + + {cust_name} Reports + + + + + + + +
+ {application} - {cust_name} +
+ + + +

[Printable Report]

+

+
+ Send by E-Mail to: + +

+ + +
+ {date_time} + Report by Requests +
+ +
Activity:{activity}Attending:{numb_attending}Starting:{start_date}Ending:{end_date}
+ + + + + + + + + diff --git a/admin/Views/report_by_activity_csv.html b/admin/Views/report_by_activity_csv.html new file mode 100644 index 0000000..be47a59 --- /dev/null +++ b/admin/Views/report_by_activity_csv.html @@ -0,0 +1,4 @@ +"Activity","Number Attending","Start Date","End Date","{attendeeTermCap}","Pay Type","Status","Phone","Desired Date","E-Mail","DOB","Guardian","Contact","Contact Phone","Med History","Allergy Meds","{title}" +{report_body} +"Total Activities","{total_activities}" +"Total {attendeesTermCap}","{total_attendees}" diff --git a/admin/Views/report_by_activity_csv_Body_Attendee.html b/admin/Views/report_by_activity_csv_Body_Attendee.html new file mode 100644 index 0000000..a4c4361 --- /dev/null +++ b/admin/Views/report_by_activity_csv_Body_Attendee.html @@ -0,0 +1,2 @@ +"","","","","{attendee}","{pay_type}","{status_text}","{phone}","{desired_date}","{email}","{dob}","{guardian}","{emer_contact}","{emer_phone}","{med_history}","{allergy_med}","{value}" + \ No newline at end of file diff --git a/admin/Views/report_by_activity_csv_Body_Head.html b/admin/Views/report_by_activity_csv_Body_Head.html new file mode 100644 index 0000000..7d95a67 --- /dev/null +++ b/admin/Views/report_by_activity_csv_Body_Head.html @@ -0,0 +1,2 @@ + +"{activity}","{numb_attending}","{start_date}","{end_date}","{email}" diff --git a/admin/Views/report_by_attendee.html b/admin/Views/report_by_attendee.html new file mode 100644 index 0000000..5295029 --- /dev/null +++ b/admin/Views/report_by_attendee.html @@ -0,0 +1,50 @@ + + + + {cust_name} Reports + + + + + + + +
+ {application} - {cust_name} +
+ + + +

[Printable Report]

+

+
+ Send by E-Mail to: + +

+ + +
+ {date_time} + Report by {attendeesTermCap} +
+ +
{attendeeTermCap}StatusPhoneDesired DateE-Mail
+ + + + + + +{report_body} +
+ + + + +
Total {attendeesTermCap}:{total_attendees}
 
+ + + + + + diff --git a/admin/Views/report_by_attendee_Body.html b/admin/Views/report_by_attendee_Body.html new file mode 100644 index 0000000..731a0e5 --- /dev/null +++ b/admin/Views/report_by_attendee_Body.html @@ -0,0 +1,100 @@ + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
{attendeeTermCap}:{attendee}
Activity:{activity}
Phone:{phone}
Payment Method:{pay_type}
Status:{status_text}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Desired Date:  {desired_date}
Emergency Info:Required
Date of Birth:{dob}
Guardian:{guardian}
Contact:{emer_contact}
Phone:{emer_phone}
Medical history:{med_history}
Allergy Meds:{allergy_med}
+   +
+ + + + + + + + + + +
 Additional Data
{indent}{title}:  {value}
+
 
+ + + + + + +{report_body} +
+ + + + + + + + + +
Total Registrations:{total_registrations}Total {attendeesTermCap}:{total_attendees}Total Charges:{total_charges}
+
 
+ + + + + diff --git a/admin/Views/report_by_registration_Body.html b/admin/Views/report_by_registration_Body.html new file mode 100644 index 0000000..36c33e9 --- /dev/null +++ b/admin/Views/report_by_registration_Body.html @@ -0,0 +1,260 @@ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Registration ID:  {id}
Date Registered:  {date}
E-Mail Address:  {email}
OK to E-Mail:  {email_ok}
 
Entered By Admin User
Payment Method:  {pay_type}
Status:  {status_text}
Total Charges:  {total_money}
Comp Code Supplied:  {pay_code}
Card Type:  {cc_type}
Name on Card:  {cc_name}
Card Number:  {cc_numb}
Expiration:  {cc_exp}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Billing / Registered by
Name:  {lname}, {fname}
Address:  {addr1}
 {addr2}
 {city}, {state_name} {zip}
 {country_name}
Phone:  {phone}
FAX:  {fax}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{contact_information_title}
{prompt_contact_fname}:  {contact_fname}
{prompt_contact_lname}:  {contact_lname}
{prompt_contact_addr1}:  {contact_addr1}
{prompt_contact_addr2}:  {contact_fname}
 {contact_city}, {contact_state_name} {contact_zip}
{prompt_contact_country} {contact_country_name}
{prompt_contact_phone}:  {contact_phone}
{prompt_contact_fax}:  {contact_fax}
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + {name} + + , + + {name} + + + + {/if:have_med_info}--> + + + + + + + + + + + + + + + +
{eventTermCap}:  {activity}
Desired Date:  {desired_date}
Number {attendingTermCap}:  {numb_attending}
{attendeesTermCap}:   + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{name}
   Date of Birth:  {dob}Parent/Guardian:  {guardian}
 Emergency Contact:  {emer_contact}Emergency Phone:  {emer_phone}
 Brief Medical History:  {med_history}
 Alergies/Medications:  {allergy_med}
+
 Additional Data
{indent}{title}:  {value}
+
+ + +   + + \ No newline at end of file diff --git a/admin/Views/report_by_registration_MF_Data.html b/admin/Views/report_by_registration_MF_Data.html new file mode 100644 index 0000000..e8d6470 --- /dev/null +++ b/admin/Views/report_by_registration_MF_Data.html @@ -0,0 +1,204 @@ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Registration ID:{id}
Date Registered:  {date}
Name:{lname}, {fname}
Address:{addr1}
 {addr2}
 {city}, {state} {zip}
 {country}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
E-Mail Address:{email}
OK to E-Mail:{email_ok}
Phone:{phone}
FAX:{fax}
 
Entered By Admin User
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Payment Method:{pay_type}
Status:{status_text}
Total Charges:{total_money}
Comp Code Supplied:{pay_code}
Card Type:{cc_type}
Name on Card:{cc_name}
Card Number:{cc_numb}
Expiration:{cc_exp}
+
+ + + + + + + + + + + + + + + + + + + + {name} + + , + + {name} + + + + {/if:have_med_info}--> + + + + + + + + + + + + + + + + + +
{eventTermCap}:{activity}
Number {attendingTermCap}:  {numb_attending}
{attendeesTermCap}: + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{name}
   Date of Birth:{dob}Parent/Guardian:{guardian}
 Emergency Contact:{emer_contact}Emergency Phone:{emer_phone}
 Brief Medical History:{med_history}
 Alergies/Medications:{allergy_med}
+
 Additional Data
{indent}{title}:  {txt_val}
+
+ + +   + + \ No newline at end of file diff --git a/admin/Views/report_by_registration_csv.html b/admin/Views/report_by_registration_csv.html new file mode 100644 index 0000000..c7696ed --- /dev/null +++ b/admin/Views/report_by_registration_csv.html @@ -0,0 +1,7 @@ +"ID","Last Name","First Name","Address 1","Address 2","City","State","ZIP","Country","E-Mail","E-Mail OK","Phone","FAX","{prompt_contact_lname}","{prompt_contact_fname}","{prompt_contact_addr1}","{prompt_contact_addr2}","{prompt_contact_city}","{prompt_contact_state}","{prompt_contact_zip}","{prompt_contact_country}","{prompt_contact_phone}","{prompt_contact_fax}","Entered by Admin","Pay Method","Status","Total","Comp Code","Card Type","Name on Card","Card Number","Expiration","Activity","{attendeeTermCap}","DOB","Guardian","Contact","Contact Phone","Med History","Allergy Meds","{title}" + +{report_body} + +"Total Registrations","{total_registrations}" +"Total {attendeesTermCap}","{total_attendees}" +"Total Charges","{total_charges}" diff --git a/admin/Views/report_by_registration_csv_Body.html b/admin/Views/report_by_registration_csv_Body.html new file mode 100644 index 0000000..547eb90 --- /dev/null +++ b/admin/Views/report_by_registration_csv_Body.html @@ -0,0 +1,2 @@ +"{id}","{lname}","{fname}","{addr1}","{addr2}","{city}","{state}","{zip}","{country}","{email}","{email_ok}","{phone}","{fax}","{contact_lname}","{contact_fname}","{contact_addr1}","{contact_addr2}","{contact_city}","{contact_state}","{contact_zip}","{contact_country}","{contact_phone}","{contact_fax}","Yes","{pay_type}","{status_text}","{total_money}","{pay_code}","{cc_type}","{cc_name}","{cc_numb}","{cc_exp}","{activity}","{name}","{dob}","{guardian}","{emer_contact}","{emer_phone}","{med_history}","{allergy_med}","{value}""{contact_lname}","{contact_fname}","{contact_addr1}","{contact_addr2}","{contact_city}","{contact_state}","{contact_zip}","{contact_country}","{contact_phone}","{contact_fax}","Yes","{pay_type}","{status_text}","{total_money}","{pay_code}","{cc_type}","{cc_name}","{cc_numb}","{cc_exp}","{activity}","","{dob}","{guardian}","{emer_contact}","{emer_phone}","{med_history}","{allergy_med}","{value}" +{/if:have_attendees}--> \ No newline at end of file diff --git a/admin/Views/report_request.html b/admin/Views/report_request.html new file mode 100644 index 0000000..8914950 --- /dev/null +++ b/admin/Views/report_request.html @@ -0,0 +1,235 @@ + +

+

Select Report

+{reason_text} +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{eventTermCap}(s):{reg_select}
Status:{status_select}
Report by: + +
Sort by: + +
Output Type: + +
 
Filter by Activity Date
Filter by Registration Date
Filter by Desired Date
 
Entered By Admin User: + +
 
Member: + +
Member ID:
 
Include Dynamic Field Data: + + + + Only available when reporting on a single activity. +
Show field IDs rather than titles: + + + This conserves space in reports.
Consider using Custom field IDs in
form to make these more obvious. +
+
+ + +
+
+ diff --git a/admin/Views/reports_csv.html b/admin/Views/reports_csv.html new file mode 100644 index 0000000..eee8a40 --- /dev/null +++ b/admin/Views/reports_csv.html @@ -0,0 +1 @@ +{body} diff --git a/admin/Views/reports_print.html b/admin/Views/reports_print.html new file mode 100644 index 0000000..a5f5624 --- /dev/null +++ b/admin/Views/reports_print.html @@ -0,0 +1,23 @@ + + + Registration Reports + + + + + + + + + + +
+
{cust_name}
+ + {body} + +
+ + \ No newline at end of file diff --git a/admin/Views/view_attendees.html b/admin/Views/view_attendees.html new file mode 100644 index 0000000..f611ede --- /dev/null +++ b/admin/Views/view_attendees.html @@ -0,0 +1,71 @@ + +

 

+ {eventsTermCap} / {attendeesTermCap} + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
{eventTermCap}: {regname}
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Selected: {rate_class}
{attendeesTermCap}:   + + + + + + + + + + + + + + + + + + + + + + + + +
+ {name} +
 Date of Birth: {dob}    Parent/Guardian: {guardian}
 Emergency Contact: {emer_contact}    Emergency Phone: {emer_phone}
 Brief Medical History: {med_history}
 Alergies/Medications: {allergy_med}
+
+

 

+ Original Submission Summary + + + + +
Updates do not show in this summary.
See above for current data.
{summary}
+ diff --git a/admin/Views/welcome.html b/admin/Views/welcome.html new file mode 100644 index 0000000..0359a80 --- /dev/null +++ b/admin/Views/welcome.html @@ -0,0 +1,1099 @@ + + +

System Updates and Information

+ +
+

Welcome to the Gaslight Media Event Registration System.

+

+ In an effort to provide our customers with the best possible service, Gaslight Media will from time to + time make improvements to this application and correct problems that we have noticed + or that have been reported to us. + We will post information regarding such updates here so that you can be aware of improvements + and learn how to use new features. As always, please let us know if you have any concerns, + need any assistance, or would like to suggest new features. +

+

+ Some items below refer to a "configuration option". These options are not customer selectable. Please + let us know if you would like to consider a change with one of these options.
+

    List of configurable options

+ +

+ +

Recent Updates

+ +

    February 14, 2014

+
    +

    Minor Output Changes

    +
  • + {eventTermCap} location is now included in registration confirmation E-Mail messages and stored summaries. +

    + Due to customer requests, we have added the {eventTerm} location in all E-Mail messages and stored summaries for + any new {registrationTerm} requests. If no location is provided for the {eventTerm}, the location line will not + be included in these E-Mail messages or summaries. +

    +

    + Note that summaries stored before this change will not include the location information. +

    +
  • +
+ +

    October 30, 2013

+ + + +

    September 13, 2013

+ + + +

    September 9, 2013

+ + +

    May 28, 2013

+ + +

    March 21, 2013

+ + +

    February 19, 2013

+ + +

    2012 Updates

+ + +

 

+

+ + Gaslight Media
+ 120 E. Lake Street
+ Petoskey, MI 49770
+ 231-487-0692
+ info@gaslightmedia.com +

+ + +
+ + diff --git a/admin/index.phtml b/admin/index.phtml new file mode 100644 index 0000000..a167638 --- /dev/null +++ b/admin/index.phtml @@ -0,0 +1,4135 @@ + + + + +

Oops! We have a problem here.

+

For some reason your last request could not be completed.

+

+ We\'re sorry for the inconvenience. If this continues to be a problem for you, + please call Gaslight Media at 231-487-0692 and tell us what is displayed below. +

+

+ + + + + + +
Application:GLM Event Registration
Section:Admin
File:index.phtml
Line:'.$error['line'].'
ERROR:'.$error['message'].'
+

+ + + '; + break; + default: + // No Problems Here + break; + } +} +register_shutdown_function('shutdownFunction'); + +// Route ancillary requests as required +if (isset($_REQUEST['route_app'])) { + switch($_REQUEST['route_app']) { + case 'calendar_popup': + include( GLM_APP_BASE.'Common/Registrations_V3/front-end/calendar.phtml'); + break; + } + exit; +} + +include( GLM_APP_BASE.'Common/Registrations_V3/front-end/reg_setup.php'); +$config = new Zend_Config_Ini(BASE_PATH.'config/application.ini', strtolower($_ENV['GLM_HOST_ID'])); +$server_config = new Zend_Config_Ini(BASE_PATH.'/config/server.ini', strtolower($_ENV['GLM_HOST_ID'])); + +$GLOBALS['reg_config'] = $config->event_registration->toArray(); +//var_dump($GLOBALS['reg_config']); + +include( GLM_APP_BASE.'Common/Registrations_V3/front-end/reg_functions.inc' ); + +define( 'THIS_SCRIPT', BASE_URL.'admin/Registrations/index.php'); + + +$nl = "\n"; // New line character to ease use + +$link_data = ''; +$form_data = ''; + + // + // Local Functions + // + + // Function to add parameters to $link_data + +function add_link_data( $name, $value ) + { + global $link_data; + + if( $link_data != '' ) + $link_data .= '&'; + $link_data .= "$name=$value"; + } + +function add_form_data( $name, $value ) + { + global $form_data; + + $form_data .= ''.$nl; + } + +// Get all standard input data +$Action = filter_request('Action', FILTER_SANITIZE_STRING); +$Option = filter_request('Option', FILTER_SANITIZE_STRING); +$id = filter_request('id', FILTER_SANITIZE_STRING); +$start = filter_request('start', FILTER_SANITIZE_NUMBER_INT); +$status = filter_request('status', FILTER_SANITIZE_NUMBER_INT); +$cc_conf = filter_request('cc_conf', FILTER_SANITIZE_STRING); + + // Build global tag data for view files + +$view_tags = array ( "global" => array() ); +$v = &$view_tags["global"]; + + // Set default view and style locations + +$qs_style = 'style.css'; +$v['stylesheet'] = BASE_APP_URL.'Common/Registrations_V3/admin/style.css'; +$qs_viewpath = GLM_APP_BASE.'Common/Registrations_V3/admin/Views'; + +// Check for local/custom stylesheet +if ($config->event_registration->custom_view_files && file_exists(SI_BASE_PATH.'Toolkit/Registrations/Views/admin/style.css')) { + $v['stylesheet'] = BASE_SECURE_URL.'Toolkit/Registrations/Views/admin/style.css'; +} + +// Function to check if a local/custom views are on and directory exists for front-end - replaces the normal parse_view() function +function parse_view_localcheck($use_local, $file_name, $tokens, $show_unused = true) +{ + global $config; + + $viewpath = GLM_APP_BASE.'Common/Registrations_V3/admin/Views/'.$file_name; + + if ($use_local && file_exists(SI_BASE_PATH.'Toolkit/Registrations/Views/admin/'.$file_name)) { + $viewpath = SI_BASE_PATH.'Toolkit/Registrations/Views/admin/'.$file_name; + } + + return parse_view($viewpath, $tokens, $show_unused); +} + + // Get some standard view tags + +$v['base_url'] = BASE_URL; +$v['base_app_url'] = BASE_APP_URL; +$v['this_script'] = THIS_SCRIPT; +$v['copyright_years'] = '2002, '.date('Y'); +$v['cust_name'] = $config->event_registration->organization; +$v['cust_address'] = $config->event_registration->organization_address; +$v['cust_city'] = $config->event_registration->organization_city; +$v['cust_state'] = $config->event_registration->organization_state; +$v['cust_zip'] = $config->event_registration->organization_zip; +$v['cust_phone'] = $config->event_registration->organization_phone; +$v['cust_logo'] = SI_CUST_LOGO_MEDIUM_URL; +$v['application'] = $config->event_registration->title; +$v['gen_bulletin'] = ''; +$v['form_data'] = &$form_data; +$v['link_data'] = &$link_data; +$v['categoryTerm'] = $config->event_registration->word->category; +$v['categoryTermCap'] = ucfirst($config->event_registration->word->category); +$v['categoriesTerm'] = $config->event_registration->word->categories; +$v['categoriesTermCap'] = ucfirst($config->event_registration->word->categories); +$v['subcategoryTerm'] = $config->event_registration->word->sub_category; +$v['subcategoryTermCap'] = ucfirst($config->event_registration->word->sub_category); +$v['subcategoriesTerm'] = $config->event_registration->word->sub_categories; +$v['subcategoriesTermCap'] = ucfirst($config->event_registration->word->sub_categories); +$v['attributeTerm'] = $config->event_registration->word->attribute; +$v['attributeTermCap'] = ucfirst($config->event_registration->word->attribute); +$v['attributesTerm'] = $config->event_registration->word->attributes; +$v['attributesTermCap'] = ucfirst($config->event_registration->word->attributes); +$v['eventTerm'] = $config->event_registration->word->event; +$v['eventTermCap'] = ucfirst($config->event_registration->word->event); +$v['eventsTerm'] = $config->event_registration->word->events; +$v['eventsTermCap'] = ucfirst($config->event_registration->word->events); +$v['registerTerm'] = $config->event_registration->word->register; +$v['resisterTermCap'] = ucfirst($config->event_registration->word->register); +$v['registrationTerm'] = $config->event_registration->word->registration; +$v['registrationTermCap'] = ucfirst($config->event_registration->word->registration); +$v['registrationsTerm'] = $config->event_registration->word->registrations; +$v['registrationsTermCap'] = ucfirst($config->event_registration->word->registrations); +$v['registeringTerm'] = $config->event_registration->word->registering; +$v['registeringTermCap'] = ucfirst($config->event_registration->word->registering); +$v['registeredTerm'] = $config->event_registration->word->registered; +$v['registeredTermCap'] = ucfirst($config->event_registration->word->registered); +$v['attendeeTerm'] = $config->event_registration->word->attendee; +$v['attendeeTermCap'] = ucfirst($config->event_registration->word->attendee); +$v['attendeesTerm'] = $config->event_registration->word->attendees; +$v['attendeesTermCap'] = ucfirst($config->event_registration->word->attendees); +$v['attendingTerm'] = $config->event_registration->word->attending; +$v['attendingTermCap'] = ucfirst($config->event_registration->word->attending); +$v['attendedTerm'] = $config->event_registration->word->attended; +$v['attendedTermCap'] = ucfirst($config->event_registration->word->attended); +$v['memberTerm'] = $config->event_registration->word->member; +$v['memberTermCap'] = ucfirst($config->event_registration->word->member); +$v['user_idTerm'] = $config->event_registration->word->user_id; +$v['user_idTermCap'] = ucfirst($config->event_registration->word->user_id); +$v['passwordTerm'] = $config->event_registration->word->password; +$v['passwordTermCap'] = ucfirst($config->event_registration->word->password); +$v['instructorTerm'] = $config->event_registration->word->instructor; +$v['instructorTermCap'] = ucfirst($config->event_registration->word->instructor); +$v['instructorsTerm'] = $config->event_registration->word->instructors; +$v['instructorsTermCap'] = ucfirst($config->event_registration->word->instructors); +$v['restricted_userTerm'] = $config->event_registration->word->restricted_user; +$v['restricted_userTermCap'] = ucfirst($config->event_registration->word->restricted_user); +$v['restricted_usersTerm'] = $config->event_registration->word->restricted_users; +$v['restricted_usersTermCap'] = ucfirst($config->event_registration->word->restricted_users); + +$v["registrations_title"] = $config->event_registration->title; +$v['title_use_payment_comp_code'] = $config->event_registration->titles->use_payment_comp_code; +$v['title_payment_comp_code'] = $config->event_registration->titles->payment_comp_code; +$v['title_send_a_check'] = $config->event_registration->titles->send_a_check; +$v['title_call_from_merchant'] = $config->event_registration->titles->call_from_merchant; +$v['title_paid_cash'] = $config->event_registration->titles->paid_cash; +$v['title_pay_by_credit_card'] = $config->event_registration->titles->pay_by_credit_card; + +// Optional contact data +$v['show_contact_data'] = ($config->event_registration->show_contact_data ? 'YES' : 'NO'); +$v['show_same_button'] = ($config->event_registration->show_same_button ? 'YES' : 'NO'); +$v['contact_information_title'] = $config->event_registration->titles->contact_information; +$v['use_contact_fname'] = ($config->event_registration->prompt->contact_fname != '' ? 'YES' : 'NO'); +$v['required_contact_fname'] = ($config->event_registration->required->contact_fname ? 'YES' : 'NO'); +$v['prompt_contact_fname'] = $config->event_registration->prompt->contact_fname; +$v['use_contact_lname'] = ($config->event_registration->prompt->contact_lname != '' ? 'YES' : 'NO'); +$v['required_contact_lname'] = ($config->event_registration->required->contact_lname ? 'YES' : 'NO'); +$v['prompt_contact_lname'] = $config->event_registration->prompt->contact_lname; +$v['use_contact_addr1'] = ($config->event_registration->prompt->contact_addr1 != '' ? 'YES' : 'NO'); +$v['required_contact_addr1'] = ($config->event_registration->required->contact_addr1 ? 'YES' : 'NO'); +$v['prompt_contact_addr1'] = $config->event_registration->prompt->contact_addr1; +$v['use_contact_addr2'] = ($config->event_registration->prompt->contact_addr2 != '' ? 'YES' : 'NO'); +$v['required_contact_addr2'] = ($config->event_registration->required->contact_addr2 ? 'YES' : 'NO'); +$v['prompt_contact_addr2'] = $config->event_registration->prompt->contact_addr2; +$v['use_contact_city'] = ($config->event_registration->prompt->contact_city != '' ? 'YES' : 'NO'); +$v['required_contact_city'] = ($config->event_registration->required->contact_city ? 'YES' : 'NO'); +$v['prompt_contact_city'] = $config->event_registration->prompt->contact_city; +$v['use_contact_state'] = ($config->event_registration->prompt->contact_state != '' ? 'YES' : 'NO'); +$v['required_contact_state'] = ($config->event_registration->required->contact_state ? 'YES' : 'NO'); +$v['prompt_contact_state'] = $config->event_registration->prompt->contact_state; +$v['use_contact_zip'] = ($config->event_registration->prompt->contact_zip != '' ? 'YES' : 'NO'); +$v['required_contact_zip'] = ($config->event_registration->required->contact_zip ? 'YES' : 'NO'); +$v['prompt_contact_zip'] = $config->event_registration->prompt->contact_zip; +$v['use_contact_country'] = ($config->event_registration->prompt->contact_country != '' ? 'YES' : 'NO'); +$v['required_contact_country'] = ($config->event_registration->required->contact_country ? 'YES' : 'NO'); +$v['prompt_contact_country'] = $config->event_registration->prompt->contact_country; +$v['use_contact_phone'] = ($config->event_registration->prompt->contact_phone != '' ? 'YES' : 'NO'); +$v['required_contact_phone'] = ($config->event_registration->required->contact_phone ? 'YES' : 'NO'); +$v['prompt_contact_phone'] = $config->event_registration->prompt->contact_phone; +$v['use_contact_fax'] = ($config->event_registration->prompt->contact_fax != '' ? 'YES' : 'NO'); +$v['required_contact_fax'] = ($config->event_registration->required->contact_fax ? 'YES' : 'NO'); +$v['prompt_contact_fax'] = $config->event_registration->prompt->contact_fax; + + + // Set some global flags + +$using_registered_users = $config->event_registration->registered_users; +$using_medical_info = $config->event_registration->medical_info; + + // + // Menus + // + +$menu1 = $menu2 = $menu3 = $menu4 = $menu5 = ''; +if( substr( $Action, 0, 3 ) == "Mis" ) + { + $menu1 .= '[Misc] '; + $id = 1; + $menu2 .= admin_menu( "Mis", "Miscellaneous", $id, $Option, 've', '', $link_data ); + } + else + $menu1 .= '[Misc] '; + +// Categories - Respects configuration of categories on/off and sub-categories on/off + +if ($config->event_registration->main_categories) { + + if( substr( $Action, 0, 3 ) == "Tod" ) + { + // Only include sub-menus if sub-categories are on + $menu1 .= '['.$v['categoriesTermCap'].'] '; + + if( substr( $Action, 0, 7 ) == 'Tod_Mai' ) + { + if( substr( $Action, 0, 7 ) == 'Tod_Mai' ) + { + if ($config->event_registration->sub_categories) { + $menu2 .= '['.$v['categoriesTermCap'].'] '; + } + $menu3 .= admin_menu( "Tod_Mai", $v['categoriesTermCap'], $id, $Option, 'aeuvdl', '', $link_data ); + } + else + if ($config->event_registration->sub_categories) { + $menu2 .= '['.$v['categoriesTermCap'].'] '; + } + } + else + $menu2 .= '['.$v['categoriesTermCap'].'] '; + + // If we have sub-categories, include that in the sub menu + if ($config->event_registration->sub_categories) { + + if( substr( $Action, 0, 7 ) == 'Tod_Cat' ) + { + if( substr( $Action, 0, 7 ) == 'Tod_Cat' ) + { + $menu2 .= '['.$v['subcategoriesTermCap'].'] '; + $menu3 .= admin_menu( "Tod_Cat", $v['subcategoriesTermCap'], $id, $Option, 'aeuvdl', '', $link_data ); + } + else + $menu2 .= '[Class/Activity Cateories] '; + } + else + $menu2 .= '['.$v['subcategoriesTermCap'].'] '; + + } // Sub Categories + + } + else + $menu1 .= '['.$v['categoriesTermCap'].'] '; + +} // categories + + +// Attributes +if ($config->event_registration->attributes) { + if( substr( $Action, 0, 3 ) == "Att" ) + { + $menu1 .= '['.$v['attributesTermCap'].'] '; + $menu2 .= admin_menu( "Att", $v['attributesTermCap'], $id, $Option, 'aeuvdl', '', $link_data ); + } + else + $menu1 .= '['.$v['attributesTermCap'].'] '; +} + +// Events +if( substr( $Action, 0, 3 ) == "Eve" ) + { + $menu1 .= '['.$v['eventsTermCap'].'] '; + $menu2 .= admin_menu( "Eve", $v['eventsTermCap'], $id, $Option, 'lveda', '', $link_data ); + $menu2 .= ' - '; + + if( substr( $Action, 0, 11 ) == 'Eve_For_Edi' || empty($id) || $Option == 'Confirm Delete' ) + { + if( substr( $Action, 0, 11 ) == 'Eve_For_Edi' && $option != 'Confirm Delete' ) + $menu2 .= '[Edit Form] '; + else + $menu2 .= '[Edit Form] '; + } + else + $menu2 .= '[Edit Form] '; + + if(!empty($id) ) + { + $menu2 .= '[Dates Calendar] '; + } + else + $menu2 .= '[Dates Calendar] '; + + } + else + $menu1 .= '['.$v['eventsTermCap'].'] '; + +// Members +if ($config->event_registration->have_members) { + if( substr( $Action, 0, 3 ) == "Mem" ) + { + $menu1 .= '[Members] '; + $menu2 .= admin_menu( "Mem", "Members", $id, $Option, 'lve', '', $link_data ); + } + else + $menu1 .= '[Members] '; +} + + +// Registered User +if ($config->event_registration->registered_users) { + if( substr( $Action, 0, 3 ) == "Use" ) + { + $menu1 .= '[Registered Users] '; + $menu2 .= admin_menu( "Use", "Registered Users", $id, $Option, 'alveda', '', $link_data ); + } + else + $menu1 .= '[Registered Users] '; +} + +// Registrations +if( substr( $Action, 0, 3 ) == "Reg" ) + { + + $Action_Save = $Action; + if ($Action == 'Reg_Att' && $_REQUEST['Option'] == 'Update') { + $Action = 'Reg'; + $Option = 'View'; + } + + $menu1 .= '[Submissions] '; + $menu2 .= admin_menu( "Reg", "Submissions", $id, $Option, 'euvl', '', $link_data ); + $menu2 .= ' - '; + + if( substr( $Action, 0, 7 ) == 'Reg_Att' ) + { + if( substr( $Action, 0, 7 ) == 'Reg_Att' ) + $menu2 .= '[Edit '.$v['attendeeTermCap'].'] '; + else + $menu2 .= '[Edit '.$v['attendeesTermCap'].'] '; + } + elseif (($id-0) > 0) + $menu2 .= '[Edit '.$v['attendeeTermCap'].'] '; + else + $menu2 .= '[Edit '.$v['attendeeTermCap'].'] '; + + $Action = $Action_Save; + } + else + $menu1 .= '[Submissions] '; + +// Reports +if( substr( $Action, 0, 3 ) == 'Rep' ) + { + $menu1 .= '[Reports] '; + } + else + $menu1 .= '[Reports] '; + +// If an event is currently selected, then take them directly to that event. +if ($Action == 'Eve' && $Option == 'View') { + $menu1 .= ' - [Enter New Registration]'; +} else { + $menu1 .= ' - [Enter New Registration]'; +} + +// If we're not printing this page, do all the top stuff and nav +if( !isset($_REQUEST['PrintReport']) || $_REQUEST['PrintReport'] != 'Yes' ) { + $v['menu'] = ''; + if( !empty($menu1) ) $v['menu'] .= "$menu1
"; + if( !empty($menu2) ) $v['menu'] .= "$menu2
"; + if( !empty($menu3) ) $v['menu'] .= "$menu3
"; + if( !empty($menu4) ) $v['menu'] .= "$menu4
"; + if( !empty($menu5) ) $v['menu'] .= "$menu5
"; + $v['menu'] .= '

'; +} else { + $v['menu'] = ''; +} + + // + // Main Processing + // + +$v['body'] = $v['message'] = ''; +$qs_viewfile = 'admin.html'; + +switch( $Action ) + { + + + case "Mis": + + $reg_fields = array + ( + 'b_1' => 'b_1, break.

Misc '.$v['eventTermCap'].' Text

, , FALSE, b_4, ev', + 'pay_codes' => 'pay_codes, multifield.2.{line_numb}: {field_1} Description: {field_2}
, + Payment Codes, FALSE, pay_codes, aeuv', + 'b_2' => 'b_2, break.

Text for Various Pages

, , FALSE, b_4, ev', + 'regbulletin' => 'regbulletin, richtext.600.200.encoded, Text for top of first page, FALSE, regbulletin, euv', + 'cat_page_text' => 'cat_page_text, richtext.600.200.encoded, Text for top of Category page, FALSE, cat_page_text, euv', + 'sub_cat_page_text' => 'sub_cat_page_text, richtext.600.200.encoded, Text for top of Sub-Category page, FALSE, sub_cat_page_text, euv', + 'select_page_text' => 'select_page_text, richtext.600.200.encoded, Text for top of '.$v['eventTermCap'].' selection page, FALSE, select_page_text, euv', + 'event_page_text' => 'event_page_text, richtext.600.200.encoded, Text for top of '.$v['eventTermCap'].' detail page, FALSE, event_page_text, euv', + 'cart_page_text' => 'cart_page_text, richtext.600.200.encoded, Text for top of Shopping Cart page, FALSE, cart_page_text, euv', + 'checkout_page_text' => 'checkout_page_text, richtext.600.200.encoded, Text for top of Checkout page, FALSE, checkout_page_text, euv', + 'summary_page_text' => 'summary_page_text, richtext.600.200.encoded, Text for top of Summary page, FALSE, summary_page_text, euv', + 'b_3' => 'b_3, break.

Terms and Conditions

, , FALSE, b_4, ev', + 'regterms' => 'regterms, richtext.600.200.encoded, '.$v['eventTermCap'].' Terms and Conditions, FALSE, regterms, euv', + 'b_4' => 'b_4, break.

Notification E-Mail to '.$v['instructorTermCap'].'

, , FALSE, b_4, ev', + 'notify_subject' => 'notify_subject, text.50, E-Mail Subject Line, TRUE, notify_subject, euv', + 'notify_text' => 'notify_text, richtext.600.200.encoded, Notification E-Mail Message, TRUE, notify_text, euv', + 'b_5' => 'b_5, break.

Acknowledgement E-Mail to '.$v['attendeeTermCap'].'

, , FALSE, b_4, ev', + 'req_ack_subject' => 'req_ack_subject, text.50, E-Mail Subject Line, TRUE, req_ack_subject, euv', + 'req_ack_text' => 'req_ack_text, richtext.600.200.encoded, Acknowledgement E-Mail Message, TRUE, req_ack_text, euv' + ); + + // Remove fields not used when either main or just sub cateogories are off. + if (!$config->event_registration->main_categories) { + unset($reg_fields['cat_page_text']); + unset($reg_fields['sub_cat_page_text']); + } elseif (!$config->event_registration->sub_categories) { + unset($reg_fields['sub_cat_page_text']); + } + + $r = admin_process_records_r + ( + "misc", // Table + '', // Where + 'sort', // Order fields + CONN_STR, // Connect String + 1, // Current ID + $reg_fields, // Fields array + 'view,edit', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Mis', // Action + "", // Passed parameter + 'Miscellaneous', // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '' // Title View + ); + + $v['body'] .= $r['text']; + + + // If a successful add, then reload page to display the newly added event. + if (($Option == 'Add New' || $Option == 'Update') && $r['status'] = true) { + + $url = THIS_SCRIPT.'?Action=Mis&Option=View&id='.$r['id']; + echo ' + + + Reloading to re-display page + + + +
+

Reloading to re-display page with updated information.

+

If you are not immediately redirected, please click below.

+ Redisplay +
+ + + '; + exit; + + } + + break; + + + case "Tod_Mai": + + if( $Option == 'Add New' ) + { + $sort = 9999; + } + + $todo_fields = array + ( + 'id' => 'id, int, ID, DISPLAY, id, euvl', + 'name' => 'name, text.50, Name, UNIQUE, name, naeuvlfd', + 'restricted' => 'restricted, checkbox, '.$v['restricted_usersTermCap'].' Only, + FALSE, restricted, naeuvl', + 'med_info'=> 'med_info,checkbox, Emergency/Med Info, FALSE, med_info, naeuvl', + 'image' => 'image, image.t, Image, FALSE, image, naeuv', + 'descr' => 'descr, richtext.600.200.encoded, Description, FALSE, descr, naeuvd', + 'sort' => 'sort, order, Order, TRUE, sort, naeuvl' + ); + if (!$using_medical_info) { + unset($todo_fields['med_info']); + } + + // If there's no restricted area catid then drop that field. + if (($config->event_registration->restricted_area_catid-0) == 0) { + unset($todo_fields['restricted']); + } + + $r = admin_process_records_r + ( + "todo", // Table + '', // Where + 'name', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $todo_fields, // Fields array + 'new,view,edit,delete,filter,strong,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Tod_Mai', // Action + "", // Passed parameter + $v['categoriesTermCap'], // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '' // Title View + ); + + $v['body'] .= $r['text']; + + // If a successful add, then reload page to display the newly added event. + if (($Option == 'Add New' || $Option == 'Update') && $r['status'] = true) { + + if (isset($r['id'])) { + $id = $r['id']; + } + + $url = THIS_SCRIPT.'?Action=Tod_Mai&Option=View&id='.$id; + echo ' + + + Reloading to re-display page + + + +
+

Reloading to re-display page with updated information.

+

If you are not immediately redirected, please click below.

+ Redisplay +
+ + + '; + exit; + + } + + break; + + + case "Tod_Cat": + + if( !($t = reg_db_auto_get_data( "SELECT id FROM todo;;", SI_CONN_STR, FALSE )) ) + { + $v['body'] = '

No '.$v['categoriesTermCap'].'!
Please add '.$v['categoriesTermCap'].' first.

'; + break; + } + + if( $Option == 'Add New' ) + { + $sort = 9999; + } + + $cat_fields = array + ( + 'id' => 'id, int, ID, DISPLAY, id, euvl', + 'name' => 'name, text.50, Name, UNIQUE, name, naeuvlf', + 'todo' => 'todo, pointer.todo.name,Main Category, TRUE, todo, naeuvlf', + 'image' => 'image, image.t, Image, FALSE, image, naeuv', + 'descr' => 'descr, richtext.600.200.encoded, Description, FALSE, descr, naeuv', + 'sort' => 'sort, order, Order, TRUE, sort, naeuvl' + ); + + $r = admin_process_records_r + ( + "category", // Table + '', // Where + 'name', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $cat_fields, // Fields array + 'new,view,edit,delete,strong,filter,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Tod_Cat', // Action + "", // Passed parameter + $v['subcategoriesTermCap'], // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '' // Title View + ); + + $v['body'] .= $r['text']; + + break; + + case "Att": + + if( $Option == 'Add New' ) { + $sort = 9999; + } + + $attr_fields = array + ( + 'id' => 'id, int, ID, DISPLAY, id, euvl', + 'name' => 'name, text.50, Name, UNIQUE, name, naeuvlfd', + 'descr' => 'descr, richtext.600.200.encoded, Description, FALSE, descr, naeuvd', + 'sort' => 'sort, order, Order, TRUE, sort, naeuvl' + ); + + $r = admin_process_records_r + ( + "attribute", // Table + '', // Where + 'name', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $attr_fields, // Fields array + 'new,view,edit,delete,strong,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Att', // Action + "", // Passed parameter + $v['attributesTermCap'], // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '' // Title View + ); + + $v['body'] .= $r['text']; + + break; + + case 'Eve': + + // Check for a "Add" action and ask the user to select a main category (todo) first + if ($config->event_registration->sub_categories && $Option == 'Add' && + (!isset($_REQUEST['todo']) || ($_REQUEST['todo']-0) <= 0) ) { + + // Get list of main categories (todo) + $sql = " + SELECT id, name + FROM todo + WHERE id IN + ( + SELECT DISTINCT todo FROM category + ) + ORDER BY sort, name; + "; + $todos = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE ); + + $v['body'] .= ' + New '.$v['eventTermCap'].'

+ (Required fields in red) +

+ + +

Start by selecting a '.$v['categoryTermCap'].'.

+

+ '.$v['categoryTermCap'].': + +

+ +
+

Note: Only '.$v['categoriesTermCap'].' that have '.$v['subcategoriesTermCap'].' are shown.

+ '; + + break; + } + + // Check for duplicate request + if( $Option == 'Duplicate') + { + // If we have a good id and good data + if(($src_id = ($id-0)) > 0 && + ($src_data = db_auto_get_row( "SELECT * FROM reg WHERE id = $src_id;", 0, CONN_STR, FALSE )) ) + { + + // Copy the registration (event) data to a new ID adding --DUPLICATE-- to the name + $sql = " + INSERT INTO reg + ( + category, + name, + descr, + notify_email, + active, + image, + start_date, + end_date, + dates, + times, + duration, + location, + cutoff_date, + cutoff_date2, + cutoff_date3, + cutoff_date4, + rates_descr, + rates_1, + rates_2, + rates_3, + rates_4, + attendee_limit, + attendee_max, + attendee_count, + form_revision, + sort, + terms, + notes, + need_attendees, + event_code, + short_descr + ) + VALUES + ( + ".$src_data['category'].", + '--DUPLICATE-- ".addslashes($src_data['name'])."', + '".addslashes($src_data['descr'])."', + '".addslashes($src_data['notify_email'])."', + '".$src_data['active']."', + '".addslashes($src_data['image'])."', + ".($src_data['start_date']==''?'null,':"'".addslashes($src_data['start_date'])."',")." + ".($src_data['end_date']==''?'null,':"'".addslashes($src_data['end_date'])."',")." + '".addslashes($src_data['dates'])."', + '".addslashes($src_data['times'])."', + '".addslashes($src_data['duration'])."', + '".addslashes($src_data['location'])."', + ".($src_data['cutoff_date']==''?'null,':"'".addslashes($src_data['cutoff_date'])."',")." + ".($src_data['cutoff_date2']==''?'null,':"'".addslashes($src_data['cutoff_date2'])."',")." + ".($src_data['cutoff_date3']==''?'null,':"'".addslashes($src_data['cutoff_date3'])."',")." + ".($src_data['cutoff_date4']==''?'null,':"'".addslashes($src_data['cutoff_date4'])."',")." + '".addslashes($src_data['rates_descr'])."', + '".addslashes($src_data['rates_1'])."', + '".addslashes($src_data['rates_2'])."', + '".addslashes($src_data['rates_3'])."', + '".addslashes($src_data['rates_4'])."', + '".$src_data['attendee_limit']."', + ".$src_data['attendee_max'].", + ".$src_data['attendee_count'].", + ".$src_data['form_revision'].", + ".$src_data['sort'].", + '".addslashes($src_data['terms'])."', + '".addslashes($src_data['notes'])."', + '".$src_data['need_attendees']."', + '".addslashes($src_data['event_code'])."', + '".addslashes($src_data['short_descr'])."' + ) + RETURNING id; + "; + + // Insert the new duplicate and get the new ID + $ret = db_auto_get_row( $sql, 0, CONN_STR, FALSE ); + $dst_id = $ret['id']; + + // Get any form data for the original + $sql = " + SELECT * + FROM magicform + WHERE form_id = '$src_id' + OR form_id LIKE '$id.%' + ORDER BY form_id; + "; + + $src_form_fields = reg_db_auto_get_data( $sql, CONN_STR, FALSE ); + if (is_array($src_form_fields) && count ($src_form_fields) > 0) { + + // We have some form field information, so duplicate that also + $sql = ''; + foreach ($src_form_fields as $s) { + + // Translate form_id for this field entry + if ($s['form_id'] == $src_id) { + $new_id = $dst_id; + } else { + $new_id = "$dst_id.".substr($s['form_id'],strlen($src_id)+1); + } + + // Check for IDs in data1 and translate them + $s['data1'] = str_replace('~'.$src_id.'.', '~'.$dst_id.'.', $s['data1']); + + $sql .= " + INSERT INTO magicform + ( + form_id, + custom_id, + title, + type, + descr, + active, + required, + data1, + sort, + expanded, + style, + file, + cols, + rows, + size, + format, + default_val + ) + VALUES + ( + '$new_id', + '".$s['custom_id']."', + '".addslashes($s['title'])."', + ".$s['type'].", + '".addslashes($s['descr'])."', + '".$s['active']."', + '".$s['required']."', + '".addslashes($s['data1'])."', + ".$s['sort'].", + '".$s['expanded']."', + '".addslashes($s['style'])."', + '".addslashes($s['file'])."', + ".$s['cols'].", + ".$s['rows'].", + '".addslashes($s['size'])."', + '".addslashes($s['format'])."', + '".addslashes($s['default_val'])."' + ); + "; + } + reg_db_auto_exec( $sql, 0, CONN_STR, FALSE ); + + } // If have src_form data + + } // Option Duplicate + $Option = 'View'; + $id = $dst_id; + } + + if( $Option == 'Add New' ) + { + $attendee_count = 0; + $form_revision = 1; + } + + + $date_specific = filter_request('date_specific', FILTER_SANITIZE_STRING); + $start_date = filter_request('start_date', FILTER_SANITIZE_STRING); + $end_date = filter_request('end_date', FILTER_SANITIZE_STRING); + $cutoff_date = filter_request('cutoff_date', FILTER_SANITIZE_STRING); + + if( ($Option == 'Add New' || $Option == 'Update') && + $date_specific == 'on' && + ($start_date == '' || $end_date == '' || $cutoff_date == '') ) { + $v['body'] .= '
Error:

Start, End, and First Cutoff dates are required for a Date Specific '.$v['eventTermCap'].'.
+ Click "Back" on your browser to make necessary corrections

'; + break; + } + + // Check if we're supposed to automatically mark past events as inactive + if ($Option == 'List' && $config->event_registration->auto_inactive) { + $sql = "UPDATE reg SET active = 'f' WHERE end_date < 'today'"; + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + } + + // Default to showing Active events only + if( $Option == 'List' && $active == '' ) { + $active = 2; + } + + $date_specific_default = true; + + $reg_fields = array + ( + 'id' => 'id, int, ID, DISPLAY, id, euvl', + 'event_code' => 'event_code, text.15, '.$v['eventTermCap'].' Code - Short, TRUE, event_code, naeu', + 'event_code_l' => 'event_code, text.15, Code, TRUE, event_code, lvf', + 'category' => '(updated in conditionals below)', + 'subcategory' => '(updated in conditionals below)', + 'subcategory_l' => '(updated in conditionals below)', + 'attribute' => 'attribute, multipointer.attribute.name.....reg_attr.reg.attr, '.$v['attributeTermCap'].', FALSE, attribute, naeuv', + + 'b_09' => ', break.To select multiple '.$v['attributesTerm'].' above, click and drag across multiple options.
+ To turn on or off an individual '.$v['attributeTerm'].' above, hold the CTRL key and click an option., + , FALSE, , ne', + 'name' => 'name, text.50, Name, TRUE, name, naeuvlf', + 'active' => 'active, checkbox, Active, FALSE, active, naeuvlf', + 'b_05' => ', break.

 

'.$v['eventTermCap'].' dates, + , FALSE, , nev', + 'date_specific_n' => 'date_specific, checkbox, '.$v['eventTermCap'].' is Date Specific, SUPPLIED, date_specific_default, n', + 'date_specific_l' => 'date_specific, checkbox, Date Specific, FALSE, date_specific, l', + 'date_specific' => 'date_specific, checkbox, '.$v['eventTermCap'].' is Date Specific, FALSE, date_specific, aeuvf', + 'b_06' => ', break.If '.$v['eventTermCap'].' is Date Specific then the following dates are required., + , FALSE, , ne', + 'start_date_f' => 'start_date, daterange.0.720, Date '.$v['eventTermCap'].' Starts, FALSE, start_date, f', + 'start_date_l' => 'start_date, date.0.720, Starts, FALSE, start_date, l', + 'start_date' => 'start_date, date.0.720, Date '.$v['eventTermCap'].' Starts, FALSE, start_date, naeuv', + 'end_date_f' => 'end_date, daterange.0.720..start_date, Date '.$v['eventTermCap'].' Ends, FALSE, end_date, f', + 'end_date_l' => 'end_date, date.0.720..start_date, Ends, FALSE, end_date, l', + 'end_date' => 'end_date, date.0.720..start_date, Date '.$v['eventTermCap'].' Ends, FALSE, end_date, naeuv', + 'b_07' => ', break.If '.$v['eventTermCap'].' is NOT Date Specific then do you want to ask user for a desired date?., + , FALSE, , ne', + 'ask_date' => 'ask_date, checkbox, Ask for desired date, FALSE, ask_date, naeuvf', + 'use_calendar' => 'use_calendar, checkbox, Use [Dates Calendar], FALSE, use_calendar, naeuv', + 'b_08' => ', break.If you select the above option, use the [Dates Calendar] menu option at the top of the page to set available dates., + , FALSE, , nev', + 'b_01' => ', break.

 

General '.$v['eventTermCap'].' Information, + , FALSE, , nev', + 'notify_email' => 'notify_email, multifield.1.#{line_numb}: {field_1}
, E-Mail Notification To, FALSE, notify_email, naeuv', + 'dates' => 'dates, text.50, Description of days held, FALSE, dates, naeuv', + 'times' => 'times, text.50, Times, FALSE, times, naeuv', + 'duration' => 'duration, text.50, Duration, FALSE, duration, naeuv', + 'location' => 'location, text.50, Location, FALSE, location, naeuv', + 'instructor' => 'instructor, text.50, '.$v['instructorTermCap'].', FALSE, instructor, naeuv', + 'image' => 'image, image.t, Image, FALSE, image, naeuv', + 'reg_file' => 'reg_file, file, File, FALSE, reg_file, naeuv', + 'reg_file_title' => 'reg_file_title, text.50, File Title, FALSE, reg_file_title, naeuv', + 'b_02' => ', break.

 

Detailed '.$v['eventTermCap'].' Information, + , FALSE, , nev', + 'short_descr' => 'short_descr, richtext.600.100.encoded, Short Description
(keep short), FALSE, short_descr, naeuv', + 'descr' => 'descr, richtext.600.200.encoded, '.$v['eventTermCap'].' Description, FALSE, descr, naeuv', + 'rates_descr' => 'rates_descr, richtext.600.200.encoded, Levels Description, FALSE, rates_descr, naeuv', + 'b_03' => ', break.

 

Rate options and dates, + , FALSE, , nev', + 'b_1' => ', break.
Supply date/price ranges as required. Last supplied date is final reservation cut-off date.
+ If '.$v['eventTermCap'].' is NOT Date Specific, then the First Cutoff Date Settings are used., + , FALSE, , nev' + ); + + // If we have sub-categories, update reg.todo field with correct data - it's used for reference to the category in admin only + if ($config->event_registration->sub_categories) { + // Also, forceably update all list_name fields for all category entries. *** NEED TO MAKE THIS MORE INTELEGENT *** + $sql = " + UPDATE reg R + SET todo = + ( + SELECT C.todo + FROM category C + WHERE C.id = R.category + ); + UPDATE category CC SET list_name = + ( + SELECT T.name || ' - ' || C.name + FROM todo T, category C + WHERE C.id = CC.id + AND T.id = C.todo + ); + "; + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + + } + + // If we're not using categories or sub-categories, drop them + if (!$config->event_registration->main_categories) { + unset($reg_fields['category']); + } + if (!$config->event_registration->sub_categories) { + unset($reg_fields['subcategory']); + } + + // If we are, then setup to show category and list_name + if ($config->event_registration->main_categories && $config->event_registration->sub_categories) { + $reg_fields['category'] = 'todo, pointer.todo.name, '.$v['categoryTermCap'].', DISPLAY, todo, naeuvlf'; + if ($Option == "Add") { + $reg_fields['subcategory'] = 'category, pointer.category.list_name.id.todo = '.$_REQUEST['todo'].', '.$v['subcategoryTermCap'].', TRUE, category, naeuf'; + } else { + $reg_fields['subcategory'] = 'category, pointer.category.list_name, '.$v['subcategoryTermCap'].', TRUE, category, naeuf'; + } + $reg_fields['subcategory_l'] = 'category, pointer.category.name, '.$v['subcategoryTermCap'].', TRUE, category, vl'; + } + + // If we're not using sub-categories, just look at the main cateogories + if ($config->event_registration->main_categories && !$config->event_registration->sub_categories) { + $reg_fields['category'] = 'category, pointer.todo.name, Category, TRUE, category, naeuvlf'; + // Otherwise if this is an "n,a,e,u" then trash the category field. + } elseif (in_array($Option,array('Add','Add New','Edit','Update'))) { + unset($reg_fields['category']); + } + + // If we're not using attributes, drop them + if (!$config->event_registration->attributes) { + unset($reg_fields['attribute']); + unset($reg_fields['b_09']); + } + + // If we're doing member registration + if ($config->event_registration->have_members) { + + $rf2 = array( + 'b_2' => ', break.
First Cutoff Date Settings

, , FALSE, , nev', + 'rates_1_memb' => 'rates_1_memb, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Members, FALSE, rates_1_memb, naeuv', + 'rates_1' => 'rates_1, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Non-Members, FALSE, rates_1, naeuv', + 'cutoff_date' => 'cutoff_date, date.0.720, First Cutoff Date, FALSE, cutoff_date, naeuv', + 'b_3' => ', break.
Second Cutoff Date Settings

, , FALSE, , nev', + 'rates_2_memb' => 'rates_2_memb, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Members, FALSE, rates_2_memb, naeuv', + 'rates_2' => 'rates_2, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Non-Members, FALSE, rates_2, naeuv', + 'cutoff_date2' => 'cutoff_date2, date.0.720, Second Cutoff Date, FALSE, cutoff_date2, naeuv', + 'b_4' => ', break.
Third Cutoff Date Settings

, , FALSE, , nev', + 'rates_3_memb' => 'rates_3_memb, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Members, FALSE, rates_3_memb, naeuv', + 'rates_3' => 'rates_3, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Non-Members, FALSE, rates_3, naeuv', + 'cutoff_date3' => 'cutoff_date3, date.0.720, Third Cutoff Date, FALSE, cutoff_date3, naeuv', + 'b_5' => ', break.
Fourth Cutoff Date Settings

, , FALSE, , nev', + 'rates_4_memb' => 'rates_4_memb, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Members, FALSE, rates_4_memb, naeuv', + 'rates_4' => 'rates_4, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Non-Members, FALSE, rates_4, naeuv', + 'cutoff_date4' => 'cutoff_date4, date.0.720, Final Cutoff Date, FALSE, cutoff_date4, naeuv' + ); + $reg_fields = array_merge ( $reg_fields, $rf2 ); + + } else { + + $rf2 = array( + 'b_2' => ', break.
First Cutoff Date Settings

, , FALSE, , nev', + 'rates_1' => 'rates_1, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Rate Options, FALSE, rates_1, naeuv', + 'cutoff_date' => 'cutoff_date, date.0.720, First Cutoff Date, FALSE, cutoff_date, naeuv', + 'b_3' => ', break.
Second Cutoff Date Settings

, , FALSE, , nev', + 'rates_2' => 'rates_2, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Rate Options, FALSE, rates_2, naeuv', + 'cutoff_date2' => 'cutoff_date2, date.0.720, Second Cutoff Date, FALSE, cutoff_date2, naeuv', + 'b_4' => ', break.
Third Cutoff Date Settings

, , FALSE, , nev', + 'rates_3' => 'rates_3, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Rate Options, FALSE, rates_3, naeuv', + 'cutoff_date3' => 'cutoff_date3, date.0.720, Third Cutoff Date, FALSE, cutoff_date3, naeuv', + 'b_5' => ', break.
Fourth Cutoff Date Settings

, , FALSE, , nev', + 'rates_4' => 'rates_4, multifield.4.#{line_numb}: Name {field_1} Base $ {field_2} Per '.$v['attendeeTermCap'].' $ {field_3} '.$v['attendeeTermCap'].' Credits {field_4}
, + Rate Options, FALSE, rates_4, naeuv', + 'cutoff_date4' => 'cutoff_date4, date.0.720, Final Cutoff Date, FALSE, cutoff_date4, naeuv' + ); + $reg_fields = array_merge ( $reg_fields, $rf2 ); + + } + $rf3 = array( + + 'b_payment' => ', break.

 

Payment Options
+ If these items are checked, front-end users will be blocked from using these methods
+ and payment by these methods will be restricted to admin users only., + , FALSE, , nev', + 'restrict_comp_code' => 'restrict_comp_code, checkbox, Block payment type: Comp Code, FALSE, restrict_comp_code, naeuv', + 'restrict_check' => 'restrict_check, checkbox, Block payment type: Check, FALSE, restrict_check, naeuv', + 'restrict_call_from_merchant' => 'restrict_call_from_merchant, checkbox, Block payment type: Call from Merchant, FALSE, restrict_call_from_merchant, naeuv', + 'restrict_cash' => 'restrict_cash, checkbox, Block payment type: Cash, FALSE, restrict_cash, naeuv', + 'restrict_credit_card' => 'restrict_credit_card, checkbox, Block payment type: Credit Card, FALSE, restrict_credit_card, naeuv', + 'mf_charges_by_attendee' => 'mf_charges_by_attendee, checkbox, Mutliply MagicForm checkbox/picklist values by attendees, FALSE, mf_charges_by_attendee, naeuv', + 'b_attendees' => ', break.

 

'.$v['attendeeTermCap'].' Options, + , FALSE, , nev', + 'need_attendees' => 'need_attendees, checkbox, Ask for '.$v['attendeesTermCap'].', FALSE, need_attendees, naeuv', + 'attendee_limit' => 'attendee_limit, checkbox, Limited number of '.$v['attendeesTermCap'].' for this '.$v['eventTermCap'].', FALSE, attendee_limit, naeuv', + 'attendee_max' => 'attendee_max, int, Maximum number of '.$v['attendeesTermCap'].' for this '.$v['eventTermCap'].', FALSE, attendee_max, naeuv', + 'attendee_count' => 'attendee_count, int, Current No. of '.$v['attendeesTermCap'].' '.$v['registeredTermCap'].', FALSE, attendee_count, aeuv', + 'attendee_max_per_sub' => 'attendee_max_per_sub, int, Maximum number of '.$v['attendeesTermCap'].' per '.$v['registrationTermCap'].', FALSE, attendee_max_per_sub, naeuv', + 'b_per_sub_comment' => ', break.(Used if asking for '.$v['attendeesTermCap'].' - set to 0 for unlimited), + , FALSE, , nev', + 'require_registered_user' => 'require_registered_user, checkbox, '.$v['registrationTermCap'].' must be submitted by a '.$v['memberTermCap'].', FALSE, require_registered_user, naeuv', + 'b_misc' => ', break.

 

Terms and Conditions, + , FALSE, , nev', +// 'pay_codes' => 'pay_codes, multifield.2.{line_numb}: {field_1} Description: {field_2}
, +// Payment Codes, FALSE, pay_codes, aeuv', + 'terms' => 'terms, richtext.600.200.encoded, Terms and Conditions
Specific to this '.$v['eventTermCap'].', FALSE, terms, aeuv', + 'sort' => 'sort, order, Order, TRUE, sort, naeuvl', + 'form_revision' => 'form_revision, int, Form Revision, TRUE, form_revision, av', + ); + $reg_fields = array_merge ( $reg_fields, $rf3 ); + + // If members are not enabled remove member restriction option + if ($config->event_registration->have_members != 'Yes') { + unset($reg_fields['require_registered_user']); + } + + // Check payment configuration and remove any methods that are turned off globally for this site + $remove_count = 0; + if ($config->event_registration->payment_methods->comp_code != 'Yes') { + unset($reg_fields['restrict_comp_code']); + $remove_count++; + } + if ($config->event_registration->payment_methods->check != 'Yes') { + unset($reg_fields['restrict_check']); + $remove_count++; + } + if ($config->event_registration->payment_methods->call_from_merchant != 'Yes') { + unset($reg_fields['restrict_call_from_merchant']); + $remove_count++; + } + if ($config->event_registration->payment_methods->cash != 'Yes') { + unset($reg_fields['restrict_cash']); + $remove_count++; + } + if ($config->event_registration->payment_methods->credit_card != 'Yes') { + unset($reg_fields['restrict_credit_card']); + $remove_count++; + } + // If there's none left then remove all traces of this section + if ($remove_count == 5) { + unset($reg_fields['b_payment']); + } + + + // If event is not date-specific, then drop the rates and cutoffs after the first set + if (in_array($Option,array('Edit','View','Update')) && ($id-0) > 0) { + + $ds_data = db_auto_get_row( "SELECT date_specific FROM reg WHERE id = $id;", 0, CONN_STR, FALSE ); + + // If not date specific, drop all but the first; + if ($ds_data['date_specific'] == 'f') { + unset($reg_fields['b_3']); + unset($reg_fields['rates_2_memb']); + unset($reg_fields['rates_2']); + unset($reg_fields['cutoff_date2']); + unset($reg_fields['b_4']); + unset($reg_fields['rates_2_memb']); + unset($reg_fields['rates_3']); + unset($reg_fields['cutoff_date3']); + unset($reg_fields['b_5']); + unset($reg_fields['rates_4_memb']); + unset($reg_fields['rates_4']); + unset($reg_fields['cutoff_date4']); + } + } + + $r = admin_process_records_r + ( + "reg", // Table + '', // Where + 'sort', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $reg_fields, // Fields array + 'view,edit,delete,duplicate,filter,strong,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Eve', // Action + "", // Passed parameter + $v['eventsTermCap'], // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '' // Title View + ); + + // If successful delete, then delete all associated MagicForm fields + + if( $Option == 'Confirm Delete' && $r['status'] = true ) + reg_db_auto_exec( "DELETE FROM magicform WHERE form_id LIKE '$id.%'; DELETE FROM magicform WHERE form_id = '$id';", CONN_STR, FALSE ); + + // If a successful add, then reload page to display the newly added event. + if (($Option == 'Add New' || $Option == 'Update') && $r['status'] = true) { + + if (isset($r['id'])) { + $id = $r['id']; + } + + $url = THIS_SCRIPT.'?Action=Eve&Option=View&id='.$id; + echo ' + + + Reloading to re-display page + + + +
+

Reloading to re-display page with updated information.

+

If you are not immediately redirected, please click below.

+ Redisplay +
+ + + '; + exit; + + } + + + $v['body'] .= $r['text']; + + break; + + case "Eve_For_Edi": + + // Get info on the selected form + + if( !($reg_data = db_auto_get_row( "SELECT * FROM reg WHERE id = $id;", 0, CONN_STR, FALSE )) ) + { + $r['text'] = '
INTERNAL ERROR

Selected Form not found.

'; + break; + } + + $v['body'] .= $reg_data['name'].'

'; + + add_link_data( 'id', $id ); + add_link_data( 'Action', 'Eve_For_Edi' ); + add_form_data( 'id', $id ); + add_form_data( 'Action', 'Eve_For_Edi' ); + + $r = magic_form_edit( $id, $mf_format ); + + if( $r['modified'] ) + reg_db_auto_exec( "UPDATE reg SET form_revision = form_revision + 1 WHERE id = $id;" ); + + if( $r['success'] ) + $v['body'] .= '[Test this form]'.$r['text']; + else + $v['body'] .= 'Something really wrong with MagicForms'; + + break; + + // Test a form + + case "Eve_For_Edi_Tes": + + // Get info on the selected form + + if( !($reg_data = db_auto_get_row( "SELECT * FROM reg WHERE id = $id;", 0, CONN_STR, FALSE )) ) + { + $r['text'] = '

INTERNAL ERROR

Selected Form not found.

'; + break; + } + + $v['reg_name'] .= $reg_data['name'].'

'; + add_form_data( 'id', $id ); + + // Check for default data + + if( !empty($_REQUEST['field_data']) ) + $fd = unserialize( stripslashes($_REQUEST['field_data']) ); + else + $fd = ''; + + $r = magic_form_display( $id, $mf_styles, null, $fd ); + $v['magic_form'] .= $r['text']; + $v['required'] = ($r['required']?'Yes':'No'); + $v['problem'] = stripslashes($problem); + $qs_viewfile = 'form_edit_test.html'; + break; + + // Test a form + + case "Eve_For_Edi_Tes_Sub": + + // Get info on the selected form + + if( !($reg_data = db_auto_get_row( "SELECT * FROM reg WHERE id = $id;", 0, CONN_STR, FALSE )) ) + { + $r['text'] = '

INTERNAL ERROR

Selected Form not found.

'; + break; + } + + $v['reg_name'] .= $reg_data['name']; + add_form_data( 'id', $id ); + + // Get sumbitted data and use only a sub-set for sending back to display form. + + $r = magic_form_submit( $id ); + $d = array(); + foreach( $r['data'] as $key=>$val ) // Build array that's a subset of the submitted data, just what's required for re-displaying form + { + $d[$key] = array( 'id' => $val['id'], 'opt_num' => $val['opt_num'], 'value' => $val['value'] ); + } + $hs = get_html_translation_table( HTML_ENTITIES ) + array( '{' => '{', ' ' => ' ', '#' => '#', "\n" => ' ' ); + $v['return_data'] = ' + + + '; + $v['problem'] = $r['problem']; + $v['html'] = $r['html']; + $v['csv'] = $r['csv']; + $v['total_value'] = $r['total_value']; + + $qs_viewfile = 'form_edit_test_result.html'; + break; + + // Event Dates + + case 'Eve_Dat': + + // Function to build empty year $ds[{month}][{day_of_month}] + function dsEmptyYear($year) { + + $ds = array(); + $days = 365; + if (date('L', strtotime("1/1/$year"))) { + $days = 366; + } + for ($i=0; $i<$days; $i++) { + $t = strtotime("01/01/$year +".($i)." days"); + $m = date('n', $t); + $ds[$m][$t] = array( + 'time' => $t, + 'date' => date('m/d/Y', $t), + 'sel' => false + ); + } + return $ds; + } + + // Create one date cell for output - if $d = 0, then it's not a real date + function dsDay($d, $set) { + + $doy = date('z', $d); + $date = date('d',$d); + $monthClass = "dsMonth".date('M', $d); + $dayClass = $monthClass.date('D', $d); + + if ($d > 0) { + $day = ' +
+
'.$date.'
+ +
+ '; + } else { + $day = '
 
+ '; + } + return $day; + } + + // Build a month for output + function dsMonth($days) { + + $x = current($days); + $firstDay = date('w', $x['time']); + $monthName = date('F', $x['time']); + $monthClass = "dsMonth".date('M', $x['time']); + + $rows = 1; + + $month = ' +
+
+
'.$monthName.'
+
All
+
None
+
+
+
Sun
+
Mon
+
Tue
+
Wed
+
Thu
+
Fri
+
Sat
+
+
+ '; + + // Check if there's leading days + if ($firstDay != 0) { + for ($w=0 ; $w<$firstDay ; $w++) { + $month .= dsDay(0,false); + } + } + + // Display days in the month + foreach($days as $day) { + // Check for end of week + if ($w++ == 7) { + $month .= ' +
+
+ '; + $w = 1; + $rows++; + } + $month .= dsDay($day['time'], $day['sel']); + } + + // Check for trailing days + if ($w < 7) { + for ( ; $w<7 ; $w++) { + $month .= dsDay(0,false); + } + } + + $month .= ' +
+ '; + + if ($rows < 6) { + $month .= ' +
 
+ '; + } + + $month .= ' +
+ '; + + return $month; + } + + + // Get data from the event + $event_data = db_auto_get_row( "SELECT date_specific, use_calendar, date_select FROM reg WHERE id = $id;", 0, CONN_STR, FALSE ); + + // Not a valid operation if the event is date_specific + if ($event_data['date_specific'] == 't') { + + $v['body'] .= ' +

This '.ucfirst($config->event_registration->word->event).' is Date Specific.

+

No action required here.

+ '; + + break; + } + + // Not selected for this event + if ($event_data['use_calendar'] != 't') { + + $v['body'] .= ' +

This '.ucfirst($config->event_registration->word->event).' is not set to use the Dates Calendar feature.

+

No action required here.

+ '; + + break; + } + + // See if a year is supplied, if not, get current year + if (isset($_REQUEST['ds_year'])) { + $ds_year = ($_REQUEST['ds_year']-0); + } else { + $ds_year = date('Y'); + } + + // Try to break out any stored data + $ds_data = array(); + if ($event_data['date_select'] != '') { + $ds_data = unserialize($event_data['date_select']); + } + + // Check to see if a year delete has been requested + if ($Option == 'Delete Year') { + + if ($_REQUEST['deleteYear'] == 'Delete') { + unset($ds_data[$ds_year]); + reg_db_auto_exec( "UPDATE reg SET date_select = '".serialize($ds_data)."' WHERE id = $id;", 0, CONN_STR, FALSE ); + $v['body'] .= ' +

All dates for '.$ds_year.' have been deleted.

+ '; + break; + } + + $v['body'] .= ' +

Note: To delete a year you must enter exactly "Delete".

+ '; + } + + // Check to see if a year has just been submitted + $ds_in = $_REQUEST['day']; + if (is_array($ds_in)) { + // For each day supplied + while (list($key, $val) = each($ds_in)) { + $t = strtotime("01/01/$ds_year +".($key)." days"); + $m = date('n', $t); + + // Add it to the data array + $ds_data[$ds_year][$m][$t] = array( + 'time' => $t, + 'date' => date('m/d/Y', $t), + 'sel' => ($ds_in[$key] == 1) + ); + } + + // Store the entire data array back to the event + reg_db_auto_exec( "UPDATE reg SET date_select = '".serialize($ds_data)."' WHERE id = $id;", 0, CONN_STR, FALSE ); + + // Check if a previous or next year was requested + if ($Option == 'Previous Year') { + $ds_year--; + } elseif ($Option == 'Next Year') { + $ds_year++; + } elseif ($Option != 'Delete Year') { + + // This is just a submit, so say it's stored and be done with it. + $v['body'] .= ' +

'.ucfirst($config->event_registration->word->event).' Dates Submitted.

+ '; + break; + } + + } + + // Check to see if we have the selected year yet - if not, then create a blank one. + if (!isset($ds_data[$ds_year])) { + $ds_data[$ds_year] = dsEmptyYear($ds_year); + } + + $v['body'] .= ' + + +
+

Dates '.ucfirst($config->event_registration->word->event).' Occurs: '.$ds_year.'

+
+ + + +
+
+ + + +
+
+
+
Set all dates for this year
+
Clear all dates for this year
+
+
+ Enter "Delete" to delete this entire year:
+
+
+ '; + + // Build year display - process months + foreach($ds_data[$ds_year] as $m) { + $v['body'] .= dsMonth($m); + } + + $v['body'] .= " +
+
+
+
+
+ + "; + + break; + + + case 'Mem': + + // Check if a new password has been submitted + if (isset($_REQUEST['password_new']) && ($password = trim($_REQUEST['password_new'])) != '') { + + $pw_md5 = md5($password); + $reg_id = ($_REQUEST['id'] - 0); + reg_db_auto_exec( "UPDATE members.member SET member_passwd = '$pw_md5' WHERE member_id = $reg_id;", CONN_STR, FALSE ); + + } + + $member_fields = array + ( + 'member_id' => 'member_id, text.20, Memb ID, FALSE, member_id, vlf', + 'fname' => 'fname, text.40, First Name, TRUE, fname, vlf', + 'lname' => 'lname, text.40, Last Name, TRUE, lname, vlf', + 'member_id_e' => 'member_id, text.20, Memb ID, DISPLAY, member_id, e', + 'fname_e' => 'fname, text.40, First Name, DISPLAY, fname, e', + 'lname_e' => 'lname, text.40, Last Name, DISPLAY, lname, e', + 'city' => 'city, text.40, City, FALSE, city, vlf', + 'state' => 'state, text.5, State, FALSE, state, vlf', + 'zip' => 'zip, text.12, ZIP/Postal Code, FALSE, zip, vf', + 'phone' => 'phone, text.15, Phone Number, FALSE, phone, vf', + 'email' => 'email, text.40, E-Mail Address, TRUE, email, vf', + 'member_login' => 'member_login, text.15, Login, FALSE, member_login, vl', + 'password' => 'password_new, text.15, Password (Enter to change), FALSE, password_new, e', + ); + + $r = admin_process_records_r + ( + "members.member", // Table + '', // Where + 'lname, fname', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $member_fields, // Fields array + 'new,view,edit,filter,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Mem', // Action + '', // Passed parameter + 'Member', // Base Title + array(), // View string + $Option, // Option + $start, // Starting row for lists + '', // Other Options + '', // Title View + '', // Quick Tip + 'member_id' // ID Field + ); + + $v['body'] .= $r['text']; + + // If displaying detail, create link to go directly to registrations front-end for this user + if ($Option == 'View') { + + $v['body'] .= ' +
+
+ + + + + +
+
+ '; + + } + + break; + + case 'Use': + + // Check if a new password has been submitted + if (isset($_REQUEST['password_new']) && ($password = trim($_REQUEST['password_new'])) != '') { + + $pw_md5 = md5($password); + $reg_id = ($_REQUEST['id'] - 0); + reg_db_auto_exec( "UPDATE registrant SET password = '$pw_md5' WHERE id = $reg_id;", CONN_STR, FALSE ); + + } + + $user_fields = array + ( + 'id' => 'id, int, Registered User #, DISPLAY, id, ev', + 'id_l' => 'id, int, User #, DISPLAY, id, l', + 'is_member' => 'is_member, checkbox, Member, FALSE, is_member, vlf', + 'member_id' => 'member_id, text.20, Memb ID, FALSE, member_id, vlf', + 'fname' => 'fname, text.40, First Name, TRUE, fname, naeuvlf', + 'lname' => 'lname, text.40, Last Name, TRUE, lname, naeuvlf', + 'addr1' => 'addr1, text.40, Address, FALSE, addr1, naeuv', + 'addr2' => 'addr2, text.40, Address, FALSE, addr2, naeuv', + 'city' => 'city, text.40, City, FALSE, city, naeuvl', + 'state' => 'state, text.5, State, FALSE, state, naeuv', + 'zip' => 'zip, text.12, ZIP/Postal Code, FALSE, zip, naeuv', + 'zip_l' => 'zip, text.12, ZIP, FALSE, zip, l', + 'country' => 'country, text.10, Country, FALSE, country, naeuv', + 'winder_addr' => 'winter_addr, text.40, Winter Address, FALSE, winter_addr, naeuv', + 'phone' => 'phone, text.15, Phone Number, FALSE, phone, naeuvlf', + 'email' => 'email, text.40, E-Mail Address, TRUE, email, naeuvf', + 'b2' => ', break.Note that the E-Mail address must be unique.
+ There cannot be two registered users with the same E-Mail address., , FALSE, , ev', + 'email_l' => 'email, text.40, E-Mail, TRUE, email, l', + 'password' => 'password_new, text.15, Password
Enter to change, FALSE, password_new, e', + 'email_ok' => 'email_ok, checkbox, OK to send E-Mail, FALSE, email_ok, naeuv', + 'user_trace_info' => 'user_trace_info, text, User Tracking Info, FALSE, user_trace_info,v' + ); + + if (!$config->event_registration->have_members) { + unset($user_fields['is_member']); + unset($user_fields['member_id']); + } + + $r = admin_process_records_r + ( + "registrant", // Table + '', // Where + 'lname, fname', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $user_fields, // Fields array + 'new,view,edit,delete,strong,filter,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Use', // Action + '', // Passed parameter + 'Registered User', // Base Title + array(), // View string + $Option, // Option + $start // Starting row for lists + ); + + $v['body'] .= $r['text']; + + // If displaying detail, create link to go directly to registrations front-end for this user + if ($Option == 'View') { + + // Get the needed user information + $sql = " + SELECT is_member, member_id + FROM registrations.registrant + WHERE id = $id + ;"; + $user_data = db_auto_get_row($sql, 0, CONN_STR, FALSE); + + // If the + $member_id = ''; + if ($user_data['is_member'] == 't') { + $member_id = $user_data['member_id']; + } + + $v['body'] .= ' +
+
+ + + + + + +
+
+ '; + + } + + break; + + + case "Reg_Att": + + $id = ($id-0); + + if ($id == 0) + break; + + $reason = array(); + + // Check if updated data is being submitted + if ($_REQUEST['Option'] == 'Update') { + + $att_data = array(); + + // Scan submitted data + while (list($key, $val) = each($_REQUEST)) { + + // If it's an attendee name field + if (substr($key, -5) == '_name') { + + // att_{cart_id}_{attendee_id}_name + $a = explode("_", $key); + + // Sanitize input + $s = 'att_'.$a[1].'_'.$a[2].'_'; + $name = filter_input(INPUT_POST, $s.'name', FILTER_SANITIZE_STRING); + $dob = filter_input(INPUT_POST, $s.'dob', FILTER_SANITIZE_STRING); + $guardian = filter_input(INPUT_POST, $s.'guardian', FILTER_SANITIZE_STRING); + $emer_contact = filter_input(INPUT_POST, $s.'emer_contact', FILTER_SANITIZE_STRING); + $emer_phone = filter_input(INPUT_POST, $s.'emer_phone', FILTER_SANITIZE_STRING); + $med_history = filter_input(INPUT_POST, $s.'med_history', FILTER_SANITIZE_STRING); + $allergy_med = filter_input(INPUT_POST, $s.'allergy_med', FILTER_SANITIZE_STRING); + + // If delete is not requested or there's a name - otherwise we just don't processes it. + if ($_REQUEST['att_'.$a[1].'_'.$a[2].'_delete'] == '' && $name != '' ) { + + if ($_REQUEST[$s."med_required"] == 'true') { + + if (empty($dob)) { + $reason[]['text'] = "DOB is required for $name."; + } + if (empty($emer_contact)) { + $reason[]['text'] = "Emergency contact is required for $name."; + } + if (empty($emer_phone)) { + $reason[]['text'] = "Emergency phone is required for $name."; + } + } + + $attendee_id = count($att_data[$a[1]]) + 1; + $att_data[$a[1]][$attendee_id] = array( + 'attendee_id' => $attendee_id, + 'name' => $name, + 'dob' => $dob, + 'guardian' => $guardian, + 'emer_contact' => $emer_contact, + 'emer_phone' => $emer_phone, + 'med_history' => $med_history, + 'allergy_med' => $allergy_med + ); + } + } + } + + // Store the updated attendee information - Even if there's problems with the submission + while (list($key, $val) = each($att_data)) { + + // Get the current number attending for this activity detail record + $detail_data = db_auto_get_row( "SELECT registration, numb_attending, R.attendee_limit FROM reg_detail D, reg R WHERE D.id = $key AND R.id = D.registration;", 0, SI_CONN_STR, FALSE ); + + // Serialize the new attendee data for storage + $numb_attending = count($val); + $attendees = serialize($val); + $sql = " + UPDATE reg_detail + SET numb_attending = $numb_attending, + attendees = '".addslashes($attendees)."' + WHERE id = $key; + "; + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + + // Now update the reg attendee numbers accordingly, but only if the registrations are limited + if ($detail_data['attendee_limit'] == 't') { + $diff = $numb_attending - $detail_data['numb_attending']; + $sql = " + UPDATE reg + SET attendee_count = attendee_count + $diff + WHERE id = ".$detail_data['registration']."; + "; + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + } + } + + } + + // If there's no submission problems or just displaying edit form for the first time + if ($_REQUEST['Option'] != 'Update' || count($reason) > 0) { + + // Get data for this registration + $reg_data = db_auto_get_row( "SELECT lname, fname, date_entered, status FROM reg_req WHERE id = $id;", 0, SI_CONN_STR, FALSE ); + if ($config->event_registration->sub_categories) { + $sql = " + SELECT D.*, R.name as RegName, T.med_info + FROM reg_detail D, reg R, category C, todo T + WHERE D.reg_req = $id + AND R.id = D.registration + AND C.id = R.category + AND T.id = C.todo + ORDER BY R.name, D.id + ;"; + } else { + $sql = " + SELECT D.*, R.name as RegName, T.med_info + FROM reg_detail D, reg R, todo T + WHERE D.reg_req = $id + AND R.id = D.registration + AND T.id = R.category + ORDER BY R.name, D.id + ;"; + } + $reg_detail = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE ); + + // If we have some events listed + if (is_array($reg_detail) && count($reg_detail) > 0) { + + $t['have_regs'] = 'YES'; + + // Build attendee arrays + while (list($key, $val) = each($reg_detail)) { + + // Try to unserialize the attendees (new style) + $a = unserialize(stripslashes($val['attendees'])); + + // If successful + if ($a) { + $reg_detail[$key]['attendee_array'] = $a; + + // Otherwise it's the old "," separated list + } else { + $a = explode(",", $val['attendees']); + $reg_detail[$key]['attendee_array'] = array(); + $a_id = 0; + foreach ($a as $att) { + + // Create a detail array entry for each attendes (id=0 means not stored yet) + $reg_detail[$key]['attendee_array'][] = array( + 'attendee_id' => ++$a_id, + 'name' => $att, + 'dob' => $val['dob'], + 'guardian' => $val['guardian'], + 'emer_contact' => $val['emer_contact'], + 'emer_phone' => $val['emer_phone'], + 'med_history' => $val['med_history'], + 'allergy_med' => $val['allergy_med'] + ); + } + } + + // Create a new detail array entry for a possible additional attendee + $reg_detail[$key]['attendee_array'][] = array( + 'attendee_id' => count($reg_detail[$key]['attendee_array']) + 1, + 'name' => '', + 'dob' => '', + 'guardian' => '', + 'emer_contact' => '', + 'emer_phone' => '', + 'med_history' => '', + 'allergy_med' => '' + ); + + // Now drop the old contact/med info since we don't need it anymore and it interferes with the new view parameters + unset($reg_detail[$key]['dob']); + unset($reg_detail[$key]['guardian']); + unset($reg_detail[$key]['emer_contact']); + unset($reg_detail[$key]['emer_phone']); + unset($reg_detail[$key]['med_history']); + unset($reg_detail[$key]['allergy_med']); + } + } else { + $t['have_regs'] = 'NO'; + } + + // Display Attendee Edit Form + $tags = $view_tags; + $t =& $tags["global"]; + + $t['this_script'] = THIS_SCRIPT; + + // Check for failure reason + if (count($reason) > 0) { + $tags['reason'] = $reason; + $t['have_reason'] = 'YES'; + } else { + $t['have_reason'] = 'NO'; + } + + $t['reg_id'] = $id; + $t['lname'] = $reg_data['lname']; + $t['fname'] = $reg_data['fname']; + $t['date_entered'] = $reg_data['date_entered']; + $t['status'] = $si_reg_status_types[$reg_data['status']]; + $tags['detail'] = $reg_detail; + $v['body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "edit_attendees.html", $tags, 'FALSE' ); + break; + } + // Falls through if there's a good attendee submission + + case "Reg": + + // If updating + if( $Option == 'Update' ) + { + // Get needed registration data + $sql = "SELECT status + FROM reg_req + WHERE reg_req.id = $id + ;"; + $reg_data = db_auto_get_row( $sql, 0, CONN_STR, FALSE ); + + // Get registration detail for all events (cart entries) in this request + $sql = " + SELECT D.*, R.need_attendees + FROM reg_detail D, reg R + WHERE D.reg_req = $id + AND R.id = D.registration + ORDER BY D.id + ;"; + $reg_detail = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE ); + + // If there's at least one event registered + if (count($reg_detail) > 0) { + + // Check if canceling a registration that's not been canceled + if( $status == SI_REG_STATUS_CANCELED && $reg_data['status'] != SI_REG_STATUS_CANCELED) { + + $sql = ''; + reset($reg_detail); + foreach ($reg_detail as $rd) { + + // If the event counts attendees + if ($rd['need_attendees'] == 't') { + + // Decriment attendees by the number in this registration + $sql .= "UPDATE reg SET attendee_count = attendee_count - ".$rd['numb_attending']." WHERE id = ".$rd['registration'].";\n"; + } + } + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + + // check if un-canceling a registration + } elseif( $status != SI_REG_STATUS_CANCELED && $reg_data['status'] == SI_REG_STATUS_CANCELED) { + + $sql = ''; + reset($reg_detail); + foreach ($reg_detail as $rd) { + + // If the event counts attendees + if ($rd['need_attendees'] == 't') { + + // Incriment attendees by the number in this registration + $sql .= "UPDATE reg SET attendee_count = attendee_count + ".$rd['numb_attending']." WHERE id = ".$rd['registration'].";\n"; + } + } + reg_db_auto_exec( $sql, CONN_STR, FALSE ); + + } + + } // if there's at least one event registerred + + // If confirming credit card paymnet + $send_conf = false; + if( $status == SI_REG_STATUS_CC_PAID && $reg_data['status'] == SI_REG_STATUS_CC_PEND ) + { + if( empty($cc_conf) ) + { + $v['body'] .= '

Credit Card Confirmation # Required

+ Please include a confirmation number when confirming a credit card paymnet.

+ '; + $status = SI_REG_STATUS_CC_PEND; + } + else + { + $_REQUEST['cc_numb'] = "....... ".substr( $_REQUEST['cc_numb'], -4 ); + $send_conf = true; + + } + } // If confirming credit card paymnet + + if( $reg_data['attendee_count'] > $reg_data['attendee_max'] ) + echo '

Warning: '.$v['attendeeTermCap'].' limit for this convention exceeded.

+ '; + } // If updating + + // If sort order hasn't been selected, check on default in config file. + if (!isset($GLOBALS['sortclicked']) && !isset($GLOBALS['sortclicked_new'])) { + if ($config->event_registration->admin_opt->Submissions->sort_field != '') { + $GLOBALS['sortclicked'] = $config->event_registration->admin_opt->Submissions->sort_field; + } + if ($config->event_registration->admin_opt->Submissions->sort_direction != '') { + $GLOBALS['list_sort_direction'] = $config->event_registration->admin_opt->Submissions->sort_direction; + } + } + + // Check if status hasn't been defined and provide default + if (!isset($_REQUEST['status']) && $config->event_registration->admin_opt->Submissions->status != '') { + $x = explode(",", $config->event_registration->admin_opt->Submissions->status); + $_REQUEST['status'] = array(); + foreach($x as $y) { + if (isset($si_reg_status_array[trim($y)])) { + $status[] = $si_reg_status_array[trim($y)]; + } + } + $_REQUEST['status'] = $status; + } + + $reg_fields = array + ( + 'id' => 'id, int, Reg #, DISPLAY, id, evlf', + 'user_trace_info' => 'user_trace_info, text, User Tracking Info, FALSE, user_trace_info, v', + 'date_entered' => 'date_entered, date, Date Submitted, FALSE, date_entered, f', + 'date_entered_l' => 'date_entered, date, Submitted, FALSE, date_entered, l', + 'b0' => ', break.

Submitted By:

, , FALSE, , ev', + 'fname' => 'fname, text.40, First Name, FALSE, fname, euvlf', + 'lname' => 'lname, text.40, Last Name, FALSE, lname, euvlf', + 'org' => 'org, text.40, Company/Organization, FALSE, org, euvf', + 'org_l' => 'org, text.40, Org, FALSE, org, l', + 'title' => 'title, text.20, Title, FALSE, title, euv', + 'addr1' => 'addr1, text.40, Address, FALSE, addr1, euv', + 'addr2' => 'addr2, text.40, Address, FALSE, addr2, euv', + 'city' => 'city, text.40, City, FALSE, city, euv', + 'state' => 'state, text.5, State, FALSE, state, euv', + 'zip' => 'zip, text.12, ZIP/Postal Code, FALSE, zip, euv', + 'country' => 'country, text.10, Country, FALSE, country, euv', + 'phone' => 'phone, text.15, Phone Number, FALSE, phone, euv', + 'fax' => 'fax, text.15, FAX Number, FALSE, fax, euv', + 'b1' => ', break.

'.$config->event_registration->titles->contact_information.':

, , FALSE, , ev', + 'contact_fname' => 'contact_fname, text.40, '.$config->event_registration->prompt->contact_fname.', FALSE, contact_fname, euvf', + 'contact_lname' => 'contact_lname, text.40, '.$config->event_registration->prompt->contact_lname.', FALSE, contact_lname, euvf', + 'contact_addr1' => 'contact_addr1, text.40, '.$config->event_registration->prompt->contact_addr1.', FALSE, contact_addr1, euv', + 'contact_addr2' => 'contact_addr2, text.40, '.$config->event_registration->prompt->contact_addr2.', FALSE, contact_addr2, euv', + 'contact_city' => 'contact_city, text.40, '.$config->event_registration->prompt->contact_city.', FALSE, contact_city, euv', + 'contact_state' => 'contact_state, text.5, '.$config->event_registration->prompt->contact_state.', FALSE, contact_state, euv', + 'contact_zip' => 'contact_zip, text.12, '.$config->event_registration->prompt->contact_zip.', FALSE, contact_zip, euv', + 'contact_country' => 'contact_country, text.10, '.$config->event_registration->prompt->contact_country.', FALSE, contact_country, euv', + 'contact_phone' => 'contact_phone, text.15, '.$config->event_registration->prompt->contact_phone.', FALSE, contact_phone, euv', + 'contact_fax' => 'contact_fax, text.15, '.$config->event_registration->prompt->contact_fax.', FALSE, contact_fax, euv', + 'b11' => ', break.

Other Information:

, , FALSE, , ev', + 'email' => 'email, text.40, E-Mail Address, FALSE, email, euv', + 'email_ok' => 'email_ok, checkbox, OK to send E-Mail, FALSE, email_ok, euv', + 'b2' => ', break.

Member Information:


, , FALSE, , ev', + 'is_member' => 'is_member, checkbox, Member, FALSE, is_member, euvlf', + 'member_id' => 'member_id, text.10, Memb ID, FALSE, member_id, euvlf', + 'b3' => ', break.

Charges and Payment:


, , FALSE, , ev', + 'total' => 'total, money, Total charges, FALSE, total, euv', + 'status' => 'status, list.'.$si_reg_status_list.', Status, FALSE, status, euvl', + 'status_f' => 'status, list.'.$si_reg_status_list.'..multi~blank, Status, FALSE, status, f', + 'b4' => ', break.Credit Card Conf # required when confirming credit card., , FALSE, , e', + 'b5' => ', break.

Credit Card Information

, , FALSE, , ev', + 'cc_name' => 'cc_name, text.40, Name on Credit Card, FALSE, cc_name, euv', + 'cc_numb' => 'cc_numb, text.20, Credit Card Number, FALSE, cc_numb, euv', + 'cc_exp' => 'cc_exp, text.10, Credit Card Expiration, FALSE, cc_exp, euv', + 'cc_cvv' => 'cc_cvv, text.10, Credit Card CVV #, FALSE, cc_cvv, euv', + 'cc_conf' => 'cc_conf, text.20, Credit Card Conf #, FALSE, cc_conf, euvf', + 'b6' => ', break.
, , FALSE, , ev', + 'notes' => 'notes, textbox.40.5, Notes, FALSE, notes, euv' +// 'summary' => 'summary, rawtext, Original Stored Summary, FALSE, summary, v' + ); + + + if (!$config->event_registration->show_contact_data) { + unset($reg_fields['b1']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_fname == '') { + unset($reg_fields['contact_fname']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_lname == '') { + unset($reg_fields['contact_lname']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_addr1 == '') { + unset($reg_fields['contact_addr1']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_addr2 == '') { + unset($reg_fields['contact_addr2']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_city == '') { + unset($reg_fields['contact_city']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_state == '') { + unset($reg_fields['contact_state']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_zip == '') { + unset($reg_fields['contact_zip']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_country == '') { + unset($reg_fields['contact_country']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_phone == '') { + unset($reg_fields['contact_phone']); + } + if (!$config->event_registration->show_contact_data || $config->event_registration->prompt->contact_fax == '') { + unset($reg_fields['contact_fax']); + } + + if (!$config->event_registration->have_members) { + unset($reg_fields['b2']); + unset($reg_fields['is_member']); + unset($reg_fields['member_id']); + } + + $r = admin_process_records_r + ( + "reg_req", // Table + '', // Where + 'date_entered, id', // Order fields + CONN_STR, // Connect String + $id, // Current ID + $reg_fields, // Fields array + 'view,edit,filter,sortlinks', // Options + 20, // Rows + THIS_SCRIPT, // URL + 'Reg', // Action + '', // Passed parameter + 'Submissions', // Base Title + array(), // View string + $Option, // Option + $start // Starting row for lists + ); + + // If need to send confirmation to customer + if ($send_conf) { + + // Send confirmation to Customer + + $req_data = db_auto_get_row( "SELECT * FROM reg_req WHERE id = $id;", 0, CONN_STR, FALSE ); + + $v['checkout_type'] = 'Confirmation'; + $v['request_numb'] = $req_data['id']; + $v['fname'] = $req_data['fname']; + $v['lname'] = $req_data['lname']; + $v['org'] = $req_data['org']; + $v['title'] = $req_data['title']; + $v['addr1'] = $req_data['addr1']; + $v['addr2'] = $req_data['addr2']; + $v['city'] = $req_data['city']; + $v['state'] = $req_data['state']; + $v['zip'] = $req_data['zip']; + $v['country'] = $req_data['country']; + $v['phone'] = $req_data['phone']; + $v['fax'] = $req_data['fax']; + $v['email'] = $req_data['email']; + $v['total'] = money($req_data['total']); + $v['cc_type'] = $req_data['cc_type']; + $v['cc_name'] = $req_data['cc_name']; + $v['cc_numb'] = $req_data['cc_numb']; + $v['cc_conf'] = $req_data['cc_conf']; + $v['cc_exp'] = $req_data['cc_exp']; + $v['html_summary'] = $req_data['summary']; + + $html_summary = parse_view_localcheck($config->event_registration->custom_view_files, "registrations_cc_confirmation.html", $view_tags ); + $email_content = "--ContentBoundry\n" + ."Content-Type: text/plain; charset=\"US-ASCII\"\n" + ."\n" + .( SI_CUST_EMAIL_MODE == 3 ? $text_summary : "This message may only be read using an HTML enabled E-Mail client." ) + ."\n" + ."--ContentBoundry\n" + ."Content-Type: text/html; charset=\"US-ASCII\"\n" + ."\n" + .$html_summary + ."\n" + ."--ContentBoundry--\n" + ."\n"; + if( !empty($req_data['email']) ) { + debug_mail( $req_data['email'], $config->event_registration->organization." Payment Confirmation", "$email_content.", "From: ".$config->event_registration->organization." <".$config->event_registration->organization_from_email.">" + ."\nMime-Version: 1.0\nContent-Type: multipart/alternative; boundary=ContentBoundry\n"); + } + } + + // If Option is View, then display current attendee and original summary information + if ($Option == 'View' || $Option == 'Update') { + + // Get the summary + $reg_data = db_auto_get_row( "SELECT summary FROM reg_req WHERE reg_req.id = $id;", 0, CONN_STR, FALSE ); + + // Get the attendee information + if ($config->event_registration->sub_categories) { + $sql = " + SELECT D.*, R.name as RegName, T.med_info + FROM reg_detail D, reg R, category C, todo T + WHERE D.reg_req = $id + AND R.id = D.registration + AND C.id = R.category + AND T.id = C.todo + ORDER BY R.name, D.id + ;"; + } else { + $sql = " + SELECT D.*, R.name as RegName, T.med_info + FROM reg_detail D, reg R, todo T + WHERE D.reg_req = $id + AND R.id = D.registration + AND T.id = R.category + ORDER BY R.name, D.id + ;"; + } + $reg_detail = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE ); + + // If we have some events listed + $t['have_regs'] = 'NO'; + + if (is_array($reg_detail) && count($reg_detail) > 0) { + + $t['have_regs'] = 'YES'; + + // Build attendee arrays + while (list($key, $val) = each($reg_detail)) { + + // Try to unserialize the attendees (new style) + $a = unserialize(stripslashes($val['attendees'])); + // If successful + if ($a) { + $reg_detail[$key]['attendee_array'] = $a; + + // Otherwise it's the old "," separated list + } else { + $a = explode(",", $val['attendees']); + $reg_detail[$key]['attendee_array'] = array(); + $a_id = 0; + foreach ($a as $att) { + + // Create a detail array entry for each attendes + $reg_detail[$key]['attendee_array'][] = array( + 'attendee_id' => ++$a_id, + 'name' => $att, + 'dob' => $val['dob'], + 'guardian' => $val['guardian'], + 'emer_contact' => $val['emer_contact'], + 'emer_phone' => $val['emer_phone'], + 'med_history' => $val['med_history'], + 'allergy_med' => $val['allergy_med'] + ); + } + } + + // Now drop the old contact/med info since we don't need it anymore and it interferes with the new view parameters + unset($reg_detail[$key]['dob']); + unset($reg_detail[$key]['guardian']); + unset($reg_detail[$key]['emer_contact']); + unset($reg_detail[$key]['emer_phone']); + unset($reg_detail[$key]['med_history']); + unset($reg_detail[$key]['allergy_med']); + + // Additional things we need to pass + $reg_detail[$key]['date_specific'] = ($val['date_specific']=='t' ? 'YES' : 'NO'); + } + + } + + // Display Attendee View + $tags = $view_tags; + $t =& $tags["global"]; + $tags['detail'] = $reg_detail; + + // Add original summary to view + $t['summary'] = stripslashes($reg_data['summary']); + $r['text'] .= parse_view_localcheck($config->event_registration->custom_view_files, "view_attendees.html", $tags, 'FALSE' ); + + } + + $v['body'] .= $r['text']; + + break; + + case "Rep": + + if ($Option == '') { + $Option = 'Select Report'; + } + + $tags = $view_tags; + $t =& $tags["global"]; + $t['this_script'] = THIS_SCRIPT; + $t['PrintReport'] = ($_REQUEST['PrintReport'] == 'Yes' ? 'YES' : 'NO'); + $t['members'] = ($config->event_registration->have_members ? 'YES' : 'NO'); + $t['date_time'] = date('l m/d/Y g:i:s'); + $t['med_info_on'] = ($config->event_registration->medical_info ? 'YES' : 'NO'); + + $by_activity_date = ($_REQUEST['by_activity_date'] == 'on'); + $t['by_activity_date'] = ($by_activity_date ? 'CHECKED': ''); + $by_registration_date = ($_REQUEST['by_registration_date'] == 'on'); + $t['by_registration_date'] = ($by_registration_date ? 'CHECKED': ''); + $by_desired_date = ($_REQUEST['by_desired_date'] == 'on'); + $t['by_desired_date'] = ($by_desired_date ? 'CHECKED': ''); + + $reason = array(); + $t['reason_text'] = ''; + + // This is for links to print reports + $t['print_params'] = + 'Action=Rep&Option=Display+Report' + .'&event='.$_REQUEST['event'] + .'&status='.$_REQUEST['status'] + .'&output_by='.$_REQUEST['output_by'] + .'&sort_by='.$_REQUEST['sort_by'] + .'&output_type='.$_REQUEST['output_type'] + .'&activity_start_date='.$_REQUEST['activity_start_date'] + .'&activity_end_date='.$_REQUEST['activity_end_date'] + .'®istration_start_date='.$_REQUEST['registration_start_date'] + .'®istration_end_date='.$_REQUEST['registration_end_date'] + .'&admin_user='.$_REQUEST['admin_user'] + .'&is_member='.$_REQUEST['is_member'] + .'&member_id='.$_REQUEST['member_id'] + .'&dyn_data='.$_REQUEST['dyn_data'] + ; + + $act_start_date = ''; + $act_end_date = ''; + $reg_start_date = ''; + $reg_end_date = ''; + $desired_start_date = ''; + $desired_end_date = ''; + + // Do some checks on Display Report + if ($Option == 'Display Report') { + + // Check Activity Date range + $act_start_date = strtotime($_REQUEST['activity_start_date']); + $act_end_date = strtotime($_REQUEST['activity_end_date']); + if ($act_end_date < $act_start_date) { + $reason[] = 'Activity End Date cannot be earlier than Activity Start Date'; + } + + // Check registration date range + $reg_start_date = strtotime($_REQUEST['registration_start_date']); + $reg_end_date = strtotime($_REQUEST['registration_end_date']); + if ($reg_end_date < $reg_start_date) { + $reason[] = 'Registration End Date cannot be earlier than Registration Start Date'; + } + + // Check registration date range + $desired_start_date = strtotime($_REQUEST['desired_start_date']); + $desired_end_date = strtotime($_REQUEST['desired_end_date']); + if ($desired_end_date < $desired_start_date) { + $reason[] = 'Desired End Date cannot be earlier than Desired Start Date'; + } + + if (count($reason) > 0) { + $Option = 'Select Report'; + } + } + + // Report steps + switch( $Option ) { + + case 'Select Report': + + // Get registrations list - what we get depens on whether there's categories and sub-categories + // If there's both main and sub categories + if ($config->event_registration->main_categories && $config->event_registration->sub_categories) { + $sql = " + SELECT R.id AS reg_id, R.name AS reg_name, T.id AS cat_id, T.name AS cat_name, C.id AS subcat_id, C.name AS subcat_name + FROM reg R, todo T, category C + WHERE C.id = R.category + AND T.id = C.todo + ORDER BY T.name, C.name, R.name; + "; + } elseif ($config->event_registration->main_categories && !$config->event_registration->sub_categories) { + $sql = " + SELECT R.id AS reg_id, R.name AS reg_name, T.id AS cat_id, T.name AS cat_name, '' AS subcat_name + FROM reg R, todo T + WHERE T.id = R.category + ORDER BY T.name, R.name; + "; + } else { + $sql = " + SELECT R.id AS reg_id, R.name AS reg_name, '' AS cat_name, '' AS subcat_name + FROM reg R + ORDER BY R.name; + "; + + } + $reg_data = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE ); + + if(!is_array($reg_data) || count($reg_data) < 1) + { + $v['body'] .= ' + Reports - Alpha by Registrant +

+

No '.$v['registrationsTerm'].' currently in database.

+ '; + break; + } + + // Build activity selection data + $reg = ' + '; + + + // Build status selection data + $status_types = + array( + 101 => 'All Submitted', + 102 => 'All Paid', + 103 => 'All Unpaid' + ) + + $si_reg_status_types; + + $reason_text = ''; + if (count($reason) > 0) { + $reason_text = '

You have been returned to this step because ...

    '; + foreach ($reason as $r) { + $reason_text .= "
  • $r
  • "; + } + $reason_text .= '
s'; + } + + $t['reason_text'] = $reason_text; + $t['THIS_SCRIPT'] = SI_THIS_SCRIPT; + $t['reg_select'] = $reg; + $t['status_select'] = reg_build_picklist( "status", $status_types, '101', '' ); + $t['activity_start_date'] = calendar_date_select( + '6/1/2011', // Default value + $act_start_date, // Selected Date + strtotime('6/1/2011'), // Start Date + strtotime(date('m/d/Y').' +2 year'), // End Date + 'report_selection', // Form Name + 'activity_start_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + $t['activity_end_date'] = calendar_date_select( + strtotime(date('m/d/Y').' +2 year'), // Default value + $act_end_date, // Selected Date + strtotime('6/1/2011'), // Start Date + strtotime(date('m/d/Y').' +2 year'), // End Date + 'report_selection', // Form Name + 'activity_end_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + $t['reg_start_date'] = calendar_date_select( + '6/1/2011', // Default value + $reg_start_date, // Selected Date + strtotime('6/1/2011'), // Start Date + time(), // End Date + 'report_selection', // Form Name + 'registration_start_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + $t['reg_end_date'] = calendar_date_select( + date('m/d/Y'), // Default value + $reg_end_date, // Selected Date + strtotime('6/1/2011'), // Start Date + time(), // End Date + 'report_selection', // Form Name + 'registration_end_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + $t['desired_start_date'] = calendar_date_select( + '6/1/2011', // Default value + $desired_start_date, // Selected Date + strtotime('6/1/2011'), // Start Date + time(), // End Date + 'report_selection', // Form Name + 'desired_start_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + $t['desired_end_date'] = calendar_date_select( + strtotime(date('m/d/Y').' +2 year'), // Default value + $desired_end_date, // Selected Date + strtotime('6/1/2011'), // Start Date + strtotime(date('m/d/Y').' +2 year'), // End Date + 'report_selection', // Form Name + 'desired_end_date', // Field Name + 'TEXT' // Options - NO_PROMPT, TEXT, PICK, HIDE_YEAR + ); + + $v['body'] .= parse_view_localcheck($config->event_registration->custom_view_files, 'report_request.html', $tags, 'FALSE' ); + break; + + case "Display Report": + + $v['date_time'] = date('l m/d/Y g:i:s'); + $v['med_info_on'] = ($config->event_registration->medical_info ? 'YES' : 'NO'); + + $reporting = array(); + $out = ''; + + // Check for Dynamic Form Data display + $display_dyn_data = false; + if ($_REQUEST['dyn_data'] == 'on') { + $display_dyn_data = true; + } + $display_ids = false; + if ($_REQUEST['show_id'] == 'on') { + $display_ids = true; + } + + // Separate possible "cat_" or "subcat_" from front of event id + $e = explode('_',$_REQUEST['event']); + + // If a category was specified + if ($e[0] == 'cat') { + $cat_id = ($e[1] - 0); + if ($cat_id > 0) { + $event_query = " AND T.id = $cat_id"; + } + $display_dyn_data = false; // only available with single events + + // Otherwise if a sub-category was specified + } elseif ($e[0] == 'subcat') { + $subcat_id = ($e[1] - 0); + if ($subcat_id > 0) { + $event_query = " AND C.id = $subcat_id"; + } + $display_dyn_data = false; // only available with single events + + // Otherwise, it's just an event id + } else { + $event_id = ($e[0] - 0); + if ($event_id > 0) { + $event_query = " AND D.registration = $event_id"; + } + } + + // Get all form fields for selected event/activity + if ($display_dyn_data) { + $dyn_form_field_titles = magic_form_get_fields($event_id); + + // If we got fields, build text field names for possible use in output + if (count($dyn_form_field_titles) > 0) { + while (list($key, $val) = each($dyn_form_field_titles)) { + // If we're using ids rather than titles + if ($display_ids) { + $n = 'mf_'.$val['id']; + if ($val['custom_id'] != null) { + $n = $val['custom_id']; + } + $dyn_form_field_titles[$key]['title'] = stripslashes($n); + } + // provide an empty value for output + $dyn_form_field_titles[$key]['value'] = ''; + } + } + } + + // Selection of registration entries to report on + switch( $_REQUEST['status'] ) { + + // Undefined + case SI_REG_STATUS_UNDEFINED: + break; + + // All Submitted + case 101: + $status_query .= " AND (R.status != ".SI_REG_STATUS_FAILED." AND R.status != ".SI_REG_STATUS_CANCELED.")"; + $reporting[] = 'All Submitted'; + break; + + // All Paid + case 102: + $status_query .= " AND (R.status = ".SI_REG_STATUS_CC_PAID." OR R.status = ".SI_REG_STATUS_CHECK_PAID." OR R.status = ".SI_REG_STATUS_CALL_FROM_MERCHANT_PAID." OR R.status = ".SI_REG_STATUS_COMP.")"; + $reporting[] = 'All Paid'; + break; + + // All Unpaid + case 103: + $status_query .= " AND (R.status = ".SI_REG_STATUS_CC_PEND." OR R.status = ".SI_REG_STATUS_CHECK_PEND." OR R.status = ".SI_REG_STATUS_CALL_FROM_MERCHANT_PEND." OR R.status = ".SI_REG_STATUS_AT_EVENT.")"; + $reporting[] = 'All Paid'; + break; + + // CC Paid + case SI_REG_STATUS_CC_PAID: + $status_query .= " AND R.status = ".SI_REG_STATUS_CC_PAID; + $reporting[] = 'Credit Card Paid'; + break; + + // Check Pending + case SI_REG_STATUS_CHECK_PEND: + $status_query .= " AND R.status = ".SI_REG_STATUS_CHECK_PEND; + $reporting[] = 'Check Pending'; + break; + + // Check Paid + case SI_REG_STATUS_CHECK_PAID: + $status_query .= " AND R.status = ".SI_REG_STATUS_CHECK_PAID; + $reporting[] = 'Paid by Check'; + break; + + // Call from Merchant Pending + case SI_REG_STATUS_CALL_FROM_MERCHANT_PEND: + $status_query .= " AND R.status = ".SI_REG_STATUS_CALL_FROM_MERCHANT_PEND; + $reporting[] = 'Call from Merchant Pending'; + break; + + // Call from Merchant Paid + case SI_REG_STATUS_CALL_FROM_MERCHANT_PAID: + $status_query .= " AND R.status = ".SI_REG_STATUS_CALL_FROM_MERCHANT_PAID; + $reporting[] = 'Paid via Call from Merchant'; + break; + + // Complementary + case SI_REG_STATUS_COMP: + $status_query = " AND R.status = ".SI_REG_STATUS_COMP; + $reporting[] = 'Complimentary'; + break; + + // Pay at Event + case SI_REG_STATUS_AT_EVENT: + $status_query = " AND R.status = ".SI_REG_STATUS_AT_EVENT; + $reporting[] = 'Pay at Event'; + break; + + // Canceled + case SI_REG_STATUS_CANCELED: + $status_query = " AND R.status = ".SI_REG_STATUS_CANCELED; + $reporting[] = 'Canceled'; + break; + + default: + echo "ERROR: Bad status field value from form submission."; + exit; + break; + } + + $date_query = ''; + + // Selection by Activity date + if ($by_activity_date) { + $date_query .= " + AND D.reg_end >= '".date('m/d/Y', $act_start_date)."' + AND D.reg_start <= '".date('m/d/Y', $act_end_date)."' + "; + } + + // Selection by Registration date + if ($by_registration_date) { + $date_query .= " + AND R.date_entered BETWEEN '".date('m/d/Y', $reg_start_date)."' AND '".date('m/d/Y', $reg_end_date)."' + "; + } + + // Selection by Desired date + if ($by_desired_date) { + $date_query .= " + AND D.desired_date BETWEEN '".date('m/d/Y', $desired_start_date)."' AND '".date('m/d/Y', $desired_end_date)."' + "; + } + + // Check for member related filters + $member_query = ''; + if ($_REQUEST['is_member'] == 'yes') { + $member_query .= " AND R.is_member = 't'"; + } elseif ($_REQUEST['is_member'] == 'no') { + $member_query .= " AND R.is_member = 'f'"; + } + if ($_REQUEST['member_id'] != '') { + $member_query .= " AND R.member_id LIKE '%".$_REQUEST['member_id']."%'"; + } + + // Check for submitted by admin filters + $admin_query = ''; + if ($_REQUEST['admin_user'] == 'yes') { + $admin_query .= " AND R.user_trace_info = 'Entered By Admin User'"; + } elseif ($_REQUEST['admin_user'] == 'no') { + $member_query .= " AND R.user_trace_info != 'Entered By Admin User'"; + } + + // Build needed registration data fields + $reg_data_fields = "R.id, R.user_trace_info, R.fname, R.lname, R.org, R.title, R.addr1, R.addr2, + R.city, R.state, R.zip, R.country, R.phone, R.fax, R.email, R.email_ok, R.date_entered, + R.pay_type, R.pay_code, R.status, R.cc_conf, R.total, R.cc_name, R.cc_type, R.cc_numb, R.cc_exp, + R.is_member, R.member_id, R.contact_fname, R.contact_lname, R.contact_org, R.contact_title, R.contact_addr1, + R.contact_addr2, R.contact_city, R.contact_state, R.contact_zip, R.contact_country, R.contact_phone, R.contact_fax + "; + $reg_detail_fields = "D.numb_attending, D.attendees, D.charges, D.registration, D.reg_start, D.reg_end, + D.dob, D.guardian, D.emer_contact, D.emer_phone, D.med_history, D.allergy_med, D.rate_class, D.desired_date + "; + if ($display_dyn_data) { + $reg_detail_fields .= ', D.mf_data'; + } + + // Get the data for this report - How depends on whether we have categories (todo) or sub_cateogories (category) + if ($config->event_registration->sub_categories) { + $query = " + SELECT R.id AS req_id, $reg_data_fields, D.id AS detail_id, $reg_detail_fields, A.name AS act_name, A.need_attendees, + C.name AS cat_name, T.name AS todo_name, T.med_info + FROM reg_req R, reg_detail D, reg A, todo T, category C + WHERE R.id = D.reg_req + AND A.id = D.registration + AND T.id = C.todo + AND C.id = A.category + $event_query + $member_query + $admin_query + $status_query + $date_query; + "; + } elseif ($config->event_registration->main_categories) { + $query = " + SELECT R.id AS req_id, $reg_data_fields, D.id AS detail_id, $reg_detail_fields, A.name AS act_name, A.need_attendees, + T.name AS todo_name, T.med_info + FROM reg_req R, reg_detail D, reg A, todo T + WHERE R.id = D.reg_req + AND A.id = D.registration + AND T.id = A.category + $event_query + $member_query + $admin_query + $status_query + $date_query; + "; + } else { + $query = " + SELECT R.id AS req_id, $reg_data_fields, D.id AS detail_id, $reg_detail_fields, A.name AS act_name, A.need_attendees + FROM reg_req R, reg_detail D, reg A + WHERE R.id = D.reg_req + AND A.id = D.registration + $event_query + $member_query + $admin_query + $status_query + $date_query; + "; + } + + $reg_data = reg_db_auto_get_data($query, SI_CONN_STR, FALSE, 500000); + // echo "Memory - Raw Data Retrieved: ".memory_get_usage()."
"; + + // Check if we got something + if (!is_array($reg_data) || count($reg_data) == 0) { + $v['body'] = '

Sorry, no results found

'; + break; + } + + // If we're doing field data, also provide complete list + $v['have_mf_fields'] = 'NO'; + if ($display_dyn_data) { + + // Strip   from the field titles + foreach ($dyn_form_field_titles as $dff) { + $dyn_form_field_titles[$dff['id']]['title'] = str_replace(" ", "", $dff['title']); + } + + $tags['mf_fields'] = $dyn_form_field_titles; + $v['have_mf_fields'] = 'YES'; + + // Check if we're going to be doing Med Info + reset($reg_data); + $x = current($reg_data); + if (count($reg_data) > 0 && $x['med_info'] != 't') { + $v['med_info_on'] = 'NO'; + } + + } + + // Produce output based on type of report requested + switch($_REQUEST['output_by']) { + + // Report by registration entry (billing record) + case 'registration': + + // Assemble results by registration + $data = array(); + $total_charges = 0; + $total_registrations = 0; + $total_attendees = 0; + + // For each registration + while (list($key, $r) = each($reg_data)) { + + // Has this registration been added yet + if (!isset($data[$r['req_id']])) { + $data[$r['req_id']] = array( + 'id' => $r['req_id'], + 'admin_user' => ($r['user_trace_info'] == 'Entered By Admin User' ? 'YES' : 'NO' ), + 'fname' => $r['fname'], + 'lname' => $r['lname'], + 'addr1' => $r['addr1'], + 'addr2' => $r['addr2'], + 'city' => $r['city'], + 'state' => $r['state'], + 'state_name' => $si_states_array[$r['state']], + 'zip' => $r['zip'], + 'country' => $r['country'], + 'country_name' => $si_countries_array[$r['country']], + 'phone' => $r['phone'], + 'fax' => $r['fax'], + 'email' => $r['email'], + 'email_ok' => ($r['email_ok']=='t'?'Yes':'No'), + 'contact_fname' => $r['contact_fname'], + 'contact_lname' => $r['contact_lname'], + 'contact_addr1' => $r['contact_addr1'], + 'contact_addr2' => $r['contact_addr2'], + 'contact_city' => $r['contact_city'], + 'contact_state' => $r['contact_state'], + 'contact_state_name' => $si_states_array[$r['contact_state']], + 'contact_zip' => $r['contact_zip'], + 'contact_country' => $r['contact_country'], + 'contact_country_name' => $si_countries_array[$r['contact_country']], + 'contact_phone' => $r['contact_phone'], + 'contact_fax' => $r['contact_fax'], + 'date' => $r['date_entered'], + 'pay_type' => $r['pay_type'], + 'pay_type_name' => $si_pay_codes[$r['pay_type']], + 'pay_code' => ($r['pay_code'] == '0' ? '' : $r['pay_code']), + 'status' => $r['status'], + 'status_text' => $si_reg_status_types[$r['status']], + 'cc_conf' => $r['cc_conf'], + 'total' => $r['total'], + 'total_money' => money($r['total']), +// 'summary' => $r['summary'], + 'cc_name' => $r['cc_name'], + 'cc_type' => $r['cc_type'], + 'cc_numb' => $r['cc_numb'], + 'cc_exp' => $r['cc_exp'], +// 'cc_cvv' => $r['cc_cvv'], + 'numb_attending' => $r['numb_attending'], + 'detail' => array() + ); + + // Add to totals + $total_charges += $r['total']; + $total_registrations++; + + } + + // If there's attendees, create array of names + $attendees = array(); + if ($r['numb_attending'] > 0) { + + // Try to unserialize new style attendee data + $att_array = unserialize($r['attendees']); + + // If that didn't work, try to stripslashes() + if (!is_array($att_array)) { + $r['attendees'] = stripslashes($r['attendees']); + $att_array = unserialize($r['attendees']); + } + + // If that wasn't successfull, then it must be an old style name list + if (!$att_array) { + + // Break name list into an array + $att = explode(',', $r['attendees']); + + // For each name, create a new attendee data set + foreach ($att as $a) { + $att_array[] = array( + 'name' => trim($a), + 'dob' => $r['dob'], + 'guardian' => $r['guardian'], + 'emer_contact' => $r['emer_contact'], + 'emer_phone' => $r['emer_phone'], + 'med_history' => $r['med_history'], + 'allergy_med' => $r['allergy_med'] + ); + } + } + + // Dispense with serialized data that is consuming memory - Don't use unset() in that it may not free memory right away + $r['attendees'] = null; + + $attendees = $att_array; + $total_attendees += $r['numb_attending']; + } else { + // Otherwise there's only one attendee + $total_attendees++; + } + + // Add detail for this activity and provide any indents + $mf = false; + if ($display_dyn_data) { + + // Fix stated string lengths in serialized array in case there's errors. + $r['mf_data'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $r['mf_data'] ); + + $mf = unserialize($r['mf_data']); + + // If it's a new, highly encoded version, decode it and then unserialize it + if (!is_array($mf)) { + $md = html_entity_decode($r['mf_data']); + $mf = unserialize($md); + } + + // Dispense with serialized data that is consuming memory + $r['mf_data'] = null; + + // fix certain things for each field + while (list($key2, $val) = each($mf)) { + + // Indent specified level + $mf[$key2]['indent'] = ''; + for ($i=0 ; $i<$val['level'] ; $i++) { + $mf[$key2]['indent'] .= '  '; + } + + // Also strip slashes + $mf[$key2]['title'] = stripslashes($val['title']); + $mf[$key2]['value'] = stripslashes(($val['txt_val']!=''?$val['txt_val']:$val['value'])); + + // Check if we're using ids rather than titles + if ($display_ids) { + $n = $val['id']; + if ($dyn_form_field_titles[$key2]['custom_id'] != null) { + $n = $dyn_form_field_titles[$key2]['custom_id']; +// $n = $val['custom_id']; + } + $mf[$key2]['title'] = stripslashes($n); + } + + + // Also dump unneeded fields + unset($mf[$key2]['level']); + unset($mf[$key2]['type']); + unset($mf[$key2]['txt_typ']); + unset($mf[$key2]['txt_val']); + unset($mf[$key2]['opt_num']); + unset($mf[$key2]['valid']); + unset($mf[$key2]['required']); + unset($mf[$key2]['numb_val']); + unset($mf[$key2]['failure']); + } + } + + $data[$r['req_id']]['detail'][$r['detail_id']] = array( + 'id' => $r['detail_id'], + 'activity' => $r['act_name'], + 'desired_date' => $r['desired_date'], + 'have_desired_date' => ($r['desired_date'] != '' ? 'YES' : 'NO'), + 'numb_attending' => $r['numb_attending'], + 'have_attendees' => ($r['need_attendees'] == 't' ? 'YES' : 'NO'), + 'attendees' => $attendees, + 'have_mf_data' => (count($mf)>0?'YES':'NO'), + 'mf_data' => $mf, + 'have_med_info' => ($r['med_info'] == 't' ? 'YES' : 'NO') + ); + $reg_data[$key] = null; + + } // Each registration + + // Drop source data to free memory + $reg_data = null; + unset($reg_data); + + $t['total_charges'] = money($total_charges); + $t['total_registrations'] = $total_registrations; + $t['total_attendees'] = $total_attendees; + + // Sort by registrant then activity + function reg_cmp($a, $b) + { + + // Check for sort order + switch ($_REQUEST['sort_by']) { + + case "id": + if ($a['id'] == $b['id']) { + return 0; + } + return ($a['id'] < $b['id']) ? -1 : 1; + break; + + case "name": + if ($a['lname'] == $b['lname']) { + if ($a['fname'] == $b['fname']) { + return 0; + } + return ($a['fname'] < $b['fname']) ? -1 : 1; + } + return ($a['lname'] < $b['lname']) ? -1 : 1; + break; + + case "state_city": + if ($a['state'] == $b['state']) { + if ($a['city'] == $b['city']) { + return 0; + } + return ($a['city'] < $b['city']) ? -1 : 1; + } + return ($a['state'] < $b['state']) ? -1 : 1; + $order_by = "R.state, R.city"; + break; + } + + } + usort($data, "reg_cmp"); + + // Output type + $v['report_body'] = ''; + $view_tags['data'] = array(); + switch($_REQUEST['output_type']) { + + case 'web': + + // Process each registration for output and add to report body. + foreach ($data as $d) { + $view_tags['data'][0] = $d; + $data[$d['id']] = null; // Dispense with source data for this registration + $v['report_body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "report_by_registration_Body.html", $view_tags, 'FALSE' ); + } + + $viewfile = 'report_by_registration.html'; + break; + + case 'csv': + + // Process each registration for output and add to report body. + foreach ($data as $d) { + + // For each detail record + while (list($dkey, $dval) = each($d['detail'])) { + + // If we have form data + if ($dval['mf_data'] != false) { + + // Copy the list of all form fields + $new_mf_data = $dyn_form_field_titles; + + // For each form field we have from the detail + while (list($mkey, $mval) = each($dval['mf_data'])) { + // Add the data to the fields list and need to strip new lines from values + $new_mf_data[$mkey]['value'] = trim(preg_replace( '/[\r\n]/', ' ', $mval['value'])); + } + + // Now replace the form_data with the new complete list + $d['detail'][$dkey]['mf_data'] = $new_mf_data; + } + } + + $view_tags['data'][0] = $d; + + $data[$d['id']] = null; // Dispense with source data for this registration + $v['report_body'] .= preg_replace( "/(\\{\S*?\\})/", "", parse_view_localcheck($config->event_registration->custom_view_files, "report_by_registration_csv_Body.html", $view_tags, 'FALSE' )); + } + + $viewfile = 'report_by_registration_csv.html'; + break; + + } + + // echo "Memory - Raw Data: ".memory_get_peak_usage()."
"; + break; + + case 'activity': // By Event (activity) + + // Assemble results by activity + $data = array(); + $total_activities = 0; + $total_attendees = 0; + + // For each registration + while (list($key, $r) = each($reg_data)) { + + // If there's attendees, create array of names + $attendees = array(); + if ($r['numb_attending'] > 0) { + + // Try to unserialize new style attendee data + $att_array = unserialize($r['attendees']); + + // If that wasn't successfull, then it must be an old style name list + if (!$att_array) { + + // Break name list into an array + $att = explode(',', $r['attendees']); + + // For each name, create a new attendee data set + foreach ($att as $a) { + $att_array[] = array( + 'name' => trim($a), + 'dob' => $r['dob'], + 'guardian' => $r['guardian'], + 'emer_contact' => $r['emer_contact'], + 'emer_phone' => $r['emer_phone'], + 'med_history' => $r['med_history'], + 'allergy_med' => $r['allergy_med'] + ); + } + } + + // Dispense with serialized data that is consuming memory + $r['attendees'] = null; + + $attendees = $att_array; + $total_attendees += $r['numb_attending']; + } else { + // Otherwise there's only one attendee + $total_attendees++; + } + + // Check if this activity has been added + if (!isset($data[$r['registration']])) { + $data[$r['registration']] = array( + 'id' => $r['registration'], + 'activity' => $r['act_name'], + 'start_date' => $r['reg_start'], + 'end_date' => $r['reg_end'], + 'numb_attending' => 0, + 'attendees' => array() + ); + $total_activities++; + } + + // Build array of data to include with each attendee + $x = array( + 'id' => $r['req_id'], + 'fname' => $r['fname'], + 'lname' => $r['lname'], + 'addr1' => $r['addr1'], + 'addr2' => $r['addr2'], + 'city' => $r['city'], + 'state' => $r['state'], + 'state_name' => $si_states_array[$r['state']], + 'zip' => $r['zip'], + 'country' => $r['country'], + 'country_name' => $si_country_array[$r['state']], + 'phone' => $r['phone'], + 'fax' => $r['fax'], + 'email' => $r['email'], + 'email_ok' => $r['email_ok'], + 'contact_fname' => $r['contact_fname'], + 'contact_lname' => $r['contact_lname'], + 'contact_addr1' => $r['contact_addr1'], + 'contact_addr2' => $r['contact_addr2'], + 'contact_city' => $r['contact_city'], + 'contact_state' => $r['contact_state'], + 'contact_state_name' => $si_states_array[$r['contact_state']], + 'contact_zip' => $r['contact_zip'], + 'contact_country' => $r['contact_country'], + 'contact_country_name' => $si_country_array[$r['contact_country']], + 'contact_phone' => $r['contact_phone'], + 'contact_fax' => $r['contact_fax'], + 'date' => $r['date_entered'], + 'desired_date' => $r['desired_date'], + 'have_desired_date' => ($r['desired_date'] != '' ? 'YES' : 'NO'), + 'pay_type' => $r['pay_type'], + 'pay_code' => $r['pay_code'], + 'status' => $r['status'], + 'status_text' => $si_reg_status_types[$r['status']], + 'cc_conf' => $r['cc_conf'], + 'total' => $r['total'], + 'total_money' => money($r['total']), + 'summary' => $r['summary'], + 'cc_name' => $r['cc_name'], + 'cc_type' => $r['cc_type'], + 'cc_numb' => $r['cc_numb'], + 'cc_exp' => $r['cc_exp'], + 'cc_cvv' => $r['cc_cvv'], + 'mf_data' => false, + 'have_mf_data' => 'NO' + ); + + // Add detail for this activity and provide any indents + if ($display_dyn_data) { + + // Get mf_data and clear unneeded source data to free memory + $r['mf_data'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $r['mf_data'] ); + $mf_data_tmp = unserialize($r['mf_data']); + + // If it's a new, highly encoded version, decode it and then unserialize it + if (!is_array($mf_data_tmp)) { + $md = html_entity_decode($r['mf_data']); + $mf_data_tmp = unserialize($md); + } + + // If there's form data, add it to the attendee + if (is_array($mf_data_tmp)) { + + // Add the mf data + $x['have_mf_data'] = 'YES'; + while (list($key2, $val) = each($mf_data_tmp)) { + $x['mf_data'][$key2]['id'] = $val['id']; + $x['mf_data'][$key2]['title'] = stripslashes($val['title']); + $x['mf_data'][$key2]['value'] = stripslashes(($val['txt_val']!=''?$val['txt_val']:$val['value'])); + $x['mf_data'][$key2]['indent'] = ''; + for ($i=0 ; $i<$val['level'] ; $i++) { + $x['mf_data'][$key2]['indent'] .= '  '; + } + } + } // have mf_data array + + } +//var_dump($x);exit; + // Dump form data for this registration to free space + $reg_data[$key]['mf_data'] = null; + + // Add attendee data + if (count($attendees) > 0) { + + foreach($attendees as $a) { + $data[$r['registration']]['attendees'][] = array( + 'attendee' => ($r['need_attendees'] == 't' ? $a['name'] : $r['fname'].' '.$r['lname']) + ) + $x + array( + 'have_med_info' => ($a['dob'] != '' ? 'YES' : 'NO'), + 'dob' => $a['dob'], + 'guardian' => $a['guardian'], + 'emer_contact' => $a['emer_contact'], + 'emer_phone' => $a['emer_phone'], + 'med_history' => $a['med_history'], + 'allergy_med' => $a['allergy_med'] + ); + $data[$r['registration']]['numb_attending']++; + } + + // Otherwise there's no attendee list, so use registrant + } else { + + $data[$r['registration']]['attendees'][] = array( + 'attendee' => $r['fname'].' '.$r['lname'] + ) + $x; + $data[$r['registration']]['numb_attending']++; + } + + // Dump this registation source data to free space + $reg_data[$key] = null; + unset($reg_data[$key]); + + } // Each registration + + // Drop source data to free memory + $reg_data = null; + unset($reg_data); + + // Attendee Sort Function + function att_cmp($a, $b) + { + if ($a['attendee'] == $b['attendee']) { + return 0; + } + return ($a['attendee'] < $b['attendee']) ? -1 : 1; + } + + // Activity Sort Function + function act_cmp($a, $b) + { + if ($a['activity'] == $b['activity']) { + return 0; + } + return ($a['activity'] < $b['activity']) ? -1 : 1; + } + + // Sort by Activity then Attendee + while (list($key, $val) = each($data)) { + $attendees = $val['attendees']; + usort($attendees, "att_cmp"); + $data[$key]['attendees'] = $attendees; + } + usort($data, "act_cmp"); + + $t['total_activities'] = $total_activities; + $t['total_attendees'] = $total_attendees; + $t['using_medical_info'] = ($using_medical_info ? 'YES' : 'NO'); + + // Output type + switch($_REQUEST['output_type']) { + + case 'web': + + // Process each registration for output and add to report body. + $v['report_body'] = ''; + $view_tags['data'] = array(); + + // For each event/activity + foreach ($data as $d) { + + // build activity header output for current activity + $view_tags['data'][0] = array( + 'activity' => $d['activity'], + 'start_date' => $d['start_date'], + 'end_date' => $d['end_date'], + 'numb_attending' => $d['numb_attending'] + ); + $v['report_body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "report_by_activity_Body_Head.html", $view_tags, 'FALSE' ); + $view_tags['data'] = false; + + // Build attendee output for each attendee in this activity + foreach ($d['attendees'] as $a) { + $view_tags['attendees'][0] = $a; + $v['report_body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "report_by_activity_Body_Attendee.html", $view_tags, 'FALSE' ); + } + + // Add in activity footer now (no parsing required) + if( !($f = file_get( GLM_APP_BASE.'Common/Registrations_V3/admin/Views/report_by_activity_Body_Foot.html' ) ) ) { + echo "ERROR: Unable to find ".GLM_APP_BASE.'Common/Registrations_V3/admin/Views/report_by_activity_Body_Foot.html'; + exit; + } + $v['report_body'] .= $f; + $data[$d['id']] = null; // Dispense with source data for this registration + + } // for each event + + // Dispense with all supplied data in preparation for the final view parse + unset($view_tags['data']); + unset($view_tags['attendees']); + $data = null; + unset($data); + + $viewfile = 'report_by_activity.html'; + break; + + case 'csv': + + // Process each registration for output and add to report body. + $v['report_body'] = ''; + $view_tags['data'] = array(); + + // For each event/activity + foreach ($data as $d) { + + // build activity header output for current activity + $view_tags['data'][0] = array( + 'activity' => $d['activity'], + 'start_date' => $d['start_date'], + 'end_date' => $d['end_date'], + 'numb_attending' => $d['numb_attending'] + ); + $v['report_body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "report_by_activity_csv_Body_Head.html", $view_tags, 'FALSE' ); + $view_tags['data'] = false; + + // Build attendee output for each attendee in this activity + foreach ($d['attendees'] as $a) { + + // If we have form data + if ($a['mf_data'] != false) { + + // Copy the list of all form fields + $new_mf_data = $dyn_form_field_titles; + + // For each form field we have from the detail + while (list($mkey, $mval) = each($a['mf_data'])) { + // Add the data to the fields list and need to strip new lines from values + $new_mf_data[$mkey]['value'] = trim(preg_replace( '/[\r\n]/', ' ', $mval['value'])); + } + + // Now replace the form_data with the new complete list + $a['mf_data'] = $new_mf_data; + } + + $view_tags['attendees'][0] = $a; + $v['report_body'] .= preg_replace( "/(\\{\S*?\\})/", "", parse_view_localcheck($config->event_registration->custom_view_files, "report_by_activity_csv_Body_Attendee.html", $view_tags, 'FALSE' )); + + } + + $data[$d['id']] = null; // Dispense with source data for this registration + + } // for each event + + // Dispense with all supplied data in preparation for the final view parse + unset($view_tags['data']); + unset($view_tags['attendees']); + $data = null; + unset($data); + + $viewfile = 'report_by_activity_csv.html'; + break; + + } + + break; + + case 'attendee': + + // Assemble results by activity + $data = array(); + $total_attendees = 0; + + // For each registration + while (list($key, $r) = each($reg_data)) { + + $have_mf_data = 'NO'; + $mf_data_temp = false; + + // Get mf_data and clear unneeded source data to free memory + if ($display_dyn_data) { + + // Get mf_data and clear unneeded source data to free memory + $r['mf_data'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $r['mf_data'] ); + $mf = unserialize($r['mf_data']); + + // If it's a new, highly encoded version, decode it and then unserialize it + if (!is_array($mf)) { + $md = html_entity_decode($r['mf_data']); + $mf = unserialize($md); + } + + // If there's form data, add it to the attendee + if (is_array($mf)) { + + // Add the mf data + $have_mf_data = 'YES'; + while (list($key2, $val) = each($mf)) { + + $x = array( + 'id' => $key2, + 'mf_id' => $val['id'], + 'title' => stripslashes($val['title']), + 'value' => stripslashes(($val['txt_val']!=''?$val['txt_val']:$val['value'])), + 'indent' => '' + ); + for ($i=0 ; $i<$val['level'] ; $i++) { + $x['indent'] .= '  '; + } + + $mf_data_temp[] = $x; + } + } // have mf_data array + +/* + $r['mf_data'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $r['mf_data'] ); + $mf_data_temp = unserialize($r['mf_data']); + + // If it's a new, highly encoded version, decode it and then unserialize it + if (!is_array($mf_data_temp)) { + $md = html_entity_decode($r['mf_data']); + $mf_data_temp = unserialize($md); + } +*/ + + } + + $r['mf_data'] = null; + + // Add detail for this activity + $data['detail'][$r['detail_id']] = array( + 'id' => $r['detail_id'], + 'activity' => $r['act_name'], + 'numb_attending' => $r['numb_attending'], + 'have_mf_data' => $have_mf_data, + 'mf_data' => $mf_data_temp, + 'dob' => $r['dob'], + 'guardian' => $r['guardian'], + 'emer_contact' => $r['emer_contact'], + 'emer_phone' => $r['emer_phone'], + 'have_med_info' => ($r['med_info'] == 't' ? 'YES' : 'NO'), + 'med_history' => $r['med_history'], + 'allergy_med' => $r['allergy_med'], + 'fname' => $r['fname'], + 'lname' => $r['lname'], + 'addr1' => $r['addr1'], + 'addr2' => $r['addr2'], + 'city' => $r['city'], + 'state' => $r['state'], + 'zip' => $r['zip'], + 'country' => $r['country'], + 'phone' => $r['phone'], + 'fax' => $r['fax'], + 'email' => $r['email'], + 'email_ok' => $r['email_ok'], + 'contact_fname' => $r['contact_fname'], + 'contact_lname' => $r['contact_lname'], + 'contact_addr1' => $r['contact_addr1'], + 'contact_addr2' => $r['contact_addr2'], + 'contact_city' => $r['contact_city'], + 'contact_state' => $r['contact_state'], + 'contact_state_name' => $si_states_array[$r['contact_state']], + 'contact_zip' => $r['contact_zip'], + 'contact_country' => $r['contact_country'], + 'contact_country_name' => $si_country_array[$r['contact_country']], + 'contact_phone' => $r['contact_phone'], + 'contact_fax' => $r['contact_fax'], + 'desired_date' => $r['desired_date'], + 'have_desired_date' => ($r['desired_date'] != '' ? 'YES' : 'NO'), + 'date' => $r['date_entered'], + 'pay_type' => $r['pay_type'], + 'pay_code' => $r['pay_code'], + 'status' => $r['status'], + 'status_text' => $si_reg_status_types[$r['status']], + 'cc_conf' => $r['cc_conf'], + 'total' => $r['total'], + 'total_money' => money($r['total']), + 'cc_name' => $r['cc_name'], + 'cc_type' => $r['cc_type'], + 'cc_numb' => $r['cc_numb'], + 'cc_exp' => $r['cc_exp'] + ); + + // If there's attendees, create array of names + $attendees = array(); + if ($r['numb_attending'] > 0) { + + // Try to unserialize new style attendee data + $att_array = unserialize($r['attendees']); + + // If that wasn't successfull, then it must be an old style name list + if (!$att_array) { + + // Break name list into an array + $att = explode(',', $r['attendees']); + + // For each name, create a new attendee data set + foreach ($att as $a) { + $data['attendee'][] = array( + 'detail_id' => $r['detail_id'], + 'attendee' => ($r['need_attendees'] == 't' ? trim($a) : $r['fname'].' '.$r['lname']), + 'dob' => $r['dob'], + 'guardian' => $r['guardian'], + 'emer_contact' => $r['emer_contact'], + 'emer_phone' => $r['emer_phone'], + 'med_history' => $r['med_history'], + 'allergy_med' => $r['allergy_med'] + ); + } + } else { + foreach ($att_array as $a) { + $data['attendee'][] = array( + 'detail_id' => $r['detail_id'], + 'attendee' => ($r['need_attendees'] == 't' ? trim($a['name']) : $r['fname'].' '.$r['lname']), + 'dob' => $a['dob'], + 'guardian' => $a['guardian'], + 'emer_contact' => $a['emer_contact'], + 'emer_phone' => $a['emer_phone'], + 'med_history' => $a['med_history'], + 'allergy_med' => $a['allergy_med'] + ); + } + } +// $data[] = $att_array + $x; + $total_attendees += $r['numb_attending']; + + // Free attendee source data to free memory + $r['attendees'] = null; + + } else { + // Otherwise there's only one attendee + $total_attendees++; + } + + // Dump this registation source data to free space + $reg_data[$key] = null; + unset($reg_data[$key]); + + } // Each registration + + // Drop source data to free memory + $reg_data = null; + unset($reg_data); + + // Sort by attendee then activity + function att_act_cmp($a, $b) + { + if ($a['attendee'] == $b['attendee']) { + if ($a['activity'] == $b['activity']) { + return 0; + } + return ($a['activity'] < $b['activity']) ? -1 : 1; + } + return ($a['attendee'] < $b['attendee']) ? -1 : 1; + } + usort($data['attendee'], "att_act_cmp"); + + $t['total_attendees'] = $total_attendees; + $t['using_medical_info'] = ($using_medical_info ? 'YES' : 'NO'); + + // Output type + $v['report_body'] = ''; + $view_tags['data'] = array(); + + switch($_REQUEST['output_type']) { + + case 'web': + + // For each attendee listed + while (list($key, $d) = each($data['attendee'])) { + + // Place the current data in the view along with the detail for that registration + $view_tags['data'][0] = $d + $data['detail'][$d['detail_id']]; + + // Dispense with source data for this attendee - need to keep detail in case there's another attendee + $data['attendee'][$key] = null; + + $v['report_body'] .= parse_view_localcheck($config->event_registration->custom_view_files, "report_by_attendee_Body.html", $view_tags, 'FALSE' ); + } + + $data = null; + unset($data); + + $viewfile = 'report_by_attendee.html'; + break; + + case 'csv': + + // For each attendee listed + while (list($dkey, $dval) = each($data['attendee'])) { + + // Need to strip new lines for csv file fields + $detail = $data['detail'][$dval['detail_id']]; + + // If we have form data + if ($dval['mf_data'] != false) { + + // Copy the list of all form fields + $new_mf_data = $dyn_form_field_titles; + + // For each form field we have from the detail + while (list($mkey, $mval) = each($dval['mf_data'])) { + // Add the data to the fields list and need to strip new lines from values + $new_mf_data[$mkey]['value'] = trim(preg_replace( '/[\r\n]/', ' ', $mval['value'])); + } + + // Now replace the form_data with the new complete list + $dval['mf_data'] = $new_mf_data; + } + + // Place the current data in the view along with the detail for that registration + $view_tags['data'][0] = $dval + $detail; + + // Dispense with source data for this attendee - need to keep detail in case there's another attendee + $data['attendee'][$dkey] = null; + + $v['report_body'] .= preg_replace( "/(\\{\S*?\\})/", "", parse_view_localcheck($config->event_registration->custom_view_files, "report_by_attendee_csv_Body.html", $view_tags, 'FALSE' )); + } + + $data = null; + unset($data); + + $viewfile = 'report_by_attendee_csv.html'; + break; + + } + + //echo "Memory - Final: ".round(memory_get_usage()/1000000)."
"; + //echo "Memory - Peak: ".round(memory_get_peak_usage()/1000000)."
"; + + break; + + } // output by + + $tags['data'] = $data; + $data = null; + + $out .= parse_view_localcheck($config->event_registration->custom_view_files, $viewfile, $tags, 'FALSE' ); + + if ($_REQUEST['output_type'] == 'csv') { + + $len = strlen( $out ); + header( "Content-type: application/octet-stream" ); + header( "Content-Length: $len" ); + header( "Content-Disposition: attachment; filename=Registrations.csv" ); + echo $out; + exit; + + } + + if( isset($_REQUEST['PrintReport']) && $_REQUEST['PrintReport'] == 'Yes' ) { + echo $out; + exit; + } + + $email = filter_var($_REQUEST['email_to'], FILTER_VALIDATE_EMAIL); + if ($email != false) { + + $email_content = "--ContentBoundry\n" + ."Content-Type: text/plain; charset=\"US-ASCII\"\n" + ."\n" + .'Your E-Mail client does not support HTML E-Mail.' + ."\n" + ."--ContentBoundry\n" + ."Content-Type: text/html; charset=\"US-ASCII\"\n" + ."\n" + .$out + ."\n" + ."\n" + ."--ContentBoundry--\n" + ."\n"; + + debug_mail( + $email, + $config->event_registration->organization." Report", + "$email_content.", + "From: ".$server_config->email->owner."\nMime-Version: 1.0\nContent-Type: multipart/alternative; boundary=ContentBoundry\n", + '-f'.$config->event_registration->organization_from_email + ); + + $out = '

This report has been sent to: '.$email.'

'.$out; + } + + $v['body'] .= $out; + + break; + + } // switch report steps + break; + +/* May not be current + case 'FixForms': + + // This is to fix internal links in forms that were corrupted by an early form copy process. + // There is no link to this, it must be entered manually on the URL to be run. + + $v['body'] .= '
Starting Sub-Form Field Fix Process:
'; + + // Get all form data + $fd = reg_db_auto_get_data( "SELECT id, form_id, data1 FROM magicform ORDER BY form_id;", SI_CONN_STR, FALSE, 5000 ); + $v['body'] .= 'Retrieved all form data: '.count($fd).' entries found
'; + + $fids = array(); + + // Display what we got + foreach ($fd as $f) { + $v['body'] .= $f['form_id'].' - '.$f['data1'].'
'; + $x = explode('.', $f['form_id']); + $fids[$x[0]] = $x[0]; + } + $v['body'] .= '
'; + + $v['body'] .= 'Root Form IDs found: '; + $sep = ''; + foreach ($fids as $f) { + $v['body'] .= $sep.$f; + $sep = ', '; + } + $v['body'] .= '
'; + + // Try to fix the data + reset($fd); + while (list($key, $val) = each($fd)) { + + // Get the root ID for this field + $x = explode('.', $val['form_id']); + $field_id = $x[0]; + + // Look for other root form IDs that don't belong here. + reset($fids); + foreach ($fids as $wrong_id) { + // If it's any other ID than the current root + if ($field_id != $wrong_id) { + $count = 0; + $old_data1 = $val['data1']; + $x = str_replace('~'.$wrong_id.'.', '~'.$field_id.'.', $val['data1'], $count); + if ($count > 0) { + $fd[$key]['old_data1'] = $old_data1; + $fd[$key]['data1'] = $x; + $fd[$key]['fixed'] = true; + } + } + } + } + + // Display what we have now + $v['body'] .= 'Fixed Fields:
'; + $v['body'] .= '
'; + reset($fd); + + $transaction = array( + 0 => 'set search_path = registrations;' + ); + foreach ($fd as $f) { + if ($f['fixed'] == true) { + + $transaction[$f['id']] = "UPDATE magicform SET data1 = '".addslashes($f['data1'])."' WHERE id = ".$f['id'].";"; + + $v['body'] .= 'ID: '.$f['id']."
"; + $v['body'] .= ''.$f['form_id'].' - '.$f['old_data1'].'
'; + $v['body'] .= $f['form_id'].' - '.$f['data1'].'
'; + $v['body'] .= $transaction[$f[id]].'

'; + } + } + $v['body'] .= '

'; + + // Create database connection + $db = Toolkit_Database::getInstance(); + + try { + + $db->beginTransaction(); + foreach ($transaction as $sql) { + @$db->exec($sql); + } + $db->commit(); + + } catch (Exception $e) { + + $v['body'] .= 'Transaction execution problem.
'.$e->getMessage()."
Query:
$sql
"; + $db->rollback(); + + } + + + // Get all form data again + $fd = reg_db_auto_get_data( "SELECT id, form_id, data1 FROM magicform ORDER BY form_id;", SI_CONN_STR, FALSE, 5000 ); + $v['body'] .= 'Updated form data: '.count($fd).' entries found
'; + + // Display what we got + foreach ($fd as $f) { + $v['body'] .= $f['form_id'].' - '.$f['data1'].'
'; + } + $v['body'] .= '
'; + $v['body'] .= 'End of Sub-Form Field Fix Process:
'; + + break; +*/ + + case 'ReconcileAttendees': + + // This is to fix current attendee counts for events that count attendees + // There is no link to this, it must be entered manually on the URL to be run. + // Call with "&fix=true to correct errors + + // Get all events that count attendees + $sql = "SELECT id, name, attendee_max, attendee_count + FROM reg + WHERE need_attendees + ORDER BY id + ;"; + $event_data = reg_db_auto_get_data( $sql, SI_CONN_STR, FALSE, 5000 ); + + echo "

Attendee Count Reconciliation

+ + + "; + // For each event + foreach ($event_data as $ed) { + + // Get the sum of all the attendee counts from the registration detail records where those are not canceled + $sql = "SELECT sum(D.numb_attending) + FROM reg_detail D, reg_req R + WHERE D.registration = ".$ed['id']." + AND R.id = D.reg_req + AND R.status != ".SI_REG_STATUS_CANCELED." + ;"; + $sum = db_auto_get_row( $sql, 0, CONN_STR, FALSE ); + + // If we found any registrations for this event + $attendees = ($sum['sum'] - 0); + + $bgcolor = '#fff'; + $diff = $ed['attendee_count'] - $attendees; + if ($diff != 0) { + + $bgcolor = 'pink'; + + // Correct attendee count + if ($_REQUEST['fix'] == 'true') { + $sql = "UPDATE reg SET attendee_count = $attendees WHERE id = ".$ed['id'].";"; + reg_db_auto_exec( $sql, 0, CONN_STR, FALSE ); + } + } + + echo ""; + + } + + echo "
IDNameMax AttendeesExpectedCalculatedDifference
".$ed['id']."".$ed['name']."".$ed['attendee_max']."".$ed['attendee_count']."".$attendees."$diff
"; + + if ($_REQUEST['fix'] == 'true') { + echo "

All differernces corrected

"; + } + + break; + + default: + $welcome = parse_view_localcheck($config->event_registration->custom_view_files, "welcome.html", $view_tags, 'FALSE' ); + $v['body'] .= $menu.$welcome; + break; + + } + + // Check for specified default field focus + +if( !empty($mf_field_id) ) + $v['field_focus'] = 'mf_field_'.$mf_field_id; + else + $v['field_focus'] = 'default'; + + +echo parse_view_localcheck($config->event_registration->custom_view_files, $qs_viewfile, $view_tags, 'FALSE' ); // Don't show unused tags to avoid problems with hidden multi-field parameters + +?> diff --git a/admin/java_functions.js b/admin/java_functions.js new file mode 100644 index 0000000..83fdac9 --- /dev/null +++ b/admin/java_functions.js @@ -0,0 +1,287 @@ +// +// Java Functions +// + + // List all Java properties for the specified target - Used for testing + +function list_properties( target ) + { + sep = ''; + var names = ''; + var c = 0; + + var names_a = new Array(); + for( var i in target ) + { + names_a[c++] = i; + } + names_a.sort(); + + for( var i=0 ; i 0 && unused == 0 ) + { + new_num = lines + 1; // Add one to line count for new field + + new_text = document.getElementById( fname + '_text' ).value; + + t = new_text.replace( /\{line_numb\}/gi, new_num ); // Replace {n} parameters + + for( i=1 ; i<=width ; i++ ) + { + reg = new RegExp( '\{field_' + i + '\}', 'g' ); + t = t.replace( reg, '' ); + } + + document.getElementById( fname + '_fields' ).innerHTML += t; // Write out new line + + // Fill values back in + for( i=1 ; i<=lines ; i++ ) + for( j=1 ; j<=width ; j++ ) + document.getElementById( fname + '_' + i + '_' + j ).value = saved[i][j]; + + } + + // Focus on next field + setTimeout("setFocus('" + fname + '_' + 1 + '_' + 1 + "', " + ele + ")",100); + + } + +// Set focus to +function setFocus(f, ele) + { + e = document.getElementById( f ); + form = e.form; + ele++; + form.elements[ele].focus(); + } + + // Special Multi-fields that doesn't conflict with view parsing - Built specifically to support Attendee input in registrations step 2 + +function multi_fields_2( fname, cur_field, width ) + { + var lines = 0; + var unused = 0; + var saved = new Array(); + + ele = getElementIndex(cur_field); + + while( document.getElementById( fname + '_' + (lines+1) + '_1' ) ) + { + lines++; + + // Check if line is used + if( document.getElementById( fname + '_' + lines + '_1' ).value == '' ) + unused++; + + // Save all data in case we need to add a line + saved[lines] = new Array(); + for( i=1 ; i<=width ; i++ ) + { + saved[lines][i] = document.getElementById( fname + '_' + lines + '_' + i ).value; + } + } + + // If we need an additional field, rewrite everything + + if( lines > 0 && unused == 0 ) + { + new_num = lines + 1; // Add one to line count for new field + + new_text = document.getElementById( fname + '_text' ).value; + + t = new_text.replace( /\[line_numb\]/gi, new_num ); // Replace {n} parameters + for( i=1 ; i<=width ; i++ ) + { + reg = new RegExp( '\\[field_' + i + '\\]', 'g' ); + t = t.replace( reg, '' ); + } + document.getElementById( fname + '_fields' ).innerHTML += t; // Write out new line + + // Fill values back in + for( i=1 ; i<=lines ; i++ ) + for( j=1 ; j<=width ; j++ ) + { + document.getElementById( fname + '_' + i + '_' + j ).value = saved[i][j]; + } + } + + // Focus on next field + // Focus on next field + setTimeout("setFocus('" + fname + '_' + 1 + '_' + 1 + "', " + ele + ")",100); + + } + + + +//CKEditor Actions +CKEDITOR.config.toolbar_EventManagement = +[ + ['Font','FontSize','Bold','Italic'], + ['Cut','Copy','PasteText','-','Undo','Redo'], + ['NewPage', 'Preview'], + '/', + ['NumberedList','BulletedList','-','Outdent','Indent'], + ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], + ['TextColor'], + ['Link','Unlink'], + ['Table','Find','Replace','-','RemoveFormat','Source'] +] ; + + +function buildCkeditor(f) +{ + instance = CKEDITOR.instances[f]; + if (instance) { + instance.destroy(true); + instance = null; + } + + // Only try to replace the textarea if the + // CKEditor is compatible w/ the browser. + if (CKEDITOR.env.isCompatible) { + CKEDITOR.replace(f, { + toolbar : 'EventManagement' + }); + } + +} diff --git a/admin/style.css b/admin/style.css new file mode 100644 index 0000000..15f7514 --- /dev/null +++ b/admin/style.css @@ -0,0 +1,624 @@ +.pseudo_link + { + FONT-SIZE: 11px; + COLOR: #006bb7; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none + } +A:link + { + FONT-SIZE: 11px; + COLOR: #006bb7; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none + } +A:visited + { + FONT-SIZE: 11px; + COLOR: #666666; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +A:active + { + FONT-SIZE: 11px; + COLOR: #ee3a42; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +A:hover + { + FONT-SIZE: 11px; + COLOR: #006bb7; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +P + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.detailtitle + { + FONT-WEIGHT: bold; + FONT-SIZE: 13px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.places + { + FONT-WEIGHT: bold; + FONT-SIZE: 13px; + COLOR: #969696; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.featuretitle + { + FONT-WEIGHT: bold; + FONT-SIZE: 13px; + COLOR: #2e629b; + FONT-FAMILY: Verdana, Arial, Helvetica + } +.headertitle + { + BORDER-RIGHT: medium none; + BORDER-TOP: medium none; + MARGIN-TOP: 0px; + FONT-WEIGHT: bolder; + FONT-SIZE: 16pt; + MARGIN-BOTTOM: 0px; + PADDING-BOTTOM: 0px; + TEXT-TRANSFORM: none; + BORDER-LEFT: medium none; + COLOR: #093250; + PADDING-TOP: 0px; + BORDER-BOTTOM: medium none; + FONT-STYLE: normal; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.subtitle + { + BORDER-RIGHT: medium none; + BORDER-TOP: medium none; + MARGIN-TOP: 0px; + FONT-WEIGHT: bolder; + FONT-SIZE: 12pt; + MARGIN-BOTTOM: 0px; + PADDING-BOTTOM: 0px; + TEXT-TRANSFORM: none; + BORDER-LEFT: medium none; + COLOR: #093250; + PADDING-TOP: 0px; + BORDER-BOTTOM: medium none; + FONT-STYLE: normal; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + }phpinfo();exit; +echo $_PUT['Action']; + + +.terttitle + { + BORDER-RIGHT: medium none; + BORDER-TOP: medium none; + MARGIN-TOP: 0px; + FONT-WEIGHT: lighter; + FONT-SIZE: 10pt; + MARGIN-BOTTOM: 0px; + PADDING-BOTTOM: 0px; + TEXT-TRANSFORM: none; + BORDER-LEFT: medium none; + COLOR: #093250; + PADDING-TOP: 0px; + BORDER-BOTTOM: medium none; + FONT-STYLE: normal; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +H1 + { + FONT-SIZE: 16pt; + FONT-FAMILY: 'Arial, Verdana, Helvetica' + } +H2 + { + FONT-SIZE: 15pt; + FONT-FAMILY: 'Arial, Verdana, Helvetica' + } +H3 + { + FONT-SIZE: 14pt; + PADDING-BOTTOM: 0px; + FONT-FAMILY: 'Arial, Verdana, Helvetica' + } +H4 + { + FONT-SIZE: 13pt; + PADDING-BOTTOM: 0px; + FONT-FAMILY: 'Arial, Verdana, Helvetica' + } +B + { + FONT-WEIGHT: bold; + FONT-SIZE: 10pt; + FONT-FAMILY: Arial, Verdana, Helvetica + } +A + { + FONT-FAMILY: Arial, Verdana, Helvetica; + TEXT-DECORATION: underline + } +TH + { + font-size: 12px; font-family: Verdana, arial,helvetica; font-weight: bold; + } +TD + { + FONT-SIZE: 10px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +TD.small + { + FONT-SIZE: 9px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.pos_rel + { + POSITION: relative; + HEIGHT: 20px + } +.pos_abs + { + FONT-WEIGHT: bold; + FONT-SIZE: 8pt; + Z-INDEX: 90; + PADDING-TOP: 0px; + POSITION: absolute; + HEIGHT: 20px + } +#dmenu1 + { + Z-INDEX: 100 + } +#dmenu2 + { + Z-INDEX: 100 + } +#dmenu3 + { + Z-INDEX: 100 + } +#dmenu4 + { + Z-INDEX: 100 + } +#dmenu5 + { + Z-INDEX: 100 + } +#dmenu6 + { + Z-INDEX: 100 + } +A.menu + { + FONT-WEIGHT: bold; + FONT-SIZE: 8pt; + COLOR: #000000; + FONT-FAMILY: Arial, Verdana, Helvetica; + TEXT-DECORATION: none + } +A.menuitem + { + FONT-SIZE: 8pt; + COLOR: #000000; + TEXT-DECORATION: none + } +A.menuitem:link + { + FONT-SIZE: 8pt; + COLOR: #000000; + TEXT-DECORATION: none + } +A.menuitem + { + FONT-SIZE: 8pt; + TEXT-DECORATION: none + } +.menutop + { + BORDER-RIGHT: black 1px solid; + BORDER-TOP: black 1px solid; + FONT-WEIGHT: bold; + FONT-SIZE: 8pt; + BORDER-LEFT: black 1px solid; + COLOR: #ffffff; + BORDER-BOTTOM: black 1px solid; + FONT-FAMILY: Arial, Verdana, Helvetica; + TEXT-DECORATION: none + } +A.menutop:hover + { + BORDER-RIGHT: black 1px solid; + BORDER-TOP: black 1px solid; + FONT-WEIGHT: bold; + FONT-SIZE: 8pt; + BORDER-LEFT: black 1px solid; + COLOR: #ffffff; + BORDER-BOTTOM: black 1px solid; + FONT-FAMILY: Arial, Verdana, Helvetica; + TEXT-DECORATION: none + } +.copyright + { + FONT-SIZE: 8pt; + FONT-FAMILY: Arial, Verdana, Helvetica + } +.navlink + { + FONT-SIZE: 11px; + COLOR: black; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +A.subnav:active + { + FONT-WEIGHT: bolder; + FONT-SIZE: 10px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none; + } +A.subnav:link + { + FONT-WEIGHT: bolder; + FONT-SIZE: 10px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none; + } +A.subnav:visited + { + FONT-WEIGHT: bolder; + FONT-SIZE: 10px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none; + } +A.subnav:hover + { + FONT-SIZE: 10px; + COLOR: #0066cc; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: #ffffff; + TEXT-DECORATION: underline; + } +INPUT.btn + { + BORDER-RIGHT: black 1px groove; + BORDER-TOP: black 1px groove; + FONT-WEIGHT: bolder; + FONT-SIZE: 12px; + BORDER-LEFT: black 1px groove; + COLOR: #ffffff; + BORDER-BOTTOM: black 1px groove; + FONT-FAMILY: Arial; + BACKGROUND-COLOR: #999999; + } +A.image:hover + { + FONT-SIZE: 11px; + COLOR: #0066cc; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + } +.checkout + { + FONT-WEIGHT: bold; + FONT-SIZE: 13px; + COLOR: #e93244; + FONT-FAMILY: Verdana, Arial, Helvetica + } +A.criteria:active + { + FONT-SIZE: 11px; + COLOR: #e3413c; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + } +A.criteria:link + { + FONT-SIZE: 11px; + COLOR: #0067cd; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + } +A.criteria:visited + { + FONT-SIZE: 11px; + COLOR: #76a4d3; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + } +A.criteria:hover + { + FONT-SIZE: 11px; + COLOR: #0067cd; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + }phpinfo();exit; +echo $_PUT['Action']; + + +A.tab-nav-text:active + { + FONT-WEIGHT: bolder; + FONT-SIZE: 12px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none + } +A.tab-nav-text:link + { + FONT-WEIGHT: bolder; + FONT-SIZE: 12px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none + } +A.tab-nav-text:visited + { + FONT-WEIGHT: bolder; + FONT-SIZE: 12px; + COLOR: #ffffff; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: none + } +A.tab-nav-text:hover + { + FONT-SIZE: 12px; + COLOR: white; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: transparent; + TEXT-DECORATION: underline + } +.nonnav + { + FONT-SIZE: 11px; + COLOR: black; + FONT-FAMILY: Arial, Verdana + } +LI + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +A.criteria2:link + { + FONT-SIZE: 11px; + COLOR: #0067cd; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + TEXT-DECORATION: underline + } +DIV + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +INPUT + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +TEXTAREA + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +SELECT + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +OPTION + { + FONT-SIZE: 11px; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif + } +.std_textphpinfo();exit; +echo $_PUT['Action']; + + + { + padding-left: .25cm + } +.bold_text + { + font-weight: bold; + padding-left: .25cm + } +.stepdescr + { + font-weight: bold + } +.redtext + { + font-size: 12px; + color: #CC0000; + font-family: Arial, Helvetica, sans-serif; + font-weight: normal; + } +.redhead + { + font-size: 12px; + font-weight: bold; + color: #CC0000; + font-family: Arial, Helvetica, sans-serif; + } +A.link + { + font-size: 16px; + } +A.link:visited + { + font-size: 16px; + } +A.link:active + { + font-size: 16px; + } +A.link:hover + { + font-size: 16px; + } +.standout + { + COLOR: #006bb7; + font-size: 16px; + } +.standout_small + { + COLOR: #006bb7; + font-size: 11px; + } +.theader + { + font-size: 120%; + font-family: arial,helvetica; + color: #FFFFFF; + } +.text + { + font-size: 100%; + font-family: + arial,helvetica; + color: #000000; + } +.small_text + { + FONT-SIZE: 8px; + FONT-FAMILY: Arial, Helvetica; + } +.title1 + { + font-size: 22px; + font-weight: bold; color: #006bb7; + font-family: Arial, Helvetica, sans-serif; + } +.title2 + { + font-size: 22px; + font-weight: bold; + color: black; + font-family: Arial, Helvetica, sans-serif; + } +.report_title + { + font-size: 22px; + font-weight: bold; color: #006bb7; + font-family: Arial, Helvetica, sans-serif; + margin-bottom: 0.9em; + } +.report_sub_title + { + width: 100%; + } +.report_sub_title_left + { + clear: all; + float: left; + font-size: 14px; + font-weight: bold; color: #006bb7; + font-family: Arial, Helvetica, sans-serif; + margin-bottom: 0.5em; + } +.report_sub_title_right + { + float: right; + font-size: 14px; + font-weight: bold; color: #006bb7; + font-family: Arial, Helvetica, sans-serif; + margin-bottom: 0.5em; + } +.report_print_box + { + clear: both; + margin-bottom: 0.9em; + } +.menu_normal + { + FONT-SIZE: 11px; + COLOR: black; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: $FFFFFF; + } +.menu_title + { + FONT-SIZE: 11px; + COLOR: black; + font-weight: bold; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: $FFFFFF; + } +.menu_active + { + FONT-SIZE: 11px; + COLOR: white; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: #3399EE; + } +.menu_unavailable + { + FONT-SIZE: 11px; + COLOR: gray; + FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; + BACKGROUND-COLOR: $FFFFFF; + } + +.hidden {visibility: hidden;} +.welcome-text { + width: 100%; + text-align: left; +} + +.quicktip-wide { text-align: left; position: absolute; width: 700px; visibility: hidden; z-index: 100; + font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; border: 1px solid #000; margin-top: 20px; } + +.quicktip-notes { text-align: left; position: absolute; width: 400px; visibility: hidden; z-index: 100; + font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; border: 1px solid #000; margin-top: 20px; } + +.quicktip { text-align: left; position: absolute; width: 410px; visibility: hidden; z-index: 100; + font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; border: 1px solid #000; margin-top: 20px; } +.quicktip-prompt { cursor: help; } +.quicktip-titlebar { background-color: #87CEFA; } +.quicktip-title { font-weight: bold; color: black; padding: 3px; } +.quicktip-close { font-weight: bold; color: white; text-decoration: none; float: right; position: relative; display: block; padding: 3px;} +.quicktip-body { background-color: #FDF5E6; color: black; padding: 8px; font-weight: normal;} +.quicktip-fieldname { font-weight: bold; margin-bottom: 0.5em; border-bottom: 1px solid #333;} +.quicktip-prompt { cursor: help; border-bottom: 1px dashed #ccc;} +.quicktip-prompt2 { cursor: help; } + +.quickedit { text-align: left; position: absolute; width: 550px; visibility: hidden; z-index: 100; + font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; border: 1px solid #000; margin-top: 20px; } +.quickedit-prompt { cursor: help; } +.quickedit-titlebar { background-color: #87CEFA; } +.quickedit-title { font-weight: bold; color: black; padding: 3px; } +.quickedit-close { font-weight: bold; color: white; text-decoration: none; float: right; position: relative; display: block; padding: 3px;} +.quickedit-body { background-color: #FDF5E6; color: black; padding: 8px; font-weight: normal;} +.quickedit-fieldname { font-weight: bold; margin-bottom: 0.5em; border-bottom: 1px solid #333;} +.quickedit-prompt { cursor: help; border-bottom: 1px dashed #ccc;} +.quickedit-prompt2 { cursor: help; } + +.pac_std_text{font-family: Arial, Helvetica, sans-serif; padding-left: .25cm} +.pac_bold_text{font-family: Arial, Helvetica, sans-serif; font-weight: bold; padding-left: .25cm} +.pac_stepdescr{font-family: Arial, Helvetica, sans-serif; font-weight: bold} +.pac_redhead{color: #990000} +A.pac_link { font-size: 16px; } +A.pac_link:visited { font-size: 16px; } +A.pac_link:active { font-size: 16px; } +A.pac_link:hover { font-size: 16px; } + +.pac_standout { COLOR: #006bb7; font-size: 16px; } +.pac_standout_small { COLOR: #006bb7; font-size: 12px; } + +.selectCategory { + background-color: #CCC; + color: black; +} +.selectSubCategory { + background-color: #EEE; + color: black; +} diff --git a/assets/add.png b/assets/add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/assets/add.png differ diff --git a/assets/arrow_left.png b/assets/arrow_left.png new file mode 100644 index 0000000..5dc6967 Binary files /dev/null and b/assets/arrow_left.png differ diff --git a/assets/basket.png b/assets/basket.png new file mode 100644 index 0000000..b0686d7 Binary files /dev/null and b/assets/basket.png differ diff --git a/assets/calendar.png b/assets/calendar.png new file mode 100644 index 0000000..6589138 Binary files /dev/null and b/assets/calendar.png differ diff --git a/assets/cancel.png b/assets/cancel.png new file mode 100644 index 0000000..c149c2b Binary files /dev/null and b/assets/cancel.png differ diff --git a/assets/down.gif b/assets/down.gif new file mode 100644 index 0000000..a56f027 Binary files /dev/null and b/assets/down.gif differ diff --git a/assets/down_small.png b/assets/down_small.png new file mode 100644 index 0000000..b3d1a9c Binary files /dev/null and b/assets/down_small.png differ diff --git a/assets/logo.gif b/assets/logo.gif new file mode 100644 index 0000000..3d9b055 Binary files /dev/null and b/assets/logo.gif differ diff --git a/assets/tick.png b/assets/tick.png new file mode 100644 index 0000000..a9925a0 Binary files /dev/null and b/assets/tick.png differ diff --git a/assets/up.gif b/assets/up.gif new file mode 100644 index 0000000..7df1212 Binary files /dev/null and b/assets/up.gif differ diff --git a/assets/up_small.png b/assets/up_small.png new file mode 100644 index 0000000..138fabb Binary files /dev/null and b/assets/up_small.png differ diff --git a/classes/EasyPassword.php b/classes/EasyPassword.php new file mode 100644 index 0000000..0636cb8 --- /dev/null +++ b/classes/EasyPassword.php @@ -0,0 +1,42 @@ + + * Released under the terms of the GNU General Public License + * Based in part on Script released by: Jochen Kupperschmidt + * + * This is a highly modified version of this password generator for this application only. + * For original code please refer to original author. + */ + + +class EasyPassword +{ + + // Get a random dictionary word from a text file + function dictionaryWord() { + $path = GLM_APP_BASE.'Common/Registrations_V3/classes/EasyPassword.words'; + $fileload = @file($path); + $i = count($fileload)-1; + $random = rtrim($fileload[rand(0,$i)]); + return $random; + } + + // This is the function to produce the password + function generateEasyPassword() + { + $word1 = $this->dictionaryWord(); + $numb = rand(1, 9); // Generate specified amount of numbers + $word2 = $this->dictionaryWord(); + + $keys = array ($word1,$numb,$word2); // Place password components in an array + $rand_keys = array_rand($keys,3); // Randomize the 3 password components + return $keys[$rand_keys[0]].$keys[$rand_keys[1]].$keys[$rand_keys[2]]; // Return the resulting password + } + + +} + + +?> \ No newline at end of file diff --git a/classes/EasyPassword.words b/classes/EasyPassword.words new file mode 100644 index 0000000..f03284c --- /dev/null +++ b/classes/EasyPassword.words @@ -0,0 +1,828 @@ +able +ABLE +about +account +acid +across +act +addition +after +again +against +agreement +air +all +almost +among +amount +amusement +and +angle +angry +animal +answer +ant +any +apparatus +apple +approval +arch +argument +arm +army +art +as +at +attack +attempt +attention +authority +automatic +awake +baby +back +bad +bag +balance +ball +band +base +basin +basket +bath +be +beautiful +because +bed +bee +before +behaviour +belief +bell +bent +berry +between +bird +birth +bit +black +blade +blood +blow +blue +board +boat +body +boiling +book +boot +bottle +box +boy +brain +brake +branch +brass +bread +breath +brick +bridge +bright +broken +brother +brown +brush +bucket +building +bulb +burn +burst +business +butter +button +by +cake +camera +canvas +card +care +carriage +cart +cat +cause +certain +chain +chalk +chance +change +cheap +cheese +chemical +chest +chief +chin +church +circle +clean +clear +clock +cloth +cloud +coal +coat +cold +collar +colour +comb +come +comfort +committee +common +company +comparison +complete +complex +condition +connection +conscious +control +cook +copper +copy +cord +cork +cotton +cough +country +cover +cow +crack +credit +crime +cruel +crush +cry +cup +cup +current +curtain +curve +cushion +damage +danger +dark +daughter +day +dead +dear +death +debt +decision +deep +degree +delicate +dependent +design +desire +destruction +detail +development +different +digestion +direction +dirty +discovery +discussion +disease +disgust +distance +division +do +dog +door +doubt +down +drain +drawer +dress +drink +driving +drop +dry +dust +ear +early +earth +east +edge +education +effect +egg +elastic +electric +end +engine +enough +equal +error +even +event +ever +every +example +exchange +existence +expansion +experience +expert +eye +face +fact +fall +false +family +far +farm +fat +father +fear +feather +feeble +feeling +female +fertile +fiction +field +fight +finger +fire +first +fish +fixed +flag +flame +flat +flight +floor +flower +fly +fold +food +foolish +foot +for +force +fork +form +forward +fowl +frame +free +frequent +friend +from +front +fruit +full +future +garden +general +get +girl +give +glass +glove +go +goat +gold +good +government +grain +grass +great +green +grey +grip +group +growth +guide +gun +hair +hammer +hand +hanging +happy +harbour +hard +harmony +hat +hate +have +he +healthy +hear +hearing +heart +heat +help +high +history +hole +hollow +hook +hope +horn +horse +hospital +hour +house +how +humour +ice +idea +if +ill +important +impulse +in +increase +industry +ink +insect +instrument +insurance +interest +invention +iron +island +jelly +jewel +join +journey +judge +jump +keep +kettle +key +kick +kind +kiss +knee +knife +knot +knowledge +land +language +last +late +laugh +law +lead +leaf +learning +left +leg +let +letter +level +library +lift +light +like +limit +line +linen +lip +liquid +list +little +living +lock +long +look +loose +loss +loud +love +low +machine +make +male +man +manager +map +mark +market +married +mass +match +material +may +meal +measure +meat +medical +meeting +memory +metal +middle +military +milk +mind +mine +minute +mist +mixed +money +monkey +month +moon +morning +mother +motion +mountain +mouth +move +much +muscle +music +nail +name +narrow +nation +natural +near +necessary +neck +need +needle +nerve +net +new +news +night +no +noise +normal +north +nose +not +note +now +number +nut +of +off +offer +office +oil +old +on +only +open +operation +opinion +opposite +or +orange +order +ornament +other +out +oven +over +owner +page +pain +paint +paper +parallel +parcel +part +past +paste +payment +peace +pen +pencil +person +physical +picture +pig +pin +pipe +place +plane +plant +plate +play +please +pleasure +plough +pocket +point +poison +polish +political +poor +porter +position +possible +pot +potato +powder +power +present +price +print +prison +private +probable +process +produce +profit +property +prose +protest +public +pull +pump +purpose +push +put +quality +question +quick +quiet +quite +rail +rain +range +rat +rate +ray +reaction +reading +ready +reason +receipt +record +red +regret +regular +relation +request +respect +rest +reward +rhythm +rice +right +ring +river +road +rod +roll +roof +room +root +rough +round +rub +rule +run +safe +sail +salt +same +sand +say +scale +school +science +scissors +screw +sea +seat +second +secret +see +seed +seem +self +send +sense +separate +serious +servant +sex +shade +shake +shame +sharp +sheep +shelf +ship +shirt +shock +shoe +short +shut +side +sign +silk +silver +simple +sister +size +skin +skirt +sky +sleep +slip +slope +slow +small +smash +smell +smile +smoke +smooth +snake +sneeze +snow +so +soap +society +sock +soft +solid +some + +son +song +sort +sound +soup +south +space +spade +special +sponge +spoon +spring +square +stage +stamp +star +start +statement +station +steam +steel +stem +step +stick +sticky +stiff +still +stitch +stocking +stomach +stone +stop +store +story +straight +strange +street +stretch +strong +structure +such +sudden +sugar +summer +sun +support +surprise +sweet +swim +system +table +tail +take +talk +tall +taste +tax +teaching +tendency +test +than +that +the +then +theory +there +thick +thin +thing +this +thought +thread +throat +through +through +thumb +thunder +ticket +tight +till +time +tin +tired +to +toe +together +tomorrow +tongue +tooth +top +touch +town +trade +train +transport +tray +tree +trick +trouble +trousers +true +turn +twist +umbrella +under +unit +up +use +value +verse +very +vessel +view +violent +voice +waiting +walk +wall +war +warm +wash +waste +watch +water +wave +wax +way +weather +week +weight +well +west +wet +wheel +when +where +while +whip +whistle +white +who +why +wide +will +wind +window +wine +wing +winter +wire +wise +with +woman +wood +wool +word +work +worm +wound +writing +wrong +year +yellow +yes +yesterday +you +young diff --git a/classes/FileServer/AdapterAbstract.php b/classes/FileServer/AdapterAbstract.php new file mode 100644 index 0000000..0c5ac4f --- /dev/null +++ b/classes/FileServer/AdapterAbstract.php @@ -0,0 +1,405 @@ + + * @copyright 2010 Jamie Kahgee + * @license http://www.gaslightmedia.com/ Gaslightmedia + * @version CVS: $Id: AdapterAbstract.php,v 1.6 2010/06/04 11:33:54 jamie Exp $ + * @link <> + * @see References to other sections (if any)... + */ + + +/** + * Validation Secret + */ +define('IS_VALIDATE_SECRET', 'Glm0IS1secreT'); + +/** + * URL to file server, this is dynamic based on the server + * so can be setup for any sandbox + */ +define('IS_SUBMIT_URL', FILE_SERVER_URL . 'submit.phtml'); + +/** + * Adapter class for linking to the file server + * + * @category Toolkit + * @package FileServer + * @author Jamie Kahgee + * @copyright 2010 Jamie Kahgee + * @license http://www.gaslightmedia.com/ Gaslightmedia + * @version Release: @package_version@ + * @link <> + * @see References to other sections (if any)... + */ +abstract class Reg_Toolkit_FileServer_AdapterAbstract +{ + // {{{ properties + + /** + * ID of owner that was setup in the file server + * + * This is defined via the file server web interface + * @var string + * @access protected + */ + protected $ownerID; + + /** + * Owners password that was setup for them + * + * This is defined via the file server web interface + * @var string + * @access protected + */ + protected $ownerPW; + + /** + * XML to send to the file server + * @var unknown + * @access protected + */ + protected $xml; + + // }}} + // {{{ __construct() + + /** + * Constructor + * + * @param string $owner File Server owner + * @param string $pword File Server owner password + */ + public function __construct($owner = IS_OWNER_ID, $pword = IS_OWNER_PW) + { + $this->ownerID = $owner; + $this->ownerPW = $pword; + } + + // }}} + + // {{{ buildFileServerXML() + + /** + * buildFileServerXML + * + * Create the xml for the FileServerRequest + * + * @param string $fName File name to upload or delete + * @param string $type Upload, Delete or URL + * + * @return string xml content + * @access protected + */ + protected function buildFileServerXML($fName, $type) + { + $xml = new DOMDocument('1.0'); + $xml->formatOutput = true; + + $fileServerRequest = $xml->createElement('FileServerRequest'); + $fileServerRequest->setAttribute('version', '1.0'); + + // access request + $accessRequest = $xml->createElement('AccessRequest'); + $owner = $xml->createElement('Owner'); + $ownerID = $xml->createElement('OwnerID', $this->ownerID); + $ownerPW = $xml->createElement('OwnerPW', $this->ownerPW); + + $owner->appendChild($ownerID); + $owner->appendChild($ownerPW); + + $accessRequest->appendChild($owner); + + $fileServerRequest->appendChild($accessRequest); + + $file = $this->getFileElement($xml, $type, $fName); + + $fileServerRequest->appendChild($file); + $validStr = md5($this->ownerID . $this->ownerPW . IS_VALIDATE_SECRET); + + $validation = $xml->createElement('Validation', $validStr); + $fileServerRequest->appendChild($validation); + $xml->appendChild($fileServerRequest); + + return $xml->saveXML($xml); + } + + // }}} + + // {{{ delete() + + /** + * Delete a file from the file server + * + * @param string $name File name + * + * @return string file name + * @access public + * @throws Toolkit_FileServer_Exception + */ + public function delete($name) + { + // don't do anything if on development server + if (defined('DEVELOPMENT') && DEVELOPMENT == true) { + return true; + } + $ch = curl_init(); + + $fileData = array( + 'request' => $this->buildFileServerXML($name, 'Delete') + ); + $curlOptions = array( + CURLOPT_URL => IS_SUBMIT_URL, + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + + try { + $xmlDoc = new DOMDocument; + $response = str_replace('', '', $response); + $xmlDoc->loadXML($response); + $successCode = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/SuccessCode' + ); + $message = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/Message' + ); + + if ($successCode != 0) { + throw new RangeException( + "Invalid response `$response` - `$message`" + ); + } + + return $message; + } catch (RangeException $e) { + Toolkit_Logger::logException('Image Server', $e); + throw new Toolkit_FileServer_Exception( + 'Invalid File Server Response' + ); + } + } + + // }}} + + // {{{ getFileElement() + + + /** + * Gets the file element used in the XML sent to the file server + * + * @param DOMDocument $xml DOM object used to build the xml string + * @param string $type Type of manipulation (Upload, URL, Delete) + * @param string $fName File name + * + * @return DOMElement $file File xml element + * @access protected + */ + abstract protected function getFileElement( + DOMDocument $xml, + $type, + $fName + ); + + // }}} + // {{{ getErrorMessage() + + /** + * Gets an appropriate error message for file upload errors + * + * @param integer Error code + * + * @return string Error message + * @access protected + */ + protected function getErrorMessage($code) + { + switch ($code) { + case UPLOAD_ERR_INI_SIZE : + $message = 'The Uploaded file exceeds the upload max filesize directive in php.ini'; + break; + + case UPLOAD_ERR_FORM_SIZE : + $message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; + break; + + case UPLOAD_ERR_PARTIAL : + $message = 'The uploaded file was only partially uploaded'; + break; + + case UPLOAD_ERR_NO_FILE : + $message = 'No file was uploaded'; + break; + + case UPLOAD_ERR_NO_TMP_DIR : + $message = 'Missing a temporary folder'; + break; + + case UPLOAD_ERR_CANT_WRITE : + $message = 'Failed to write file to disk'; + break; + + case UPLOAD_ERR_EXTENSION : + $message = 'A PHP extension stopped the file upload'; + break; + + default : + $message = 'Unknown error uploading file'; + break; + } + + return $message; + } + + // }}} + + // {{{ upload() + + /** + * Upload a file to the File Server + * + * @param string $name $_FILES index key that holds the file data + * + * @return array Uploaded file data + * @access public + * @throws Toolkit_FileServer_Exception + */ + public function upload($name) + { + $fileType = null; + if (preg_match('/^http/', $name)) { + $fileType = 'URL'; + } elseif (isset($_FILES[$name]) && is_array($_FILES[$name])) { + $fileType = 'Upload'; + } + + if ($_FILES[$name]['error'] != 0) { + $message = $this->getErrorMessage($_FILES[$name]['error']); + throw new Toolkit_FileServer_Exception( + $message, + $_FILES[$name]['error'] + ); + } + + if (is_null($fileType)) { + return false; + } else { + $request = $this->buildFileServerXML($name, $fileType); + + $ch = curl_init(); + if ($fileType == 'URL') { + $fileData = array( + 'request' => $request + ); + } else { + $fileData = array( + 'request' => $request, + 'file_upload' => "@{$_FILES[$name]['tmp_name']}", + 'file_upload_name' => $_FILES[$name]['name'] + ); + } + + $curlOptions = array( + CURLOPT_URL => IS_SUBMIT_URL, + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + + try { + $xmlDoc = new DOMDocument(); + $response = str_replace('', '', $response); + $xmlDoc->loadXML($response); + $successCode = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/SuccessCode' + ); + $message = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/Message' + ); + $storedName = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredName' + ); + $storedSize = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredSize' + ); + $mediaType = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/MediaType' + ); + + if ($successCode != 0) { + throw new RangeException( + "Invalid response `$response` - `$message`" + ); + } + + $extension = end(explode('.', $storedName)); + return array( + 'name' => $storedName, + 'size' => $storedSize, + 'type' => $mediaType, + 'extension' => $extension, + ); + } catch (RangeException $e) { + Toolkit_Logger::logException('Image Server', $e); + throw new Toolkit_FileServer_Exception( + 'Invalid File Server Response' + ); + } + } + } + + // }}} + + // {{{ xmlPathContent() + + /** + * Extract a XML node value + * + * @param DOMDocument $dom DOM object holding the XML + * @param string $content Node name to extract content from + * + * @return mixed Node value on success, false if can't find the value + * @access protected + */ + protected function xmlPathContent(DOMDocument $dom, $content) + { + $xPath = new DOMXPath($dom); + $nodeList = $xPath->query($content); + if ($nodeList->length > 0) { + $node = $nodeList->item(0); + return $node->nodeValue; + } + + return false; + } + + // }}} +} diff --git a/classes/FileServer/FileAdapter.php b/classes/FileServer/FileAdapter.php new file mode 100644 index 0000000..24180f2 --- /dev/null +++ b/classes/FileServer/FileAdapter.php @@ -0,0 +1,101 @@ + + * @copyright 2010 Jamie Kahgee + * @license http://www.gaslightmedia.com/ Gaslightmedia + * @version CVS: $Id: FileAdapter.php,v 1.4 2010/05/25 14:02:28 jamie Exp $ + * @link <> + * @see References to other sections (if any)... + */ + +/** + * File Adapter + * + * Used for linking to the file server for file uploading, storage and deletion + * + * @category Toolkit + * @package FileServer + * @author Jamie Kahgee + * @copyright 2010 Jamie Kahgee + * @license http://www.gaslightmedia.com/ Gaslightmedia + * @version Release: @package_version@ + * @link <> + * @see References to other sections (if any)... + */ +class Reg_Toolkit_FileServer_FileAdapter extends Reg_Toolkit_FileServer_AdapterAbstract +{ + // {{{ getFileElement() + + /** + * Creates the file element for the XML string + * + * @param DOMDocument $xml XML object used to build the string + * @param string $type Type of action to take on the file (Upload, Delete) + * @param string $fName file name to delete + * + * @return DOMElement $file File xml element + * @access protected + * @throws RuntimeException + */ + protected function getFileElement(DOMDocument $xml, $type, $fName) + { + $file = $xml->createElement('File'); + + switch ($type) { + case 'Upload' : + $action = $xml->createElement('FileAction', 'Submit'); + $delivery = $xml->createElement('DeliveryMethod', 'Submit'); + $fieldName = $xml->createElement('FieldName', 'file_upload'); + + $fileName = filter_var($_FILES[$fName]['name'], FILTER_SANITIZE_STRING); + $nameParts = explode('.', $fileName); + $extension = end($nameParts); + $fieldName = $xml->createElement('Extension', end($nameParts)); + + $file->appendChild($action); + $file->appendChild($delivery); + $file->appendChild($fieldName); + break; + + case 'URL': + $action = $xml->createElement('FileAction', 'Submit'); + $delivery = $xml->createElement('DeliveryMethod', 'URL'); + $src = $xml->createElement('Src', $fName); + + $nameParts = explode('.', $fName); + $extension = end($nameParts); + $fieldName = $xml->createElement('Extension', end($nameParts)); + + $file->appendChild($action); + $file->appendChild($delivery); + $file->appendChild($src); + $file->appendChild($fieldName); + break; + + case 'Delete' : + $action = $xml->createElement('FileAction', 'Delete'); + $file->appendChild($action); + + $fileName = $xml->createElement('FileName', $fName); + $file->appendChild($fileName); + break; + + default : + throw new RuntimeException("Invalid XML type - `$type`."); + break; + } + + return $file; + } + + // }}} +} diff --git a/classes/ImageServer/Server.php b/classes/ImageServer/Server.php new file mode 100644 index 0000000..142d421 --- /dev/null +++ b/classes/ImageServer/Server.php @@ -0,0 +1,373 @@ + + * @copyright 2008 Steve Sutton + * @license Gaslight Media + * @version CVS: $Id: Server.php,v 1.19 2010/05/25 14:02:45 jamie Exp $ + * @link http://demo.gaslightmedia.com + */ + +/** + * Description for define + */ +define('IS_VALIDATE_SECRET', 'Glm0IS1secreT'); + +/** + * Description for define + */ +define('IS_SUBMIT_URL', FILE_SERVER_URL . 'submit.phtml'); + +/** + * Toolkit_Image_Server + * + * Class for implementation of the image server process Chuck has + * setup for is0.gaslightmedia.com + * Uses Curl PHP Library to upload images to the server + * + * @category Toolkit + * @package Image + * @author Steve Sutton + * @copyright 2008 Steve Sutton + * @license Gaslight Media + * @link http://demo.gaslightmedia.com + */ +class Reg_Toolkit_Image_Server +{ + // {{{ properties + + /** + * OwnerID for the Image Server User + * @var string + * @access protected + */ + protected $OwnerID; + + /** + * Owner Password + * @var string + * @access protected + */ + protected $OwnerPW; + + /** + * DOMDocument Object + * @var unknown + * @access protected + */ + protected $xml; + + // }}} + + // {{{ __construct() + + /** + * __construct + * + * @return void + * @access public + */ + function __construct() + { + $this->OwnerID = IS_OWNER_ID; + $this->OwnerPW = IS_OWNER_PW; + } + + // }}} + + // {{{ buildImageServerXML() + + /** + * buildImageServerXML + * + * Create the xml for the FileServerRequest + * + * @param string $fileName File to upload or delete + * @param unknown $type Upload or Delete + * + * @return string xml content + * @access public + */ + function buildImageServerXML($fileName, $type) + { + $xml = new DOMDocument('1.0'); + $xml->formatOutput = true; + $FileServerRequest = $xml->createElement('FileServerRequest'); + $FileServerRequest->setAttribute('version', '1.0'); + // AccessRequest part + $AccessRequest = $xml->createElement('AccessRequest'); + $Owner = $xml->createElement('Owner'); + $OwnerID = $xml->createElement('OwnerID', $this->OwnerID); + $OwnerPW = $xml->createElement('OwnerPW', $this->OwnerPW); + $Owner->appendChild($OwnerID); + $Owner->appendChild($OwnerPW); + $AccessRequest->appendChild($Owner); + $FileServerRequest->appendChild($AccessRequest); + // file part + $File = $xml->createElement('File'); + switch ($type) { + case "Upload": + $FileAction = $xml->createElement('FileAction', 'Submit'); + $DeliveryMethod = $xml->createElement('DeliveryMethod', 'Submit'); + $FieldName = $xml->createElement('FieldName', 'file_upload'); + $File->appendChild($FileAction); + $File->appendChild($DeliveryMethod); + $File->appendChild($FieldName); + $FileServerRequest->appendChild($File); + $size = filesize($_FILES[$fileName]['tmp_name']); + $validStr = md5($this->OwnerID.$this->OwnerPW.IS_VALIDATE_SECRET); + break; + case "URL": + $FileAction = $xml->createElement('FileAction', 'Submit'); + $DeliveryMethod = $xml->createElement('DeliveryMethod', 'URL'); + $Src = $xml->createElement('Src', $fileName); + $File->appendChild($FileAction); + $File->appendChild($DeliveryMethod); + $File->appendChild($Src); + $FileServerRequest->appendChild($File); + $size = strlen($fileName); + $validStr = md5($this->OwnerID.$this->OwnerPW.IS_VALIDATE_SECRET); + break; + case "Delete": + $FileAction = $xml->createElement('FileAction', 'Delete'); + $File->appendChild($FileAction); + $FileName = $xml->createElement('FileName', $fileName); + $File->appendChild($FileName); + $FileServerRequest->appendChild($File); + $validStr = md5($this->OwnerID.$this->OwnerPW.IS_VALIDATE_SECRET); + break; + } + // validation part + $Validation = $xml->createElement('Validation', $validStr); + $FileServerRequest->appendChild($Validation); + $xml->appendChild($FileServerRequest); + return $xml->saveXML($xml); + } + + // }}} + + // {{{ imageDelete() + + /** + * imageDelete + * + * Delete an image from the image server + * + * @param unknown $name Image name + * + * @return unknown image name + * @access public + */ + function imageDelete($name) + { + // don't do anything if on development server + if (defined('DEVELOPMENT') && DEVELOPMENT == true) { + return "File deleted. File: " . $name; + } + if ($name) { + $request = $this->buildImageServerXML($name, 'Delete'); + $ch = curl_init(); + $fileData = array( + 'request' => $request + ); + $curlOptions = array( + CURLOPT_URL => IS_SUBMIT_URL, + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + $xmlDoc = new DOMDocument; + $response = str_replace('', '', $response); + $xmlDoc->loadXML($response); + $SuccessCode = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/SuccessCode' + ); + $Message = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/Message' + ); + $Owner = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/Owner' + ); + $StoredName = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredName' + ); + $StoredSize = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredSize' + ); + $MediaType = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/MediaType' + ); + return $Message; + } + } + + // }}} + // {{{ imageUpload() + + /** + * imageUpload + * + * Upload image to server + * + * @param string $name Form field name of image + * + * @return string Image name + * @access public + */ + function imageUpload($name) + { + $fileType = null; + if (preg_match("/^http/", $name)) { + $fileType = 'URL'; + } elseif (is_array($_FILES[$name])) { + $fileType = 'Upload'; + } + if ($fileType) { + $request = $this->buildImageServerXML($name, $fileType); + $ch = curl_init(); + if ($fileType == "URL") { + $fileData = array( + 'request' => $request + ); + } else { + $fileData = array( + 'request' => $request, + 'file_upload' => '@'.$_FILES[$name]['tmp_name'], + 'file_upload_name' => $_FILES[$name]['name'] + ); + } + $curlOptions = array( + CURLOPT_URL => IS_SUBMIT_URL, + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + $xmlDoc = new DOMDocument; + $response = str_replace('', '', $response); + $xmlDoc->loadXML($response); + $SuccessCode = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/SuccessCode' + ); + $Message = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/ReplyStatus/Message' + ); + $Owner = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/Owner' + ); + $StoredName = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredName' + ); + $StoredSize = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/StoredSize' + ); + $MediaType = $this->xmlPathContent( + $xmlDoc, + '/FileServerResponse/File/MediaType' + ); + if ($SuccessCode != 0) { + //throw new Exception('Image Server Error said:'.$response); + throw new PEAR_Exception('Image Server Error said:'.$response); + exit; + } + return $StoredName; + } + } + + // }}} + + // {{{ getImageSize() + + /** + * getImageSize + * + * Return image data on an image from image server + * + * @param string $image Full URI to image + * http://is0/userId/imageStyle/imageName + * Must be a full URI including an authority. + * No relative URIs, the // are mandatory + * + * @return array Image data 0 => width, 1 => height, 2 => html + * @access public + * @throws PEAR Error + */ + function getImageSize($image) + { + $options = array('allowed_schemes' => array('http','https')); + if (!Validate::uri($image, $options)) { + throw new PEAR_Exception('Invalid URI for the image'); + exit; + } + + $ch = curl_init(); + $curlOptions = array( + CURLOPT_URL => "{$image}/info", + CURLOPT_HEADER => 0, + CURLOPT_RETURNTRANSFER => 1, +// CURLOPT_POSTFIELDS => $fileData + ); + curl_setopt_array($ch, $curlOptions); + + $response = curl_exec($ch); + curl_close($ch); + $wPattern = "/(.*)<\/width>/"; + preg_match($wPattern, $response, $matches); + $width = $matches[1]; + $hPattern = "/(.*)<\/height>/"; + preg_match($hPattern, $response, $matches); + $height = $matches[1]; + $html = "width=\"{$width}\" height=\"{$height}\""; + return array($width, $height, $html); + } + + // }}} + + // {{{ xmlPathContent() + + /** + * xmlPathContent + * + * Grab the content given XPath Query + * + * @param unknown $dom DOMDocument nodelist + * @param unknown $content query for XPath + * + * @return object string of node + * @access public + */ + function xmlPathContent($dom, $content) + { + $xPath = new DOMXPath($dom); + $nodelist = $xPath->query($content); + foreach ($nodelist as $entry) { + return $entry->nodeValue; + } + } + + // }}} +} diff --git a/classes/merchant_solutions.inc b/classes/merchant_solutions.inc new file mode 100644 index 0000000..3e6f85d --- /dev/null +++ b/classes/merchant_solutions.inc @@ -0,0 +1,269 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: merchant_solutions.php,v 1.0 2011/08/28 14:00:00 cscott Exp $ + */ + +define( "MS_WSDL", "https://trans.merchantsolution.com/Web/services/TransactionService?wsdl" ); + +/** + * Merchant Solutions Payment Gateway class + * + * PHP version 5 + */ + +class MerchantSolutionsPaymentGateway +{ + /** + * Request Object + * + * @var $request + * @access public + */ + public $request = false; + /** + * Communications Success flag + * + * @var $success + * @access public + */ + public $success = false; + /** + * Transaction Result + * + * @var $success + * @access public + */ + public $result = false; + /** + * Description of transaction results + * + * @var $resultDescription + * @access public + */ + public $resultDescription = false; + /** + * Raw response data + * + * @var $response + * @access public + */ + public $response = false; + /** + * Detailed approval data + * + * @var $approval + * @access public + */ + public $approval = false; + /** + * Reason card was declined + * + * @var $declineReason + * @access public + */ + public $declineReason = ''; + /** + * XML Soap Client Object + * + * @var $client + * @access public + */ + public $client; + + /** + * Request Objects + * + * @access public + */ + public $CCSaleRequest = array( + 'acctid' => false, // Merchant account, use TEST0 for testing + 'merchantpin' => false, // Merchant PIN for access to API, Login to Merchant center, then "FRISK(TM) Management" and "Configure Options" + 'amount' => false, + 'ccnum' => false, + 'expmon' => false, + 'expyear' => false, + 'ccname' => false, + 'cardpresent' => 0, + 'cardreaderpresent' => 0, + 'cvv2' => false, + 'encryptedreadertype' => 0, // Now seems to be required but is not in CCSale specification + 'conveniencefeeflag' => 0, // Now seems to be required but is not in CCSale specification + 'contactlessflag' => 0, // Now seems to be required but is not in CCSale specification + 'accttype' => 1, // 1=CC + 'profileactiontype' => 2, // 2=run a Sale for the amount requested + 'manualrecurring' => 0, // 0=Not Recurring + 'avs_override' => 0, // 0=Don't override Address Verification + 'cvv2_override' => 0, // 0=Don't override CVV2 + 'loadbalance_override' => 0, // 0=Don't override Subid load balance + 'duplicate_override' => 0, // 0=Don't override duplicate transaction + 'accountlookupflag' => 0, // 0=Don't perform account lookup + 'ci_memo' => '' // something that should be sent in the confirmation E-Mail from Merchant Solutions + ); + + /** + * Constructor + * + * @param object $d database connection + * + * @return boolean Returns value of $success parameter + * @access public + */ + function __construct($request) + { + + // Determine which type of request and setup data array + switch ($request) { + + case 'processCCSale': + $this->request = (object) $this->CCSaleRequest; + break; + + default: + return false; + break; + + } + + // Setup options related to doing the SOAP calls + ini_set('soap.wsdl_cache_enabled', 1); + use_soap_error_handler(false); + $soapOptions = array( + "exceptions" => 1, + 'connection_timeout' => 10 + ); + + $this->resultDescription = ''; + + // Setup SOAP client and get WSDL for gateway + try { + + // XDebug prevents catching fatal errors with the Soap calls + if (function_exists('xdebug_disable')) { + xdebug_disable(); + } + +// $this->resultDescription .= 'preSOAP '; + + $this->client = @new SoapClient(MS_WSDL, $soapOptions); + + + $this->resultDescription .= 'postSOAP '; + + if (function_exists('xdebug_enable')) { + xdebug_enable(); + } + +// $this->resultDescription .= 'SOAPdone '; + + // Indicate setup OK + $this->success = true; + $this->resultDescription = 'Setup Successful (WSDL)'; + + } catch (SoapFault $exception) { + +// $this->resultDescription .= 'SOAPfail '; + + // Indicate setup failure + $this->success = false; + $this->resultDescription .= 'Communications Failure (WSDL): '.$this->client->getMessage(); + } + +// $this->resultDescription .= 'SOAPsetup '.($this->success==true?'Y':'N'); + + return $this->success; + } + + /** + * Process CC Sale + * + * @return boolean Returns value of $success parameter + */ + function merchantSolutionsCCSale() + { + // Determine if we have good data supplied + $a = ($this->request->amount - 0); + if ($a == 0 || $a > 99999.99 ) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Amount'; + } + if (trim($this->request->ccnum) == '') { + $this->result = 'Invalid'; + $this->resultDescription = 'Missing Card Number'; + } + $m = ($this->request->expmon - 0); + if (!is_int($m) || $m < 1 || $m > 12) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Expiration Month'; + } + $y = ($this->request->expyear - 0); + if (!is_int($y) || $y < 2000 || $y > 2100) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Expiration Year'; + } + if (trim($this->request->ccname) == '') { + $this->result = 'Invalid'; + $this->resultDescription = 'Missing Name on Card'; + } + if ($this->result == 'Invalid') { + return true; + } + + // Try to process the transaction + try { + + // Send Request + if (function_exists('xdebug_disable')) { + xdebug_disable(); + } + $this->response = $this->client->processCCSale($this->request); + if (function_exists('xdebug_enable')) { + xdebug_enable(); + } + + // Get request result (Approved/Declined) + $this->success = true; + $this->result = $this->response->status; + $this->resultDescription = $this->response->result; + + // If Declined, say why + if ($this->result == 'Declined') { + + $x = explode(":", $this->response->result); + $this->declineReason = $x[2]; + + // Must be Approved, get approval data + } else { + + $this->success = true; + $this->approval->auth = $this->response->authcode; + $this->approval->transTime = $this->response->transdate; + $this->approval->cardType = $this->response->paytype; + + $this->resultDescription = $this->response->status; + } + + // If there's a communications failure + } catch (SoapFault $exception) { + +// if ($this->request->ccnum == '5454545454545454') { +// echo "
".print_r($exception,1)."
"; +// } + $this->success = false; + $this->resultDescription = 'Communications Failure'; + + } + + return $this->success; + } + +} + +?> diff --git a/classes/merchant_solutions.inc.SAVE b/classes/merchant_solutions.inc.SAVE new file mode 100644 index 0000000..8d022b3 --- /dev/null +++ b/classes/merchant_solutions.inc.SAVE @@ -0,0 +1,268 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: merchant_solutions.php,v 1.0 2011/08/28 14:00:00 cscott Exp $ + */ + +define( "MS_WSDL", "https://trans.merchantsolution.com/Web/services/TransactionService?wsdl" ); + +/** + * Merchant Solutions Payment Gateway class + * + * PHP version 5 + */ + +class MerchantSolutionsPaymentGateway +{ + /** + * Request Object + * + * @var $request + * @access public + */ + public $request = false; + /** + * Communications Success flag + * + * @var $success + * @access public + */ + public $success = false; + /** + * Transaction Result + * + * @var $success + * @access public + */ + public $result = false; + /** + * Description of transaction results + * + * @var $resultDescription + * @access public + */ + public $resultDescription = false; + /** + * Raw response data + * + * @var $response + * @access public + */ + public $response = false; + /** + * Detailed approval data + * + * @var $approval + * @access public + */ + public $approval = false; + /** + * Reason card was declined + * + * @var $declineReason + * @access public + */ + public $declineReason = ''; + /** + * XML Soap Client Object + * + * @var $client + * @access public + */ + public $client; + + /** + * Request Objects + * + * @access public + */ + public $CCSaleRequest = array( + 'acctid' => false, // Merchant account, use TEST0 for testing + 'merchantpin' => false, // Merchant PIN for access to API, Login to Merchant center, then "FRISK(TM) Management" and "Configure Options" + 'amount' => false, + 'ccnum' => false, + 'expmon' => false, + 'expyear' => false, + 'ccname' => false, + 'cardpresent' => 0, + 'cardreaderpresent' => 0, + 'cvv2' => false, + 'encryptedreadertype' => 0, // Now seems to be required but is not in CCSale specification + 'conveniencefeeflag' => 0, // Now seems to be required but is not in CCSale specification + 'accttype' => 1, // 1=CC + 'profileactiontype' => 2, // 2=run a Sale for the amount requested + 'manualrecurring' => 0, // 0=Not Recurring + 'avs_override' => 0, // 0=Don't override Address Verification + 'cvv2_override' => 0, // 0=Don't override CVV2 + 'loadbalance_override' => 0, // 0=Don't override Subid load balance + 'duplicate_override' => 0, // 0=Don't override duplicate transaction + 'accountlookupflag' => 0, // 0=Don't perform account lookup + 'ci_memo' => '' // something that should be sent in the confirmation E-Mail from Merchant Solutions + ); + + /** + * Constructor + * + * @param object $d database connection + * + * @return boolean Returns value of $success parameter + * @access public + */ + function __construct($request) + { + + // Determine which type of request and setup data array + switch ($request) { + + case 'processCCSale': + $this->request = (object) $this->CCSaleRequest; + break; + + default: + return false; + break; + + } + + // Setup options related to doing the SOAP calls + ini_set('soap.wsdl_cache_enabled', 1); + use_soap_error_handler(false); + $soapOptions = array( + "exceptions" => 1, + 'connection_timeout' => 10 + ); + + $this->resultDescription = ''; + + // Setup SOAP client and get WSDL for gateway + try { + + // XDebug prevents catching fatal errors with the Soap calls + if (function_exists('xdebug_disable')) { + xdebug_disable(); + } + +// $this->resultDescription .= 'preSOAP '; + + $this->client = @new SoapClient(MS_WSDL, $soapOptions); + + + $this->resultDescription .= 'postSOAP '; + + if (function_exists('xdebug_enable')) { + xdebug_enable(); + } + +// $this->resultDescription .= 'SOAPdone '; + + // Indicate setup OK + $this->success = true; + $this->resultDescription = 'Setup Successful (WSDL)'; + + } catch (SoapFault $exception) { + +// $this->resultDescription .= 'SOAPfail '; + + // Indicate setup failure + $this->success = false; + $this->resultDescription .= 'Communications Failure (WSDL): '.$this->client->getMessage(); + } + +// $this->resultDescription .= 'SOAPsetup '.($this->success==true?'Y':'N'); + + return $this->success; + } + + /** + * Process CC Sale + * + * @return boolean Returns value of $success parameter + */ + function merchantSolutionsCCSale() + { + // Determine if we have good data supplied + $a = ($this->request->amount - 0); + if ($a == 0 || $a > 99999.99 ) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Amount'; + } + if (trim($this->request->ccnum) == '') { + $this->result = 'Invalid'; + $this->resultDescription = 'Missing Card Number'; + } + $m = ($this->request->expmon - 0); + if (!is_int($m) || $m < 1 || $m > 12) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Expiration Month'; + } + $y = ($this->request->expyear - 0); + if (!is_int($y) || $y < 2000 || $y > 2100) { + $this->result = 'Invalid'; + $this->resultDescription = 'Invalid Expiration Year'; + } + if (trim($this->request->ccname) == '') { + $this->result = 'Invalid'; + $this->resultDescription = 'Missing Name on Card'; + } + if ($this->result == 'Invalid') { + return true; + } + + // Try to process the transaction + try { + + // Send Request + if (function_exists('xdebug_disable')) { + xdebug_disable(); + } + $this->response = $this->client->processCCSale($this->request); + if (function_exists('xdebug_enable')) { + xdebug_enable(); + } + + // Get request result (Approved/Declined) + $this->success = true; + $this->result = $this->response->status; + $this->resultDescription = $this->response->result; + + // If Declined, say why + if ($this->result == 'Declined') { + + $x = explode(":", $this->response->result); + $this->declineReason = $x[2]; + + // Must be Approved, get approval data + } else { + + $this->success = true; + $this->approval->auth = $this->response->authcode; + $this->approval->transTime = $this->response->transdate; + $this->approval->cardType = $this->response->paytype; + + $this->resultDescription = $this->response->status; + } + + // If there's a communications failure + } catch (SoapFault $exception) { + +// if ($this->request->ccnum == '5454545454545454') { +// echo "
".print_r($exception,1)."
"; +// } + $this->success = false; + $this->resultDescription = 'Communications Failure'; + + } + + return $this->success; + } + +} + +?> diff --git a/documentation/Conversion_from_V2.53_to_V3.txt b/documentation/Conversion_from_V2.53_to_V3.txt new file mode 100644 index 0000000..5f1ec34 --- /dev/null +++ b/documentation/Conversion_from_V2.53_to_V3.txt @@ -0,0 +1,188 @@ +Conversion instructions from V2.53 to V3 +---------------------------------------- + + +* Add the following settings to config/application.ini if not already there. + Place in rational locations. + +event_registration.organization_internal_email = "owner_internal_email" +event_registration.organization_from_email = "owner_from_email" + +event_registration.word.contact_fname => "First Name" +event_registration.word.contact_lname => "Last Name" +event_registration.word.contact_addr1 => "Address" +event_registration.word.contact_addr2 => " " +event_registration.word.contact_city => "City" +event_registration.word.contact_state => "State" +event_registration.word.contact_zip => "ZIP/Postal Code" +event_registration.word.contact_country => "Country" +event_registration.word.contact_phone => "Phone" +event_registration.word.contact_fax => "FAX" +event_registration.default = Off +event_registration.show_instructor_in_event_lists = Off +event_registration.show_instructor_in_event_detail = Off +event_registration.word.instructor = "instructor" +event_registration.word.instructors = "instructors" +event_registration.select_by_picklists = On +event_registration.word.category = "Category" +event_registration.word.categories = "Categories" +event_registration.word.sub_category = "Sub Category" +event_registration.word.sub_categories = "Sub Categories" +event_registration.show_contact_data = Off +event_registration.custom_stylesheet = On +event_registration.titles.registration_button = "Book Tour" +; Whether to show rates in lists of events - If on, specify type for displaying ("detail" = detailed, "from" = "From: {lowest cost}") +event_registration.show_rates_in_event_lists = On +event_registration.show_rates_type = "from" +event_registration.word.attribute = "type" +event_registration.word.attributes = "types" +event_registration.attributes = On +; -- Billing fields to ignore when no payment is required (free registration) +event_registration.free_use_fname = On +event_registration.free_use_lname = On +event_registration.free_use_addr1 = On +event_registration.free_use_addr2 = On +event_registration.free_use_city_state = On +event_registration.free_use_country = On +event_registration.free_use_zip = On +event_registration.free_use_phone = On +event_registration.free_use_fax = On +; -- Contact fields and terms - leave a term empty (no spaces) to not use that field in forms and reports +; NOTE that city, state, zip, and country fields must either be all used or all off! No prompt will used for output for these fields. +event_registration.show_contact_data = On +event_registration.show_same_button = Off +event_registration.titles.contact_information = "Contact" +event_registration.prompt.contact_fname = "First Name" +event_registration.required.contact_fname = On +event_registration.prompt.contact_lname = "Last Name" +event_registration.required.contact_lname = On +event_registration.prompt.contact_addr1 = "Address" +event_registration.required.contact_addr1 = On +event_registration.prompt.contact_addr2 = "" +event_registration.required.contact_addr2 = Off +event_registration.prompt.contact_city = "City" +event_registration.required.contact_city = Off +event_registration.prompt.contact_state = "State" +event_registration.required.contact_state = Off +event_registration.prompt.contact_zip = "ZIP" +event_registration.required.contact_zip = Off +event_registration.prompt.contact_country = "Country" +event_registration.required.contact_country = Off +event_registration.prompt.contact_phone = "Phone" +event_registration.required.contact_phone = On +event_registration.prompt.contact_fax = "FAX" +event_registration.required.contact_fax = Off + +* Also check these + +; status is comma-separated list of (UNPAID, CC_PEND, CC_PAID, CC_DECL, CHECK_PEND, CHECK_PAID, COMP, AT_EVENT, CASH_PAID, NO_CHARGE, OTHER_ADMIN, FAILED, CANCELED) +event_registration.admin_opt.Submissions.status = "UNPAID, CC_PEND, CC_PAID, CHECK_PEND, CHECK_PAID, AT_EVENT, COMP, CASH_PAID, NO_CHARGE, OTHER_ADMIN" + + +* Check the following new fields and tables and add as required + +- misc + alter table misc add notify_subject text; + update misc set notify_subject = 'Instructor E-Mail Subject'; + alter table misc add notify_text text; + update misc set notify_text = 'Instructor E-Mail Body'; + alter table misc add req_ack_subject text; + update misc set req_ack_subject = 'Registration Acknowledgement E-Mail Subject'; + alter table misc add req_ack_text text; + update misc set req_ack_text = 'Registration Acknowledgement E-Mail Body'; + +- category + alter table category add column list_name text; + update category set list_name = ''; + +- todo + alter table todo add column restricted bool; + +- reg + alter table reg add column require_registered_user boolean; + update reg set require_registered_user = false; + alter table reg add column duration text; + update reg set duration = ''; + alter table reg add column category integer; + alter table reg add column todo integer; + alter table reg add column ask_date bool; + update reg set ask_date = 'f'; + alter table reg add column attribute integer; + alter table reg add column use_calendar boolean; + update reg set use_calendar = 'f'; + alter table reg add column date_select text; + update reg set date_select = ''; + ALTER TABLE reg ADD COLUMN restrict_comp_code boolean; + ALTER TABLE reg ADD COLUMN restrict_check boolean; + ALTER TABLE reg ADD COLUMN restrict_cash boolean; + ALTER TABLE reg ADD COLUMN restrict_credit_card boolean; + UPDATE reg SET restrict_comp_code = 'f', restrict_check = 'f', restrict_cash = 'f', restrict_credit_card = 'f'; + ALTER TABLE reg add column attendee_max_per_sub integer; + update reg set attendee_max_per_sub = 0; + + Only do the following if there were no categoies or sub-categories + update reg set todo = 1; + update reg set category = 1; + update category set todo = 1; + + +- reg_req + Alter table reg_req add column contact_same boolean; + update reg_req set contact_same = 'f'; + Alter table reg_req add column contact_fname text; + Alter table reg_req add column contact_lname text; + Alter table reg_req add column contact_org text; + Alter table reg_req add column contact_title text; + Alter table reg_req add column contact_addr1 text; + Alter table reg_req add column contact_addr2 text; + Alter table reg_req add column contact_city text; + Alter table reg_req add column contact_state text; + Alter table reg_req add column contact_zip text; + Alter table reg_req add column contact_country text; + Alter table reg_req add column contact_phone text; + Alter table reg_req add column contact_fax text; + + +- reg_detail + alter table reg_detail add column desired_date date; + +- attribute + + CREATE TABLE registrations.attribute ( + id SERIAL, + name text, + descr text, + sort integer + ); + + ALTER TABLE registrations.attribute OWNER TO postgres; + ALTER TABLE registrations.attribute_id_seq OWNER TO postgres; + REVOKE ALL ON TABLE registrations.attribute FROM PUBLIC; + REVOKE ALL ON TABLE registrations.attribute FROM postgres; + GRANT ALL ON TABLE registrations.attribute TO postgres; + GRANT ALL ON TABLE registrations.attribute TO nobody; + REVOKE ALL ON TABLE registrations.attribute_id_seq FROM PUBLIC; + REVOKE ALL ON TABLE registrations.attribute_id_seq FROM postgres; + GRANT ALL ON TABLE registrations.attribute_id_seq TO postgres; + GRANT ALL ON TABLE registrations.attribute_id_seq TO nobody; + +- reg_attr + CREATE TABLE registrations.reg_attr ( + id SERIAL, + reg integer, + attr integer + ); + + ALTER TABLE registrations.reg_attr OWNER TO postgres; + ALTER TABLE registrations.reg_attr_id_seq OWNER TO postgres; + REVOKE ALL ON TABLE registrations.reg_attr FROM PUBLIC; + REVOKE ALL ON TABLE registrations.reg_attr FROM postgres; + GRANT ALL ON TABLE registrations.reg_attr TO postgres; + GRANT ALL ON TABLE registrations.reg_attr TO nobody; + REVOKE ALL ON TABLE registrations.reg_attr_id_seq FROM PUBLIC; + REVOKE ALL ON TABLE registrations.reg_attr_id_seq FROM postgres; + GRANT ALL ON TABLE registrations.reg_attr_id_seq TO postgres; + GRANT ALL ON TABLE registrations.reg_attr_id_seq TO nobody; + + + \ No newline at end of file diff --git a/documentation/Feature_Requests_and_Pending_Fixes.txt b/documentation/Feature_Requests_and_Pending_Fixes.txt new file mode 100644 index 0000000..f94b477 --- /dev/null +++ b/documentation/Feature_Requests_and_Pending_Fixes.txt @@ -0,0 +1,108 @@ +Current Work +------------ + +Feature Requests +---------------- + +* Consider adding the ability to have custom forms that can be used for each attendee (could replace the medical info option). Would + need to be able to edit this information when doing the [Edit Registrant] option in the submissions. + +* Add option to have reports print each attendee (student) on a separate page when using the "Report by:" "Registrants" option. + +* Send notices to registrants of events they have registered for comeing up in some amount of days. + +* search by keyword or text + +* Ability to prints attendee reports with one attendee per page including the form data. + +** Figure out how to determine if there's nothing to list (categories, sub-cats, events) and produce message on Step0 or 1 + +* Look at adding ability to have Merchant Solutions transaction E-Mail messages include more information about the registration (person, event, etc) and more text. +* When credit card is processed, store flag in session to prevent multiple submissions in case submission isn't successfully stored. +* Consider moving form-data to database entries rather than serialized array. + + +For UC +* Fix problem where clicking column header in [Submissions] reverts status selection. +* Request to have option for rates and prices to show up in lists of events. +* Permit various text terms to be defined by category and possibly by event +* Try to add costs for registrants of classes in reporting by Activity and Registrant. May be difficult due to base and per-attendee amounts. + +For myig.org + +* Customer request for admin section + 1. On the submissions page. Currently we can sort by registration number, submitted, First name, + last name, company/organization, and status. Since our registrants don't write info in the + "company/organization" field we do not use this and it appears as empty. What would be extremely + useful is to be able to sort by "School or YMCA" instead. + + 2. On the reports page. In the drop down box Report By: we'd like to have "School or YMCA" as one + of the drop down options. + My comment + I won't be able to put "School or YMCA" into that pick list. What I'm thinking is that if you select + a specific activity at the top for the report, that it will detect that and add an option in the + "Report by:" pick list that would be "Sort by form field". It would then display another pick list + that has the form fields (ones that can rationally be used for sorting) for you to select. + + 3. Export to Excel. When the report appears as an export into Excel we could use your help too. + The fields appear on the top line for columns A thru X, but after column X the fields create a + double line appearing in each registrant's submitted information. This means we can not sort our + excel file after column X. Could you fix this? We'd like all the fields to be represented along + the top line of the excel export, and only the registrant's submitted info to appear after their name. + + Consider only permitting form data when one event is selected for the report. + +* Add ability for owner to edit text for confirmation E-Mail and check on doing the same for E-Mails + to users from the admin page. +* Add ability to display all form fields in all sub-forms in reports, not just in selected sub-forms +* Add ability to detect if a single form is being included in a report and to produce a common header for form data. +* Look for anywhere that boolean values are output and make them standard so we don't have some 'Yes' and some 't'. + Consider making that the yes/no values configurable to be what the customer wants them to be. + +General +* Purge rest of references to Bay View or others. +* Fix checkout E-Mails to site owner and to contact addresses in each event on checkout. +* Don't show "Continue to Selecting Classes" when category or events are already showing on the page. +* Make it possible to use multi-select for the Status pick-list when reporting. + Default that to all except canceled or submission failed. +* Add rate class information to reporting +* Use customer configured term rather than "Activity" and "Registration" in report selection. +* Add ability to enter a class code rather than using the select list in reports. +* Add ability to return to the current report selection screen with same settings from a report. +* Ability to delete registration requests in customer admin area + Requests must be canceled or failed submissions to be deleted. +* Notices to customer and users. + - Certain payment not received notices and warnings + - Event reminder notices to registrants + - E-Mail blasts to event registrants + -- Possible attached or referenced file +* How did you hear about us data collected during checkout + - Optionally required + + +Pending Bug Fixes +----------------- + +* See if there's a way to determine rate class on previous requests + +* Reported MagicForm field problems + Hi John, + We're testing the forms, and so far we have found a couple of issues on + the first two we've tried: + 1. Existing System Evaluations (both forms): If you don't fill in a + field and you have to go back, the Are the Test Holes Dug and the Is + this Waterfront property questions come up with a duplicate field for + both the If no... and the What is the body of water questions. + 2. Existing System Evaluations (both forms): If you don't fill in all + the fields and you have to go back, you get an error message telling you + to upload the site plan, even though you've already identified it on + your hard drive and it appears in the box. + Wendi Wright + Publishing Specialist + Health Department of Northwest Michigan + 220 W. Garfield Ave. + Charlevoix, MI 49720 + (231) 547-7610 + www.nwhealth.org + + diff --git a/documentation/Install.txt b/documentation/Install.txt new file mode 100644 index 0000000..6c5cd7c --- /dev/null +++ b/documentation/Install.txt @@ -0,0 +1,371 @@ +Installation Considerations +--------------------------- + +*** USE PROCEEDURES IN WIKI - UPDATE THEM AS NECESSARY *** + + +View File Replacements + Create /Toolkit/Registrations/View/front-end directory in customer's Web site. + Place any view files that you want to replace in that directory and they will be used instead of the corresponding default view file. + DO NOT modify the View files in the common application directories. + +CSS File Replacement + Create /Toolkit/Registrations/View/front-end directory in customer's Web site. + Place a copy of the style.css file from app.gaslightmedia.com/Common/Registrations_V3/front-end/Views in that directory. + Modify that copy of the style.css file as desired. + DO NOT modify the css files in the common application directories. + +CSS Style Override + Create /Toolkit/Registrations/View/front-end directory in customer's Web site. + Create a file called "override.css" in that directory. + Add any new style information there. + You may specify a tag, class, or ID in the common app style.css file and include here any elements of it that you would like to override. + CSS specifications in the override.css file will replace those in the common app style.css file. + + +Installation instructions for this application +---------------------------------------------- + +* Add a "Registrations" page to the toolbox somewhere. + +* Copy static_page.phtml from documentation directory to Web site's static directory and name it with ID of Registrations page. + +* Add to /config/application.ini - values are examples only + +; -- Common Registrations Application - V3 -- +; Turn the event registration application On or Off +event_registration.application = On +; Customer Information +event_registration.organization = "France Tours and Guides " +event_registration.organization_short = "France Journeys" +event_registration.organization_address = "12381 Fenton Road" +event_registration.organization_city = "Fenton" +event_registration.organization_state = "MI" +event_registration.organization_zip = "48430" +event_registration.organization_phone = "810-714-3803" +event_registration.organization_toll_free = "" +event_registration.organization_internal_email = "reservations@francetoursandguides.com" +event_registration.organization_from_email = "reservations@francetoursandguides.com" +; General Setup +event_registration.copyright_start = 2010 +event_registration.event_page = 12 +; Text used with catid in URLs +event_registration.link_name = "registrations" +event_registration.have_members = Off +event_registration.registered_users = Off +event_registration.medical_info = On +event_registration.save_contacts = On +; Event Selection Process - Default is standard selection process +event_registration.default = On +event_registration.select_by_month = Off +event_registration.select_by_code = Off +event_registration.select_by_picklists = Off +event_registration.show_past_events = Off +; If On causes all past events to be set to Active off when listing events in admin section +event_registration.auto_inactive = Off +event_registration.categories_on_intro_page = On +; If main categories are off then sub_categories are not used +event_registration.main_categories = On +event_registration.show_empty_categories = Off +event_registration.sub_categories = Off +event_registration.show_empty_sub_categories = Off +event_registration.attributes = On +; Some output configuration items +event_registration.show_search_result_as_title = On +; Show event detail in search results? +event_registration.show_event_detail_in_search_results = Off +; Other items that we may or may not what to show +event_registration.display_only_mode = Off +event_registration.include_events_in_category_list = Off +event_registration.show_event_codes = On +event_registration.show_instructor_in_event_lists = Off +event_registration.show_instructor_in_event_detail = Off +event_registration.show_event_terms_in_event_detail = On +event_registration.show_cutoff_dates = Off +; Whether to show rates in lists of events - If on, specify type for displaying ("detail" = detailed, "from" = "From: {lowest cost}") +event_registration.show_rates_in_event_lists = On +event_registration.show_rates_type = "from" +; Selection of View/Template locations - Custom view and css files located in virtual server at /Toolkit/Registrations/Views +event_registration.custom_view_files = On +event_registration.custom_stylesheet = On +; Permitted methods of payment - Must be one of the following "Yes", "No", or "Restricted" (admin users only) +event_registration.payment_methods.comp_code = "Restricted" +event_registration.payment_methods.check = "Yes" +event_registration.payment_methods.cash = "Restricted" +event_registration.payment_methods.credit_card = "Yes" +event_registration.payment_methods.call_from_merchant = "Yes" +; Accepts Credit Cards bitmap (add up selected) where: Visa = 1, MasterCard = 2, American Express = 4, Discover = 8, Diners Club = 16 +event_registration.cc_accepts = 7 +; Credit Card Processing selection where: By merchant = 1, Authorize.net = 2, Merchant Solutions = 3 +event_registration.proc_method = 1 +; Authorize.net integration +; test: LOCAL_TEST, LOCAL_FAIL, TRUE, FALSE (Must be FALSE for production) +; conf: Set to TRUE to have Authorize.net send a confirmation E-Mail to the user. +event_registration.authorize_net.login = "" +event_registration.authorize_net.key = "" +event_registration.authorize_net.test = "TRUE" +event_registration.authorize_net.conf = "TRUE" +event_registration.authorize_net.merchant_email = "" +; Merchant Solutions integration +event_registration.merchant_solutions.acctid = "" +event_registration.merchant_solutions.merchantpin = "" +; Items to show in E-Mail notification to instructors +event_registration.instr_notification.billing_info = Off +event_registration.instr_notification.email = On +event_registration.instr_notification.phone = On +event_registration.instr_notification.duration = On +event_registration.instr_notification.short_descr = On +event_registration.instr_notification.contact_fname = On +event_registration.instr_notification.contact_lname = On +event_registration.instr_notification.contact_addr1 = Off +event_registration.instr_notification.contact_addr2 = On +event_registration.instr_notification.contact_city = On +event_registration.instr_notification.contact_phone = On +event_registration.instr_notification.contact_fax = On +; Text Configurations +event_registration.title = "Event Registration" +event_registration.word.category = "region" +event_registration.word.categories = "regions" +event_registration.word.sub_category = "city" +event_registration.word.sub_categories = "cities" +event_registration.word.attribute = "type" +event_registration.word.attributes = "types" +event_registration.word.event = "tour" +event_registration.word.events = "tours" +event_registration.word.registration = "registration" +event_registration.word.registrations = "registrations" +event_registration.word.register = "register" +event_registration.word.registering = "registering" +event_registration.word.registered = "registered" +event_registration.word.attendee = "traveler" +event_registration.word.attendees = "travelers" +event_registration.word.attending = "traveling" +event_registration.word.attended = "traveled" +event_registration.word.member = "member" +event_registration.word.members = "members" +event_registration.word.user_id = "user ID" +event_registration.word.password = "password" +event_registration.word.instructor = "tour operator" +event_registration.word.instructors = "tour operators" +event_registration.titles.use_payment_comp_code = "Use Payment Comp Code" +event_registration.titles.payment_comp_code = "Payment Comp Code" +event_registration.titles.send_a_check = "Send a Check" +event_registration.titles.call_from_merchant = "We will call you to complete your tour order." +event_registration.titles.paid_cash = "Paid Cash" +event_registration.titles.pay_by_credit_card = "Pay by Credit Card" +event_registration.titles.registration_button = "Book Tour" +; -- Billing fields required for each payment type +; -- Use comma separated list using: "fname, lname, addr1, addr2, city, state, country, zip, phone, fax" +event_registration.use_full_billing_info_at_top = Yes +; if use_full_billing_info_at_top = No +event_registration.bill_info_req.comp_code = "fname, lname, phone" +event_registration.bill_info_req.check = "fname, lname, phone" +event_registration.bill_info_req.cash = "fname, lname, phone" +event_registration.bill_info_req.credit_card = "fname, lname, addr1, addr2, city, state, country, zip, phone, fax" +; -- Billing fields to ignore when no payment is required (free registration) +event_registration.free_use_fname = On +event_registration.free_use_lname = On +event_registration.free_use_addr1 = On +event_registration.free_use_addr2 = On +event_registration.free_use_city = On +event_registration.free_use_state = On +event_registration.free_use_country = On +event_registration.free_use_zip = On +event_registration.free_use_phone = On +event_registration.free_use_fax = On +; Contact fields and terms - leave a term empty (no spaces) to not use that field in forms and reports +; NOTE that city, state, zip, and country fields must either be all used or all off! No prompt will used for output for these fields. +event_registration.show_contact_data = On +event_registration.show_same_button = Off +event_registration.titles.contact_information = "Lead Contact for this tour" +event_registration.prompt.contact_fname = "First Name" +event_registration.required.contact_fname = On +event_registration.prompt.contact_lname = "Last Name" +event_registration.required.contact_lname = On +event_registration.prompt.contact_addr1 = "Email Address while traveling" +event_registration.required.contact_addr1 = On +event_registration.prompt.contact_addr2 = "" +event_registration.required.contact_addr2 = Off +event_registration.prompt.contact_city = "" +event_registration.required.contact_city = Off +event_registration.prompt.contact_state = "" +event_registration.required.contact_state = Off +event_registration.prompt.contact_zip = "" +event_registration.required.contact_zip = Off +event_registration.prompt.contact_country = "" +event_registration.required.contact_country = Off +event_registration.prompt.contact_phone = "Contact Phone while traveling" +event_registration.required.contact_phone = On +event_registration.prompt.contact_fax = "" +event_registration.required.contact_fax = Off +; Admin Defaults +; sort_field is field name to sort, sort_direction is either "Forward" or "Backward" +event_registration.admin_opt.Submissions.sort_field = "" +event_registration.admin_opt.Submissions.sort_direction = "" +; status is comma-separated list of (UNPAID, CC_PEND, CC_PAID, CC_DECL, CHECK_PEND, CHECK_PAID, COMP, AT_EVENT, CASH_PAID, NO_CHARGE, OTHER_ADMIN, FAILED, CANCELED) +event_registration.admin_opt.Submissions.status = "UNPAID, CC_PEND, CC_PAID, CHECK_PEND, CHECK_PAID, AT_EVENT, COMP, CASH_PAID, NO_CHARGE, OTHER_ADMIN" +; Debug levels 0 to 3 +event_registration.debug = 0 +event_registration.debug_view = Off +event_registration.debug_mail = Off +event_registration.checkout_debug = Off + + Add debug overrides to personal section of config file and adjust as needed + +event_registration.debug = 0 +event_registration.debug_view = Off +event_registration.debug_mail = Off +event_registration.checkout_debug = Off + +* Add to /setup.phtml + + /** + * Site has Event Registration? + */ + define('EVENT_REGISTRATION', $applicationConfig->event_registration->application); + +* Create /admin/Registrations directory and copy Registrations.php from documentation directory into it. Rename to index.php + +* Add to /admin/nav.phtml + + if (defined('EVENT_REGISTRATION') && EVENT_REGISTRATION) { + $nav['Event Registration'] = 'admin/Registrations/'; + } + +* Add registration catid to "$securePagesArray = array({exisiting cat_id's},{registrations catid});" in setup.phtml + +* Commit files to version control system + + /static/??.phtml + /config/application.ini + /setup.phtml + /admin/Registrations + /admin/Registrations/index.php + /admin/nav.phtml + +* Check that file/image server account is setup and configured + + Look for file_server.owner_id in /config/server.ini + If no account is setup on is0 then add one and set configuration in server.ini + +* Update app.gaslightmedia.com/Common/Registrations_V3/documentation/Sites_Using.txt to include new site in list of + sites using this common application. + +* If you want to use local views or styles, create the following directories in the customer's virtual server. + + /Toolkit/Registrations/ + /Toolkit/Registrations/admin (for view files from app.gaslightmedia.com/Custom/Registrations_V3/admin/Views) + /Toolkit/Registrations/front-end (for view files from app.gaslightmedia.com/Custom/Registrations_V3/front-end/Views) + + Put copies of only the view files or style sheets you want to be custom into those directories. All others will use the default. + Turn on "event_registration.custom_view_files" in the config file. If off, it will ignore all custom views and styles. + YOU WILL BE RESPONSIBLE FOR KEEPING THE CUSTOM VIEW UPDATED!!! + + +To Update a Version 0 Common/Registrations app to V2.53 +---------------------------------------------------- + +Database updates for databases using Version 0 (original Common/Registrations) + +check if reg_detail table needs to be added - get from application.sql + +alter table misc add column cat_page_text text; +alter table misc add column sub_cat_page_text text; +alter table misc add column select_page_text text; +alter table misc add column event_page_text text; +alter table misc add column cart_page_text text; +alter table misc add column checkout_page_text text; +alter table misc add column summary_page_text text; +update misc set + cat_page_text = '', + sub_cat_page_text = '', + select_page_text = '', + event_page_text = '', + cart_page_text = '', + checkout_page_text = '', + summary_page_text = ''; + +Check if reg already has short_descr + alter table reg add column short_descr text; + update reg set short_descr = ''; + +alter table registrant add column is_member boolean; +alter table registrant add column member_id text; +alter table registrant add column password text; +alter table registrant add column winter_addr text; +alter table registrant add column winter_phone text; +update registrant set member_id = '' where member_id = '0'; +update registrant set is_member = 't'; +update registrant set is_member = 'f' where member_id is null or member_id = ''; + +alter table reg_req add column is_member boolean; +alter table reg_req add column member_id text; +update reg_req set is_member = 'f', member_id = ''; + +alter table misc add column pay_codes text; +update misc set pay_codes = ''; + +alter table reg add column date_specific bool; +update reg set date_specific = 'f'; + +alter table registrant add column pw_reset_code text; + +alter table todo add column med_info boolean; +update todo set med_info = 'f'; + +alter table reg add column instructor text; + +alter table reg add column reg_file text; +alter table reg add column reg_file_title text; +update reg set reg_file = ''; +update reg set reg_file_title = ''; + + Check if cart_serial has been added to reg_req + alter table reg_req add column cart_serial text; + +alter table reg_req add column registrant integer; +update reg_req R set registrant = (select max(T.id) from registrant T where T.email = R.email); + +alter table reg_detail add column cutoff_date date; +alter table reg_detail add column rate_class text; +alter table reg_detail add column charges_list text; + +alter table category add column sort integer; +update category set sort = 999; +alter table todo add column sort integer; +update todo set sort = 999; + +If the database did not have a reg_detail table or entries and there were existing registrations, +do the following query to create the reg_detail entries. + +INSERT INTO reg_detail +SELECT nextval('reg_detail_id_seq'), + id AS reg_req, + numb_attending, + attendees, + total AS charges, + registration, + reg_start, + reg_end, + '' AS notes, + mf_data, + NULL AS dob, + '' AS guardian, + '' AS emer_contact, + '' AS emer_phone, + '' AS med_history, + '' AS allergy_med, + NULL AS cutoff_date, + '' AS rate_class, + '' AS charges_list + FROM reg_req + WHERE ( + SELECT COUNT(id) + FROM reg_detail + WHERE reg_detail.reg_req = reg_req.id + ) = 0; + +May need to re-run permissions for tables and sequences. + + + diff --git a/documentation/Notes.txt b/documentation/Notes.txt new file mode 100644 index 0000000..8ba6ce0 --- /dev/null +++ b/documentation/Notes.txt @@ -0,0 +1,61 @@ +Notes on structure and operation of this system + +Front End +--------- + +Session Data + + GLM_EVENT_REG False if not setup. + User ID from registrant table for current user. False if none selected. + UserIsMember Flag indicating whether user is a member. + UserData Record from registrant table for this user. + admin_user Flag indicating an admin user is using front-end + Cart Current Shopping Cart + [cart_id] A Cart entry. + cart_id + event_id + event_name + date_specific Indicates if event is date specific. "YES" or "NO" + start_date + end_date + cutoff_date Cutoff date when this entry was selected. + rate_class Rate Class name. + charges Array of Charges + [id] A charge entry + charge_title Title of this charge + charge Unit amount of this charge + extend Extended amount of this charge + total_charges Numeric total charges + totalCharges Money formatted total charges. + need_attendees Indicates if event needs attendees. "YES" or "NO" + have_attendees Indicates if there are > 0 attendees for this entry. "YES" or "NO" + numb_attendees Current number of attendees for this entry. + attendees Array of attendees + [id] An attendee entry id + name Name of attendee + have_dob Indicates if attendee has Date of Birth. "YES" or "NO" + dob + have_guardian Indicates if attendee has guardian. "YES" or "NO" + guardian + have_emer_contact Indicates if attendee has emergency contact. "YES" or "NO" + emer_contact + have_emer_phone Indicates if attendee has emergency phone. "YES" or "NO" + emer_phone + have_med_history Indicates if attendee has medical history. "YES" or "NO" + med_history + have_allergy_med Indicates if attendee has allergy info. "YES" or "NO" + allergy_med + med_info Indicates if there's medical info. "YES" or "NO" + have_mf_data Indicated if there's MagicForm data with this entry. "YES" or "NO" + mf_data Array of MagicForm data. + haveTerms Indicates if there's additional Terms/Conditions for event. "YES" or "NO" + terms Text of additional Terms/Conditions. + Cart_Serial_Number Serial number for this cart. Stored in reg_req to prevent duplicates + Current_id Last cart entry ID. Incrimented when new entry is added. + Event Data on the currently selected event. + id ID of current event + name Name of current event + code Event code for current event + med_info Flag indicating whether current event requires medical info. + + \ No newline at end of file diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/IVR_Payment_By_Phone_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/IVR_Payment_By_Phone_Guide.pdf new file mode 100644 index 0000000..3659c56 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/IVR_Payment_By_Phone_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Batch_Processing_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Batch_Processing_Guide.pdf new file mode 100644 index 0000000..d11c946 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Batch_Processing_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_MMC_WAP_User_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_MMC_WAP_User_Guide.pdf new file mode 100644 index 0000000..0bead38 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_MMC_WAP_User_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Membership_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Membership_Guide.pdf new file mode 100644 index 0000000..ab70331 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Membership_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_SOAP_Integration_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_SOAP_Integration_Guide.pdf new file mode 100644 index 0000000..dd94489 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_SOAP_Integration_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Stored_Profile_Tokenization_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Stored_Profile_Tokenization_Guide.pdf new file mode 100644 index 0000000..eef81c7 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_Stored_Profile_Tokenization_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_WebPay_Integration_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_WebPay_Integration_Guide.pdf new file mode 100644 index 0000000..41cbb03 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_WebPay_Integration_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_XML_Integration_Guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_XML_Integration_Guide.pdf new file mode 100644 index 0000000..52a6974 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_XML_Integration_Guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_card_present_transactions_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_card_present_transactions_guide.pdf new file mode 100644 index 0000000..8823422 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_card_present_transactions_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_first_mile_middleware_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_first_mile_middleware_guide.pdf new file mode 100644 index 0000000..f3ad634 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_first_mile_middleware_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_getting_started_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_getting_started_guide.pdf new file mode 100644 index 0000000..ac17d92 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_getting_started_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_integration_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_integration_guide.pdf new file mode 100644 index 0000000..d26b7f2 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_integration_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_soap_reporting_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_soap_reporting_guide.pdf new file mode 100644 index 0000000..3c58b0f Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_soap_reporting_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_cart_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_cart_guide.pdf new file mode 100644 index 0000000..5ff8028 Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_cart_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_link_guide.pdf b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_link_guide.pdf new file mode 100644 index 0000000..8a72a9e Binary files /dev/null and b/documentation/Payment Gateways/Merchant Solutions/Documentation/MSII_web_link_guide.pdf differ diff --git a/documentation/Payment Gateways/Merchant Solutions/Notes.txt b/documentation/Payment Gateways/Merchant Solutions/Notes.txt new file mode 100644 index 0000000..c69b434 --- /dev/null +++ b/documentation/Payment Gateways/Merchant Solutions/Notes.txt @@ -0,0 +1,23 @@ + +Access to Documentation +----------------------- +URL: https://gateway.merchantsolution.com/docs/ +Email: merchantsolutions@n8dnx.org +Password: eC5^2SS9#c + mS2&Qe9V:t + +Merchant Center URL +------------------- +https://gateway.merchantsolution.com/admin/login.taf + +Test Merchant Account +--------------------- +AcctID: MSDMO +Userid: Cscott +Password: Sol#Glm3Merch +MerchantPin: rm2NcePTTc93VutRdguW2nRFQ2BiyLu9 + + + +Test Cards VISA - 5454545454545454 + diff --git a/documentation/Payment Gateways/Merchant Solutions/merchant_solutions.wsdl b/documentation/Payment Gateways/Merchant Solutions/merchant_solutions.wsdl new file mode 100644 index 0000000..bb62f58 --- /dev/null +++ b/documentation/Payment Gateways/Merchant Solutions/merchant_solutions.wsdl @@ -0,0 +1,2435 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/documentation/Registrations.php b/documentation/Registrations.php new file mode 100644 index 0000000..64275e9 --- /dev/null +++ b/documentation/Registrations.php @@ -0,0 +1,22 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: Registrations.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + * @link http://{site}/admin/Registrations + */ + +// Get main site setup +require_once '../../setup.phtml'; + +// Call common Registrations application +require_once GLM_APP_BASE.'Common/Registrations_V3/admin/index.phtml'; + +?> \ No newline at end of file diff --git a/documentation/Sites_Using.txt b/documentation/Sites_Using.txt new file mode 100644 index 0000000..020e9a5 --- /dev/null +++ b/documentation/Sites_Using.txt @@ -0,0 +1,45 @@ +Sites using the Common Registrations Application +------------------------------------------------ + +Site Version Server DB Server Database Status Members Reg Users Sub-Cats Select By Month CC Processor +------------------------------- ------- ------- ----------- ------------------- ----------- ------- ----------- ----------- --------------- --------------------------- +www.ucgaylord.org V3 ws0 ds3 ucgaylord Production No Yes No No Merchant Solutions +www.dioceseofgaylord.org V3 dev53 devdb diocese Development No Yes No Yes Manual +www.francetoursandguides.com V3 ws6 ds4 francetoursandguides Development +www.harborcountry.org V3 ws0 ds3 harborcountry Development +forms.nwhealth.org V2.53 ws0 ds4 nwhealth Production No No No No Authorize.net +www.myig.org V2.53 ws0 ds4 myig Production No No No No Authorize.net +www.miseniorcenters.org V0 ws0 +www.warmemorialhospital.org V3 ws6 devdb warmemorialhospital Development NO Yes No No + +#### Don't think this is in use anymore. www.bayviewassociation.org V2.53 ws0 ds3 bayviewassociation Production Yes Yes Yes No Authorize.net + +Using Non-Common Version +------------------------ +demo.gaslightmedia.com +www.circlemichigan.com +www.gaylordschools.com +www.migcsa.org +www.otsegocountymi.gov + + +Merchant Account Information +---------------------------- + +Merchant Solutions + + Test Merchant Account + AcctID: MSDMO + Userid: Cscott + Password: Glm3Merch#Sol + MerchantPin: BVR0V3462V5GmZK03MXtWE5u9HeUJX62 + + + UC Gaylord + Account ID: MSHLG + User ID: Admin + Password: Password@55 + MerchantPin: xfuqfA0mVk85vim0aEuysgfubV3LBdpT + + + diff --git a/documentation/application.sql b/documentation/application.sql new file mode 100644 index 0000000..d8a9bb0 --- /dev/null +++ b/documentation/application.sql @@ -0,0 +1,423 @@ + +CREATE SCHEMA registrations; + +CREATE TABLE registrations.magicform ( + id SERIAL, + form_id text, + custom_id text, + title text, + type smallint, + descr text, + active boolean, + required boolean, + data1 text, + sort smallint, + expanded boolean, + style text, + file text, + cols integer, + rows integer, + size text, + format text, + default_val text +); + +ALTER TABLE registrations.magicform OWNER TO postgres; +ALTER TABLE registrations.magicform_id_seq OWNER TO postgres; + +CREATE TABLE registrations.mf_data ( + id SERIAL, + fiid integer, + form_id text, + field_id text, + level integer, + title text, + type integer, + txt_type text, + value text, + numb_value double precision, + txt_value text, + opt_num integer, + valid boolean, + required boolean, + failure text +); + +ALTER TABLE registrations.mf_data OWNER TO postgres; +ALTER TABLE registrations.mf_data_id_seq OWNER TO postgres; + +CREATE TABLE registrations.mf_temp_file ( + id SERIAL, + file_name text, + upload_time date +); + +ALTER TABLE registrations.mf_temp_file OWNER TO postgres; +ALTER TABLE registrations.mf_temp_file_id_seq OWNER TO postgres; + +CREATE TABLE registrations.misc ( + id SERIAL, + regbulletin text, + cat_page_text text, + sub_cat_page_text text, + select_page_text text, + event_page_text text, + cart_page_text text, + checkout_page_text text, + summary_page_text text, + regterms text, + pay_codes text, + notify_text text, + notify_subject text, + req_ack_text text, + req_ack_subject text +); + +ALTER TABLE registrations.misc OWNER TO postgres; +ALTER TABLE registrations.misc_id_seq OWNER TO postgres; + +CREATE TABLE registrations.todo ( + id SERIAL, + name text, + restricted bool, + med_info bool, + image text, + descr text, + sort integer +); + +ALTER TABLE registrations.todo OWNER TO postgres; +ALTER TABLE registrations.todo_id_seq OWNER TO postgres; + + +CREATE TABLE registrations.category ( + id SERIAL, + todo integer, + name text, + list_name text, + image text, + descr text, + sort integer +); + +ALTER TABLE registrations.category OWNER TO postgres; +ALTER TABLE registrations.category_id_seq OWNER TO postgres; + +CREATE TABLE registrations.attribute ( + id SERIAL, + name text, + descr text, + sort integer +); + +ALTER TABLE registrations.attribute OWNER TO postgres; +ALTER TABLE registrations.attribute_id_seq OWNER TO postgres; + +CREATE TABLE registrations.reg ( + id SERIAL, + category integer, + todo integer, + attribute integer, + name text, + short_descr text, + descr text, + notify_email text, + active boolean, + image text, + date_specific boolean, + date_select text, + use_calendar boolean, + start_date date, + end_date date, + ask_date boolean, + dates text, + times text, + duration text, + location text, + instructor text, + cutoff_date date, + cutoff_date2 date, + cutoff_date3 date, + cutoff_date4 date, + rates_descr text, + rates_1_memb text, + rates_1 text, + rates_2 text, + rates_2_memb text, + rates_3 text, + rates_3_memb text, + rates_4 text, + rates_4_memb text, + attendee_limit boolean, + attendee_max integer, + attendee_max_per_sub integer, + attendee_count integer, + form_revision integer, + sort integer, + pay_codes text, + restrict_comp_code boolean, + restrict_check boolean, + restrict_cash boolean, + restrict_credit_card boolean, + terms text, + notes text, + need_attendees boolean, + require_registered_user boolean, + event_code text, + reg_file text, + reg_file_title text +); + + +ALTER TABLE registrations.reg OWNER TO postgres; +ALTER TABLE registrations.reg_id_seq OWNER TO postgres; + +CREATE TABLE registrations.reg_attr ( + id SERIAL, + reg integer, + attr integer +); + +ALTER TABLE registrations.reg_attr OWNER TO postgres; +ALTER TABLE registrations.reg_attr_id_seq OWNER TO postgres; + +CREATE TABLE registrations.reg_req ( + id SERIAL, + user_trace_info text, + cart_serial text, + fname text, + lname text, + org text, + title text, + addr1 text, + addr2 text, + city text, + state text, + zip text, + country text, + phone text, + fax text, + email text, + email_ok boolean, + registrant integer, + is_member boolean, + member_id text, + contact_same boolean, + contact_fname text, + contact_lname text, + contact_org text, + contact_title text, + contact_addr1 text, + contact_addr2 text, + contact_city text, + contact_state text, + contact_zip text, + contact_country text, + contact_phone text, + contact_fax text, + contact_email text, + contact_email_ok boolean, + date_entered date, + pay_type text, + pay_code text, + status smallint, + cc_conf text, + total double precision, + notes text, + summary text, + cc_name text, + cc_type text, + cc_numb text, + cc_exp text, + cc_cvv text +); + +ALTER TABLE registrations.reg_req OWNER TO postgres; +ALTER TABLE registrations.reg_req_id_seq OWNER TO postgres; + +CREATE INDEX reg_req_id_index ON registrations.reg_req (id); +CREATE INDEX reg_req_cart_serial_index ON registrations.reg_req (cart_serial); + +CREATE TABLE registrations.reg_detail ( + id SERIAL, + reg_req integer, + numb_attending smallint, + attendees text, + charges float, + registration integer, + reg_start date, + reg_end date, + desired_date date, + notes text, + mf_data text, + dob date, + guardian text, + emer_contact text, + emer_phone text, + med_history text, + allergy_med text, + cutoff_date date, + rate_class text, + charges_list text +); + +ALTER TABLE registrations.reg_detail OWNER TO postgres; +ALTER TABLE registrations.reg_detail_id_seq OWNER TO postgres; + +REVOKE ALL ON TABLE registrations.reg_detail FROM PUBLIC; +REVOKE ALL ON TABLE registrations.reg_detail FROM postgres; +GRANT ALL ON TABLE registrations.reg_detail TO postgres; +GRANT ALL ON TABLE registrations.reg_detail TO nobody; +REVOKE ALL ON SEQUENCE registrations.reg_detail_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.reg_detail_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.reg_detail_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.reg_detail_id_seq TO nobody; + + +CREATE INDEX reg_detail_id_index ON registrations.reg_detail (id); +CREATE INDEX reg_detail_req_index ON registrations.reg_detail (reg_req); +CREATE INDEX reg_detail_reg_index ON registrations.reg_detail (registration); + +CREATE TABLE registrations.registrant ( + id SERIAL, + user_trace_info text, + fname text, + lname text, + addr1 text, + addr2 text, + city text, + state text, + zip text, + country text, + phone text, + email text, + email_ok boolean, + password text, + is_member boolean, + member_id text, + winter_addr text, + winter_phone text, + pw_reset_code text +); + +ALTER TABLE registrations.registrant OWNER TO postgres; +ALTER TABLE registrations.registrant_id_seq OWNER TO postgres; + +CREATE INDEX magicform_form_id_index ON registrations.magicform USING btree (form_id); +CREATE INDEX mf_data_fiid_index ON registrations.mf_data USING btree (fiid); +CREATE INDEX mf_form_id_index ON registrations.mf_data USING btree (form_id); +CREATE INDEX registrant_id_index ON registrations.registrant USING btree (id); + + +GRANT ALL ON SCHEMA registrations TO nobody; + +REVOKE ALL ON TABLE registrations.magicform FROM PUBLIC; +REVOKE ALL ON TABLE registrations.magicform FROM postgres; +GRANT ALL ON TABLE registrations.magicform TO postgres; +GRANT ALL ON TABLE registrations.magicform TO nobody; + +REVOKE ALL ON SEQUENCE registrations.magicform_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.magicform_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.magicform_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.magicform_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.mf_data FROM PUBLIC; +REVOKE ALL ON TABLE registrations.mf_data FROM postgres; +GRANT ALL ON TABLE registrations.mf_data TO postgres; +GRANT ALL ON TABLE registrations.mf_data TO nobody; + +REVOKE ALL ON SEQUENCE registrations.mf_data_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.mf_data_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.mf_data_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.mf_data_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.mf_temp_file FROM PUBLIC; +REVOKE ALL ON TABLE registrations.mf_temp_file FROM postgres; +GRANT ALL ON TABLE registrations.mf_temp_file TO postgres; +GRANT ALL ON TABLE registrations.mf_temp_file TO nobody; + +REVOKE ALL ON SEQUENCE registrations.mf_temp_file_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.mf_temp_file_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.mf_temp_file_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.mf_temp_file_id_seq TO nobody; + +CREATE INDEX mf_temp_file_file_name_index ON registrations.mf_temp_file (file_name); +CREATE INDEX mf_temp_file_upload_time_index ON registrations.mf_temp_file (upload_time); + +REVOKE ALL ON TABLE registrations.misc FROM PUBLIC; +REVOKE ALL ON TABLE registrations.misc FROM postgres; +GRANT ALL ON TABLE registrations.misc TO postgres; +GRANT ALL ON TABLE registrations.misc TO nobody; + +REVOKE ALL ON SEQUENCE registrations.misc_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.misc_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.misc_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.misc_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.todo FROM PUBLIC; +REVOKE ALL ON TABLE registrations.todo FROM postgres; +GRANT ALL ON TABLE registrations.todo TO postgres; +GRANT ALL ON TABLE registrations.todo TO nobody; + +REVOKE ALL ON TABLE registrations.todo_id_seq FROM PUBLIC; +REVOKE ALL ON TABLE registrations.todo_id_seq FROM postgres; +GRANT ALL ON TABLE registrations.todo_id_seq TO postgres; +GRANT ALL ON TABLE registrations.todo_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.category FROM PUBLIC; +REVOKE ALL ON TABLE registrations.category FROM postgres; +GRANT ALL ON TABLE registrations.category TO postgres; +GRANT ALL ON TABLE registrations.category TO nobody; + +REVOKE ALL ON TABLE registrations.category_id_seq FROM PUBLIC; +REVOKE ALL ON TABLE registrations.category_id_seq FROM postgres; +GRANT ALL ON TABLE registrations.category_id_seq TO postgres; +GRANT ALL ON TABLE registrations.category_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.attribute FROM PUBLIC; +REVOKE ALL ON TABLE registrations.attribute FROM postgres; +GRANT ALL ON TABLE registrations.attribute TO postgres; +GRANT ALL ON TABLE registrations.attribute TO nobody; + +REVOKE ALL ON TABLE registrations.reg_attr FROM PUBLIC; +REVOKE ALL ON TABLE registrations.reg_attr FROM postgres; +GRANT ALL ON TABLE registrations.reg_attr TO postgres; +GRANT ALL ON TABLE registrations.reg_attr TO nobody; + +REVOKE ALL ON TABLE registrations.attribute_id_seq FROM PUBLIC; +REVOKE ALL ON TABLE registrations.attribute_id_seq FROM postgres; +GRANT ALL ON TABLE registrations.attribute_id_seq TO postgres; +GRANT ALL ON TABLE registrations.attribute_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.reg FROM PUBLIC; +REVOKE ALL ON TABLE registrations.reg FROM postgres; +GRANT ALL ON TABLE registrations.reg TO postgres; +GRANT ALL ON TABLE registrations.reg TO nobody; + +REVOKE ALL ON SEQUENCE registrations.reg_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.reg_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.reg_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.reg_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.reg_req FROM PUBLIC; +REVOKE ALL ON TABLE registrations.reg_req FROM postgres; +GRANT ALL ON TABLE registrations.reg_req TO postgres; +GRANT ALL ON TABLE registrations.reg_req TO nobody; + +REVOKE ALL ON SEQUENCE registrations.reg_req_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.reg_req_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.reg_req_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.reg_req_id_seq TO nobody; + +REVOKE ALL ON TABLE registrations.registrant FROM PUBLIC; +REVOKE ALL ON TABLE registrations.registrant FROM postgres; +GRANT ALL ON TABLE registrations.registrant TO postgres; +GRANT ALL ON TABLE registrations.registrant TO nobody; + +REVOKE ALL ON SEQUENCE registrations.registrant_id_seq FROM PUBLIC; +REVOKE ALL ON SEQUENCE registrations.registrant_id_seq FROM postgres; +GRANT ALL ON SEQUENCE registrations.registrant_id_seq TO postgres; +GRANT ALL ON SEQUENCE registrations.registrant_id_seq TO nobody; + +INSERT INTO registrations.misc (regbulletin, regterms, notify_text, notify_subject, req_ack_text, req_ack_subject) VALUES ('Please select the desired event.', '', 'Instructor E-Mail Subject', 'Instructor E-Mail Body', 'Registration Acknowledgement E-Mail Subject', 'Registration Acknowledgement E-Mail Body'); + \ No newline at end of file diff --git a/documentation/functions_docs.txt b/documentation/functions_docs.txt new file mode 100644 index 0000000..988dff1 --- /dev/null +++ b/documentation/functions_docs.txt @@ -0,0 +1,2991 @@ +$Id: functions_docs.txt,v 1.2 2009/10/28 18:12:30 cscott Exp $ +************************************************************************ +* * +* Gaslight Media Standard Function Library * +* * +* Copyright (c) 2000-2004 by Gaslight Media Inc. * +* * +* FILE: functions_docs.txt * +* VERSION: 1.3 * +* * +************************************************************************ + + +TO DO: +------ + + + +INDEX +----- + + Debug Functions + bool debug_mail( string $to, string $subject, string $message [, string $headers [, string $parameters]] ) + + General Functions + bool CreditVal( string $Num, string $name, string $Accepted ) + string credit_card_check( string $Num ) + + Geographic Functions + float geo_distance( $lat, $lon, $units ) + + + Database Abstraction Functions + + bool db_connect( string $conn_str, bool $fail_mode ) + bool db_close( int $dbd ) + bool db_pconnect( void ) + int db_exec( int $dbd, string $qs ) + array db_fetch_row( int $res, int $i, string $conn_str ) + bool db_freeresult( int $res ) + bool db_numrows( int $res ) + + Auto Functions + + array db_auto_get_row( string $qs, int $i, string $conn_str, bool $fail_mode ) + array[array] db_auto_get_data( string $qs, string $conn_str, bool $fail_mode, int $rows, int $start ) + bool db_auto_exec( string $qs, string $conn_str, $fail_mode, $oid ) + array db_data_fields( string $conn_str, string $table ) + + File Functions + + string file_upload( string $form_field, string $file_name, string $destination_path ) + string file_duplicte( string $file_name, string $base_path ); + bool file_delete( string $file_name, string $base_path ); + string file_get( string $file_name, int $max_size ); + bool file_ouput_secure( string $file_name, string $md5, string $path ); + + Graphics Functions + + array img_info( $path2image ) + bool graphic_thumb( string $img, string $timg, string $type ) + bool graphic_resize( string $img, string $timg, string $type, int $w, int $h ) + array img_resized( string $path2image, string $path2thumb, string $axis, int $size ) + array img_upload( string $form_field, string $image_name, string $destination_path ) + string process_image( string $image, string $image_name ) + bool delete_image( string $image_name ) + string duplicate_image( string $image_name ) + + General Support Function/Classes + + class timestampfunc + float pos_value( float $value ) + string money( float $value ) + array strtoarray( string $data ) + string arraytostr( array $array ) + string replace_tokens( string $s, array $tokens ) + string cond_replace_tokens( string $s, array $tokens ) + string replace_file_tokens( string $s ) + string tableize_array( array $array ) + string admin_field_select( array $fields, char $admin_function ) + string admin_menu_std( string $action, string $a_title, int $id, string $opt, string $options, string $add_menu, string $params ) + string admin_menu( string $action, string $option, string $a_title, int $id ) + bool clean_input( string $var_name, string $type ) + void data_to_url( array $names ) + void url_to_data( array $names ) + string data_to_url( array $data, string $prefix ) + array url_to_data( array $data, string $url, string $start_key ) + string build_nav( array $nav_table, string $menu_title, string $current_item = '', string $sub_menu = '', string $link_data = '' ) + + Category Support Functions + + string category_path_func( string $table_name ) + array cat_get_node( string $table, string $qs, string $order ) + array cat_get_nodes( string $table, string $qs, string $order ) + array cat_get_expanded_nodes( string $table, int $id ) + bool cat_resequence_siblings( string $table, int $parent ) + array cat_move_node( string $table, int $id, int ???????? ) PENDING + + High Level Functions + + array get_us_counties( $fail_mode ) + string build_picklist( string $fieldname, array $data, string $selected [, string $type] ) + string build_numeric_picklist( string $fieldname, $starting, $ending ) + string output_template( string $field ) + string calendar_date_select( string $default_value, timestamp $start_date, timestamp $end_date, + string $form_name, string $field_name ) + void calendar_display( int $month, int $year, array $date_data ) + string parse_view( string $file_name, $tokens ) + + Magic Form Functions + + array magic_form_edit( int $mf_id, array $mf_format, in5 $mf_level ) + array magic_form_display( int $mf_id, array $mf_format, int $mf_level ) + array magic_form_submit( int $mf_id, int $mf_level ) + + High Level Functions for Admin Pages + + array admin_process_records_r( string $table, string $where, string $order, string $conn_str, int $id, array $fields, + string $options, int $rows, string $url, string $action, string $params, string $a_title, string $view + string $Option ) + void admin_process_records( string $table, string $where, string $order, string $conn_str, int $id, array $fields, + string $options, int $rows, string $url, string $action, string $params, string $a_title, string $view + string $Option ) + + array admin_list_records_r( string $table, sting $where, string $order, string $conn_str, string $fields, + string $options, int $rows, int $start, string $url, string $action, + string $params, string $filters, string $a_title ) + void admin_list_records( string $table, sting $where, string $order, string $conn_str, string $fields, + string $options, int $rows, int $start, string $url, string $action, + string $params, string $filters, string $a_title ) + + array admin_new_record_r( string $table, string $conn_str, string $fields, string $url, string $action, + string $params, string $a_title, string $view ) + void admin_new_record( string $table, string $conn_str, string $fields, string $url, string $action, + string $params, string $a_title, string $view ) + + array admin_add_new_record_r( string $table, string $conn_str, string $fields, string $url, + string $action, string $a_title ) + void admin_add_new_record( string $table, string $conn_str, string $fields, string $url, + string $action, string $a_title ) + + array admin_edit_record_r( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + void admin_edit_record( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + + array admin_update_record_r( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + void admin_update_record( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + + array admin_delete_record_r( string $table, string $conn_str, int $id, string $fields, string $options, + string $url, string $action, string $a_title ) + void admin_delete_record( string $table, string $conn_str, int $id, string $fields, string $options, + string $url, string $action, string $a_title ) + + array admin_confirm_delete_record_r( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + void admin_confirm_delete_record( string $table, string $conn_str, int $id, string $fields, string $url, + string $action, string $a_title, string $view ) + + array admin_view_record_r( string $table, sting $conn_str, string $id, string $fields, string $url, + string $action, string $a_title, string $view, string $id_field ) + void admin_view_record( string $table, sting $conn_str, string $id, string $fields, string $url, + string $action, string $a_title, string $view, string $id_field ) + + void admin_user_login( string $operation, string $conn_str, string $sess_code + string $table, string $id_field, string $pw_field, + string $user_id, string $password ) + + Financial Transaction Functions + + array function authorize_net_aim( fload $amount, string $card_num, string $exp_date, string $card_code, string $currency = '', + string $fname = '', string $lname = '', string $company = '', string $address = '', string $city = '', string $state = '', string $zip = '', string $country = '', + string $phone = '', string $fax = '', string $id = '', string $ip = '', string $tax_id = '', + string $email = '', + string $invoice = '', string $descr ='', + string $ship_fname = '', string $ship_lname = '', string $ship_company = '', string $ship_address = '', string $ship_city = '', string $ship_state = '', + string $ship_zip = '', string $ship_country = '' + ) + + + + Note on SI_DEBUG levels + + 0 = No debug info + 1 = Output debug for High level functions only + 2 = Output debug for utilitiy function also + 3 = Output debug for database abstraction calls and low level functions + + +************************************************************************ +* * +* DEBUG FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + bool debug_mail( string $to, string $subject, string $message [, string $headers [, string $parameters]] ) +------------------------------------------------------------------------ + +If SI_DEBUG is = 0 + + Passes all parameters on to the standard PHP mail() function and sends + mail. + +If SI_DEBUG is > 0 + + Outputs a table showing mail that would be sent by a mail() function + call and DOES NOT ACTUALLY SEND THE MAIL. Parameters are the same as + for the PHP mail() function. + + + + Parameters + $to Recipient(s) + $subject Message Subject + $message Message Content + $headers Additional Headers + $parameters Additional Parameters + + Return value: + True if debug level is high enough to display mail debug. + Otherwise, return value is that of the actual mail() function + call. + + +************************************************************************ +* * +* GENERAL FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + bool CreditVal( string $Num, string $Name, string $Accepted ) +------------------------------------------------------------------------ + + checks for a valid credit card number doing Luhn check + + Parameters + $Num = the credit card number + $Name = the type of card + $Name can be : + mastercard, + visa, + americanexpress, + discover, + dinnercard + $Accepted = comma separated list of accepted cards. If not specified, all are accepted. + + Return value: + returns + true if number and name are good values + false if not + + Global references: + none + +------------------------------------------------------------------------ + string credit_card_check( string $Num ) +------------------------------------------------------------------------ + + Alternative strong credit card check function. This version + returns the type of the credit card if it's a good number. + + Will accept "0011-0011-0011-0011" as a good card and returns + "Test" for the card type. + + Parameters + $Num = the credit card number + + Return value: + $CardType Type of card if number is good, otherwise FALSE + + Global references: + $tids_cc_array from siteinfo.inc is required + + +************************************************************************ +* * +* GEOGRAPHIC FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + float geo_distance( float $lat1, float $lon1, float $lat2, + float $lon2, string $units ) +------------------------------------------------------------------------ + + Calculates the distance between a pair of lat/lon coordinates. + + Distance = 3963.0 * arccos[sin(lat1/57.2958) * sin(lat2/57.2958) + cos(lat1/57.2958) * cos(lat2/57.2958) * cos(lon2/57.2958 -lon1/57.2958)] + + Results are in Statue Miles + + For future reference + + Bearing = arccos[ ( sin(lat2/57.2958) - sin(lat1/57.2958)??cos(D) ) / ( cos(lat1/57.2958) - sin(D) ) ] + if result is < 0 then Bearing is 360 - result + + Parameters + $lat1 Latitude of point #1 + $lon1 Longitude of point #1 + $lat2 Latitude of point #2 + $lon2 Longitude of point #2 + $units Units of results returned + Inches, Feet, Yards, Miles (default), Nautical Miles, + Meters, Kilometers + + Return value: + float Distance + + Global references: + + +*********************************************************************** +* * +* DATABASE ABSTRACTION FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + index db_connect( string $conn_str, bool $fail_mode ) +------------------------------------------------------------------------ + + Creates a connection to database specified $conn_str, + and returns a boolean for success. + + Parameters: + $conn_str Connect String + $fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + + Return value: + Returns an index or fails using html_error() function + + Global references: + SI_DB_TYPE + +------------------------------------------------------------------------ + bool db_close(int dbd) +------------------------------------------------------------------------ + + Closes the connection to database specified by the handle dbd + returns a boolean for success + + Parameters: + dbd -- database connection handle + + Return value: + Returns 1 on success 0 if dbd is not a valid connection + + Global references: + SI_DB_TYPE + +------------------------------------------------------------------------ + bool db_pconnect( string $conn_str ) +------------------------------------------------------------------------ + +Creates a persistant connection to database specified in $conn_str +and returns a boolean for success. + + Parameters: + $conn_str Connection string + + Return value: + Returns 1 on success 0 on failure + + Global references: + SI_DB_TYPE + SI_CONN_STR + + +------------------------------------------------------------------------ + int db_exec(int $dbd, string $qs) +------------------------------------------------------------------------ + +Execute an SQL query, * returning a valid result index or zero(0) on +failure. + + Parameters: + int $dbd -- valid database connection descriptor + string $qs -- SQL query string + + Return value: + Returns a valid result index on success 0 on failure + + Global references: + None + +------------------------------------------------------------------------ + array db_fetch_row(int $res, int $i ) +------------------------------------------------------------------------ + +Stores the data in associative indices, using the field names as +keys. + + Parameters: + int $res -- valid database result index + int $i -- row number + + Return value: + Returns an associative array of key-value pairs + + Global references: + None + +------------------------------------------------------------------------ + bool db_freeresult(int $res) +------------------------------------------------------------------------ + +Free result memory. + + Parameters: + int $res -- valid database result index + + Return value: + Returns 1 for success 0 for failure + + Global references: + None + +------------------------------------------------------------------------ + bool db_numrows(int $res) +------------------------------------------------------------------------ + +Determine number of rows in a result index + + Parameters: + int $res -- valid database result index + + Return value: + Returns number of rows + + Global references: + None + +************************************************************************ +* * +* AUTO FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + array db_auto_get_row(string $qs, int $i, string $conn_str, bool $fail_mode) +------------------------------------------------------------------------ + +The auto function for retrieving an array based soley on a query +string. This function makes the connection, does the exec, fetches +the array, closes the connection, frees memory used by the result, +and then returns the array + + Parameters: + string $qs SQL query string + int $i row number + $conn_str Connect String + $fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + + Return value: + Returns an associative array of key-value pairs + + Global references: + None + + +------------------------------------------------------------------------ + array[array] db_auto_get_data(string $qs, string $conn_str, bool $fail_mode, int $rows, int $start) +------------------------------------------------------------------------ + +The auto function for retrieving an array based soley on a query +string. This function makes the connection, does the exec, fetches +the array, closes the connection, frees memory used by the result, +and then returns the array. + +This function will by default retrieve a maximum of 100 results. That +number may be increased by supplying the $rows value. You can also have +it retrieve $rows rows starting at $start. This makes it simple to +ask for the data for a single page of output when doing pagination without +having to return all matched results. + + Parameters: + string $qs SQL query string + $conn_str Connect String + Optional Parameters + $fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + $rows Maximum number of rows that will be returned + Defaults to 100 + $start Start at this row and retrieve up to $rows rows + + Return value: + Returns an associative array of key-value pairs + Each key is a text value consisting of 2 numbers separated by "|" + i.e. "10|1320" = 10th row out of 1320 total results + (Note that the total is how many matches there are and may + be more than $rows.) + + Global references: + None + +------------------------------------------------------------------------ + bool db_auto_exec(string $qs, string $conn_str, bool $fail_mode ) +------------------------------------------------------------------------ + +The auto function for executing a query. +This function makes the connection, does the exec, fetches +the array, closes the connection, frees memory used by the result, +and then returns success (not a valid result index) + + Parameters: + string $qs SQL query string + $conn_str Connect String + + Return value: + Returns 1 (or oid, if available) for success 0 for failure + + Global references: + None + +------------------------------------------------------------------------ + array db_data_fields( string $conn_str, string $table ) +------------------------------------------------------------------------ + + Parameters: + $conn_str Connect String + $table Database Table Name + + Return value: + Array of field information + + $fields[{name}]['size'] = Storage size of fields {name} + $fields[{name}]['type'] = Field type of field {name} + + Global references: + None + +************************************************************************ +* * +* FILE FUNCTIONS * +* * +************************************************************************ + + +------------------------------------------------------------------------ + string file_upload(string $temp_file, string $file_name, string $base_path) +------------------------------------------------------------------------ + +Store away an uploaded file + + Parameters: + $temp_file -- Temporary name of uploaded file + $file_name -- $form_field of file with _name + $base_path -- Optional base path for location of files - Defaults to SI_BASE_PATH + + Return value: + string $new_file_name, + + Global references: + + +------------------------------------------------------------------------ + string file_duplicate( string $file_name, string $base_path ) +------------------------------------------------------------------------ + +Duplicate a stored File and give copy the same name with a "c{n}_" preceeding it. +The {n} is a serialized number to distinguish the file from any other existing file. +This function will try serial numbers up to 1000 before giving up. + + Parameters: + $file_name -- Name of the file to duplicate + $base_path -- Optional base path for location of files - Defaults to SI_BASE_PATH + + Return value: + Returns Name of duplicate file or '' if failure. + + Global references: + + +------------------------------------------------------------------------ + bool file_delete( string $file_name, string $base_path ) +------------------------------------------------------------------------ + +Delete a stored File + + Parameters: + $file_name -- Name of the file to delete + $base_path -- Optional base path for location of files - Defaults to SI_BASE_PATH + + Return value: + Returns TRUE if all is OK or FALSE if file wasn't there + + Global references: + + +------------------------------------------------------------------------ + string file_get( string $file_name [, int $max_size], string $base_path ) +------------------------------------------------------------------------ + +Read the specified file and return the results + + Parameters: + $file_name -- $form_field of image with _name + $max_size -- Optional maximum size of file to read (0=all - default) + $base_path -- Optional base path for location of files - Defaults to SI_BASE_PATH + + Return value: + string $file_contents -- Contents of the file or FALSE if error + + Global references: + + +------------------------------------------------------------------------ + bool file_ouput_secure( string $file_name, string $md5, string $path ); +------------------------------------------------------------------------ + +Output the specified file from the specified path using secure method to protect directory. + +The directory or file specified should be unreachable via the web server, usually as a result +of using a .htaccess rule to block access to the directory. The directory must be under SI_BASE_PATH. +The file is output by actually reading the file and writing out to the browser. Only known mime types +will work since the mime type needs to be specified when the file is output. This function will attempt +to determine the mime type and if it can't will use a default type that may not result in desired action +by the user's browser. + +The md5 string is required and must match an md5 string generated by this function. The md5 string is +created from the file name with SI_FILE_SECRET appended to it. Since the user doesn't know the secret +string, any messing with the file name will result in a failure. This protects other files in the +directory when the user attempts to guess their names. + +If SI_FILE_SECRET doesn't exist or is empty this function will output an error message and exit. + +This function is required for ouput when using the "secure" option for the "file" type field in the +admin functions. + + Parameters: + $file_name -- Name of the file to output + $md5 -- MD5 String created using file name and SI_FILE_SECRET parameter + $base_path -- Optional base path for location of files - Defaults to SI_BASE_FILE_PATH + If supplied it is appended to SI_BASE_PATH to come up with + complete path. + + Return value: + bool -- True if successful, false if file is not found or md5 doesn't match. + + Global references: + SI_BASE_FILE_PATH + SI_BASE_PATH + SI_FILE_SECRET + + +************************************************************************ +* * +* GRAPHICS FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + array img_info( string $path2image ) +------------------------------------------------------------------------ + +Returns information about an image + + Parameters: + $path2image -- path to image + + Return value: + Returns $img_data = Array + ['width'] = Width + ['height'] = Height + ['type_num'] = Type Number + ['type'] = Type name + ['size'] = 'height="yyy" width="xxx"' string for use in HTML tags + ['bits'] = Bits + ['channels'] = Channels + + Global references: + + +------------------------------------------------------------------------ + bool graphic_thumb(string $img, string $timg, string $type) +------------------------------------------------------------------------ + +Creates a thumbnail image based on a full scale jpeg or gif + + NOTES: + This function expects "good" parameters. Make sure you + ereg_replace any bad escape characters (or even spaces) that + are part of $img and $timg before passing them to + graphic_thumb(). You may want to look at escapeshellcmd() or + EscapeShellArg() once we upgrade to php4.03 ./muk + + Parameters: + $img -- path to image which needs to be thumbed + $timg -- path where thumbnail will live + $type -- mime type of image e.g. "image/jpeg" + + Return value: + Returns 1 on success 0 on failure + + Global references: + DJPEG + CJPEG + PNMSCALE + GIFTOPNM + PPMTOGIF + PPMQUANT + + +------------------------------------------------------------------------ + bool graphic_resize(string $img, string $timg, string $type, int $w, int $h) +------------------------------------------------------------------------ + +Creates a thumbnail image based on a full scale jpeg or gif + + NOTES: + This function expects "good" parameters. Make sure you + ereg_replace any bad escape characters (or even spaces) that + are part of $img and $timg before passing them to + graphic_thumb(). You may want to look at escapeshellcmd() or + EscapeShellArg() once we upgrade to php4.03 ./muk + + Parameters: + $img -- path to image which needs to be resized + $timg -- path where resized image will live + $type -- mime type of image e.g. "image/jpeg" + $w -- width of new image + $h -- height of new image + + Return value: + Returns 1 on success 0 on failure + + Global references: + DJPEG + CJPEG + PNMSCALE + GIFTOPNM + PPMTOGIF + PPMQUANT + +------------------------------------------------------------------------ + array img_resized(string $path2image, string $path2thumb, string $axis, int $size) +------------------------------------------------------------------------ + + Resizes an image based on a full scale jpeg or gif + + + Parameters: + $path2image -- path to image which needs to be resized + $path2thumb -- path where resized image will live + $axis -- 'h' for height , 'w' for width , or 'a' for both + $size -- using axis size of new image + + Return value: + Returns $img_resized_array + + Global references: + + +------------------------------------------------------------------------ + array img_upload(string $form_field, string $image_name, string $destination_path) +------------------------------------------------------------------------ + +Creates a thumbnail image based on a full scale jpeg or gif + + NOTES: + This function expects "good" parameters. Make sure you + ereg_replace any bad escape characters (or even spaces) that + are part of $img and $timg before passing them to + graphic_thumb(). You may want to look at escapeshellcmd() or + EscapeShellArg() once we upgrade to php4.03 ./muk + + Parameters: + $form_field -- $form_field of image + $image_name -- $form_field of image with _name + $destination_path -- path to store uploaded image + $w -- width of new image + $h -- height of new image + + Return value: + Returns $img_upload_array + + Global references: + + +------------------------------------------------------------------------ + string process_image(string $image, string $image_name) +------------------------------------------------------------------------ + +Main function for image processing + + NOTES: + This function does the following: + 1) places image into original folder + 2) makes three images from original size and places them + into the RESIZED, MIDSIZED, and THUMB folders + + Parameters: + $image -- The variable of the image being post from the form + $image_name -- The variable_name of the image being post + + Return value: + Returns $image_name + + Global references: + + +------------------------------------------------------------------------ + bool delete_image( string $image_name ) +------------------------------------------------------------------------ + +Main function for image processing + + NOTES: + This function does the following: + 1) deletes images in all sizes for a particular name + + Parameters: + $image -- The variable of the image being post from the form + $image -- The variable_name of the image being deleted + + Return value: + Returns TRUE if all is OK or FALSE if images weren't there + + Global references: + + +------------------------------------------------------------------------ + string duplicate_image( string $image_name ) +------------------------------------------------------------------------ + +Main function for image processing + + NOTES: + This function does the following: + 1) creates a duplicate of each size of an image in each + image directory using a new filename. + + Parameters: + $image_name Name of the existing image to duplicate + + Return value: + Returns the name of the image copy or an empty string + + Global references: + + +************************************************************************ +* * +* GENERAL SUPPORT FUNCTIONS / CLASSES * +* * +************************************************************************ + + + +------------------------------------------------------------------------ + Class Name: timestampfunc +------------------------------------------------------------------------ + +Class Functions + +array newdate($timestamp) + This function is used internally by the class to + handle the dirty work of getting the month and year + out of the time stamp. Used mostly to cut down on + the number of lines of code in the class + +string first_of_month($timestamp) + This function takes a unix timestamp, and returns a + unix timestamp of the first day of the month of the + timestamp passed to it. + + string first_last_month($timestamp) + This functin takes a unix timestamp, and returns a + unix timestamp of the first day month previous to + the timestamp passed to it. + + string first_next_month($timestamp) + This function takes a unix timestamp and returns a + time stamp for the first of the next month + + string first_of_Xmonth($timestamp,$x) + This function takes a unix timestamp, and the number + of months to calculate for ($x). $x can be positive + or negative. The function returns a time stamp for + the first day of whatever the return month is. + + + +------------------------------------------------------------------------ + float pos_value( float $value ) +------------------------------------------------------------------------ + +This function the value only if it's positive, otherwise return 0 + + Parameters: + $value Value to check + + Return value: + float value if > 0 + + Global references: + None + + +------------------------------------------------------------------------ + string money( string $value, string $option) +------------------------------------------------------------------------ + +This function returns a string formatted for US Dollars + + Parameters: + $value Value in dollars to format + $option Optional control parameter + "NOPREFIX" - Do not display $ in front of number + + Return value: + String containing money formatted string with "$" + + Global references: + None + + +------------------------------------------------------------------------ + array strtoarray( string $s ) +------------------------------------------------------------------------ + +This function converts a standard data string to an array + + Parameters: + $s Standard data string + key^value~key^value^... + + Return value: + Array containing data from string or FALSE + + Global references: + None + + +------------------------------------------------------------------------ + string arraytostring( array $a, string $type ) +------------------------------------------------------------------------ + +This function converts an array into a standard data string + + Parameters: + $a An array containing data for the string + + Return value: + Standard data string in the form of + key^value~key^value^... + or FALSE if there's an error. + + Global references: + None + + +------------------------------------------------------------------------ + string replace_tokens( string $s, array $tokens ) +------------------------------------------------------------------------ + +This function replaces all occurances of the tokens listed in $tokens +with the string associated with each token where each token is found +in the string surrounded by curly braces ( "{" and "}" ) + + Parameters: + $s String to be modified + $tokens Array of tokens to use for replacement + Key is name of token + Value is string that replaces token + + Return value: + Modified string + + Global references: + None + + +------------------------------------------------------------------------ + string cond_replace_tokens( string $s, array $tokens ) +------------------------------------------------------------------------ + +This function checks for " ... " +syntax. With this syntax, one sting is used when the if condition is +true and the other when it isn't. + + There are two forms of the {if:...} syntax: + + + + In this form, the condition is true if the token named "t" is + not empty ( = "" ). + + + + In this form, the condition is true if the value of the token + named "t" is equal to the string "v". + + Parameters: + $s String to be modified + $tokens Array of tokens to use for tests and replacement + Key is name of token + Value is string that replaces token + + Return value: + Modified string + + Global references: + None + + +------------------------------------------------------------------------ + string replace_file_tokens( string $s ) +------------------------------------------------------------------------ + +This function checks for the "file" token and replaces the token and +all contents of it with the contents of the file. The second form +permits text between the start and end of the token that would be +displayed when directly viewing the file. + + The syntax is: + + + or + any_text + + Where f is the name of a file to insert + + + In this form, the condition is true if the value of the token + named "t" is equal to the string "v". + + Parameters: + $s String to be modified + + Return value: + Modified string + + Global references: + None + + +------------------------------------------------------------------------ + string tableize_array( array $a ) +------------------------------------------------------------------------ + +Produce HTML table describing contents of an array + + Parameters: + $a Array to be described + + Return value: + String with HTML code to display array + + Global references: + None + + +------------------------------------------------------------------------ + string admin_field_select( array $fields, char $filter ) +------------------------------------------------------------------------ + +Select field data from an array based on which function it will be used for + + Parameters: + $fields Complete standard admin_..._record() format field data + with the addition of a set of characters. These + characters indicate which function the line applies to. + (n)ew, (a)dd, (e)dit, (u)pdate, (d)elete, (c)confirm, + (v)iew, (l)ist, (f)ilter + $filter Filter character indicating which type of admin function + filter to use (n, a, e, u, d, c, v, l, or f) + + Return value: + String ready to be fed into $fields parameter of admin function + + Global references: + none + +------------------------------------------------------------------------ + string admin_menu_std( string $action, string $a_title, int $id, + string $opt, string $options, string $add_menu, string $params ); + string admin_menu( string $action, string $a_title, int $id, + string $opt, string $options, string $add_menu, string $params ); +------------------------------------------------------------------------ + +Generate standard admin low-level menu. admin_menu() generates older HTML while +admin_menu_std() generates newer standard GLM HTML for admin areas (
's). + + Parameters: + $action Action this menu is associated with + $a_title Title to display at left of menu + $id ID of current record + $opt Current Option being executed (Normally $Option) + $options String of characters indicating which options are + to be provided + l=list, v=view, e=edit, d=delete, a=add + $add_menu Additional Menu items to be included at end. + $params Additional link Parameters that need to be passed in the form + of typlical link data ( x=x1&y=y1&... ) + + Return value: + String ready to be displayed. Does not include trailing
+ + Global references: + none + + +------------------------------------------------------------------------ + string clean_input( string $var_name, string $type, bool $required ) +------------------------------------------------------------------------ + +Cleanup input parameters and test them for proper type of data then +place cleaned up input values back into the parameter referenced. + + Parameters: + $var_name Name of the input variable to clean up (not the parameter itself + $type Expected type of the parameter - Optional, defaults to 'text' + int Integer number + float Floating point number (accepts integer also) + Also trims "$" if included + phone Phone number (any legal style) + zip ZIP/Postal Codes (Any legal style) + text General Text input + state Checks against state list in siteinfo.inc + country Checks against country list in siteinfo.inc + email Checks for legal E-Mail address + creditcard Checks for legal Credit Card number + date Checks for legal Date/time + inet Checks for legal Internet Address or Netmask (IP) + $required Field is require (true/false) + + Return value: + string Returns an empty string if all is OK, or an error message + if not. + + Global References + References the specified parameter as a global + $si_states_array for type 'state' + $si_countries_array for type 'country' + + +------------------------------------------------------------------------ + string data_to_url( array $data, string $prefix ) +------------------------------------------------------------------------ + +Build the parameter list of a search engine friendly URL using the supplied +parameters. The url will include only the parameters, properly encoded, in +the sequence they appear in the array and separated by /'s. + + Parameters: + $data Array of data to include. Key is name of parameter + and array values are the values to be passed in the URL. + Note that the keys are for caller reference only and + are not really used in this funtion. + $prefix Any desired URL prefix to include. + + Returned Value: + string The search engine friendly URL + + Global References: + (none) + +------------------------------------------------------------------------ + array url_to_data( array $data, string $url, string $start_key ) +------------------------------------------------------------------------ + +Read a list of parameters from a search engine friendly URL and stuff the +results in the returned array. + + Parameters + $data Array similar to that used in data_to_url() function + except that the array values are not used. Keys are + the names of the parameters. Note that the keys are + for caller reference only and are not really used in + this function. URL parameters are assumed to be in + the same order as the array. + $url URL to parse as source of parameter data. + $start_key String used to identify postion in the URL where the + parameter values start. The function will search for + this string plus a following / and will use anything + following as the parameter list. + + Returned Value: + array Array of data similar to that passed to data_to_url() + function containing parameter names as the keys and + parameter values as the array values. + + Global References: + (none) + + +------------------------------------------------------------------------ +string build_nav( array $nav_table, string $menu_title, string $current_item = '', + string $sub_menu = '', string $link_data = '' ) +------------------------------------------------------------------------ + +Builds standard navigation code. + + Parameters: + $nav_table Array of menu items - Contains: + key Name of menu item + 'title' Text to display for Menu item + 'url' URL for link from menu to selected item + $menu_title Title for top of menu + $current_item Name of the current menu item as listed in $menu + $sub_menu Sub-Menu text to be included at point of current_item + $link_data Additional link data to be appended to URL + + Returned Value: + string HTML of menu + + Global References: + (none) + + + +************************************************************************ +* * +* CATEGORY SUPPORT FUNCTIONS * +* * +************************************************************************ + + Note that category functions assume the following fields in tables + + Field Key Req Description + ------- ----------- -------------------------------------- + id Yes Unique ID for the category node + parent Yes Parent node id + name Category Name field + sort Sort order field for (sub)category + +------------------------------------------------------------------------ + string category_path_func( string $table_name ) +------------------------------------------------------------------------ + +Returns PL/pgSQL category_path support function for specified data table + +Before running these functions on any database the language must be +loaded into the database using the following command line. + + createlang -h {server} -U {user} plpgsql {database_name} + + Parameters: + string $table_name Name of category table + + Return value: + + string String containing function definition. Must load this by + including it in a query. Best to do that as part of a + transaction to make sure the function doesn't change by + another process. + + Global references: + None + +------------------------------------------------------------------------ + array cat_get_node( string $table, string $qs, string $order ) + array cat_get_nodes( string $table, string $qs, string $order ) +------------------------------------------------------------------------ + +This function returns an array of results from a category table using +the supplied query string. + +The results are sorted by category hierarchy. + +cat_get_node() is for getting a single node +cat_get_nodes() is for getting a list of nodes + ( results are similar to db_auto_get_row() and db_auto_get_data() ) + + Parameters: + $table Table name to query + $qs Query string used to select category nodes + Defaults to nothing + $order ORDER BY string for ordering results other than by category path + + Return value: + array Array of nodes data containing all fields for each record + in the category table + + Also included with each node array is an array element called 'parent_data' + that provides the following... + ['cat_names'] An array of parent node names from top level down + ['cat_id_path'] A "|" delimited string of the cat ID path + (all parents in sequence followed by the current id) + ['cat_ids'] An array of the cat ID from top level down + (all parents in sequence followed by the current id) + ['cat_level'] A number indicating the category level of current node + 0 = Top level + + or FALSE if none + + Global references: + None + +------------------------------------------------------------------------ + array cat_get_expanded_nodes( string $table, int $id ) +------------------------------------------------------------------------ + +This function returns an array of results from a category table suitable +for use with a contracted menu of categories. Categories that are returned +are the target and all siblings of all parents. + +The results are sorted by category hierarchy. + +Parameters: + $table Table name to query + $id ID of target category node + + Return value: + array Array of nodes data containing all fields for each record + in the category table + + Also included with each node array is an array element called 'parent_data' + that provides the following... + ['cat_names'] An array of parent node names from top level down + ['cat_ids'] An array of parent id's from top level down + ['cat_level'] A number indicating the category level of current node + 0 = Top level + + Global references: + None + + +------------------------------------------------------------------------ + array cat_get_tree( string $table, int $id ) +------------------------------------------------------------------------ + + ***** NOT IMPLEMENTED ***** + +This function returns an array of results from a category table that +includes the entire tree of a target category and every category subordinate +to it. + +The results are sorted by category hierarchy. + +Parameters: + $table Table name to query + $id ID of target category node + + Return value: + array Array of nodes data containing all fields for each record + in the category table + + Also included with each node array is an array element called 'parent_data' + that provides the following... + ['cat_names'] An array of parent node names from top level down + ['cat_ids'] An array of parent id's from top level down + ['cat_level'] A number indicating the category level of current node + 0 = Top level + + Global references: + None + + +------------------------------------------------------------------------ + bool cat_resequence_siblings( string $table, int $parent ) +------------------------------------------------------------------------ + +This function resequences the "order" field of a group of siblings +to normalize the numbering. It renumbers by 10's starting at 10 to +permit insertion of new nodes at any point or to move a node to any +point. + + Parameters: + $table Table name to query + $parent Parent ID + + Return value: + bool TRUE or FALSE (if some error) + + Global references: + None + + +------------------------------------------------------------------------ + array cat_move_node( string $table, int $id, int $new_parent ) +------------------------------------------------------------------------ + + **** PENDING **** + +This function resequences the "order" field of a group of siblings +to normalize the numbering. It renumbers by 10's starting at 10 to +permit insertion of new nodes at any point or to move a node to any +point. + + Parameters: + $table Table name to query + $parent Parent ID + + Return value: + bool TRUE or FALSE (if some error) + + Global references: + None + + +------------------------------------------------------------------------ + bool cat_delete_node( string $table, int $id, string $method ) +------------------------------------------------------------------------ + + **** PENDING **** + +This function deletes a target node. Depending on $method, it will either +delete all children or assign them to the deleted node's parent. + + Parameters: + $table Table name to query + $parent Parent ID + $method Method of deletion + "node" - Delete the node only and assign children to parent + DEFAULT + "tree" - Delete all children as well as the target node + + Return value: + bool TRUE or FALSE (if some error) + + Global references: + None + + +************************************************************************ +* * +* HIGH-LEVEL FUNCTIONS * +* * +************************************************************************ + + + +------------------------------------------------------------------------ + string build_numeric_picklist( string $fieldname, int $starting, int $ending, + int $selected ) +------------------------------------------------------------------------ + +This function returns a string containing the HTML code for a picklist +with the specified name and containing sequential numeric OPTIONS. + + Parameters: + $fieldname Field name + $starting Lowest number in list + $ending Highest number in list + $selected Start with this number selected (optional) + + Return value: + String containing HTML code for picklist + + Global references: + None + + + +------------------------------------------------------------------------ + string build_picklist( string $fieldname, array $data, string $selected [, string $type] + [, string $options] ) +------------------------------------------------------------------------ + +This function returns an HTML string that provides picklist input + + Parameters: + $fieldname Field name + $data Array of pick list options + $selected Index to match for "SELECTED" option + (or "" if none) + $type (optional) Type of source array + "standard" - Array element Index is OPTION value and element value is text to display + "simple" - Array element value is both text and OPTION value + $options Optional list of options - {option1}~{option2}~... + Options are: + blank Include blank option + numeric Order numeric by value + alpha Order alphanumeric by value + ascending Order ascending + descending Order Descending + multi Multiple selection permitted + + Return value: + String containing HTML code for picklist + + Global references: + None + + +------------------------------------------------------------------------ + string build_radio_buttons( string $fieldname, array $data, string $selected + [, string $separator] [, string $type] [, string $options] ) +------------------------------------------------------------------------ + +This function returns an HTML string that provides Radio Button input + + Parameters: + $fieldname Field name + $data Array or standard data string of radio button options + $selected Index to match for "SELECTED" option + (or "" if none) + $type (optional) Type of source array + "standard" - Array index is button value, array data is displayed text + "simple" - Array element data is both button value and text + $options Optional list of options - {option1}~{option2}~... + Options are: + numeric Order numeric by value + alpha Order alphanumeric by value + ascending Order ascending + descending Order Descending + before Text before button (default) + after Text after button + $separator String to be used as separator for radio button options + + Return value: + String containing HTML code for radio button input + + Global references: + None + + +------------------------------------------------------------------------ + string calendar_date_select( string $default_value, timestamp $start_date, timestamp $end_date, + string $form_name, string $field_name, string $options, string $no_earlier ) +------------------------------------------------------------------------ + + This function creates a date input form with a link to a pop-up calendar + + Parameters: + $default_value Text to use as default value for input field + $selected_date Timestamp of date that should be selected by default + in pop-up calendar + $start_date Timestamp of first date to allow in pop-up calendar + $stop_date Timestamp of last date to allow in pop-up calendar + $form_name Name of submission form + $field_name Base name of target field in Form + Saves results into: + {$field_name}_date + {$field_name}_month (includes year) + $options Optional controls - comma separated + NO_PROMPT No (month/day/year) prompt + TEXT Single text input field (default) + PICK Month, Day, Year picklists + HIDE_YEAR Hide year picklist + $no_earlier Optional name of form field that may contain a date + that should be used as the earliest date to + set as the default date. If $selected_date is + earlier than this, set $selected_date to this date. + + Return value: String containing complete form + + Global references: + None + + +------------------------------------------------------------------------ + string calendar_display( int $month, int $year, array $date_data + [, string $headerinfo] [, string Rmonthinfo] ) +------------------------------------------------------------------------ + +Build an HTML calendar with data from the array in each date + + Parameters: + $month Numeric month value 1-12 + $year Numeric year value e.g. 2002 + $date_data array, index must be number of day, + ["text"] is displayed inside calendar + ["link"] is link target + $headerinfo String to place under the Month and Year + $monthinfo String to replace Month/Year title line + + Return value: calendar as string + + Global references: + None + + + +------------------------------------------------------------------------ + array get_us_counties( string $state, bool $fail_mode, $include_any ) +------------------------------------------------------------------------ + +This function returns an array containing the names of counties in the +state specified. + + Parameters: + $state 2 letter code of state + $fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + #include_any Include an option "(any)", which = "" + + Return value: + Array of counties + + Global references: + None + + +------------------------------------------------------------------------ + string parse_view( string $file_name, array $tokens, bool $show_unused ) +------------------------------------------------------------------------ + +This function loads a "view" file, replaces all occurances of +the specified tokens. The view file may also designate areas to +exclude from the file (discard), may specify header, body, and footer +regions, and may specify a set of body designs that are to be used in +rotation for sets of body tokens. + + Parameters: + $file_name Full path and name of view file + $tokens A multi-dimentional array of sets of tokens + + The view file may include the following designators: + + **** NEED TO REWRITE THIS DOCUMENTATION **** + **** ALSO CHANGE REPLACEMENTS T%O NOT USE REGEX **** + + + + Replace all occurances with contents of filename. The file name + is relative to the root of the web site. i.e. ... + + + + ... will include the file SI_BASE_PATH."/sales/policy.inc". + + and + + All text between EXCLUDE and /EXCLUDE comments will be deleted. + This permits the inclusion of areas in the view file that allow + for more a more complete perspective when laying out the view + file such that it can be directly viewed on a browser or in an + HTML layout package. + + Both start and end EXCLUDE tags must be used or the area will not + be excluded from the results. + + and + + The {BODY} and {/BODY} comment tags designate the start and end + of a "body" section of the view file file. Text before the + {BODY} tag is considered the "header" and text after the {/BODY} + tag is considered the "footer". + + The body section is parsed and added to the result multiple + times, once for each set of "body" tokens. + + Both {BODY} and {/BODY} tags must be used together or not at all. + There can be only one set of such tags in a view file. If they + do not exist, the whole file is parsed as a unit using the + "global" tokens only. + + and + + The body of a view file may be separated into "sections" by + including the {SECTION} comment tags. When there are multiple + sections of the body, these sections are used in rotation as + each set of "body" tokens is applied. There may be any number of + {SECTION} comment tags or none at all. These tags may not appear + in the header or footer of the view file. + + $tokens array as the following structure + + + "global" => array + ( + token => string, + token => string, + ... + tokey key/value sets used in header, footer or for the + whole file if the file is not separated by comment tags. + ) + "body" => array + ( + 0 => array + ( + token => string, + token => string, + ... + token key/value sets used for a body section + ) + 1 => array + ( + token => string, + token => string, + ... + token key/value sets used for a body section + ) + ... + The "body" array contains as many sets of data as + there are to be copies of the body section. + ) + + Return value: + String representing modified view file contents. + + Global references: + None + +************************************************************************ +* * +* MAGIC FORM FUNCTIONS * +* * +************************************************************************ + +****WARNING: NEED TO UPDATE MAGIC FORM DOCUMENTATION TO INCLUDE FIELD FORMATS AND DEFAULT SELECTIONS/VALUES. **** + + +Magic Forms are forms that are built by the user and that can contain a +number of different field types and optional sub-forms. + +There are 3 functions associated with Magic Forms. They are... + + magic_form_edit() Create/Edit a Form + magic_form_display() Display a form + magic_form_submit() Process a submitted form + +Magic Forms uses a single database table to store all form data. The name +of this table is specified using the MF_TABLE defined parameter. + +Database Table Schema + + CREATE TABLE magicform + ( + id SERIAL, + form_id text, + custom_id text, + title text, + type smallint, + descr text, + active bool, + required bool, + data1 text, + sort smallint, + expanded bool, + style text, + image text, + cols int, + rows int + ); + +After creating this table, create an index for the id field. + + CREATE INDEX magicform_form_id_index ON magicform( form_id ); + +Magic Forms also use a "format" array that contains information on what output +formats are available and how to display them. These can include anything from +simple one line formats for each field, to complex multi-column formats. These +format specifications use the View Tags capability to permit complex and +conditional use of form components. The following is an example. + +$mf_format = array + ( + + 'Default' => array + ( + 'types' => ' 1 2 3 4 5 6 20 21 23 30 31 ', // Field types - MUST HAVE SPACE EACH SIDE OF VALUES + 'short_name' => 'Default', // A short name used in form edit + 'cols' => 1, // Number of columns per row + 'start' => '', // Text when starting this style + 'row_start' => '', // Text when starting a row + 'body' => '
    + {title}
    + {descr}
    + {image}
    + {input} +
      {sub_forms}
    +
', // Text for each column + 'col_empty' => '', // Text for empty columns + 'row_end' => '', // Text for end of each row + 'end' => '', // Text when switching to different style + 'sub_form' => '
    {sub_form}
' // Text for each sub-form (yes, there could be multiples) + ), + + 'Prompt/Input on single line' => array + ( + 'types' => ' 1 2 3 4 5 6', + 'short_name' => 'Single Line', + 'cols' => 1, + 'start' => '', + 'row_start' => '', + 'body' => '{title} + {image} + {input} +
    {sub_forms}
+ ', + 'col_empty' => '', + 'row_end' => '', + 'end' => '', + 'sub_form' => '
    {sub_form}
' + ), + + '2 Column Table' => array + ( + 'types' => ' 1 2 3 4 5 6 ', + 'short_name' => '2 Column', + 'cols' => 2, + 'start' => '
', + 'row_start' => '', + 'body' => '', + 'row_end' => '', + 'end' => '
+ {title}
+ {descr}
+ {input} +

{sub_forms} + ', + 'col_empty' => '

 

', + 'sub_form' => '{sub_form}
' + ), + +Note that each format element has a list of field "types" with which it can +be used. The magic_form_edit() function will read the list of "types" for +each format specification and select the first format found for a particular +field type as the default for that type. Only those formats that have a +particular field type will be available for that type. The field types are... + + 1 Checkbox + 2 Number + 3 Text + 4 Text Box + 5 Picklist + 6 Radio Buttons + 20 Section Title + 21 Misc. Text + 22 Horizontal Line + 23 Blank Line + 24 Image + 31 Calculated Field (not implimented) + + +------------------------------------------------------------------------ + array magic_form_edit( int $mf_id, array $mf_format, in5 $mf_level ) +------------------------------------------------------------------------ + +This function is a complete user interface for building a form. Simply call +this function with a unique form id. Each time a change is requested by the +user, the page will be submitted. When submitted, call this function again. +The user requests will be passed back to it with global submitted parameters. + + Parameters: + $mf_id A unique int ID for this form + $mf_format Format array + $mf_level A sub-form level counter - Do not use! + This parameter is used internally to keep track of + recursion into sub-forms. + + + Return value: + Array containing the following elements + + 'success' Boolean true, or false if there is a problem + 'modified' Form has been modified in a way that old end-user + data may not be valid anymore. + 'text' The full text of the form management ouput. + Send this text to the user's browser to display + form management interface. + + Global references: + MF_TABLE SQL database table name to use + (various) Various other user submitted form parameters. These + parameters all begin with 'mf_'. + +------------------------------------------------------------------------ + array magic_form_display( int $mf_id, array $mf_format, int $mf_fiid, + array $mf_def_data, int $mf_level ) +------------------------------------------------------------------------ + +This function provides the HTML code to display a Magic Form to a user. + + Parameters: + $mf_id A unique int ID for this form + $mf_format Format array + $mf_fiid ID of user data for this instance of the form. This is + used when the user data is to be called from the database. + Otherwise the $mf_def_data paramter can be used to + provide data received by the magic_form_submit() function. + $mf_def_data Array of default data. There is an element for each + field that should be populated with the provided + data, checked, or selected. The 'data' array returned + by the magic_form_submit() function can be used to + supply this default data. The elements actually used + are the element index (id of the field) and 'value'. + This value is used either when this function is calling + it'self for a sub-form or when the data is being passed + by the application from a prior submission using the + magic_form_submit() function. + $mf_level A sub-form level counter - Do not use! + This parameter is used internally to keep track of + recursion into sub-forms. + + Return value: + Array containing the following elements + + 'success' Boolean true, or false if there is a problem + 'text' The full text of the form management ouput. + Send this text to the user's browser to display + the final form. + 'required' Boolean flag indicating if there are any "required" + fields. This can be used to determine if some text + should be displayed to the user about required fields. + + Global references: + MF_TABLE SQL database table name to use + (various) Various other user submitted form parameters. These + parameters all begin with 'mf_' and then the numeric + record id of the form element from the MF_TABLE. + + + +------------------------------------------------------------------------ + array magic_form_submit( int $mf_id, int $mf_fiid, array $mf_def_data, int $mf_level ) +------------------------------------------------------------------------ + +This function is used to process a user submitted form that was created by +the magic_form_display() function. It can optionally accept an array of data +to be used as the default values for each field. + + Parameters: + $mf_id A unique int ID for this form + $mf_fiid A unique ID used as a key to store submitted data. + If this parameter is "null" then data is not stored. + $mf_def_data An array of user data from a prior use of this function. + When this parameter is supplied, this data is used rather + than checking for form submission data. This permits + reprocessing of sumbitted data for the purpose of storing + the data or generating the HTML, CSV, or other results. + $mf_level A sub-form level counter - Do not use! + This parameter is used internally to keep track of + recursion into sub-forms. + + Return value: + Array containing the following elements + + 'success' Boolean true, or false if there is a problem + 'data' Array of data results. Each element is a field result. + This array can be supplied back to magic_form_display() as the + $mf_def_data array to supply default values for fields. + The index of each field result is the record id of that + field in MF_TABLE. Each field result is an array containing... + + 'id' Field id + 'title' Field title + 'type' Field type number + 'txt_typ' Field type name + 'value' Submitted value + 'txt_val' Text version of result (for things like + boolean true/false results) + 'opt_num' Option number for checkbox, picklist, & radio buttons + 'valid' Boolean flag indicating whether the field + data is valid + 'required' Boolean flag indicating if field is required + 'failure' Text string indicating any submission problem + + 'html' HTML code to display a table of the results + 'csv' Results prepaired as .csv (quoted, comma separated) + 'problem' Text listing any submission problems, such as + required fields that weren't completed + + Global references: + MF_TABLE SQL database table name to use + (various) Various other user submitted form parameters. These + parameters all begin with 'mf_' and then the numeric + record id of the form element from the MF_TABLE. + +------------------------------------------------------------------------ + bool magic_form_store_data( int $mf_id, int $mf_fiid, array $mf_def_data ) +------------------------------------------------------------------------ + +This function simply stores the data supplied in the $mf_def_data array (generated +by a previous call to magic_form_submit(). The data is stored with the unique $mf_fiid +to specify this particular instance of the submitted form data. Any information that +had been previously stored for the speficied $mf_fiid is deleted before storing the +new data. + + Parameters: + $mf_id A unique int ID for this form + $mf_fiid A unique ID used as a key to store this instance of + the submitted data. + $mf_def_data An array of user data from a prior call to magic_form_submitt(). + + Return value: + bool Success (true) of Failure (false) + + Global references: + (none) + + +************************************************************************ +* * +* SUPPORT FOR HIGH-LEVEL ADMIN FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + array explode_trim( string $separator, string $string ) +------------------------------------------------------------------------ + +Explodes a string into pieces and trims whitespace from ends of each piece. + + Parameters: + $separator Delimiter character + $string String to explode + + Return value: + Array containing exploded, trimmed strings + + Global references: + None + + +************************************************************************ +* * +* HIGH-LEVEL ADMIN FUNCTIONS * +* * +************************************************************************ + + +------------------------------------------------------------------------ + array admin_process_records_r( string $table, string $where, string $order, + string $conn_str, int $id, array $fields, string $options, + int $rows, string $url, string $action, + string $params, string $a_title, string $view + string $Option, string $other_opt ) + void admin_process_records( string $table, string $where, string $order, + string $conn_str, int $id, array $fields, string $options, + int $rows, string $url, string $action, + string $params, string $a_title, string $view + string $Option, string $other_opt ) +------------------------------------------------------------------------ + +This is the whole kitten-kabootle. Call this to fully process a table +including add, edit, delete, view, and list. + +See various functions for full description of parameters + + Parameters: + $table Name of dabase table + $where Any additional "WHERE" clause for query + $order Any additional "ORDER BY" clause for query + $conn_str Connect String + $id ID of current record + $fields Array of fields as used by admin_field_select() + $options Comma separated list of options + $rows Maximum number of rows per page + $url URL of next processing page + $action Action to be passed to next processing page (says what we're working on) + $params A "|" separated list of Additional parameters to be passed on links + $a_title Page title to display + $view Optional View to replace standard output for each Option type + This is an array where there is an element for each Option + where the indicies are 'Add', 'Add New', 'Edit', 'Update', ... + $Option Current Option (Add, Edit, ... ) + $start Starting record for lists + $other_opt Other options to pass to subsequent admin functions + $title_view Optional View to replace normal title output. + + Return value: + admin_process_records_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_process_records() (none) + + Global references: + None + + +------------------------------------------------------------------------ + array admin_list_records_r( string $table, sting $where, string $oder, + string $conn_str, string $fields, + string $options, int $rows, int $start, + string $url, string $action, + string $params, string $filters, + string $a_title ) + void admin_list_records( string $table, sting $where, string $oder, + string $conn_str, string $fields, + string $options, int $rows, int $start, + string $url, string $action, + string $params, string $filters, + string $a_title ) +------------------------------------------------------------------------ + +The auto function retrieves the desired data using the query string, +then builds a table of the results and displays it along with paging. + +The displayed table can optionally have edit, and delete funtions for +each result. + +If options are specified, then links are placed at the end of each +data record for each of the specified options. An additional parameter +(Option) is passed to the page to indicate the options that was selected +by the user. It will be "New", "Add New", "Display", "Edit" or "Delete". + +If option "new" is selected, then a link to add a new entry is placed +at the top of the page. + +If option "filter" is selected, then a filter form is placed at the +top. + + Parameters: + $table Name of dabase table + $where Any additional "WHERE" clause for query + $order Any additional "ORDER BY" clause for query + {field}.{nav_option}.{nav_option}|{field}|{field}| + Where: {nav_option} + "order_descending" - Use Descending order for this field + $conn_str Connect String + $fields List of fields to display (see below) + $options Comma separated list of options + new = Provide new option + view = Profide display option + edit = Provide edit option + delete = Provide delete option + filter = Provide search fields + sortlinks = Make column headers clickable to resort by that column + nopageing = Don't display paging links + noborder = Don't display table borders + opview.v = View text for Operation Column + v = View text, can use {n}, {encode:n}, {link_params}, {form_params} + Can also user predefined links {op_view}, {op_edit}, {op_delete}, {op_duplicate}, + {op_url} <- base url, {op_id} <- id of current record + $fail_mode Failure Mode + TRUE = Abort with HTML + FALSE = Return with fail code + $rows Maximum number of rows per page + $start Start at this row and retrieve up to $rows rows + $url URL of next processing page + $action Action to be passed to next processing page (says what we're working on) + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $filters A "|" separated list of fields to provide search + capability for. Each field is specified as + {field},{type},{title},[ignore],{value} // SOMEDAY WE HAVE TO USE A DIFFERENT DELIMITER THAN "," + Where: {field} = Field to filter on + {type}.....{option} = Type of field - Option specified in filter sub-field [5] + Otherwise type uses normal type sub-fields + Where: {option} = + any - Match the text in any case anywhere in the field - case insensitive + (This is the default type option) + exact - Exact match (default for type pointer) + like - Match the text anywhere in the field - case sensitive + begin - Match the text at the beginning only - case insensitive + {title} = Title for input field + {value} = Parameter with Supplied value + Only required is option "filter" is selected + Special field type "daterange" permits filtering by range of dates + $a_title Page title to display + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {filter} - Filter input form + {link_params} - Additional Parameters in Link format + {form_params} - Additional parameters in form format (hidden fields) + {new} - Create new record link + {nav} - Pagenation nav links + {body} - Designates start of body + {section} - Designates a separation between sections + Sections are used round-robin fasion for record output. + {/body} - Designates end of body + + Output is built as... + 1) $a_title + 2) Content before {body} + 3) Records displayed round-robin with sections + 4) Content after {/body} + + $fields parameter is a string with mulitple field declarations. + + "{name},{type}`{format},{title}|{name},{type},{title}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int - Integer value + fixed.n - Fixed precision, "n" digits after "." + float - Floating value + money - Money (outputs as $xxx,xxx.xx) + text - Simple text field + password - Same as text except that output is displayed as *'s + textbox - Same as text + url - Web page link + date - Date field (currently same as text) + image.s - Image of size "s" + o = Original + r = Resized + m = Midsized + t = Thumb + file.d.{options} - File (displays file name as a link) + d = Directory under base path for site + {options} include + secure = display using secure output to protect directory (need to protect directory using .htaccess) + Use display_secure_file() function to output file + list.{list}.{default}.{picklist_options} - List of options from picklist + state.{default} - Special case of list + country.{default} - Special case of list + pointer - Pointer to data in anohter table (see below) + multipointer - Pointer to data in another table where multiples can be selected + checkbox - Yes/No boolian field + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + order - Output order spec + {title} = Title for table header + {format} = Optional format spec for output, use {field_name} style tags to include + any other raw field data from another field in the list. Only used when + $view is not specified. + + Type "pointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where} + {disp_field} can specify multiple fields separated by "~" + + Type "multipointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where}.{link_table}.{this_table_pointer_field}.{other_table_pointer_field} + + Where: {type} = "pointer" + {other_table} = Table used to get data + {disp_field} = Field in {other_table} to output to user for each + {value_field} = When specified, is the field the value must match rather than "id" + (for now, this field must be an integer) + {where} = WHERE field of query to use for selecting data from {other_table} + (optional - defaults to none) + + Return value: + admin_list_records_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_list_records() (none) + + Global references: + None + + + +------------------------------------------------------------------------ + array admin_new_record_r( string $table, + string $conn_str, string $fields, + string $url, string $action, string $params + string $params, string $a_title, string $view, + string $options ) + void admin_new_record( string $table, + string $conn_str, string $fields, + string $url, string $action, string $params + string $params, string $a_title, string $view, + string $options ) +------------------------------------------------------------------------ + +This function builds a new entry input form with the specified fields. + + Parameters: + $table Name of dabase table + $conn_str Connect String + $fields List of fields to display (see below) + $url URL to page for submitting this form + $action Value of "Action" parameter for program at $url + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of page + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {submit} - submit button + {link_params} - Additional parameters in link format + {form_params} - Additional parameters in form format (hidden fields) + $options Optional control options - comma separated + "borders" = Turn on borders in table + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{title},{required},{value}|{name},{type},{title},{required},{value}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int.w - Integer value + fixed.n - Fixed precision + float.w - Floating value + money - Formats as $xx.xx + text.w - Simple text field + password.w - Same as text field except that input is displayed as *'s + url.w - Web link + date.d1.d2.o.ne - Date field (currently same as text) + textbox.w.h - Textbox + richtext.w.h.filter - Textbox with enhanced editing - w & h in pixels + use w > 550 and h > 100 + filter is either blank or "encoded" to have text html encoded. + file.e - File (file type (e) is optional) + image - Image + pointer.t.f.v.q.p.s - Pointer to data in another table (see below) + checkbox - True/False field, Presented as Checkbox + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + bitmap.b - Bitmapped check boxes, Names for each bit listed in + sequence in b + list.{list}.{default}.p - List of options for picklist/display (see below) + state.{default}.p - Special form of list, uses state table from siteinfo.inc + break.{text} - Break in list - Displays {text} in value field + order - Output order value (automatically normalized) + + where: w = Width, h = height, n = # of digits, + t = table, b = "~" separated list + f = Field in other table from which to get displayed text + v = Field in other table from which to get value (if other than "id") + q = Optional WHERE clause + e = Optional File type required (extension) + p = Pick list build options - {option1}~{option2}~... + (see build_picklist() for options) + s = Field in other table used to sort results retrieved from that table + d1 = Number of days before current date to permit selection + d2 = Number of days after current date to permit selection + o = Date selection options - see calendar_date_select() function + ne = Name of other field that this date field should default to no earlier than + + {title} = Title for table header + {required} = Required field (TRUE/FALSE/UNIQUE/SUPPLIED/DISPLAY/HIDDEN) + {value} = Name of variable containing supplied/hidden/displayed value + For checkboxes use "CHECKED" + + {required} value descriptions + TRUE = Normal input field, must be filled in + FALSE = Normal input field, optionally filled in + UNIQUE = Normal Input field, must be filled in, must be unique (type "text" only) + SUPPLIED = Value for input field is supplied, may be changed by user + DISPLAY = Value for field is supplied in variable who's name is listed and displayed, but can't be changed + HIDDEN = Value for field is supplied in variable who's name is listed, passed on in "hidden" input field + + Type "pointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where} + + Where: {type} = "pointer" + {other_table} = Table used to get data + {disp_field} = Field in {other_table} to output to user for each + {value_field} = Use the field specified here for the OPTION VALUE rather than "id" + (optional - defaults to "id") + {where} = WHERE field of query to use for selecting data from {other_table} + (optional - defaults to none) + {pick_opt} = Picklist options separated by '~' ( see build_picklist() ) + + Type "list" builds a pick list using the "~" separated list {list} + {value}^{option}~{value}^{option}~... + Where {value} = Value provided when option selected + {option} = Text displayed for picklist entry + + This will use the indicated table and fields as source for a pick list + + Return value: + admin_new_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_new_record() (none) + + Global references: + None + + +------------------------------------------------------------------------ + array admin_add_new_record_r( string $table, + string $conn_str, string $fields, + string $url, string $action, string $params, string $a_title ) + int admin_add_new_record( string $table, + string $conn_str, string $fields, + string $url, string $action, string $params, string $a_title ) +------------------------------------------------------------------------ + +This function adds a record submitted from a form produced by the +admin_new_record() function. + + Parameters: + $table Name of dabase table + $conn_str Connect String + $fields List of fields to submit (see below) + $url URL to page for submitting this form + $action Value of "Action" parameter for program at $url + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of page + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + {result} - Results of submission + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{required},{value}|{name},{type},{title},{required},{value}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int - Integer value + fixed - Fixed precision + float - Floating value + money - Money formatted + text - Simple text field + password - Same as text + state - Same as text + textbox - Same as text + date - Date + url - Web link + image - Image + pointer - Pointer value (expects integer value ID of other record) + file - File + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + order - Ouput order field - (future - normalized by this function to 10's after insert) + {title} = Title of field for error output if not supplied + {required} = Required field (TRUE/FALSE/UNIQUE/SUPPLIED) + {value} = Parameter name of supplied data + (for SUPPLIED assign the value to a variable + and pass the variable name) + + Return value: + admin_add_new_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_add_new_record() oid - If successfull, otherwise 0 + + Global references: + $HTTP_POST_VARS, $HTTP_POST_FILES + +------------------------------------------------------------------------ + array admin_edit_record_r( string $table, string $conn_str, + int $id, string $fields, + string $url, string $action, string $params, string $a_title, + string $view, string $options ) + void admin_edit_record( string $table, string $conn_str, + int $id, string $fields, + string $url, string $action, string $params, string $a_title, + string $view, string $options ) +------------------------------------------------------------------------ + +This function builds an edit entry input form with the specified fields. + + Parameters: + $table Name of dabase table + $conn_str Connect String + $id Unique value of "id" field of record to edit + $fields List of fields to display (see below) + $url URL to page for submitting this form + $action Value of "Action" parameter for program at $url + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of page + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + {submit} is submit button + $options Optional control options - comma separated + "borders" = Turn on borders in table + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{title},{required},{value}|{name},{type},{title},{required},{value}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int.w - Integer value + fixed.n - Fixed precision + float.w - Floating value + money.w - Money formatted + text.w - Simple text field + password.w - Same as text except that input is displayed as *'s + text.w - Web link + textbox.w.h - Textboxd + richtext.w.h - Textbox with enhanced editing - w & h in pixels + use w > 550 and h > 100 + date.d1.d2.o.ne - Date field + image - Image + pointer.t.f.v.q.p.s - Pointer to data in anohter table (see below) + list.{list}.{default}.p - List of options for picklist/display (see below) + state.{default}.p - Special form of list - uses states table from siteinfo.inc + country.{default}.p - Special form of list - uses countries table from siteinfo.inc + break.{text} - Break in list - Displays {text} in value field + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + order - Output order field + + where: w = Width, h = height, n = # of digits, + t = table, f = field, q = Optional WHERE clause + v = Field in other table from which to get value (other than "id") + p = Pick list build options - {option1}~{option2}~... + (see build_picklist() for options) + s = Field in other table used to sort query resuts + d1 = Number of days before current date to permit selection + d2 = Number of days after current date to permit selection + o = Date selection options - see calendar_date_select() function + ne = Name of other field that this date field should default to no earlier than + + {title} = Title for table header + {required} = Required field (TRUE/FALSE/UNIQUE/SUPPLIED/DISPLAY/HIDDEN) + {value} = Parameter name of supplied data + (for SUPPLIED/DISPLAY/HIDDEN assign the value to a variable + and pass the variable name) + Also, if this value is used for type pointer, it will use it to match + the "SELECTED" option in the pick list + + Type "pointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where} + + Where: {type} = "pointer" + {other_table} = Table used to get data + {disp_field} = Field in {other_table} to output to user for each + {value_field} = Use the field specified here for the OPTION VALUE rather than "id" + (optional - defaults to "id") + {where} = WHERE field of query to use for selecting data from {other_table} + (optional - defaults to none) + + Type "list" builds a pick list using the "~" separated list {list} + {value}^{option}~{value}^{option}~... + Where {option} = Text displayed for picklist entry + + This will use the indicated table and field as source for a pick list + + Return value: + admin_edit_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_edit_record() (none) + + Global references: + None + + +------------------------------------------------------------------------ + array admin_update_record_r( string $table, string $conn_str, int $id, + string $fields, string $url, string $action, string $params + string $a_title, string $view ) + void admin_update_record( string $table, string $conn_str, int $id, + string $fields, string $url, string $action, string $params + string $a_title, string $view ) +------------------------------------------------------------------------ + +This function updates a record submitted from a form produced by the +admin_edit_record() function. + + Parameters: + $table Name of dabase table + $conn_str Connect String + $id Unique value of the "id" field of the record to update + $fields List of fields to update (see below) + $url URL to page for submitting this form + $action Value of "Action" parameter for program at $url + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of Page + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + {result} - Result of submission + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{required},{value}|{name},{type},{title},{required},{value}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int - Integer value + fixed - Fixed precision + float - Floating value + money - Money formatted + text - Simple text field + text - Same as text + state - Same as text + textbox - Same as text + date - Date + url - Web link + image - Image + pointer - Pointer (expects integer value ID of other record) + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + order - Ouput order spec - (future - normalize to every 10 after update) + {title} = Title of field for error output if not supplied + {required} = Required field (TRUE/UNIQUE/FALSE/SUPPLIED) + {formfield} = Name of form field with supplied data + (for SUPPLIED assign the value to a variable + and pass the variable name) + + Return value: + admin_update_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_update_record() (none) + + Global references: + $HTTP_POST_VARS, $HTTP_POST_FILES + + +------------------------------------------------------------------------ + array admin_delete_record_r( string $table, string $conn_str, $id, + string $fields, string $options, + string $url, string $action, string $params, string $a_title ) + void admin_delete_record( string $table, string $conn_str, $id, + string $fields, string $options, + string $url, string $action, string $params, string $a_title ) +------------------------------------------------------------------------ + +This function retrieves data for the specified record, displays it +then askes the user to acknowledge if they want the record deleted. + +Display of the record data is handled similar to the admin_list_records() +function. + + Parameters: + $table Name of dabase table + $conn_str Connect String + $id Unique of the "id" field of the record to delete + $fields List of fields to display (see below) + $options Comma separated list of options + strong = Strong confirmation, + requires user to type "Confirm" + $action Value of "Action" parameter when calling program from links + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of Page - May contain {n} replacements + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + {submit} is submit button + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{title}|{name},{type},{title}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int - Integer value + fixed:n - Fixed precision, "n" digits after "." + float - Floating value + money - Money formatted + text - Simple text field + password - Same as text except that output is displayed as *'s + state - Same as text + textbox - Same as text + url - Web link + date - Date field (currently same as text) + image:s - Image of size "s" + o = Original + r = Resized + m = Midsized + t = Thumb + pointer - Pointer to data in anohter table (see below) + check.t.f = Check a field in other table for references to this record + Do not delete if entries exist. + t = name of other table + f = field in other table that points to the ID of this record + {title} = Title for table header + {control} = Required field (SUPPLIED/DISPLAY/HIDDEN) + {formfield} = Name of form field with supplied data + (for SUPPLIED assign the value to a variable + and pass the variable name - SUPPLIED is not displayed) + + Type "pointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where} + + Where: {type} = "pointer" + {other_table} = Table used to get data + {disp_field} = Field in {other_table} to output to user for each + {value_field} = When specified, is the field the value must match rather than "id" + (for now, this field must be an integer) + {where} = WHERE field of query to use for selecting data from {other_table} + (optional - defaults to none) + + Return value: + admin_delete_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_delete_record() (none) + + Global references: + +------------------------------------------------------------------------ + array admin_confirm_delete_record_r( string $table, string $conn_str, int $id, + string $fields, string $url, string $action, + string $params, string $a_title, string $view ) + bool admin_confirm_delete_record( string $table, string $conn_str, int $id, + string $fields, string $url, string $action, + string $params, string $a_title, string $view ) +------------------------------------------------------------------------ + +This function receives a form submission from a delete request produced +by admin_delete_record(). It does a number of things in sequence. + +1) Check to make sure the field "Delete" contains exactly "Confirm" +2) Check fields for "reference"s that need to be protected. If there are any + check the "id" field in the specified table to see if any point + toward this record. If there are, don't delete the record. +3) Check to see if there are any "image" fields specified. If so it + deletes those images. +4) Delete the record + + Parameters: + $table Name of dabase table + $conn_str Connect String + $id Unique value of the "id" field of the record to update + $fields List of fields to check for certain things such as images to delete + and subordinate table entries (references) + $url URL to page for submitting this form + $action Value of "Action" parameter for program at $url + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of Page + $view Optional View to replace standard output - May contain + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + {result} - Result of submitssion, success or failure + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{title}|{name},{type},{title}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + reference - Reference to check (see below) + image - Image to delete + {title} = Title of field for error output if not supplied + + If {type} = reference, then has following format + reference.{table}.{field} + Where: {table} = Table to check for reference + {field} = Field in that table (to see if = id of current record) + + Return value: + admin_confirm_delete_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_confirm_delete_record() TRUE or FALSE (if not deleted) + + Global references: + $HTTP_POST_VARS + + +------------------------------------------------------------------------ + array admin_view_record_r( string $table, sting $conn_str, string $id, + string $fields, string $url, string $action, + string $params, string $a_title, string $view, string $options, string $quick_tip, string $id_field ) + void admin_view_record( string $table, sting $conn_str, string $id, + string $fields, string $url, string $action, + string $params, string $a_title, string $view, string $options, string $quick_tip, string $id_field ) +------------------------------------------------------------------------ + +The auto function retrieves the record specified by $id and displays +the result. + + Parameters: + $table Name of dabase table + $id Numeric value of "id" field for desired record + $conn_str Connect String + $fields List of fields to display (see below) + $url URL of next processing page + $action Action to be passed to next processing page (says what we're working on) + $params A "|" separated list of Additional parameters to be passed on links + {name}.{value}|{name}.{value}|... + $a_title Title of this table for use in headers + $view View to use for display of this record (see view discription) + {n} - Replace with value of parameter n + {encode:n} - Replace with urlencoded() value of paramter n + {link_params} - Additional parameters in Link format + {form_params} - Additional parameters in Form format (hidden fields) + $options Optional control options - comma separated + "borders" = Turn on borders in table + $quick_tip Optional Pop-up Quick tip message for page + $id_field Name of id field if not "id" + + $fields parameter is a string with mulitple field declarations. + + "{name},{type},{title}|{name},{type},{title}|..." + + Where: {name} = Name of the data field in the database + {type} = Type - how it should be displayed + int - Integer value + fixed.n - Fixed precision, "n" digits after "." + float - Floating value + money - Money formatted + text - Simple text field + password - Same as text except that output is displayed as *'s + rawtext - Same as text but doesn't parse hard breaks to
+ textbox - Same as text + url - Web link + date - Date field (currently same as text) + image.s - Image of size "s" + o = Original + r = Resized + m = Midsized + t = Thumb + file - File (displays file as a link to a popup window) + pointer - Pointer to data in anohter table (see below) + list.{list} - List of options for picklist/display (see below) + state - Special form of list + lat.n - Latitude (stored as deg, + = N) (n = precision) + lon.n - Longitude (stored as deg, + = E) (n = precision) + break.{text} - Break in list - Displays {text} in value field + Breaks must have unique dummy field name + order - Output order spec + {title} = Title for table header + + Type "pointer" has a sub-structure for the "{type}" field + {type}.{other_table}.{disp_field}.{value_field}.{where} + {disp_field} can specify multiple fields separated by "~" + + Any type can be followed with ".hidden" to prevent it from being included with default output + (does not affect values specified in $view) + + Where: {type} = "pointer" + {other_table} = Table used to get data + {disp_field} = Field in {other_table} to output to user for each + {value_field} = (bugus field, not used in this function since this function displays only) + {where} = WHERE field of query to use for selecting data from {other_table} + (optional - defaults to none) + + Description of $view: The $view parameter is an optional layout for + outputing the record. If the $view parameter isn't supplied, the + data is displayed in sequential format down the page, as is the default + for the admin_edit_record() function. If the $view parameter is supplied, + it is used as the HTML for displaying the page. Fields to be displayed + are designated by "{x}" where x is the database field name. + + Return value: + admin_view_record_r() returns array( 'text' => {text to display}, 'status' => {return status} ); + admin_view_record() (none) + + Global references: + None + + + +------------------------------------------------------------------------ + void admin_user_login( string $operation, string $conn_str, string $sess_code + string $table, string $id_field, string $pw_field, + string $user_id, string $password, string $where, string $cookie, + int $timeout ) +------------------------------------------------------------------------ + +This function does one of two things... + + 1) Compare User ID and password to see if it's OK for someone to log in + If User ID and password match, then session data is created for + this user and that includes a timestamp of the last activity + 2) Check to see if a session is currently valid + This breaks up the session code into 3 segments. One is the + MD5 stiring of the user E-Mail and last timestamp, and the next + is the timestamp from the last activity. If the last timestamp + and user user ID & password don't combine to match the MD5 string, then the + user session is invalid. If it does match, then the timestamp + is checked to see if it has been longer than the allowed + timeout period since the user's last activity. The last segment + is the unique numeric "id" of the user's record. + + Parameters: + $operation The desired operation to perform + $conn_str Standard database connection string + $sess_code Session code (blank for operation login, record id for create ) + $table Database table where user data is stored + $id_field Field in $table where user's ID is stored + $pw_field Field in $table where user's password is stored + $user_id User's ID (blank for operation verify) OPTIONAL + $password User's password (blank for operation verify) OPTIONAL + $where Optional additional query clause to be ANDed to ID/Password check + $cookie Optional name of cookie used to track login, if not set uses passed parameters instead + $sess_timeout Optional session timeout value in seconds, if not provided uses SI_SES_TIMEOUT + + SI_SES_TIMEOUT Global define that specifies timeout period in seconds + + Operations: + + login This operation attempts to log in a new user + + verify This operation verifies an active login + session. + + create This operation creates a new user session and links it + to a user record without doing an id/password check. The + user record id is passed in $sess_code field. + + Return value: + + login Returns false if login failure otherwise session data + verify Returns false if login failure otterwise session data + + + Session data is an array containing all the fields in the user data record + and the following special array indexes... + + session_code The MD5 string, timestamp and record number combined + session_link The session code in URL link format + session_form The session code in hidden form field format + + session_code is built as follows + {md5}-{timestamp}-{record id} + + WHERE: {md5} MD5 string derived from + user's ID + timestamp + id field + secret + + Global references: + SI_SES_TIMEOUT Global define that specifies timeout period in seconds + + + +************************************************************************ +* * +* FINANCIAL FUNCTIONS * +* * +************************************************************************ + +------------------------------------------------------------------------ + array function authorize_net_aim( + string $login, string $key, string $test, string $conf, string $merch_email, + float $amount, string $card_num, string $exp_date, string $card_code, + Following parameters may be optional + string $currency, + string $fname, string $lname, string $company, string $address, string $city, string $state, string $zip, string $country, + string $phone, string $fax, string $id, string $ip, string $tax_id, + string $email, + string $invoice, string $descr, string $header, string $footer, + string $ship_fname, string $ship_lname, string $ship_company, string $ship_address, string $ship_city, string $ship_state, + string $ship_zip, string $ship_country ) +------------------------------------------------------------------------ + +This function submits a transaction request to Authorize.Net and returns a transaction result. + +Submission parameters + + string $login Authorize.net Merchant Login + string $key Authorize.net Merchant Key + string $test Test Mode ( FALSE - Production mode, TRUE - Test Mode, LOCAL TEST - Local only-don't send to Authorize.net ) + string $conf Send confirmation to customer E-Mail (TRUE - FALSE) + string $merch_email Send confirmation to merchant E-Mail (TRUE - FALSE) + + (Need to write rest of this part) + + Authorize.net processing + + Test card # + + TEST CARD CARD TYPE + NUMBER + 370000000000002 American Express + 6011000000000012 Discover + 5424000000000015 MasterCard + 4007000000027 Visa + + +Return + + The result is an array containing result data or FALSE if it's unable to submit to + or get a response from Authorize.Net. + + [0] Response Code - 1 = Approved, 2 = Declined, 3 = Error, 4 = Held for review, + ( GLM Added Codes: 100 = System Exec call failed, 101 = No data returned from Exec Call, 102 = No data returned from Authorize.net, + 103 = MD5 Hash verification failure ) + [1] Response Sub-Code (?) + [2] Response Reason Code - See documentation + [3] Response Reason Text + [4] Approval Code - 6 character authorization code + [5] AVS Result Code - Address Verification result + [6] Transaction ID - Unique identifier for transaction with Authorize.Net - Used for updates to the transaction + These fields are echoed from supplied data if they were submitted + [7] Invoice Number + [8] Description + [9] Amount + [10] Method + [11] Transaction Type + [12] Customer ID + [13] First Name + [14] Last Name + [15] Company + [16] Billing Address + [17] City + [18] State + [19] Zip + [20] Country + [21] Phone + [22] Fax + [23] E-Mail + [24] Ship First Name + [25] Ship Last Name + [26] Ship Company + [27] Ship Address + [28] Ship City + [29] Ship State + [30] Ship Zip + [31] Ship Country + [32] Tax + [33] Duty + [34] Freight + [35] Tax Exempt Flag + [36] P.O. # + These fields are generated by Authorize.Net + [37] MD5 Hash to authenticate response from Authorize.Net + [38] Card Code (CVV) verification - M = Match, N - No Match, P = Not Processed, S = Should have been present, U = Issuer unable to process request + [39] Cardholder CAVV Authentication Verification + Blank Not validated + 0 Erroneous data submitted + 1 Failed validation + 2 Passed validation + 3-4 Validation could not be performed + 5-6 (reserved) + 7 Failed validation + 8 Passed validation + 9 Failed validation + A Passed validation + B Passed validation + [40]-[67] Reserved + [68] Echo of merchant defined fields + + diff --git a/documentation/static_page.phtml b/documentation/static_page.phtml new file mode 100644 index 0000000..dc494bd --- /dev/null +++ b/documentation/static_page.phtml @@ -0,0 +1,11 @@ + diff --git a/documentation/work_in_progress.txt b/documentation/work_in_progress.txt new file mode 100644 index 0000000..4f9cc9c --- /dev/null +++ b/documentation/work_in_progress.txt @@ -0,0 +1,18 @@ +Work in Progress +---------------- + +Updates to database + + alter table reg add column restrict_call_from_merchant boolean; + update reg set restrict_call_from_merchant = false; + + + + +---- OLD STUFF ---- + +Adding option for requiring registered user for an event + alter table reg add column require_registered_user boolean; + update reg set require_registered_user = false; + + Check on member option not enabling this checkbox in admin/index.phtml \ No newline at end of file diff --git a/front-end/Views/Files_Explanation.txt b/front-end/Views/Files_Explanation.txt new file mode 100644 index 0000000..2149b33 --- /dev/null +++ b/front-end/Views/Files_Explanation.txt @@ -0,0 +1,22 @@ +View Files Descriptions +----------------------- + +create_account.html Create a new account page - Used only with Registered Users on +forgot_password.html Forgot Password Page - Used only with Registered Users on +new_password.html Set a new Password Page - Used only with Registered Users on +notify_event_contacts.html E-Mail sent to contacts for a specific event when someone registers +password_reset.html Password Reset Page - Used only with Registered Users on +registration_price_guide.html NOT CURRENTLY IN USE +registrations_confirmation.html E-Mail sent to users when their registration is confirmed +registrations_step0.html Registrations Intro Page - If enabled +registrations_step1.html Main category selection page - Also has search fields and registered user log-in +registrations_step2.html List available events page +registrations_step3.html Event detail and registration page +registrations_step4.html Shopping Cart Page +registrations_step5.html Checkout Page +registrations_step6.html Checkout complete page and registration summary +registrations_store.html Summary of registration for storing into database +registrations_summary.html Summary of registration page +style.css Default styles for pages + May be overridden by /Toolkit/Registrations/front-end/Views/override.css in customer server directory + diff --git a/front-end/Views/create_account.html b/front-end/Views/create_account.html new file mode 100644 index 0000000..b83ec8b --- /dev/null +++ b/front-end/Views/create_account.html @@ -0,0 +1,112 @@ + + + + + + + +

+ + +
+

Your request was not submitted. Please check the following items.

+
    + +
  • {text}
  • + +
+
+ + + +
+ + +

If you are a {customer_long_name} member and know your member "Username" and "Password", please enter that here.

+

Fields in red are required.

+ + + +
Username:
Password:
  +
+

+ A registered member account is required to receive member rates. If you are a member and do not + know your Username and Password, please call {customer_long_name} to have them create those for you. +

+
+ + +

 

+ + +

We found your member information. Please complete the form below to setup your account.

+

If the information below if for another member, it means that you do not get your correct Username and Password. + Please contact {customer_long_name} for assistance in correcting this situation.

+
+ + + +
+ + + + +
Note:
+

+ We already have a registered user in our database with the E-Mail address you supplied. Please check the E-Mail address below. If this is your correct + E-Mail address, we can send you an E-Mail message containing with a link to a page where you may reset the password for this account. +

+ Please send me E-Mail to reset my password. + + +
+ + + + + + +

Fields in red are required.

+ + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
Phone:
FAX:
E-Mail Address:
Verify E-Mail Address:
{word_event_cap} {word_registeration_cap} Password: +
+ This password is only for use with {registrations_title}. + If you have a {customer_long_name} member area password, it will remain the same. +
 
Please send me updates regarding {customer_long_name}
 
  +
+
+ +

 

+
+ + +

Otherwise...

+ +
+ +
+
+
diff --git a/front-end/Views/forgot_password.html b/front-end/Views/forgot_password.html new file mode 100644 index 0000000..e960243 --- /dev/null +++ b/front-end/Views/forgot_password.html @@ -0,0 +1,107 @@ + + + + + + + +
+ +

Forgotten Password

+ + +
+ Please Note:
+
    + +
  • {text}
  • + +
+
+ + +
+ + + +
+
+
+
+ + + + + + + +
+

{customer_long_name} {word_Members}

+

+ Pleased enter your {customer_long_name} member {word_user_id}. + If you do not know your {word_user_id}, please call {customer_long_name} + at {customer_phone} for assistance. +

+

+ We will send an E-Mail message with information on how to reset + your password to the E-Mail address of record for your {customer_long_name} + {word_member} account. +

+
+ + + + + + + + +
{word_User_id}:
+
+
+
+ + + +
+
+
+
+ + + + + + + +
+

Non-{word_Members}

+

Please enter the E-Mail address you used when you {word_registered} here before.

+

+ We will send an E-Mail message with information on how to reset + your password to this E-Mail address. +

+
+ + + + + + + + +
E-Mail Address:
+
+
+
+ + Return to {word_Events} +
+
diff --git a/front-end/Views/new_password.html b/front-end/Views/new_password.html new file mode 100644 index 0000000..50fd59f --- /dev/null +++ b/front-end/Views/new_password.html @@ -0,0 +1,66 @@ + + + + + + + +
+ + +
+ Please Note:
+
    + +
  • {text}
  • + +
+
+ + +
+ +

New Password Entry

+ +
+
+
+
+ + + + + + + +
+

Please enter the Password Reset Code provided earlier and a new password for you to use.

+

You will need to enter the new password twice to verify the exact password you are requesting.

+
+ + + + + + + + + + + + + + + + +
Password Reset Code:
New Password:
New Password Again:
+
+
+
+ Return to {word_Events} +
+
diff --git a/front-end/Views/notify_event_contacts.html b/front-end/Views/notify_event_contacts.html new file mode 100644 index 0000000..6abe3c8 --- /dev/null +++ b/front-end/Views/notify_event_contacts.html @@ -0,0 +1,143 @@ + + + + + {notify_intro} +

 

+ + + + + + + + + + + + + + + + + + + + + + + + + +
{word_Registration} Submitted By:
+ + + + + + + + + + + +
Name:{fname} {lname}
Address{addr1}
 {addr2}
 {city}, {state} {zip} {country}
Phone:{phone}
E-Mail Address:{email}
+
{contact_information_title}:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{prompt_contact_fname}: {contact_fname}
{prompt_contact_lname}: {contact_lname}
{prompt_contact_addr1}: {contact_addr1}
{prompt_contact_addr2}: {contact_addr2}
 {contact_city}, {contact_state} {contact_zip} {contact_country}
Phone: {contact_phone}
FAX: {contact_fax}
+
{word_Registering} For:
+ + + + + + + + + + + + + + + + + + + + +
{word_Event} Name:{event_name}
Description:{short_descr}
Dates:{start_date} through {end_date}
Days:{days}
Duration:{duration}
Desired Date:{desired_date_int}
Location:{location}
{word_Registration} Selected:{rate_class}
Number of {word_Attendees}:{numb_attendees}
+
Additional Information:
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
{name}
Date of Birth:{dob}
Guardian:{guardian}
Emergency Contact:{emer_contact}
Emergency Phone:{emer_phone}
Medical History:{med_history}
Allergy Medications:{allergy_med}
+
 
 
{indent}{title}:  {value}
+
+ + \ No newline at end of file diff --git a/front-end/Views/notify_site_owner.html b/front-end/Views/notify_site_owner.html new file mode 100644 index 0000000..e24936b --- /dev/null +++ b/front-end/Views/notify_site_owner.html @@ -0,0 +1,250 @@ + + + + + + + + + + + +

A {word_Event} request has been submitted.

+

Request #: {reg_req_id}

+ + +

 

+ + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Submitted by:
+ + + + + + + +
Name: {fname} {lname}
Address: {addr1}
 {addr2}
 {city}, {state} {zip} {country}
Phone: {phone}
FAX: {fax}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Charges: {grandTotal}
Payment Type: {payment_type_text}
Payment Code: {pay_code}
Credit Card: {cctype_store} {ccnum_trunc}
exp: {ccmonth_store}/{ccyear_store}
Name on Card: {ccname}
Auth Code: {auth_code}
+
{contact_information_title}:
+ + + + + + + + + + + + + + + + + + + + + + +
{prompt_contact_fname}: {contact_fname}
{prompt_contact_lname}: {contact_lname}
{prompt_contact_addr1}: {contact_addr1}
{prompt_contact_addr2}: {contact_addr2}
 {contact_city}, {contact_state} {contact_zip} {contact_country}
Phone: {contact_phone}
FAX: {contact_fax}
+
E-Mail: {email}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if:ask_date}--> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {name}, {name} + + + {/if:med_info}--> + + + + + + + + + + + + + + + + + +
{word_Event}: {event_name}
Location: {location}
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Days: {days}
Selected: {rate_class}
 
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Total{totalCharges}
 
{word_Attendees}:
   {name}
+ + + + + + + + + + + + + + + + + + + +
 Date of Birth: {dob}
 Parent/Guardian: {guardian}
 Emergency Contact: {emer_contact}
 Emergency Phone: {emer_phone}
 Brief Medical History: {med_history}
 Alergies/Medications: {allergy_med}
+
 
Additional Data:
{indent}{title}:  {value}
+
+
+
+ + + + diff --git a/front-end/Views/password_reset.html b/front-end/Views/password_reset.html new file mode 100644 index 0000000..f897195 --- /dev/null +++ b/front-end/Views/password_reset.html @@ -0,0 +1,44 @@ + + + + + + + +
+ + +
+ Please Note:
+
    + +
  • {text}
  • + +
+
+ + +
+ +

Password Reset

+ +
+
+
+

An E-Mail message has been sent to the address on record for your user account.

+

+ The E-Mail message contains a link to a Web page where you will be able to enter a new password for your account. + You will also need to enter the Password Reset Code below. +

+

 

+

Password Reset Code: {reset_password}

+

 

+

+ Please write this code down. You will need it to reset your account password. +

+
+
+ Return to {word_Events} +
diff --git a/front-end/Views/registration_price_guide.html b/front-end/Views/registration_price_guide.html new file mode 100644 index 0000000..874e1a7 --- /dev/null +++ b/front-end/Views/registration_price_guide.html @@ -0,0 +1,123 @@ + + + +Price Guide + + + + + + + + + + +
+ + Date and Price Guide
+ {convention_name}
+ {start_date} through {end_date} +

+ [Close Window] +

+ +

Unable to display price guide

+ {reason} + +

+ If before {cutoff_date} + + + + + +

+ If on or after {cutoff_date} and before {cutoff_date2} +

+ + +

+ If on or after {cutoff_date2} and before {cutoff_date3} +

+ + +

+ If on or after {cutoff_date3} and before {cutoff_date4} +

+ + + + + + + + {/if:have_rates_1}--> +
 Base Rate{word_Attendees} IncludedPer additional {word_Attendee}
{rate_class}{base_rate} {attendee_credits} {attendee_rate} 
+
+ + + + + + + + {/if:have_rates_2}--> +
 Base Rate{word_Attendees} IncludedPer additional {word_Attendee}
{rate_class}{base_rate} {attendee_credits} {attendee_rate} 
+
+ + + + + + + + {/if:have_rates_3}--> +
 Base Rate{word_Attendees} IncludedPer additional {word_Attendee}
{rate_class}{base_rate} {attendee_credits} {attendee_rate} 
+
+ + + + + + + + {/if:have_rates_4}--> +
 Base Rate{word_Attendees} IncludedPer additional {word_Attendee}
{rate_class}{base_rate} {attendee_credits} {attendee_rate} 
+
+ + + + + + +

+ No submissions accepted after last date above. +

+ {/if:reason}--> + + + diff --git a/front-end/Views/registrations_confirmation.html b/front-end/Views/registrations_confirmation.html new file mode 100644 index 0000000..0becae2 --- /dev/null +++ b/front-end/Views/registrations_confirmation.html @@ -0,0 +1,247 @@ + + + + + + + + + + + + {ack_intro} +

 

+ + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Submitted by:
+ + + + + + + +
Name: {fname} {lname}
Address: {addr1}
 {addr2}
 {city}, {state} {zip} {country}
Phone: {phone}
FAX: {fax}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Charges: {grandTotal}
Payment Type: {payment_type_text}
Payment Code: {pay_code}
Credit Card: {cctype_store} {ccnum_trunc}
exp: {ccmonth_store}/{ccyear_store}
Name on Card: {ccname}
Auth Code: {auth_code}
+
{contact_information_title}:
+ + + + + + + + + + + + + + + + + + + + + + +
{prompt_contact_fname}: {contact_fname}
{prompt_contact_lname}: {contact_lname}
{prompt_contact_addr1}: {contact_addr1}
{prompt_contact_addr2}: {contact_addr2}
 {contact_city}, {contact_state} {contact_zip} {contact_country}
Phone: {contact_phone}
FAX: {contact_fax}
+
E-Mail: {email}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if:ask_date}--> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {name}, {name} + + + {/if:med_info}--> + + + + + + + + + + + + + + + + + +
{word_Event}: {event_name}
Location: {location}
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Days: {days}
Selected: {rate_class}
 
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Total{totalCharges}
 
{word_Attendees}:
   {name}
+ + + + + + + + + + + + + + + + + + + +
 Date of Birth: {dob}
 Parent/Guardian: {guardian}
 Emergency Contact: {emer_contact}
 Emergency Phone: {emer_phone}
 Brief Medical History: {med_history}
 Alergies/Medications: {allergy_med}
+
 
Additional Data:
{indent}{title}:  {value}
+
+
+
+ + + + diff --git a/front-end/Views/registrations_step0.html b/front-end/Views/registrations_step0.html new file mode 100644 index 0000000..15bbc1b --- /dev/null +++ b/front-end/Views/registrations_step0.html @@ -0,0 +1,127 @@ + + + + + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + + +
+ Please Note:
+
    + +
  • {text}
  • + +
+
+ + +
+ +
+
+
+
+ +
+

{word_Member} Login

+
+ + + + + + + + + + + + + +
{word_User_id}:
{word_Password}:
Forgot my {word_Password}
+
+
+
+

{customer_name} {word_Members}

+

+ Please log in using your member {word_user_id} and + {word_password}. This is required to receive member rates and features. +

+
+
+ +
+
+
+ +
+
+

Guest Login

+
+
+ + + + + + + + + + + + + + + + +
E-Mail Address:
Registrant Password:
Forgot my {word_Password}
+
+
+ +
+ +

Returning Guest

+

+ Returning Guests may log in using your E-mail address and + the {word_password} you selected earlier. +

+ +
+
+
+ + Select {word_Events} + +
+
+
+
\ No newline at end of file diff --git a/front-end/Views/registrations_step1.html b/front-end/Views/registrations_step1.html new file mode 100644 index 0000000..2125cdd --- /dev/null +++ b/front-end/Views/registrations_step1.html @@ -0,0 +1,447 @@ +
+ + + + + + + + + + + + + +
+ {word_Registration} being entered by Admin User +
+ + +
+ +

{regCatPageText}

+ +
+ + +
+

Your request was not submitted. Please check the following items.

+
    + +
  • {text}
  • + +
+
+ + + + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + + + {customer_long_name} Member logged in
- Log Out + + + {/if:have_registered_users}--> + + + + +
+ + +

+ If you know your {word_Event} code: + + +

+
+ + + +
+ +
+ + + + +
+
+ +

Select {word_category} of {word_Event} or search by month.

+

+ Select Month: + + +

+
+
+ + + + +
+
+ +

Select from the following

+

+ + {word_Category}: + + + +
+ {word_SubCategory}: + + +

+ +
+
+ + + + + + +
+ + + View Cart + Check Out + + +
+
+ + + + +
+ +

{name}

+ Select {word_Category} + + Select {word_Category} + + {/if:doing_sub_categories}--> +
+ + + + {descr}
+ + + +
+ + {title_select_event_button} + +

{reg_name}

+ +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {reg_start_date} through {reg_end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + + No Charge + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + {/if:free}--> +
+
+ +
+ +
+ + {title_select_event_button} + +

{reg_name}

+ +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {reg_start_date} through {reg_end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + No Charge + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + {/if:free}--> + +
+
+ + + +
+
+ + + +
+ + + +

{name}

+ {descr}
+ + +
+

{reg_name}

+ +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {reg_start_date} through {reg_end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + + + No Charge + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + {/if:free}--> + +
+
+ +
+ +
+

{reg_name}

+ +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {reg_start_date} through {reg_end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + + No Charge + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + {/if:free}--> + +
+
+ + + +
+
+ + + {/if:selection}--> + + + + + + + +

 

+

Terms and Conditions

+{regTerms} + +
+ + diff --git a/front-end/Views/registrations_step2.html b/front-end/Views/registrations_step2.html new file mode 100644 index 0000000..b967910 --- /dev/null +++ b/front-end/Views/registrations_step2.html @@ -0,0 +1,280 @@ + + + + + + + + + + +

{search_request}

+ + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regSelectPageText}

+
+ + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + + + + + + + + + Select More + + + + View Cart + Check Out + + + + +

Showing {word_events} for {month}

+ + + + +

{special_bulletin}

+ + +
+ + + + + + +

{name}

+

Too late for on-line {word_registration}. - Please call.

+ + +

{name}

+

Sorry, currently sold out.

+ + {title_select_event_button} + +

{name}

+ {/if:full}--> + + {title_select_event_button} + +

{name}

+ {/if:limited}--> + {/if:too_late}--> + + + +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {start_date} through {end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + +
{word_Attendees}:  {attendee_max} {word_attendees}. Currently sold out.
File:   + + + {reg_file_title} + + +
+ +
+ + + +

{name}

+

Too late for on-line {word_registration}. - Please call.

+ + +

{name}

+

Sorry, currently sold out.

+ + {title_select_event_button} + +

{name}

+ {/if:full}--> + + {title_select_event_button} + +

{name}

+ {/if:limited}--> + {/if:too_late}--> + + + +

{reg_short_descr}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {start_date} through {end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
Cost:   + + + + {reg_rate} {reg_base} + + plus {reg_per_attendee}, {reg_included} included, + by {reg_submit_by} + +
+ + + + + Starting at: {from_rate} + + +
{word_Attendees}:  {attendee_max} {word_attendees}. Currently sold out.
File:   + + + {reg_file_title} + + +
+ +
+ + +

{regTerms}

+
+
+ + diff --git a/front-end/Views/registrations_step3.html b/front-end/Views/registrations_step3.html new file mode 100644 index 0000000..1e1293c --- /dev/null +++ b/front-end/Views/registrations_step3.html @@ -0,0 +1,270 @@ + + + + + + + + + + + + + +

{page_title}

+ + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regEventPageText}

+
+ + + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + + Select More + + + View Cart + Check Out + + + +

Please call to {title_select_event_button}

+ + +
+
+ + + + + +
+ Your request was not processed because:
+
    + +
  • {text}
  • + +
+
+ +
+ + {form_data} +

{reg_name}

+ +

{reg_descr}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{word_Event} Code:  {reg_code}
{word_Attribute}:   + + {attr_name}, {attr_name} + +
When:  From {start_date} through {end_date}
Days:  {reg_days}
Times:  {reg_times}
Duration:  {reg_duration}
{word_Instructor}:  {reg_instructor}
Location:  {reg_location}
{word_Attendees}:  {attendee_max} {word_attendees}. Currently sold out.
File:   + + + {reg_file_title} + + +
 
Additional terms and conditions for this {word_Event}:
{reg_terms}
 
+
+ +


+ + +

Too late for on-line {word_registration}. - Please call.

+ + + Please select the desired rate: + + +

{rates_descr}

+ + +
+ + + + {rate_class_name}    {rate_class_base} + +     includes {attendee_credits} {word_attendees}, {rate_class_rate}/additional {word_attendee} + +
+ + + + + + ({rateNote}) + + + + + + +

+ Please enter your desired date: +

+ + + + + + +

{word_Attendees}

+

+ Please enter all {word_attendee} names, using one box per {word_attendee}. Additional boxes will be created as needed. + All {word_attendees} will be {word_registered} at the level selected above. Each {word_attendee} must have a first and last name. + Please use your tab key to create a new {word_attendee} field. +

+

{word_Attendee} Names:

+ + Enter a maximum of {max_per_sub} {word_attendees}. + +

{attendees}

+ + + +

Please provide the following additional information... + +
Fields in red are required. + +

+ +
+ {magic_form} +
+ + +
+ +
+ Please wait while we add this to your cart. +
+
+ + {/if:too_late}--> + + + +
+
+
diff --git a/front-end/Views/registrations_step4.html b/front-end/Views/registrations_step4.html new file mode 100644 index 0000000..508a1d4 --- /dev/null +++ b/front-end/Views/registrations_step4.html @@ -0,0 +1,147 @@ + + + + + + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regCartPageText}

+
+ + + + {customer_long_name} Member logged in - Log Out + + + + Select More + + Check Out + + + +

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+
+ + + +

Your selected {word_events}

+ + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

{event_name}

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Days: {days}
Selected: {rate_class}
+
+ Remove +
+
 
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
 Sub-Total + {totalCharges}
 
Grand Total:{grandTotal}
+
+
+
+ + + + Select More + + Check Out + + + +
+
diff --git a/front-end/Views/registrations_step5.SAVE2 b/front-end/Views/registrations_step5.SAVE2 new file mode 100644 index 0000000..0339105 --- /dev/null +++ b/front-end/Views/registrations_step5.SAVE2 @@ -0,0 +1,905 @@ + + + + + + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regCheckoutPageText}

+
+ + + + {customer_long_name} Member logged in - Log Out + + + + +
+

Your request was not submitted. Please check the following items.

+
    + +
  • {text}
  • + +
+
+ + + Select More + + + View Cart + + + +
+ + + {form_data} + + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + +
+
+

{word_Event} Summary

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

{start_date} through {end_date}

+ +

Desired Date: {desired_date}

+ + {/if:date_specific}--> +

{event_name}

+
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Sub Total{totalCharges}
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if:med_info}--> +
 {word_Attendee}Required emergency contact and medical information.
 {name}
 Date of Birth: Parent/Guardian:
 Emergency Contact: Emergency Phone:
 Brief Medical History:
 Alergies/Medications:
 {word_Attendees}: + + {name}, + {name} + +
+
 
Additional terms/conditions: {terms}
 
Grand Total:{grandTotal}
+
+
+
+

Fields in red are required.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Contact Information:

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+

{contact_information_title}:

+

+

Same as above:

Same as billing information +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {prompt_contact_fname}: +
+ {prompt_contact_lname}: +
+ {prompt_contact_addr1}: +
+ {prompt_contact_addr2}: +
+ {prompt_contact_city}: +
+ {prompt_contact_state}: + {contact_state}
+ {prompt_contact_zip}: +
+ {prompt_contact_country}: + {contact_country}
+ {prompt_contact_phone}: +
+ {prompt_contact_fax}:
+
+ +

Returning User Login Information:

+ +

+ + + + + + + + +
E-Mail Address:
{word_Password}:
Retain this {word_password} for future {word_registrations}. {password_msg}
+

+
+ +


+ + + + + +

Select payment method:

+ + + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_use_payment_comp_code} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

{title_payment_comp_code}:

+
+
+ {/if:pay_by_comp_code}--> + + + +
+ For Admin Users Only: + +

+ + + + + + + + {title_send_a_check} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_check}--> + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_call_from_merchant} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ + {/if:pay_by_call_from_merchant}--> + + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_paid_cash} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_cash}--> + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_pay_by_credit_card} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

The fees totaled above will be charged to your credit card once this form is submitted

+ + + + + + + +
Card Type:{cctype}
Name on Card:
Card #:
Expiration Date:Month {ccmonth} Year {ccyear}
CVV #:
CVV is the three digit number on the
signature side of your credit card.
+
+
+ {/if:pay_by_credit_card}--> + + +

+ Please send me future information by email: +

+
+ +
+ Please wait while we process your {word_registration} +
+
+ + + +

 

+

Terms and Conditions

+{regTerms} + +
+
+ + + +
diff --git a/front-end/Views/registrations_step5.html b/front-end/Views/registrations_step5.html new file mode 100644 index 0000000..b7faa70 --- /dev/null +++ b/front-end/Views/registrations_step5.html @@ -0,0 +1,904 @@ + + + + + + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regCheckoutPageText}

+
+ + + + {customer_long_name} Member logged in - Log Out + + + + +
+

Your request was not submitted. Please check the following items.

+
    + +
  • {text}
  • + +
+
+ + + Select More + + + View Cart + + + +
+ + + {form_data} + + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + +
+
+

{word_Event} Summary

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

{start_date} through {end_date}

+ +

Desired Date: {desired_date}

+ + {/if:date_specific}--> +

{event_name}

+
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Sub Total{totalCharges}
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if:med_info}--> +
 {word_Attendee}Required emergency contact and medical information.
 {name}
 Date of Birth: Parent/Guardian:
 Emergency Contact: Emergency Phone:
 Brief Medical History:
 Alergies/Medications:
 {word_Attendees}: + + {name}, + {name} + +
+
 
Additional terms/conditions: {terms}
 
Grand Total:{grandTotal}
+
+
+
+

Fields in red are required.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Contact Information:

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+

{contact_information_title}:

+

+

Same as above:

Same as billing information +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {prompt_contact_fname}: +
+ {prompt_contact_lname}: +
+ {prompt_contact_addr1}: +
+ {prompt_contact_addr2}: +
+ {prompt_contact_city}: +
+ {prompt_contact_state}: + {contact_state}
+ {prompt_contact_zip}: +
+ {prompt_contact_country}: + {contact_country}
+ {prompt_contact_phone}: +
+ {prompt_contact_fax}:
+
+ +

Returning User Login Information:

+ +

+ + + + + + + + +
E-Mail Address:
{word_Password}:
Retain this {word_password} for future {word_registrations}. {password_msg}
+

+
+ +


+ + + + +

Select payment method:

+ + + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_use_payment_comp_code} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

{title_payment_comp_code}:

+
+
+ {/if:pay_by_comp_code}--> + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + + {title_send_a_check} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_check}--> + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_call_from_merchant} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ + {/if:pay_by_call_from_merchant}--> + + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_paid_cash} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_cash}--> + + + +
+ For Admin Users Only: + +

+ + + + + + {/if:one_payment_type_available}--> + {title_pay_by_credit_card} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

The fees totaled above will be charged to your credit card once this form is submitted

+ + + + + + + +
Card Type:{cctype}
Name on Card:
Card #:
Expiration Date:Month {ccmonth} Year {ccyear}
CVV #:
CVV is the three digit number on the
signature side of your credit card.
+
+
+ {/if:pay_by_credit_card}--> + + +

+ Please send me future information by email: +

+
+ +
+ Please wait while we process your {word_registration} +
+
+ + + +

 

+

Terms and Conditions

+{regTerms} + +
+
+ + + +
diff --git a/front-end/Views/registrations_step5.html.SAVE b/front-end/Views/registrations_step5.html.SAVE new file mode 100644 index 0000000..c461431 --- /dev/null +++ b/front-end/Views/registrations_step5.html.SAVE @@ -0,0 +1,799 @@ + + + + + + + + + +
+ + +
+ {word_Registration} being entered by Admin User +
+ + +
+

{regCheckoutPageText}

+
+ + + + {customer_long_name} Member logged in - Log Out + + + + +
+

Your request was not submitted. Please check the following items.

+
    + +
  • {text}
  • + +
+
+ + + Select More + + + View Cart + + + +
+ + + {form_data} + + +
+

+ Current Registered User:  {userFname} {userLname}    (not me or log me out) +
(A {customer_long_name} member) +

+ + +
+
+

{word_Event} Summary

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

{start_date} through {end_date}

+ +

Desired Date: {desired_date}

+ + {/if:date_specific}--> +

{event_name}

+
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Sub Total{totalCharges}
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if:med_info}--> +
 {word_Attendee}Required emergency contact and medical information.
 {name}
 Date of Birth: Parent/Guardian:
 Emergency Contact: Emergency Phone:
 Brief Medical History:
 Alergies/Medications:
 {word_Attendees}: + + {name}, + {name} + +
+
 
Additional terms/conditions: {terms}
 
Grand Total:{grandTotal}
+
+
+
+

Fields in red are required.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Contact Information:

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+

{contact_information_title}:

+

+

Same as above:

Same as billing information +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {prompt_contact_fname}: +
+ {prompt_contact_lname}: +
+ {prompt_contact_addr1}: +
+ {prompt_contact_addr2}: +
+ {prompt_contact_city}: +
+ {prompt_contact_state}: + {contact_state}
+ {prompt_contact_zip}: +
+ {prompt_contact_country}: + {contact_country}
+ {prompt_contact_phone}: +
+ {prompt_contact_fax}:
+
+ +

Returning User Login Information:

+ +

+ + + + + + + + +
E-Mail Address:
{word_Password}:
Retain this {word_password} for future {word_registrations}. {password_msg}
+

+
+ +


+ + + +

Select payment method:

+ + + +
+ For Admin Users Only: + +

+ + + + {title_use_payment_comp_code} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

{title_payment_comp_code}:

+
+
+ {/if:pay_by_comp_code}--> + + + +
+ For Admin Users Only: + +

+ + + + {title_send_a_check} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_check}--> + + + +
+ For Admin Users Only: + +

+ + + + {title_paid_cash} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +
+
+ {/if:pay_by_cash}--> + + + +
+ For Admin Users Only: + +

+ + + + {title_pay_by_credit_card} +

+
+ +

Please provide the following information:

+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
First Name:
Last Name:
Address:
 
City:
State/Prov.:{state}
Country:{country}
ZIP/Postal Code:
+
+ + + + + + + +
Phone:
FAX:
+
+ +

The fees totaled above will be charged to your credit card once this form is submitted

+ + + + + + + +
Card Type:{cctype}
Name on Card:
Card #:
Expiration Date:Month {ccmonth} Year {ccyear}
CVV #:
CVV is the three digit number on the
signature side of your credit card.
+
+
+ {/if:pay_by_credit_card}--> + + +

+ Please send me future information by email: +

+
+ +
+ Please wait while we process your {word_registration} +
+
+ + + +

 

+

Terms and Conditions

+{regTerms} + +
+
+ + + +
diff --git a/front-end/Views/registrations_step6.html b/front-end/Views/registrations_step6.html new file mode 100644 index 0000000..9457f19 --- /dev/null +++ b/front-end/Views/registrations_step6.html @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + Return to {word_Events} +
+ + + + +
{word_Registration}: {checkout_type}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

{word_Registering} for: {reg_name}

{word_Registration} Tracking #:  {request_numb}
+ Thank you for your {word_registering}.
+ Please print this page. +
Entered by Admin User
+ + This is a REQUEST only.
+ You will be contacted shortly to confirm that your payment has been processed.
+ Please contact us if you do not receive a confirmation within 48 hours. +
+
 

+ + + + + + + +
Contact Information:  + {fname} {lname} +
{addr1} +
{addr2} +
{city}, {state} {zip} {country} +
+
+ + + + + + + + + + + + + + + + + + +
Phone: {phone}
FAX: {fax}
E-Mail: {email}
 
Comp Code accepted - No payment required.
You will be paying when you arrive at {word_event}.
Credit Card: {cctype_store} {ccnum} exp: {ccmonth_store}/{ccyear_store}
Name on Card: {ccname}
Authorization Code: {auth_code}
+
 

+ + + + + + + + + +
{word_Registration} Level: {rate_name}
Number of {word_Attendees}: {numb_attendees} at {rate} each
{attendees}
+

 

+ + + + + + + + + +
ChargesPer {word_Attendee}Total
{charge_title}  {charge}  {extend}
{charge_title}  {charge}  {extend}
Total {total_charges}
+

 
+ + + + +
{word_Registration} Terms and Conditions

+ +

{regTerms} + +

+
 

{customer_long_name}
{customer_address}
{customer_city}, {customer_state} {customer_zip}
{customer_phone}
+
+ + + diff --git a/front-end/Views/registrations_store.html b/front-end/Views/registrations_store.html new file mode 100644 index 0000000..8b1f879 --- /dev/null +++ b/front-end/Views/registrations_store.html @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
Entered by Admin User
Submitted by:
+ + + + + + + + +
Name: {fname} {lname}
Address: {addr1}
 {addr2}
 {city}, {state} {zip} {country}
Phone: {phone}
FAX: {fax}
E-Mail: {email}
+
+ + + + + + + + + + + + + +
Total Charges: {grandTotal}
Payment Type: {payment_type_text}
Payment Code: {pay_code}
Credit Card: {cctype_store} {ccnum_trunc}
exp: {ccmonth_store}/{ccyear_store}
Name on Card: {ccname}
Auth Code: {auth_code}
+
{contact_information_title}:
+ + + + + + + + + + + + + + + + + + + + + + +
{prompt_contact_fname}: {contact_fname}
{prompt_contact_lname}: {contact_lname}
{prompt_contact_addr1}: {contact_addr1}
{prompt_contact_addr2}: {contact_addr2}
 {contact_city}, {contact_state} {contact_zip} {contact_country}
Phone: {contact_phone}
FAX: {contact_fax}
+
 
E-Mail: {email}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {name}, + {name} + + + {/if:med_info}--> + + + + + + + + + + +
{word_Event}: {event_name}
Location: {location}
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Selected: {rate_class}
 
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Total{totalCharges}
 
{word_Attendees}:  
   {name}
+ + + + + + + + + + + + + + + + + + + +
 Date of Birth: {dob}
 Parent/Guardian: {guardian}
 Emergency Contact: {emer_contact}
 Emergency Phone: {emer_phone}
 Brief Medical History: {med_history}
 Alergies/Medications: {allergy_med}
+
 
Additional Data:
{indent}{title}:  {txt_val}
+
diff --git a/front-end/Views/registrations_summary.html b/front-end/Views/registrations_summary.html new file mode 100644 index 0000000..e04bc25 --- /dev/null +++ b/front-end/Views/registrations_summary.html @@ -0,0 +1,224 @@ + + + + + + + +
+ + +
+

{regSummaryPageText}

+
+ +

Thank you for your request. Please print this page.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Submitted by:
+ + + + + + + +
Name: {fname} {lname}
Address: {addr1}
 {addr2}
 {city}, {state} {zip} {country}
Phone: {phone}
FAX: {fax}
+
+ + + + + + + + + + + + + +
Total Charges: {grandTotal}
Payment Type: {payment_type_text}
Payment Code: {pay_code}
Credit Card: {cctype_store} {ccnum_trunc}
exp: {ccmonth_store}/{ccyear_store}
Name on Card: {ccname}
Auth Code: {auth_code}
+
{contact_information_title}:
+ + + + + + + + + + + + + + + + + + + + + + +
{prompt_contact_fname}: {contact_fname}
{prompt_contact_lname}: {contact_lname}
{prompt_contact_addr1}: {contact_addr1}
{prompt_contact_addr2}: {contact_addr2}
 {contact_city}, {contact_state} {contact_zip} {contact_country}
Phone: {contact_phone}
FAX: {contact_fax}
+
Additional Information:
+ + +
E-Mail: {email}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {name}, + {name} + + + + {/if:med_info}--> + + + + + + + + + + + + + + + + +
{word_Event}: {event_name}
Location: {location}
Dates: {start_date} through {end_date}
Desired Date: {desired_date}
Selected: {rate_class}
 
ChargesPer {word_Attendee}Total
{charge_title}{charge}{extend}
{charge_title}{charge}{extend}
Total{totalCharges}
 
{word_Attendees}:
   {name}
+ + + + + + + + + + + + + + + + + + + +
 Date of Birth: {dob}
 Parent/Guardian: {guardian}
 Emergency Contact: {emer_contact}
 Emergency Phone: {emer_phone}
 Brief Medical History: {med_history}
 Alergies/Medications: {allergy_med}
+
 
Additional Data:
{indent}{title}:  {txt_val}
+
+ + +
diff --git a/front-end/Views/style.css b/front-end/Views/style.css new file mode 100644 index 0000000..efa4e60 --- /dev/null +++ b/front-end/Views/style.css @@ -0,0 +1,188 @@ +/* All buttons */ +a.button { + display: inline-block; + border: 1px solid rgba(128, 128, 128, .2); + border-radius: 5px; + color: white; + text-decoration: none; + font-weight: bold; + } +.button span { + padding: 3px 3px 3px 8px; + margin-left: 27px; + display: inline-block; + background: rgba(128, 128, 128, .0); + border-left: 1px solid rgba(255, 255, 255, .4); + } +/* Shopping Cart */ +.showcart { + background: #808080 url(../../assets/basket.png) no-repeat 5px 2px; + background: rgba(128, 128, 128, .5) url(../../assets/basket.png) no-repeat 5px 2px; + width: 120px; + margin: 10px 10px 10px 0px; +} +a.showcart:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.showcart:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } +/* Book Now Button */ +.booknow { + background: #808080 url(../../assets/add.png) no-repeat 5px 2px; + background: rgba(128, 128, 128, .5) url(../../assets/add.png) no-repeat 5px 5px; + width: 150px; + margin: 10px 10px 10px 0px; + float:right; +} +a.booknow:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.booknow:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } +/* Select More Button */ +.selectmore { + background: #808080 url(../../assets/arrow_left.png) no-repeat 5px 5px; + background: rgba(128, 128, 128, .5) url(../../assets/arrow_left.png) no-repeat 5px 5px; + width: 120px; + margin: 10px 10px 10px 0px; +} +a.selectmore:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.selectmore:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } +/* Remove Button */ +.remove { + background: #808080 url(../../assets/cancel.png) no-repeat 5px 5px; + background: rgba(128, 128, 128, .5) url(../../assets/cancel.png) no-repeat 5px 5px; + width: 120px; + margin: 5px 0px 0px 0px; +} +a.remove:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.remove:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } +/* Checkout Button */ +.checkout { + background: #808080 url(../../assets/tick.png) no-repeat 5px 3px; + background: rgba(128, 128, 128, .5) url(../../assets/tick.png) no-repeat 5px 3px; + width: 120px; + margin: 10px 10px 10px 0px; + } +a.checkout:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.checkout:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } +/* Misc Wide Button */ +.wide { + background: rgba(128, 128, 128, .5); + /*width: 220px;*/ + margin: 10px 10px 10px 0px; + } +a.wide:hover { + border: 1px solid rgba(128, 128, 128, 1); + background-color: rgba(128, 128, 128, 1); + } +a.wide:hover span { + border-left: 1px solid rgba(128, 128, 128, 0); + background: rgba(128, 128, 128, 0); + } + + /* Images */ +.regImage { + float: right; + margin: 0 0 20px 20px; + } + + +.thCartRight { + text-align: right; +} + +.thCartLeft { + text-align: left; +} + +.tdCartRight { + text-align: right; +} + +.tdCartLeft { + text-align: left; +} + +.regWarning { + color: red; +} +.regRequired { + color: red; + padding-right: 5px; +} +.regFieldName { + padding-right: 5px; +} +.regItem { + clear: both; + margin-bottom: 10px; +} +.regImage { + float: right; + margin-bottom: 5px; + margin-left: 10px; +} +.regListItem { + margin-left: 10px; + margin-bottom: 5px; +} +.required { + color: red; +} +.inputStandard { +} +.inputMedium { + width: 240px; +} +.inputLarge { + width: 420px; +} +.adminUser { + font-size: 14px; + color: red; + padding: 10px; + border-style: solid; + border-width: 1px; + border-color: black; +} +#pleaseWait { + visibility: hidden; + display: none; + font-weight: bold; + background-color: rgba(128, 128, 128, .5); + color: white; + padding: 8px; + border: 1px solid black; +} +.lightBorder { + font-size: 14px; + padding: 10px; + border-style: solid; + border-width: 1px; + border-color: black; +} \ No newline at end of file diff --git a/front-end/calendar.phtml b/front-end/calendar.phtml new file mode 100644 index 0000000..af131bc --- /dev/null +++ b/front-end/calendar.phtml @@ -0,0 +1,297 @@ +'January','February','March','April','May','June','July','August','September','October','November','December'); + +$error = ""; + +$start_date = filter_request('start_date', FILTER_SANITIZE_STRING); +$end_date = filter_request('end_date', FILTER_SANITIZE_STRING); +$form_name = filter_request('form_name', FILTER_SANITIZE_STRING); +$field_name = filter_request('field_name', FILTER_SANITIZE_STRING); +$cur_month = filter_request('cur_month', FILTER_SANITIZE_STRING); +$cur_year = filter_request('cur_year', FILTER_SANITIZE_STRING); +$selected_date = filter_request('selected_date', FILTER_SANITIZE_STRING); +$start_date = filter_request('start_date', FILTER_SANITIZE_STRING); +$end_date = filter_request('end_date', FILTER_SANITIZE_STRING); +$form_name = filter_request('form_name', FILTER_SANITIZE_STRING); + +if( empty($start_date) ) + $error .= "Missing Start Date
"; +if( empty($end_date) ) + $error .= "Missing End Date
"; +if( empty($form_name) ) + $error .= "Missing Form Name
"; +if( empty($field_name) ) + $error .= "Missing Field Name
"; + +if( !empty( $error ) ) + { + echo "ERROR:
".$error; + exit; + } + +if( trim($selected_date) == '' ) + $selected_date = $start_date; + else + $selected_date = strtotime( $selected_date ); + +if( $selected_date < $start_date ) + $selected_date = $start_date; +if( $selected_date > $end_date ) + $selected_date = $end_date; + + // If there is a no_ealier date - check it against supplied selected date + +if( !empty($no_earlier) ) + { + $no_earlier_timestamp = strtotime( $no_earlier ); + if( $no_earlier_timestamp > $selected_date ) + $selected_date = $no_earlier_timestamp; + } + +$selected = getdate( $selected_date ); +$start = getdate( $start_date ); +$end = getdate( $end_date ); + + // If this is the first time we're called, then the currently selected month is + // the same as that of the selected date. + +if( empty($cur_month) ) + $cur_month = $selected["mon"]; +if( empty($cur_year) ) + $cur_year = $selected["year"]; + +// $YearToShow = $selected["year"]; +// $MonthToShow = $selected["mon"]; +// $DayToShow = $selected["mday"]; + + + // Display calendar header and days + +echo ' + + Calendar + + + + +
+ + + + + + + + + + + + + + + + '; + + // Display blanks up to first day of the month + +$offset = date( "w", mktime( 0, 0, 0, $cur_month, 1, $cur_year ) ); +if( $offset > 0 ) + echo str_repeat( "\n",$offset ); + + // For each day of the month + +$NumberOfDays = date( "t", mktime( 0, 0, 0, $cur_month, 1, $cur_year ) ); +for( $i=1 ; $i<=$NumberOfDays ; $i++ ) + { + $this_date = mktime( 0, 0, 0, $cur_month, $i, $cur_year ); + $DayOfWeek = date( "w", $this_date ); + + // Start a new row each Sunday, unless it's the 1st of the month + + if( $DayOfWeek == 0 && $i != 1 ) + { + print "\n"; + } + + // If we're not at the default selected date, display date normally + + if( $i != $selected["mday"] || $cur_month != $selected["mon"] || $cur_year != $selected["year"] ) + $this_date_style = "t"; + else + $this_date_style = "d"; + + // If the date we're displaying is within the start/end range + + if( ($this_date > $start_date-86400) && ($this_date < $end_date) ) + echo "\n"; + else + print "\n"; + + } + + +if( ( ($offset == 5) && ($NumberOfDays > 30) ) || ( ($offset == 6) && ($NumberOfDays > 29) ) ) + { + if( 42-$NumberOfDays-$offset > 0 ) + { + echo str_repeat( "\n",42-$NumberOfDays-$offset ); + } + print "\n"; + } + elseif( ($NumberOfDays != 28) || ($offset > 0) ) + { + if (35-$NumberOfDays-$offset > 0) + { + echo str_repeat("\n",35-$NumberOfDays-$offset); + print "\n"; + } + } + +echo '
+ + '; +echo prevnext($cur_month,$cur_year,$selected_date,$form_name,$field_name,$start_date,$end_date,$start,$end); +echo '
SunMonTueWedThuFriSat
 
$i$i 
 
+
+ + + '; + +function prevnext($cur_month,$cur_year,$selected_date,$form_name,$field_name,$start_date,$end_date,$start,$end) + { + // If there's prior month(s) + + if( mktime( 0, 0, 0, $cur_month, 1, $cur_year ) > mktime( 0, 0, 0, $start["mon"], 1, $start["year"] ) ) + { + $prev_month = $cur_month -1; + $prev_year = $cur_year; + if( $prev_month == 0 ) + { + $prev_month = 12; + $prev_year--; + } + + $newURL = THIS_SCRIPT."?route_app=calendar_popup&cur_month=$prev_month&cur_year=$prev_year&selected_date=$selected_date&start_date=$start_date&end_date=$end_date&form_name=$form_name&field_name=$field_name"; + + $back = "<< Back"; + } + else + $back = "<< Back"; + + + // If there's a next month + + if( mktime( 0, 0, 0, $cur_month, 1, $cur_year ) < mktime( 0, 0, 0, $end["mon"], 1, $end["year"] ) ) + { + $next_month = $cur_month +1; + $next_year = $cur_year; + if( $next_month == 13 ) + { + $next_month = 1; + $next_year++; + } + $newURL = THIS_SCRIPT."?route_app=calendar_popup&cur_month=$next_month&cur_year=$next_year&selected_date=$selected_date&start_date=$start_date&end_date=$end_date&form_name=$form_name&field_name=$field_name"; + $next = "Next >>"; + } + else + $next = "Next >>"; + + $output = ' + + + + +
'.$back.''.$next.'
'; + // $output .= "\n"; + return $output; + } + +?> diff --git a/front-end/category_select_popup.phtml b/front-end/category_select_popup.phtml new file mode 100644 index 0000000..df527b0 --- /dev/null +++ b/front-end/category_select_popup.phtml @@ -0,0 +1,414 @@ + + + + + + Gaslight Media - Category Selection + + + + + '; + + + + // If no ID was supplied assume id=0 (mythical root), otherwise get data + +if( empty($id) ) + { + $id = 0; + $def_cat_data = false; + } + else + $def_cat_data = cat_get_node( $table, $qs = "id = $id" ); + + // If no reference ID was supplied assume 0 (mythical root), otherwise get data + +if( empty($ref_id) ) + { + $ref_id = 0; + $def_ref_data = false; + } + else + $def_ref_data = cat_get_node( $table, $qs = "id = $ref_id" ); + + + // Build link data to pass on + + +$link_data = "table=$table&field_name=$field_name&options=$options&selected=&title=".urlencode($title)."&edit_width=$edit_width&edit_height=$edit_height&pop_width=$pop_width&pop_height=$pop_height&ref_id=$ref_id"; +$func_data = "table.$table|field_name.$field_name|options.$options|selected.|title.".urlencode($title)."|edit_width.$edit_width|edit_height.$edit_height|pop_width.$pop_width|pop_height.$pop_height|ref_id.$ref_id"; +$form_data = ' + + + + + + + + + + '; + + // Determine Options Selected + +$opt_limited = $opt_add = $opt_edit = $opt_delete = $opt_fullpath = $opt_selfullpath = $opt_noselfref = $FALSE; + +if( trim($options) != '' ) + { + $opts = explode( "~", $options ); + if( is_array($opts) ) + { + foreach( $opts as $opt ) + { + switch( $opt ) + { + + case "limited": $opt_limited = TRUE; break; // Display minimally expanded category list with "+" expansion links + case "add": $opt_add = TRUE; break; // Enable ability for user to add additional categories + case "edit": $opt_edit = TRUE; break; // Enable ability for user to edit categories + case "delete": $opt_delete = TRUE; break; // Enable ability for user to delete categories + case "fullpath": $opt_fullpath = TRUE; break; // Return full category path and name into displayed field + case "selfullpath": $opt_selfullpath = TRUE; break; // Display category path and name rather than indented for selection + case "noselfref": $opt_noselfref = TRUE; break; // Don't permit selection of self or below + + default: + echo "ERROR: Option \"$opt\" is not known!"; + exit; + break; + } + } + } + } + + +switch( $Action ) + { + + case "Edit": + echo " + "; + break; + + default: + echo " + "; + break; + }; + +switch( $Action ) + { + + case "Edit": + + echo '[Return to category selection]

'; + + if( $Option == "Add" ) + $parent = $id; + + if( $Option == "Add" || $Option == "Edit" ) + { + if( ($cat_data = cat_get_node( $table, $qs = "id = $parent" ) ) ) + echo 'Sub Category of: '.$cat_data['cat_fullpath'].'

'; + else + echo 'Top Level Category

'; + } + + if( $Option == 'Delete' ) + { + if( ($children = cat_get_nodes( $table, "parent = $id" )) ) + { + echo ' + + + +
+ Unable to Delete Category:
+ This category has child category entries. You must delete all children first. +

'; + break; + } + + // Check any other specified tables for reference to this category + + if( trim($check_tables) != '' ) + { + if( is_array($tables = explode( "|", $check_tables )) ) + { + foreach( $tables as $t ) + { + if( is_array($x = explode( "~", $t )) ) + { + if( db_auto_get_row( "SELECT COUNT(id) FROM ".$x[0]." WHERE ".$x[1]." = $id;", 0, SI_CONN_STR, FALSE ) ) + { + echo ' + + + +
+ Unable to Delete Category:
+ This category is in use by the application. +

'; + break; + } + } + } + } + + } + } + + admin_process_records + ( + $table, // Table + '', // Where + '', // Order fields + SI_CONN_STR, // Connect String + $id, // Current ID + ${'si_category_'.$table}, // Fields array + 'add,edit,delete,strong', // Options + 20, // Rows + SI_THIS_SCRIPT, // URL + 'Edit', // Action + $func_data."|id.$id", // Passed parameter + 'Category', // Base Title + '', // View string + $Option, // Option + $start // Starting row for lists + ); + + break; + + // Display available nodes + + default: + + // Get Nodes + + if( $opt_limited ) + $r = cat_get_expanded_nodes( $table, $id ); + else + $r = cat_get_nodes( $table ); + + // Display list of nodes + + $self_ref_notice = false; + + echo ' + '; + + if( is_array($r) ) + { + reset($r); + $numb = count($r); + + while( list($key, $val) = each($r) ) + { + + echo ' + '; + } + + } + else + echo ''; + + if( $opt_add ) + { + echo ' + + '; + } + + echo '
'; + + // Break out node information + + $info = explode( '~', $key ); + + // Build full path and name if requested + + if( $opt_fullpath ) + $cat_name = $info[1]; + else + $cat_name = $val['name']; + + + // Check to see if we need to prevent a self reference + + if( !$def_ref_data || !$opt_noselfref || strncmp( $def_ref_data['cat_id_path'], $val['cat_id_path'], 1000 ) != 0 ) + { + + // Display expand/contract link + + if( $info[4] > 0 ) + { + if( $val['expanded'] == FALSE ) + echo '+'; + else + echo '-'; + } + else + echo ' '; + + echo ''; + + // if use select full path + + if( $opt_selfullpath ) + { + echo '  '.$info[1].' + '; + } + else + { // otherwise use indented + + // Add appropriate indent + + for( $i=0 ; $i<$val['cat_level'] ; $i++ ) + echo "    "; + + echo '  '.$val['name'].' + '; + } + + } + else + { + echo ''; + for( $i=0 ; $i<$val['cat_level'] ; $i++ ) + echo "    "; + + echo '  '.$val['name'].' * + '; + $self_ref_notice = true; + } + + if( $opt_edit ) + echo '[Edit] '; + if( $opt_add ) + echo '[Add Sub] '; + if( $opt_delete ) + echo '[Delete] '; + + + echo '
No Categories Listed
 
[Add New Top-Level Category]
+ '; + + if( $self_ref_notice ) + echo '


+ + + +
*You may not select this category or any underneath it as it would cause a circular reference.
'; + break; + + } + +echo ' + + '; + +?> diff --git a/front-end/index.html b/front-end/index.html new file mode 100644 index 0000000..d134b6e --- /dev/null +++ b/front-end/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/front-end/java_functions.js b/front-end/java_functions.js new file mode 100644 index 0000000..0a8d034 --- /dev/null +++ b/front-end/java_functions.js @@ -0,0 +1,289 @@ +// +// Java Functions +// + + // List all Java properties for the specified target - Used for testing + +function list_properties( target ) + { + sep = ''; + var names = ''; + var c = 0; + + var names_a = new Array(); + for( var i in target ) + { + names_a[c++] = i; + } + names_a.sort(); + + for( var i=0 ; i 0 && unused == 0 ) + { + new_num = lines + 1; // Add one to line count for new field + + new_text = document.getElementById( fname + '_text' ).value; + + t = new_text.replace( /\{line_numb\}/gi, new_num ); // Replace {n} parameters + + for( i=1 ; i<=width ; i++ ) + { + reg = new RegExp( '\{field_' + i + '\}', 'g' ); + t = t.replace( reg, '' ); + } + + document.getElementById( fname + '_fields' ).innerHTML += t; // Write out new line + + // Fill values back in + for( i=1 ; i<=lines ; i++ ) + for( j=1 ; j<=width ; j++ ) + document.getElementById( fname + '_' + i + '_' + j ).value = saved[i][j]; + + } + + // Focus on next field + setTimeout("setFocus('" + fname + '_' + 1 + '_' + 1 + "', " + ele + ")",100); + + } + +// Set focus to +function setFocus(f, ele) + { + e = document.getElementById( f ); + form = e.form; + ele++; + form.elements[ele].focus(); + } + + // Special Multi-fields that doesn't conflict with view parsing - Built specifically to support Attendee input in registrations step 2 + +function multi_fields_2( fname, cur_field, width ) + { + var lines = 0; + var unused = 0; + var saved = new Array(); + + ele = getElementIndex(cur_field); + + while( document.getElementById( fname + '_' + (lines+1) + '_1' ) ) + { + lines++; + + // Check if line is used + if( document.getElementById( fname + '_' + lines + '_1' ).value == '' ) + unused++; + + // Save all data in case we need to add a line + saved[lines] = new Array(); + for( i=1 ; i<=width ; i++ ) + { + saved[lines][i] = document.getElementById( fname + '_' + lines + '_' + i ).value; + } + } + + // If we need an additional field, rewrite everything + + if( lines > 0 && unused == 0 ) + { + new_num = lines + 1; // Add one to line count for new field + + new_text = document.getElementById( fname + '_text' ).value; + + t = new_text.replace( /\[line_numb\]/gi, new_num ); // Replace {n} parameters + for( i=1 ; i<=width ; i++ ) + { + reg = new RegExp( '\\[field_' + i + '\\]', 'g' ); + t = t.replace( reg, '' ); + } + document.getElementById( fname + '_fields' ).innerHTML += t; // Write out new line + + // Fill values back in + for( i=1 ; i<=lines ; i++ ) + for( j=1 ; j<=width ; j++ ) + { + document.getElementById( fname + '_' + i + '_' + j ).value = saved[i][j]; + } + } + + // Focus on next field + // Focus on next field + setTimeout("setFocus('" + fname + '_' + 1 + '_' + 1 + "', " + ele + ")",100); + + } + + + +//CKEditor Actions +CKEDITOR.config.toolbar_EventManagement = +[ + ['Font','FontSize','Bold','Italic'], + ['Cut','Copy','PasteText','-','Undo','Redo'], + ['NewPage', 'Preview'], + '/', + ['NumberedList','BulletedList','-','Outdent','Indent'], + ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], + ['TextColor'], + ['Link','Unlink'], + ['Table','Find','Replace','-','RemoveFormat','Source'] +] ; + + +function buildCkeditor(f) +{ + instance = CKEDITOR.instances[f]; + if (instance) { + instance.destroy(true); + instance = null; + } + + // Only try to replace the textarea if the + // CKEditor is compatible w/ the browser. + if (CKEDITOR.env.isCompatible) { + CKEDITOR.replace(f, { + toolbar : 'EventManagement', +// width : 570, +// height : 400 + }); + } + +} diff --git a/front-end/magic_forms_function.inc b/front-end/magic_forms_function.inc new file mode 100644 index 0000000..0150d55 --- /dev/null +++ b/front-end/magic_forms_function.inc @@ -0,0 +1,2686 @@ + 0 ) { + return( 'ERROR: Found unmatched "(" in "'.$exp.'"' ); + } + + // If variables are supplied - Replace variables with values + if( is_array( $vars ) ) { + + // First scan to make sure all have numeric values (remember, we're doing math here) and clean them up + $non_numeric = false; + while( list($k, $v) = each($vars) ) { + if( !is_numeric(trim($v)) ) + { + $vars[$k] = '{'.$k.'='.$v.'}'; + $non_numeric = true; + } else { + $vars[$k] = (float) ($v + 0); // Clean up input + } + } + + $exp = replace_tokens( $exp, $vars ); + + // now get rid of any parameters that didn't get replaced (such as from unused sub-forms) + $pattern = '/\{[^\}]*}/i'; + $exp = preg_replace($pattern, '0', $exp); + + // if( $non_numeric ) + // return( 'ERROR: Bad value in "'.$exp.'"' ); + + if( strstr($exp, '{') ) { + return( 'ERROR: "'.$exp.'"' ); + } + } + + // Check for tokens that don't match a valid variable + if( preg_match( '(\{|\})', $exp ) ) { + return( 'ERROR: Unmatched variables in "'.$exp.'"' ); + } + + // Recheck expression after variable replacement + if( !preg_match( '/^([0-9 ^+-\.\/\*\(\)]|'.$functions.')+$/', $exp ) ) { + return( 'ERROR: Illegal character or sequence in "'.$exp.'"' ); + } + + // Evaluate expression + $r = 'ERROR: Unable to evaluate expression "'.$exp.'"'; // Pre-load error message + @eval( '$r = ('.$exp.');' ); // If successful replaces error with result + if( $r{0} == 'E' ) { + return( $r ); + } + + // Check for valid result + if( !is_float($r) && !is_int($r) ) { + return( 'ERROR: Bad result "'.$r.'" is not a number from expression "'.$exp.'"' ); + } + + // Insure that result is only a floating point number + $r = (float) $r; + return( $r ); +} + +// Get all numeric fields for use in formulas +function get_all_numeric_vars( $mf_id ) +{ + + $mf_fields = array(); + + $mf_fields = reg_db_auto_get_data( " + SELECT * + FROM ".MF_TABLE." + WHERE form_id = '$mf_id' + OR form_id LIKE '$mf_id.%' + ORDER BY sort; + ", SI_CONN_STR, FALSE ); + + if( $mf_fields ) { + foreach( $mf_fields as $mf ) { + + switch( $mf['type'] ) { + case 1: // Check`ox + case 2: // Number + case 5: // Picklist (will be checked for numeric values) + case 6: // Radio Buttons (will be checked for numeric values) + case 31: // Calculated field (will be processed in order) + $fid = ( $mf['custom_id'] == '' ? 'mf_'.$mf['id'] : $mf['custom_id'] ); + $field_list[$mf['id']] = array( 'fid' => $fid, 'title' => $mf['title'] ); + break; + default: + break; + } + + } + } + + return $field_list; +} + + +// Support function to get all numeric variable ID's for a sub-form +function get_sub_vars( $form_id ) +{ + $vars = array(); + + // If there's a sub-form, get a list of fields with numeric values that can be used to return a value for this option + if( $form_id != '' && ($sub_fields = reg_db_auto_get_data(" + SELECT id, title, custom_id + FROM ".MF_TABLE." + WHERE form_id = '$form_id' + AND ( type = 1 OR type = 2 OR type = 5 OR type = 6 OR type = 31 ) + ORDER BY sort + ;", SI_CONN_STR, FALSE )) ) { + foreach( $sub_fields as $sf ) { + + // Add this field ID and + $fid = ( empty($sf['custom_id']) ? 'mf_'.$sf['id'] : $sf['custom_id'] ); + $vars[$fid] .= $fid.' - '.$sf['title']; + + } + } + + return( $vars ); +} + + +// MagicForm - Edit Form + +function magic_form_edit( $mf_id, $mf_format, $mf_level = 0 ) +{ + // + // Needed Enhancements + // + // Calculated fields - based on results from other fields + // + + /* data1 field description + * + * {title}~{subform_id}~{misc_data}|{title}~{subform_id}~{misc_data}|... + * + */ + + global $mf_formats, $mf_styles; + + // Clean up all input + $mf_action_id = filter_request('mf_action_id'); + $mf_action = filter_request('mf_action'); + + $mf_field_id = filter_request('mf_field_id'); + $mf_position = filter_request('mf_position'); + $mf_field_option = filter_request('mf_field_option'); + $mf_option_id = filter_request('mf_option_id'); + $mf_option_name = filter_request('mf_option_name'); + $mf_option_value = filter_request('mf_option_value'); + $mf_option_value_type = filter_request('mf_option_value_type'); + $mf_option_value_src = filter_request('mf_option_value_src'); + $mf_position = filter_request('mf_position'); + $mf_position_num = filter_request('mf_position_num'); + $mf_field_text = filter_request('mf_field_text'); + $mf_field_imagesize = filter_request('mf_field_imagesize'); + $mf_field_title = filter_request('mf_field_title'); + $mf_field_descr = filter_request('mf_field_descr'); + $form_data = filter_request('form_data'); + $link_data = filter_request('link_data'); + $mf_type = filter_request('mf_type'); + $mf_style = filter_request('mf_style'); + $mf_field_cols = filter_request('mf_field_cols'); + $mf_field_rows = filter_request('mf_field_rows'); + $mf_custom_id = filter_request('mf_custom_id'); + $mf_field_file = filter_request('mf_field_file'); // ???? FILE + $mf_field_file_name = filter_request('mf_field_file_name'); // ???? + $mf_field_file_delete = filter_request('mf_field_file_delete'); + $mf_format_type = filter_request('mf_format_type'); + $mf_format_char = filter_request('mf_format_char'); + $mf_format_dec = filter_request('mf_format_dec'); + $mf_format_min = filter_request('mf_format_min'); + $mf_format_max = filter_request('mf_format_max'); + $mf_def_val = filter_request('mf_def_val'); + + // If first entry to edit form, get all numeric fields for formulas + if ($mf_level == 0) { + $field_list = get_all_numeric_vars( $mf_id ); + } + + // Always pass along the current form/sub-form with any action requests + + $mf_form_data = ''; + $mf_link_data = '&mf_action_id='.$mf_id; + + $r['success'] = false; // Assume a failed return + $r['modified'] = false; // Assume we're not modifying the form - This is set to true for anything that changes the form in a way that old form results can't be used anymore. + $r['text'] = ''; // With no text + + // If we have a field ID then get data for that too + if( !empty($mf_field_id) && ($mf_field_data = db_auto_get_row( "SELECT * FROM ".MF_TABLE." WHERE id = $mf_field_id;", 0, CONN_STR, FALSE )) ) { + $mf_field_data1 = $mf_field_data['data1']; + } else { + $mf_field_data1 = ''; + } + + $mf_normalize = false; + $mf_custom_id_update_message = ''; + + // + // Process Actions + // + + if( $mf_action_id == $mf_id ) { + switch( $mf_action ) { + + case "Add Field": + + // Add new field with default data + $f = db_auto_get_row( "INSERT INTO ".MF_TABLE." ( form_id, title, type, active, required, sort, expanded, style, format, file, cols, rows ) + VALUES ( '$mf_id', '', 0, 't', 'f', $mf_position, 't', 'Default', '', '', 20, 4 ); + SELECT currval('".MF_TABLE."_id_seq') AS id;", 0, CONN_STR, FALSE ); // Get new field ID + $mf_field_id = $f['id']; + $mf_normalize = true; + break; + + case "Set Type": + + // Is there a request to place a duplicate of an existing field here + + if( trim($mf_dupe_id) != '' ) { + + // Try to find the field by custom id + if( !($md = db_auto_get_row( "SELECT * FROM ".MF_TABLE." WHERE custom_id = '$mf_dupe_id';", 0, CONN_STR, FALSE )) ) { + + // Can't find custom ID so should be numeric field ID + $mf_dupe_id = substr( $mf_dupe_id, 3 ); + if( !is_numeric( $mf_dupe_id ) || ($mf_dupe_id = $mf_dupe_id+0) == 0 ) { + break; // Not numeric so quit here + } + + // Now try to get it by numeric ID + if( !($md = db_auto_get_row( "SELECT * FROM ".MF_TABLE." WHERE id = $mf_dupe_id;", 0, CONN_STR, FALSE )) ) { + break; // Not found quit here + } + } + + $md_temp = $md['form_id'].'.'.$mf_dupe_id; + + // Copy dupe target to current field + $md['data1'] = str_replace( $md_temp.'.', $mf_field_data['form_id'].'.'.$mf_field_id.'.', $md['data1'] ); + $md['form_id'] = $mf_field_data['form_id']; + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET title = '".$md['title']."', type = ".$md['type'].", descr = '".$md['descr']."', active = '".$md['active']."', data1 = '".$md['data1']."', sort = 9990, + form_id = '".$md['form_id']."', expanded = 't', style = '".$md['style']."', file = '', cols = ".$md['cols'].", rows = ".$md['rows'].", custom_id = '', size = '".$md['size']."', + format = '".$md['format']."', default_val = '".$md['default_val']."', required = '".$md['required']."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + + // Start and array with the dupe field and then add any sub-form data + if( ($mf_dupe_subs = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id like '".$md_temp.'.'."%';", CONN_STR, FALSE, 999 )) && is_array($mf_dupe_subs) ) { + + $qs = ''; + + // Copy all sub-form - Temporarily stuff $mf_field_id into 'file' to be able to find all of these and also the original ID for each in the custom_id field + foreach( $mf_dupe_subs as $ds ) { + $qs .= "INSERT INTO ".MF_TABLE." (title, type, descr, active, data1, sort, form_id, expanded, style, file, cols, rows, custom_id, size, format, default_val, required ) + VALUES ( '".$ds['title']."', ".$ds['type'].", '".$ds['descr']."', '".$ds['active']."', '".$ds['data1']."', ".$ds['sort'].", + '".$ds['form_id']."', 'f', '".$ds['style']."', '$mf_field_id', ".$ds['cols'].", ".$ds['rows'].", '".$ds['id']."', '".$ds['size']."', + '".$ds['format']."', '".$ds['default_val']."', '".$ds['required']."' );\n"; + } + $mf_dupe_subs = reg_db_auto_get_data( $qs."SELECT * FROM ".MF_TABLE." WHERE file = '$mf_field_id';", CONN_STR, FALSE, 999 ); + + // Build array for translating old ID's to new + $mf_trans = array( $mf_dupe_id => $mf_field_id ); + foreach( $mf_dupe_subs as $ds ) { + $mf_trans[$ds['custom_id']] = $ds['id']; + } + + // Now use translation array to translate form ID's as needed + $qs = ''; + reset( $mf_dupe_subs ); + foreach( $mf_dupe_subs as $ds ) { + reset( $mf_trans ); + $data1_temp = $ds['data1']; + $form_id_temp = $ds['form_id']; + while( list($key, $val) = each($mf_trans) ) { + $data1_temp = str_replace( '.'.$key.'.', '.'.$val.'.', $data1_temp ); + $form_id_temp = str_replace( '.'.$key.'.', '.'.$val.'.', $form_id_temp ); + } + // Update each sub and clear the temp values in file and custom_id + $qs .= "UPDATE ".MF_TABLE." SET data1 = '".$data1_temp."', form_id = '".$form_id_temp."', file = '', custom_id = '' WHERE id = ".$ds['id'].";\n"; + } + + reg_db_auto_exec( $qs, CONN_STR, FALSE ); + } + + } else { + + // Determine default style format for this type - First format that can be used for this type + reset( $mf_styles ); + while( list($key, $val) = each($mf_styles) ) { + if( strstr( $val['types'], ' '.$mf_type.' ' ) ) { + $mf_style .= $key; + break; + } + } + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET type = $mf_type, style = '$mf_style' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + if( $mf_type == 1 ) { // IF checkbox + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = 'Yes~~~|No~~~' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + } + } + break; + + case "Set Style": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET style = '$mf_style' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Set Field Format": + + $x = $mf_format_type.'~'.$mf_format_char.'~'.$mf_format_dec.'~'.$mf_format_min.'~'.$mf_format_max; + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET format = '$x' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Add Option": + + if( trim($mf_field_option) == '' ) { + break; + } + + if( !empty($mf_field_data1) ) { + $x = $mf_field_data1."|".$mf_field_option."~~"; + } else { + $x = $mf_field_option."~~"; + } + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = '".addslashes($x)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Add Subform": + + /* + * Subform ID's are created as follows... + * + * {parent_id}.{new_id}.{timestamp} + */ + + $x = explode( "|", $mf_field_data1 ); // Separate data into options + $y = explode( "~", $x[$mf_option_id-1] ); // Separate specified option parameters + $x[$mf_option_id-1] = $y[0]."~$mf_id.$mf_field_id.".time().'~'.$y[2].'~'.$y[3]; + $mf_field_data1 = implode( "|", $x ); + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_data1)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Delete Subform": + + // $r['modified'] = true; + $x = explode( "|", $mf_field_data1 ); + $y = explode( "~", $x[$mf_option_id-1] ); + $x[$mf_option_id-1] = $y[0].'~~'.$y[2].'~'.$y[3]; + $mf_field_data1 = implode( "|", $x ); + + // Delete any Images or Files associated with these fields + + if( ($del_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id LIKE '".$y[1]."%';" )) ) { + foreach( $del_fields as $d ) { + switch( $d['type'] ) { + case 24: // Image + reg_delete_image( $d['file'] ); + break; + case 25: // File + reg_file_delete( $d['file'] ); + break; + default: + break; + } + } + } + + reg_db_auto_exec( "DELETE FROM ".MF_TABLE." WHERE form_id LIKE '".$y[1]."%'; UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_data1)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Edit Option Name": + + // $r['modified'] = true; + $x = explode( "|", $mf_field_data1 ); + $y = explode( "~", $x[$mf_option_id-1] ); + $x[$mf_option_id-1] = $mf_option_name.'~'.$y[1].'~'.$y[2].'~'.$y[3]; + $mf_field_data1 = implode( "|", $x ); + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_data1)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Edit Option Value": + + // $r['modified'] = true; + if ((clean_input( 'mf_option_value', 'float', false )) == '') { // Validate input value as floating point + $x = explode( "|", $mf_field_data1 ); + $y = explode( "~", $x[$mf_option_id-1] ); + $x[$mf_option_id-1] = $y[0].'~'.$y[1].'~'.$mf_option_value.'~'.$mf_option_value_type.'~'.$mf_option_value_src; + $mf_field_data1 = implode( "|", $x ); + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_data1)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + + } + + break; + + case "Delete Option": + + $r['modified'] = true; + $x = explode( "|", $mf_field_data1 ); + $y = explode( "~", $x[$mf_option_id-1] ); + array_splice( $x, $mf_option_id-1, 1 ); + $mf_field_data1 = implode( "|", $x ); + + // Delete any Images or Files associated with these fields + + if( ($del_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id LIKE '".$y[1].".%';" )) ) { + foreach( $del_fields as $d ) + { + switch( $d['type'] ) { + case 24: // Image + reg_delete_image( $d['file'] ); + break; + case 25: // File + reg_file_delete( $d['file'] ); + break; + default: + break; + } + } + } + + // Delete any sub-forms and update this field data + // Make sure we have a form ID before we try this or we could wipe out all MF field data + if( trim($y[1]) != '' ) { + reg_db_auto_exec( "DELETE FROM ".MF_TABLE." WHERE form_id LIKE '".$y[1].".%'; UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_data1)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + } + break; + + case "Reposition": + + if( !empty( $mf_position_num ) ) { + if (clean_input( 'mf_position_num', 'integer', true ) == '') { + if ($mf_position_num > 999) { + $mf_position_num = 999; + } + $mf_position = $mf_position_num * 10; + if( $mf_position > $mf_field_data['sort'] ) { + $mf_position += 1; + } else { + $mf_position -= 1; + } + } else { + break; + } + } + + // $r['modified'] = true; + if (($mf_position-0) > 0) { + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET sort = $mf_position WHERE id = $mf_field_id;", CONN_STR, FALSE ); + } + $mf_normalize = true; + break; + + case "Toggle Active": + + // $r['modified'] = true; + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET active = '".($mf_field_data['active']=='t'?'f':'t')."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Toggle Required": + + // $r['modified'] = true; + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET required = '".($mf_field_data['required']=='t'?'f':'t')."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Toggle Expanded": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET expanded = '".($mf_field_data['expanded']=='t'?'f':'t')."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Expand All": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET expanded = 't' WHERE form_id = '$mf_id';", CONN_STR, FALSE ); + break; + + case "Contract All": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET expanded = 'f' WHERE form_id = '$mf_id';", CONN_STR, FALSE ); + break; + + case "Update Text": + + // $r['modified'] = true; + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET data1 = '".addslashes($mf_field_text)."' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Update Field": + + // $r['modified'] = true; + $other_fields = ''; + if( $mf_field_data['type'] >= 2 && $mf_field_data['type'] <= 4 ) { + $other_fields .= ', cols = '.$mf_field_cols; + } + if( $mf_field_data['type'] == 4 ) { + $other_fields .= ', rows = '.$mf_field_rows; + } + if( $mf_field_data['type'] == 2 || $mf_field_data['type'] == 3 ) { + $other_fields .= ", default_val = '$mf_def_val'"; + } + if( $mf_field_data['type'] == 31 ) { + $other_fields .= ", data1 = '$mf_field_text'"; + } + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET title = '".addslashes($mf_field_title)."', descr = '".addslashes($mf_field_descr)."'$other_fields WHERE id = $mf_field_id;", CONN_STR, FALSE ); + break; + + case "Update Image": + + // $r['modified'] = true; + $new_image = ''; + $image_update = false; + + $mfFile = $_FILES['mf_field_image']; + $mf_field_image_delete = filter_request('mf_field_image_delete'); + $mf_field_image_size = filter_request('mf_field_image_size'); + + // if there's an existing image and we're either deleting or replacing it + if( $mf_field_data['file'] != '' && ( $mf_field_image_delete == 'on' || $mfFile['name'] != '' ) ) { + reg_delete_image( $mf_field_data['file'] ); + $image_update = true; + } + + // If there's an image supplied + if( $mfFile['name'] != '' ) { + $new_image = reg_process_image('mf_field_image'); + $image_update = true; + } + + if( $image_update ) { + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET file = '".addslashes($new_image)."', size = '$mf_field_imagesize' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + } else { + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET size = '$mf_field_imagesize' WHERE id = $mf_field_id;", CONN_STR, FALSE ); + } + + break; + + case "Update File": + + $existing_filename = $mf_field_data['file']; + + $mfFile = $_FILES['mf_field_file']; + $mf_field_image_delete = filter_request('mf_field_image_delete'); + + $new_filename = trim($mfFile['name']); + + // If delete is requested or there's a new file upload AND there's an existing file, then delete the old one + + if( ( $mf_field_file_delete == 'on' || $mfFile['name'] != '' ) && $existing_filename != '' ) { + reg_file_delete( $existing_filename ); + $existing_filename =''; + } + + if( $mfFile['name'] != '' ) { + if( !($new_filename = reg_file_upload('mf_field_file')) ) + $new_filename = ''; + } else { + $new_filename = $existing_filename; + } + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET file = '".addslashes($new_filename)."' WHERE id= $mf_field_id;" ); + + break; + + case "Set Custom ID": + + // $r['modified'] = true; + $mf_custom_id = trim($mf_custom_id); + + if( $mf_custom_id != '' && db_auto_get_row( "SELECT id FROM ".MF_TABLE." WHERE form_id = '$mf_id' AND custom_id = '$mf_custom_id';" ) ) { + $mf_custom_id_update_message = 'ID in Use.'; + } else { + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET custom_id = '".trim($mf_custom_id)."' WHERE id = $mf_field_id;" ); + } + + break; + + case "Clear Default": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET default_val = '' WHERE id = $mf_field_id;" ); + + break; + + case "Set Default": + + reg_db_auto_exec( "UPDATE ".MF_TABLE." SET default_val = '".$mf_def_val."' WHERE id = $mf_field_id;" ); + + break; + + case "Delete": + + // $r['modified'] = true; + + // Delete any Images or Files associated with these fields + + if( ($del_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id LIKE '$mf_id.%' OR id = $mf_field_id;" )) ) { + foreach( $del_fields as $d ) { + switch( $d['type'] ) { + case 24: // Image + reg_delete_image( $d['file'] ); + break; + case 25: // File + reg_file_delete( $d['file'] ); + break; + default: + break; + } + } + } + + if( trim($mf_id.$mf_field_id) != '' ) { + reg_db_auto_exec( "DELETE FROM ".MF_TABLE." WHERE form_id LIKE '$mf_id.$mf_field_id.%' OR id = $mf_field_id;", CONN_STR, FALSE ); + } + break; + + default: + break; + + } // switch $mf_action + + } // if $mf_action_id + + // If we need to normalize the sort numbers + if( $mf_normalize ) { + $mf_data = reg_db_auto_get_data( "SELECT id, sort FROM ".MF_TABLE." WHERE form_id = '$mf_id' ORDER BY sort;", CONN_STR, FALSE ); + $qs = 'BEGIN;'.$nl; + $i = 10; + foreach( $mf_data as $mf ) { + $qs .= "UPDATE ".MF_TABLE." SET sort = ".$i." WHERE ID = ".$mf['id'].";\n"; + $i += 10; + } + reg_db_auto_exec( $qs."COMMIT;", CONN_STR, FALSE ); + } + + // + // Display current form status + // + + $font_size = '100%'; // Font size percentage to use for form elements + + $mf_bgcolor = ($mf_level % 2); + + $r['text'] .= ''.$nl; + + // Get the MagicForm data + if( ($mf_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id = '$mf_id' ORDER BY sort;", CONN_STR, FALSE )) ) { + + foreach( $mf_fields as $mf ) { + + $base_form_data = ' + '.$form_data.$mf_form_data.' + + '; + + $mf_field_values = $mf_field_content = $mf_text = $mf_type_text = $mf_field_prompt = $mf_field_params = ''; + + $mf_title_req = $mf_required = false; + + /* + $mf_title_req Field needs title data + $mf_field_content sub-form area + $mf_type_text Name for type of field + $mf_field_prompt Additional text for prompt in title area of a field + $mf_field_params Additional field parameters to request in pop-up edit box in title area of a field + */ + + switch( $mf['type'] ) { + + + // Checkbox + + case 1: + + $mf_title_req = true; + $mf_field_content .= '
'; + $mf_type_text = 'Checkbox'; + + $mf_field_prompt = '
Descr: '.$mf['descr'].''; + $mf_field_params = $base_form_data.' +
+ + + + + + + + + + +
 Title:
 Descr:
+
+ + '; + + $mf_field_content .= ''; + + if( !empty($mf['data1']) ) { + + $mf_data1 = explode("|", $mf['data1']); + for ($i=1 ; $i<=count($mf_data1) ; $i++) { + + $x = explode("~", $mf_data1[$i-1]); + + // Process Sub-Forms before this field in case we need the data + if ($x[1] != '') { + $rs = magic_form_edit($x[1], $mf_format, $mf_level+1); + } + + // Build list of variables from sub-forms to optionally use as value + $sub_vars = array(); + $vars = ''; + if ($x[1] != '') { + $sub_vars = get_sub_vars($x[1]); + } + while (list($key, $val) = each($sub_vars)) { + $vars .= ''; + } + + // Set option value output format + + if (trim($x[4]) != '' && isset($sub_vars[$x[4]])) { + $xv = $sub_vars[$x[4]]; + } elseif (trim($x[2]) != '') { + switch($x[3]) { + case 1: + $xv = money($x[2]); + break; + default: + $xv = $x[2]; + break; + } + } else { + $xv = '(no value)'; + } + + $mf_field_content .= ' + + + + '; + if ($i == $mf['default_val']) { + $mf_field_content .= ''; + } else { + $mf_field_content .= ''; + } + + // Check if sub-form displayed + if( $x[1] != '' ) { + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + } + $mf_field_content .= '
Option: '.stripslashes($x[0]).'
' + .quick_edit( $mf['id'].'.'.$i, 'Value: '.$xv, + '
'.$base_form_data.' + + + + + + + + + + + +
Source of Value: + +
Specified value:
Value Type: + +
+ +
' ) + .'
+ '.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + + + '; + + $mf_field_content .= '
Default Selection
Set as default selection
'.$rs['text'].'
'; + break; + + // Number + + case 2: + $mf_type_text = 'Number'; + $mf_title_req = true; + + $mf_field_prompt = '
Descr: '.$mf['descr'].'
+ Columns: '.$mf['cols'].'
Default Value: '.$mf['default_val'].'
'; + $mf_field_params = $base_form_data.' + + + + + + + + + + + + + + + + + + + + + +
 Title:
 Descr:
 Columns:
 Default Value:
+
+ + '; + + $mf_field_content .= ''; + + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=2 ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + $mf_field_content .= ' + + + + + '; + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + + $mf_field_content .= '
Option: '.($i==1?'No Response':'Response Provided').''.($x[2]>0?money($x[2]):'').''.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + '; + + $mf_field_content .= ' +
'.$rs['text'].'
'; + + break; + + // Text field + + case 3: + $mf_type_text = 'Text'; + $mf_title_req = true; + $mf_type_text = 'Text'; + $mf_required = true; // Can be a required field + + $mf_field_prompt = '
Descr: '.$mf['descr'].'
+ Columns: '.$mf['cols'].'
Default Value: '.$mf['default_val'].'
'; + $mf_field_params = $base_form_data.' + + + + + + + + + + + + + + + + + + + + + +
 Title:
 Descr:
 Columns:
 Default Value:
+
+ + '; + + $mf_field_content .= ''; + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=2 ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + $mf_field_content .= ' + + + + + + '; + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + + $mf_field_content .= '
Option: '.($i==1?'No Response':'Response Provided').''.($x[2]>0?money($x[2]):'').''.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + '; + + $mf_field_content .= ' +
'.$rs['text'].'
'; + + break; + + // Text Box + + case 4: + $mf_type_text = 'Text Box'; + $mf_title_req = true; + $mf_type_text = 'Text Box'; + $mf_required = true; // Can be a required field + + $mf_field_prompt = '
Descr: '.$mf['descr'].'
Columns: '.$mf['cols'].'
Rows: '.$mf['rows'].'
'; + $mf_field_params = $base_form_data.' + + + + + + + + + + + + + + + + + + + + + +
 Title:
 Descr:
 Columns:
 Rows:
+
+ + '; + + $mf_field_content .= ''; + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=2 ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + $mf_field_content .= ' + + + + + + '; + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + + $mf_field_content .= '
Option: '.($i==1?'No Response':'Response Provided').''.($x[2]>0?money($x[2]):'').''.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + '; + + $mf_field_content .= ' +
'.$rs['text'].'
'; + break; + + // Picklist + + case 5: + + // Radio Buttons + + case 6: + $mf_title_req = true; + $mf_required = true; // Can be a required field + + switch( $mf['type'] ) { + case 5: + $mf_type_text = 'Picklist'; + break; + case 6: + $mf_type_text = 'Radio Buttons'; + break; + } + + $mf_field_prompt = '
Descr: '.$mf['descr'].''; + $mf_field_params = $base_form_data.' + + + + + + + + + + + +
 Title:
 Descr:
+
+ + '; + + $mf_field_content .= ''; + if( !empty($mf['data1']) ) { + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=count($mf_data1) ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + + // Process Sub-Forms before this field in case we need the data + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + } + + // Build list of variables from sub-forms to optionally use as value + $sub_vars = array(); + $vars = ''; + if( $x[1] != '' ) { + $sub_vars = get_sub_vars( $x[1] ); + } + while( list($key, $val) = each($sub_vars) ) { + $vars .= ''; + } + + // Set option value output format + if( trim($x[4]) != '' && isset($sub_vars[$x[4]]) ) { + $xv = $sub_vars[$x[4]]; + } elseif( trim($x[2]) != '' ) { + switch( $x[3] ) { + case 1: + $xv = money($x[2]); + break; + default: + $xv = $x[2]; + break; + } + } else { + $xv = '(no value)'; + } + + $mf_field_content .= ' + + + + + '; + + if( $i == $mf['default_val'] ) { + $mf_field_content .= ''; + } else { + $mf_field_content .= ''; + } + + if( $x[1] != '' ) { + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + } else { + $mf_field_content .= ''.$nl; + } + + $mf_field_content .= ' + + + +
' + .quick_edit( $mf['id'].'.'.$i, 'Option: '.stripslashes($x[0]), + '
+ '.$base_form_data.' + +
+ + +
' ) + .'
' + .quick_edit( $mf['id'].'.'.$i."_value", 'Value: '.$xv, + '
'.$base_form_data.' + + NOTE: Option value must be a number. Do not include a $ for monetary values.
+ Leave blank for no value.

+ + + + + + + + + + +
Source of Value: + +
Specified value:
Value Type: + +
+ +

' ) + .'
+ '.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + [delete] + + + '; + + $mf_field_content .= ' +
DEFAULT: Click to clear default selection
Set as default selection
'.$rs['text'].'
No options selected yet.
' + .quick_edit( '_add_option_'.$mf['id'], + '[Add Option]', + '
+ '.$base_form_data.' + Option Name: + + +
' ) + .'
+ '; + $mf_title_req = true; + break; + + // File Upload + + case 7: + $mf_type_text = 'File Upload'; + $mf_title_req = true; + $mf_required = true; // Can be a required field + + $mf_field_prompt = '
Descr: '.$mf['descr'].''; + $mf_field_params = $base_form_data.' + + + + + + + + + + + +
 Title:
 Descr:
+
+ + '; + + $mf_field_content .= ''; + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=2 ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + $mf_field_content .= ' + + + + + + '; + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + + $mf_field_content .= '
Option: '.($i==1?'No Response':'Response Provided').''.($x[2]>0?money($x[2]):'').''.( $x[1] == '' ? + '[Sub-Form]' + : + '[Delete Sub-Form]' + ).' + '; + + $mf_field_content .= ' +
'.$rs['text'].'
'; + + break; + + + // Section Title + + case 20: + $mf_type_text = 'Section Title'; + $mf_title_req = true; + $mf_field_prompt = ''.($mf['data1']!='' ? stripslashes($mf['data1']) : '(Section title not set)').''; + $mf_field_params = + $base_form_data.' + + + + + + +
 Title:
+
+ + ' ; + + break; + + // Misc. Text + + case 21: + $mf_type_text = 'Misc. Text'; + $mf_text .= $mf['expanded'] != 't' ? 'Misc Text' : 'Misc Text'; + $mf_field_content .= quick_edit( $mf['id'], ( + $mf['data1'] != '' ? ( $mf['expanded'] == 't' ? + stripslashes($mf['data1']) + : + substr( stripslashes($mf['data1']), 0, 225 ).' ...' + ) + : + '(Misc. text not set)' + ), + $base_form_data.' + + + + + + +
 Misc. Text:
+
+ + ' + ); + + $mf_field_prompt = ''; + $mf_field_params = ''; + + break; + + // Horizontal Line + + case 22: + $mf_type_text = 'Horiz Line'; + $mf_text = '
'; + break; + + // Blank Line + + case 23: + $mf_type_text = 'Blank Line'; + $mf_text .= '(a blank line)'; + break; + + // Display Image + + case 24: + $mf_title_req = true; + $mf_type_text = 'Image'; + + $mf_field_prompt = '
Descr: '.$mf['descr'].''; + $mf_field_params = $base_form_data.' + + + + + + + + + + + +
 Title:
 Descr:
+
+ + '; + + switch( $mf['size'] ) { + case 'original': + $image_size_url = ORIGINAL; + break; + case 'resized': + $image_size_url = RESIZED; + break; + case 'midsized': + $image_size_url = MIDSIZED; + break; + default: + case 'thumb': + $image_size_url = THUMB; + break; + } + + $mf_field_content .= quick_edit( + $mf['id'].'_image', + ( $mf['file'] != '' ? '' : '(Image not set)' ), + $base_form_data.' + + + + + + + + + + + + + + + + +
'.( $mf['file'] != '' ? '':'(no image)').'
Delete existing Image:
Image Size: + +
Select Image:
+
+ + ' ); + break; + + // File Download + case 25: + $mf_title_req = true; + $mf_type_text = 'File Download'; + + $mf_field_prompt = '
Descr: '.$mf['descr'].''; + $mf_field_params = $base_form_data.' + + + + + + + + + + + +
 Title:
 Descr:
+
+ + '; + + $mf_field_content .= quick_edit( + $mf['id']."_file", + ( $mf['file'] != '' ? 'File: '.$mf['file'].'' : '(File not provided)' ), + $base_form_data.' + '.( $mf['file'] != '' ? ' + + + + + + ' : '' ).' + + + + +
Current File: + '.$mf['file'].' + Delete this file +
 
Upload/Replace File:
+
+ + '); + + break; + + // Calculated field + + case 31: + + // Do we need a title line? + $mf_title_req = true; + $mf_type_text = 'Calculated'; + $mf_required = true; // Can be a required field + + $mf_field_prompt = '
Descr: '.$mf['descr'].'
Formula: '.($mf['data1']!=''?stripslashes($mf['data1']):'(Formula not set)').'
'; + + // Build html for list of fields that can be used as numeric parameter source + $field_list_html = ''; + + // Display available fields that may be referenced in a formumla, if we have any + $haveFieldsForFormulas = false; + if (is_array($field_list) && count($field_list) > 0) { + while (list($fkey, $f) = each($field_list)) { + if ($fkey != $mf['id']) { + $field_list_html .= ''.$f['title'].''; + $haveFieldsForFormulas = true; + } + } + } + + // If we have no fields available for formulas, note that in the table + if (!$haveFieldsForFormulas) { + $field_list_html .= '(no fields currently available for caluculations)'; + } + + $mf_field_params = $base_form_data.' + + + + + + + + + + + + + + + + +
 Title:
 Descr:
 Formula:
+
+ +

 

+
+ Fields that may be referenced in the forumula.
Click field below to insert into formula.

+ + + '.$field_list_html.' +
Field IDTitle
+
+
    +
  • Only fields that can have a numeric value are listed and may be used in a formula.
  • +
  • Only fields preceeding this calculated field are available for this formula.
  • +
  • Formula may have any of the following operators: + - . * ( )
  • +
  • + Formula may include any of the following functions:
    +   abs, acos, asin, atan, ceil, deg2rad, exp, floor,
    +   log10, log, pi, pow, rand, round, sin, sqrt, tan
    +   For usage see http://www.w3schools.com/php/php_ref_math.asp +
+ '; + + $mf_field_content .= ''; + $mf_data1 = explode( "|", $mf['data1'] ); + for( $i=1 ; $i<=2 ; $i++ ) { + $x = explode( "~", $mf_data1[$i-1] ); + $mf_field_content .= ''; + if( $x[1] != '' ) { + $rs = magic_form_edit( $x[1], $mf_format, $mf_level+1 ); + if( $rs['success'] ) { + $mf_field_content .= ''; + } + if( $rs['modified'] ) { + $r['modified'] = true; + } + } + $mf_field_content .= ''.$nl; + } + $mf_field_content .= '
'.$rs['text'].'
'; + break; + + case 0: + default: + $mf_field_content = ' '; + break; + } + + // Build list of available styles for this field + + $mf_style_list = ''; + reset( $mf_styles ); + while( list($key, $val) = each($mf_styles) ) + if( strstr( $val['types'], ' '.$mf['type'].' ' ) ) + $mf_style_list .= ''; + + // Extract current format info and build list of possible formats for this field + + $mf_cf = explode( '~', $mf['format'] ); + $mf_format_list = ''; + reset( $mf_formats ); + while (list($key, $val) = each($mf_formats)) { + if( strstr( $val['types'], ' '.$mf['type'].' ' ) ) + $mf_format_list .= ''; + } + + // Display Title, descr, and optionally size with QuickEdit pop-up + if( $mf_title_req || $mf_field_params != '' ) { + if( $mf['expanded'] == 't' ) { + $mf_text .= quick_edit( $mf['id'], + ($mf_title_req?'Title: '.$mf['title'].'':'') + .( $mf['expanded'] == 't' ? $mf_field_prompt : '' ), + $mf_field_params ); + } else { + $mf_text .= '
'.$id_form.''.($mf_title_req?'Title: '.$mf['title'].'':'').'
'; + } + } + + $r['text'] .= ' + + ' + .'
+ +  ' + .' ' + .'  + '; + if( $mf['expanded'] == 't' ) + { + $r['text'] .= '
+ ' + .( $mf_type_text != '' ? + $mf_type_text + .'
+ ' + .quick_edit( $mf['id']."_style", + $mf_styles[$mf['style']]['short_name'], + '
+ + '.$form_data.$mf_form_data.' + Set style For this field: + + + + +
' ).' +

+ '.( $mf_format_list != '' ? ' + ' + .quick_edit( $mf['id']."_format", + ( $mf_cf[0] != '' ? $mf_formats[$mf_cf[0]]['short_name'] : 'Default Format' ), + '
+
+ '.$form_data.$mf_form_data.' + + + + + + + + + + + + + + + + + + + +
Format Type: + +
Maximum Characters/Digits to left of decimal point:
Digits after Decimal Point:
Number Range: Min Max
(Note: Not all fields used for all format types.)
+
+
' ).' +

+ ' : '' ).' + ID: ' + .quick_edit( $mf['id']."_id", + ( $mf['custom_id'] != '' ? $mf['custom_id'] : 'mf_'.$mf['id'] ), + '
+
+ '.$form_data.$mf_form_data.' + Custom ID: + +
+ Clear to reset to default ID.

+ +

+
' ).' +

'.( $mf_custom_id_update_message != '' ? ''.$mf_custom_id_update_message.'
' : '' ).' + ' : + quick_edit( $mf['id'], + 'Type Not Set', + '
+
+ '.$form_data.$mf_form_data.' + Set field type: + + + +
+
' ).'
+ Field Style Not Set' + ).'
+ + '.( $mf['active'] == 't' ? 'Active' : 'Active' ).'  
+ '.( $mf['type'] > 1 && $mf['type'] < 20 ? ''.($mf['required']=='t'?'Required':'Required').'  ':' ').' + + '; + } + + $r['text'] .= ' + '; + + if( !empty($mf_text) ) + $r['text'] .= ' '.$mf_text.''; + else + $r['text'] .= '  '; + + $r['text'] .= ' + '.( $mf['expanded'] == 't' ? + '[Contract]
+ [Delete] 
+ [Add Above] ' + : + '[Expand]' + ).' + + + '.( $mf['expanded'] == 't' ? ''.$mf_field_content.'' : '' ).' + + '; + } + } + + + $r['text'] .= ' + [Add New Field] + [Expand All] + [Contract All] + + '; + $r['success'] = true; + + return( $r ); + + +} + + // MagicForm - Display Form + +function magic_form_display( $mf_id, $mf_styles, $mf_fiid = null, $mf_def_data = array(), $mf_level = 0 ) + { + + global $mf_formats; + + // Get the fields specifications for the specified form + $mf_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id = '$mf_id' ORDER BY sort;", CONN_STR, FALSE ); + + // If this is level 0, get any data supplied from earlier form submissions, if level > 0 then use data we already have + if ($mf_fiid != null) { + $mf_data = reg_db_auto_get_data( "SELECT * FROM ".MF_DATA_TABLE." WHERE fiid = '$mf_fiid' ORDER BY sort;", CONN_STR, FALSE ); + } else { + $mf_data = &$mf_def_data; + } + + // Initialize results array + $r = array( 'success' => true, 'text' => '', 'required' => false ); + $r_scriptInit = "'; + $v['input'] = $sub_func.$sel; + break; + + case 7: // File Upload + $inp = trim( str_replace( array( '|', '~' ), '', $inp ) ); + $v['input'] = ' + + '; + if( $inp != '' ) { + $v['input'] .= ''; + } + $v['input'] .= '
'.$inp.' Delete
'; + + $ans = explode( "|", $mf['data1'] ); // Separate answers + + $an = explode( '~', $ans[0] ); + if( !empty($an[1]) ) { + $sub = magic_form_display( $an[1], $mf_styles, null, $mf_def_data, $mf_level ); + if( $sub['success'] ) { + $v['sub_forms'] .= '
'.str_replace( "{sub_form}", $f['sub_form'], $sub['text'] ).'
'; + } else { + $v['sub_forms'] .= '

FORM ERROR: Unable to process sub-form for checkbox: '.$mf['title'].'

'; + } + } + $an = explode( '~', $ans[1] ); + if( !empty($an[1]) ) { + $sub = magic_form_display( $an[1], $mf_styles, null, $mf_def_data, $mf_level ); + if( $sub['success'] ) { + $v['sub_forms'] .= '

'.str_replace( "{sub_form}", $f['sub_form'], $sub['text'] ).'
'; + } else { + $v['sub_forms'] .= '

FORM ERROR: Unable to process sub-form for checkbox: '.$mf['title'].'

'; + } + } + break; + + case 20: // Section Title + $v['title'] = stripslashes($mf['data1']); + $v['input'] = ''; + break; + + case 21: // Misc. Text + $v['title'] = ''; + $v['input'] = stripslashes($mf['data1']); + break; + + case 24: // Image + switch ($mf['size']) { + case 'original': + $image_size_url = ORIGINAL; + break; + case 'resized': + $image_size_url = RESIZED; + break; + case 'midsized': + $image_size_url = MIDSIZED; + break; + default: + case 'thumb': + $image_size_url = THUMB; + break; + } + + $v['image'] = ''; + break; + + case 25: // File + $v['title'] = ''.(trim($mf['title'])!=''?$mf['title']:$mf['file']).''; + break; + + case 22: // Horizontal Line + case 23: // Blank Line (space) + default: + $v['title'] = ''; + $v['input'] = ''; + break; + + } // Type + + $r['text'] .= parse_string_view( $f['body'], $view_tags ); + + } // Active + } // Each field + + // If not at the last column, fill with blank cells before closing + if( $current_column < $mf_styles[$current_style]['cols'] ) { + for( $i=$current_column ; $i<=$mf_styles[$current_style]['cols'] ; $i++ ) { + $r['text'] .= $mf_styles[$current_style]['col_empty']; + } + } + $r['text'] .= $mf_styles[$current_style]['row_end'].$mf_styles[$current_style]['end']; + $r['text'] .= $r_scriptInit."\n"; + + } + + if( !empty($problem) ) { + echo "Problems processing this form.

$problem

"; + } + + return( $r ); + + } + + +/* MagicForm - Get Fields + * + * returns fields as array where index is field 'id' containing + * integer id Record ID of form field + * text form_id Raw ID of form field + * text custom_id Custom ID of form field + * text title Title + * integer type Type of field + * text active Always 't' since only active fields are returned + * integer level Sub-form level, 1 = top level + * integer field_order Sequential display order, sub-form fields fall in just after parent + */ + +function magic_form_get_fields( $mf_id, $mf_level = 0 ) +{ + + static $mf_fields; + static $field_numb; + + // If this is the first entry, clear $mf + if ($mf_level == 0) { + $mf_fields = array(); + $field_numb = 0; + } + + $mf_level++; + + // Get the fields specifications for the specified form + $mf_data = reg_db_auto_get_data( "SELECT id, form_id, custom_id, title, type, active, data1 FROM ".MF_TABLE." WHERE form_id ~ '^$mf_id$' ORDER BY sort;", CONN_STR, FALSE ); + + if (is_array($mf_data)) { + foreach ($mf_data as $mf) { + if( $mf['active'] == 't' && $mf['type'] > 0 && $mf['type'] < 20) { + + // Add this field to the list + $mf['level'] = $mf_level; + $mf['field_order'] = ++$field_numb; + $mf_fields[$mf[id]] = $mf; + + // Look for any sub-fields + $opts = explode( "|", $mf['data1']); + foreach( $opts as $opt ) { + $x = explode( "~", $opt ); + if ($x[1] != '') { + magic_form_get_fields( $x[1], $mf_level ); + } + } + } // Active + } // Each field + } + + // If this is not level 0 then don't bother returning results + if ($mf_level > 1) { + return; + } + + //echo "

".print_r($mf_fields,1)."
";exit; + return $mf_fields; +} + + + // MagicForm - Submit Form + +function magic_form_submit($mf_id, $mf_fiid = null, $mf_def_data = null, $mf_level = 0, $v2 = false) +{ + + global $mf_formats; + + static $values = array(); + if ($v2 != false) { + $values = $v2; + } + + $mf_level++; // Incriment MagicForm recurse level (not shure why we're doing this though) + + // Get form field specifications + + $mf_fields = reg_db_auto_get_data( "SELECT * FROM ".MF_TABLE." WHERE form_id = '$mf_id' ORDER BY sort;", CONN_STR, FALSE ); + + // Initialize result array + + $mf_results = array( 'success' => true, 'data' => array(), 'total_value' => 0, 'html' => '', 'csv' => ($mf_level==1?'"ID","Sub Form Level","Title","Type","Data","Value","Valid","Required","Notes"'."\n":''), 'problem' => '' ); + + $problem = ''; + $current_collumn = 1; + + $mf_total_value = 0; // Accumulates a total of the optional value data for checkboxes, picklists, and radio buttons + + if (is_array($mf_fields)) { + + reset( $mf_fields ); + foreach( $mf_fields as $mf ) { + + // If it's a supplied data field and it's active (type 0 is "not set" so don't use it) + if (($mf['type'] > 0 && $mf['type'] < 20 || $mf['type'] == 31) && $mf['active'] == 't') { + + // Determine Field ID + + $mf_field_id = ( $mf['custom_id'] != '' ? $mf['custom_id'] : 'mf_'.$mf['id'] ); + + $res = array( + 'id' => $mf_field_id, + 'level' => $mf_level, + 'title' => $mf['title'], + 'type' => $mf['type'], + 'txt_typ' => '', + 'value' => '', + 'txt_val' => '', + 'opt_num' => '', + 'valid' => true, + 'required' => false, + 'numb_val' => '', + 'failure' => '' + ); + + // Set text for field type + + switch ($mf['type']) { + case 1: + $res['txt_typ'] = 'Checkbox'; + $inData = filter_request('mf_'.$mf['id']); + break; + case 2: + $res['txt_typ'] = 'Number'; + $inData = filter_request('mf_'.$mf['id'], FILTER_SANITIZE_NUMBER_FLOAT, 0); + break; + case 3: + $res['txt_typ'] = 'Text'; + $inData = filter_request('mf_'.$mf['id']); + break; + case 4: + $res['txt_typ'] = 'Text Box'; + $inData = filter_request('mf_'.$mf['id']); + break; + case 5: + $res['txt_typ'] = 'Pick List'; + $inData = filter_request('mf_'.$mf['id'], FILTER_SANITIZE_NUMBER_INT, 0); + break; + case 6: + $res['txt_typ'] = 'Radio Buttons'; + $inData = filter_request('mf_'.$mf['id'], FILTER_SANITIZE_NUMBER_INT, 0); + break; + case 7: + $res['txt_typ'] = 'File Upload'; + break; + case 31: + $res['txt_typ'] = 'Calculated'; + $input = false; + break; + default: + break; + } + + + // If we didn't get previously submitted data + if ($mf_def_data == null) { + $inp = $inData; // Get form input value + } else { + $inp = $mf_def_data[$mf_field_id]; // Get value from supplied array + } + + + $sub = ''; // Assume no sub-form + + // Check if a required field is not populated - don't check type 1, > type 20, or file uploads (7) and only if required. + if ($mf['type'] > 1 && $mf['type'] < 20 && $mf['type'] != 7 && $mf['required'] == 't') { + $res['required'] = true; + if ($inp == '' || ($mf_type['type']==7 && $inp=='none')) { // if field is required and not provided + $res['valid'] = false; + $res['failure'] = 'Required response not provided.'; + $mf_results['problem'] .= '
  • "'.$mf['title'].'" requires a response that was not provided.
  • '."\n"; + } + } + + // Get id or custom id for use with $variables array + $fid = ( $mf['custom_id'] == '' ? 'mf_'.$mf['id'] : $mf['custom_id'] ); + + $res['num_val'] = ' '; + switch ($mf['type']) { + + case 1: // Checkbox + + $ans = explode( "|", $mf['data1'] ); // Separate possible answers + + $sub_id = ''; + + if ($inp == 'on') { + $res['value'] = 't'; + $res['txt_val'] = 'Yes'; + $res['opt_num'] = '1'; + $an = explode( '~', $ans[0] ); + $sub_id = $an[1]; + if ($an[2] != '') { + $res['numb_val'] = $an[2]; + } + } else { + $res['value'] = 'f'; + $res['txt_val'] = 'No'; + $res['opt_num'] = '2'; + $an = explode( '~', $ans[1] ); + $sub_id = $an[1]; + if ($an[2] != '') { + $res['numb_val'] = $an[2]; + } + } + + if ($sub_id != '') { + $sub = magic_form_submit( $sub_id, $mf_fiid, $mf_def_data, $mf_level ); + if (!$sub['success']) { + $mf_results['problem'] .= $sub['problem']; + } else { + $mf_total_value += $sub['total_value']; + } + } + + if ($an[4] != '' && isset($values[$an[4]])) { + $values[$fid] = $values[$an[4]]; + $res['failure'] = 'Value from '.$an[4]; + } else { + $values[$fid] = $an[2]; // Save option numeric value for calculated fields + } + + $res['num_val'] = $values[$fid]; + + break; + + case 2: // Number + + $inp = preg_replace( "/[\$,]/", "", $inp ); + $values[$fid] = $inp; + $inp = filter_var($inp, FILTER_SANITIZE_NUMBER_FLOAT ); + + case 3: // Text + case 4: // Text Box + + // Extract field format specs + + $mf_cf = explode( '~', $mf['format'] ); + $mf_cf_size = $mf_cf[1] + ($mf_cf[2]>0?1:0) + $mf_cf[2]; + $mf_cf_out = str_replace( '{chars}', $mf_cf[1], $mf_formats[$mf_cf[0]]['format'] ); + $mf_cf_out = str_replace( '{prec}', $mf_cf[2], $mf_cf_out ); + + if (trim($inp) != '') { + + // Clean input string and block high-bit characters + $inp = filter_var($inp, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH ); + + if ($mf_cf[3] != '' && $inp < $mf_cf[3]) { + $res['valid'] = false; + $res['failure'] .= 'Value not in range'; + $mf_results['problem'] .= '
  • "'.$mf['title'].'" requires a value greater than or equal to '.$mf_cf[3].'.
  • '."\n"; + } + + if ($mf_cf[4] != '' && $inp > $mf_cf[4]) { + $res['valid'] = false; + $res['failure'] .= 'Value not in range'; + $mf_results['problem'] .= '
  • "'.$mf['title'].'" requires a value less than or equal to '.$mf_cf[4].'.
  • '."\n"; + } + + if ($mf_formats[$mf_cf[0]]['regex'] != '' && preg_match( '/^'.$mf_formats[$mf_cf[0]]['regex'].'$/', $inp ) == 0) { + $res['valid'] = false; + $res['failure'] .= 'Input format not valid'; + $mf_results['problem'] .= '
  • "Value supplied to '.$mf['title'].'" was not valid. Must be '.$mf_cf['0'].' (i.e. '.$mf_formats[$mf_cf[0]]['sample'].').
  • '."\n"; + } + } + + $res['value'] = ( $mf_cf_out != '' ? sprintf( $mf_cf_out, $inp ) : $inp ); + $res['txt_val'] = $res['value']; + + break; + + case 5: // Picklist + + $res['opt_num'] = $inp; + $opts = explode( "|", $mf['data1'] ); // Separate Options + if ($inp != '') { // If an options is selected + $x = explode( "~", $opts[$inp-1] ); // Separate data for selected option + $res['value'] = $x[0]; // Use option name + if ($x[2] != '') { + $res['numb_val'] = $x[2]; + } + } else { + $res['value'] = ''; + } + + // Check selected option for Sub-Form + $n = 1; + foreach ($opts as $opt) { + $an = explode( "~", $opt ); + if ($inp == $n && !empty($an[1])) { + $sub = magic_form_submit( $an[1], $mf_fiid, $mf_def_data, $mf_level ); + + if (!$sub['success']) { + $mf_results['problem'] .= $sub['problem']; + } + + // Save any option value for calculated fields + if ($an[4] != '' && isset($values[$an[4]])) { + $values[$fid] = $values[$an[4]]; + } else { + $values[$fid] = $an[2]; + } + $res['num_val'] = $values[$fid]; + + $mf_total_value += $sub['total_value']; // ??? CPS + } + $n++; + } + + $res['txt_val'] = $res['value']; + break; + + case 6: // Radio Buttons + + $res['opt_num'] = $inp; + $opts = explode( "|", $mf['data1'] ); // Separate Options + if ($inp != '') { // If an options is selected + $x = explode( "~", $opts[$inp-1] ); // Separate data for selected option + $res['value'] = $x[0]; // Use option name + if ($x[2] != '') { + $res['numb_val'] = $x[2]; + } + } else { + $res['value'] = ''; + } + $opts = explode( "|", $mf['data1'] ); + + // Check selected button for Sub-Form + $n = 1; + foreach ($opts as $opt) { + $an = explode( "~", $opt ); + if ($inp == $n && !empty($an[1])) { + + $sub = magic_form_submit( $an[1], $mf_fiid, $mf_def_data, $mf_level ); + + if (!$sub['success']) { + $mf_results['problem'] .= $sub['problem']; + } else { + $mf_total_value += $sub['total_value']; + } + // Save any option value for calculated fields + $values[$fid] = $an[2]; + $res['num_val'] = $values[$fid]; + } + $n++; + } + + $res['txt_val'] = $res['value']; + break; + + case 7: // File Upload - Converted to using File Server + + $new_filename = ''; + + $existing_file = trim(filter_request('exist_mf_'.$mf['id'])); + $new_file = filter_request('mf_'.$mf['id']); + $delete_file_request = filter_request('delete_mf_'.$mf['id']); + + // If there's a new file uploaded + if ($new_file['name'] != '') { + + $existing_file = ''; + + // If we can't get the uploaded file + if (!($new_filename = reg_file_upload( 'mf_'.$mf['id'] ))) { + $mf_results['problem'] .= '
  • Unable to upload file for "'.$mf['title'].'".
  • '."\n"; + $new_filename = ''; + + // File upload successful + } else { + + // Get current saved uploaded files that are older than 2 days + $expire = date('m/d/Y', strtotime('-2 days')); + $qs = "select * from mf_temp_file where upload_time < '$expire';"; + $del = reg_db_auto_get_data( $qs, CONN_STR, FALSE ); + + // If there are any old unused files that need to be deleted + if (is_array($del) && count($del) > 0) { + + // Delete each expired file + foreach ($del as $d_file) { + reg_file_delete($d_file['file_name']); + } + + // And delete it from mf_temp_file + $qs = "DELETE FROM mf_temp_file WHERE file_name = '".$d_file['file_name']."' AND upload_time = '".$d_file['upload_time']."';"; + reg_db_auto_exec( $qs, CONN_STR, FALSE ); + } + + // Now add the new file to mf_temp_file to keep track of it till it's used or timed out + $qs = "INSERT INTO mf_temp_file (file_name, upload_time) VALUES ('$new_filename', 'now' );"; + reg_db_auto_exec( $qs, CONN_STR, FALSE ); + } + + // Or if we're deleting an existing file + } elseif ($delete_file_request == 'on') { + + $existing_file = ''; // We'll let the code above delete the file from the server when it times out. + + // Or if we have an existing file + } elseif ($existing_file != '') { + + $new_filename = $existing_file; + + } + + // if field is required and not provided + if ($mf['required'] == 't' && $new_filename == '' ) { + $res['valid'] = false; + $res['failure'] = 'Required response not provided.'; + $mf_results['problem'] .= '
  • "'.$mf['title'].'" requires a response that was not provided. SS
  • '."\n"; + } + + $res['value'] = $new_filename; + $res['txt_val'] = ''.$new_filename.''; + + break; + + + // Calculated field + + case 31: + + // Replace view_tag friendly [] characters with {} for use with standard token replacement function + $f = str_replace( '[', '{', str_replace( ']', '}', $mf['data1'] ) ); + + // Perform calculation + $inp = do_math( $f, $values ); + + $inp = str_replace( '{', '[', str_replace( '}', ']', $inp ) ); + + // Check for an error message returned + if( $inp{0} == 'E' ) + { + $res['failure'] = $inp; + $res['valid'] = false; + $inp = ''; + } + + $res['value'] = $inp; + $values[$fid] = $inp; + $res['num_val'] = $inp; + + // If this is a Grand_Total field, then report this value as the value result of the form submission + if( $mf['custom_id'] == 'Form_Value') + { + $form_value = $inp; + } + + break; + + + + default: + break; + + } // Type + + // Push the current result and any sub-form results onto the end of the result array. + if ($mf['type'] > 0) + $mf_results['data'][$mf['id']] = $res; + $mf_results['csv'] .= '"'.$res['id'].'","'.$res['level'].'","'.$res['title'].'","'.$res['txt_typ'].'","'.$res['value'].'","'.$res['numb_val'].'","'.($res['valid']?'t':'f').'","'.($res['required']?'t':'f').'","'.$res['failure'].'"'."\n"; + $x = ''; for( $i=0 ; $i<$mf_level ; $i++ ) $x .= '  '; + $mf_results['html'] .= ''.$res['id'].''.$x.$res['title'].' '.$res['txt_typ'].' '.( $res['txt_val'] != '' ? $res['txt_val'] : $res['value'] ).' '.$res['numb_val'].' '.($res['valid']?'Yes':'No').''.($res['required']?'Yes':'No').''.$res['failure'].' '."\n"; + + // If there's a sub-form + + if (is_array($sub)) { + + // Add data from sub-form + $mf_results['html'] .= $sub['html']; + $mf_results['csv'] .= $sub['csv']; + while (list($key, $val) = each($sub['data'])) { + $mf_results['data'][$key] = $val; + } + } + + } // Active + + } // Each field + + } + + if ($mf_level == 1) { + $mf_results['html'] = ''."\n".$mf_results['html']."
    Field IDTitleTypeDataValueData ValidRequiredFailure
    \n"; + } + if ($mf_results['problem'] != '') { + $mf_results['success'] = false; + } + + $mf_results['total_value'] = $mf_total_value; + return( $mf_results ); + +} + + // MagicForm - Store Data + +function magic_form_store_data( $mf_id, $mf_fiid, $mf_def_data ) +{ + + // Delete previous entries using the supplied form instance id ($mf_fiid) + + $qs = "BEGIN;\nDELETE FROM ".MF_DATA_TABLE." WHERE fiid = $mf_fiid;\n"; + + // Store new data + + foreach ($mf_def_data as $mf) { + $qs .= "INSERT INTO ".MF_DATA_TABLE." ( fiid, form_id, field_id, level, title, type, txt_type, value, numb_value, txt_value, opt_num, valid, required, failure ) + VALUES ( $mf_fiid, $mf_id, '".addslashes($mf['id'])."', ".(empty($mf['level'])?'NULL':$mf['level']).", '".addslashes($mf['title'])."', + ".(empty($mf['type'])?'NULL':$mf['type']).", '".addslashes($mf['txt_type'])."', '".addslashes($mf['value'])."', + ".($mf['numb_val']!=''?$mf['numb_val']:'NULL').", '".addslashes($mf['txt_value'])."', ".($mf['opt_num']>0?$mf['opt_num']:'NULL').", + '".($mf['valid']?'t':'f')."', '".($mf['required']?'t':'f')."', '".addslashes($mf['failure'])."' );\n"; + } + $qs .= "COMMIT;\n"; + + if ( !reg_db_auto_exec($qs)) { + return( false ); + } else { + return( true ); + } + +} + + +?> \ No newline at end of file diff --git a/front-end/reg_functions.inc b/front-end/reg_functions.inc new file mode 100644 index 0000000..bb9d5ac --- /dev/null +++ b/front-end/reg_functions.inc @@ -0,0 +1,8112 @@ + + '; + } + +// Display E-Mail if debug level > 0 + +function debug_mail( $to, $subject, $message, $headers = '', $parameters = '' ) +{ + + if( $GLOBALS['reg_config']['debug_mail'] ) + { + echo '

    + + + + + + + +
    MAIL DEBUG
    Recipient(s): '.$to.'
    Subject: '.$subject.'
    Headers:
    '.$headers.'
    Parameters:
    '.$parameters.'
    '.$message.'
    +

    + '; + return( true ); + } + else + return( mail( $to, $subject, $message, $headers, $parameters ) ); + +} + + +// Clean up input parameters and test them for proper type of data + +function clean_input( $var_name, $type = 'text', $required = false ) +{ + + $reason = ''; // If problems, indicates reason here + + // Trim whitespace, slashes, and stupid characters + + $in = stripslashes( trim( $_REQUEST[$var_name] ) ); + + if( $in != '' ) + { + switch( $type ) + { + + case 'int': + if (!is_numeric($in)) { + $reason = 'not an integer'; + } else { + $in = intval($in); + } + break; + + case 'float': + $in = preg_replace("/^(\\$)?(.*)$/i", "\\2", $in); + if (!is_numeric($in)) { + $reason = 'not a valid number'; + } else { + $in = (float) $in; + } + break; + + case 'phone': + if (preg_match("/^((\([0-9]{3}\))[ ]*|([0-9]{3}) *-* *)?[0-9]{3} *-* *[0-9]{4} *.{0,10}$/i", $in) == 0) { + $reason = 'not a valid phone number'; + } else { // Reformat as we want it + $in = preg_replace("/^((\(([0-9]{3})\))[ ]*|(([0-9]{3}))[ -]*)?([0-9]{3}) *-* *([0-9]{4}) *(.{0,10})$/i", "\\3\\4-\\6-\\7 \\8", $in); + } + break; + + case 'zip': + // Check if it's a US ZIP + if (preg_match("/^(([0-9]{5})([ -+]?([0-9]{4}))?)$/i", $in) != 0) { + $in = preg_replace("/^([0-9]{5})[ -+]?([0-9]{4})$/i", "\\1-\\2", $in); + if (strlen($in) < 8) { + $in = preg_replace("/^([0-9]{5}).*/i", "\\1", $in); + } + } elseif (preg_match("/^[a-zA-Z]\d[a-zA-Z][ -]?\d[a-zA-Z]\d$/i", $in ) != 0) { + $in = preg_replace("/^([a-zA-Z]\d[a-zA-Z])[ -]?(\d[a-zA-Z]\d)$/i", "\\1 \\2", $in); + } + else + $reason = 'not a valid ZIP or Postal Code'; + break; + + case 'state': + global $si_states_array; + if (!isset($si_states_array[$in])) { + $reason = 'not a valid state code'; + } + break; + + case 'country': + global $si_countries_array; + if (!isset($si_countries_array[$in])) { + $reason = 'not a valid country code'; + } + break; + + case 'email': + if (preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", $in) == 0) { + $reason = 'not a valid E-Mail address'; + } + break; + + case 'creditcard': + global $si_cc_verify; + $match = FALSE; + reset($si_cc_verify); + while (list($k, $v) = each($si_cc_verify)) { + if (preg_match("/".$v."/i", $in) != 0) { + $match = TRUE; + break; + } + } + if (!$match) { + $reason = 'not a valid credit card number'; + } + break; + + case 'date': + if (($t = strtotime($in)) === -1) { + $reason = 'not a valid date'; + } else { + $in = date('n/j/Y', $t); + } + break; + + case 'text': + break; + + case 'inet': + if (preg_match("/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i", $in) == 0) { + $reason = 'not a valid IP address or netmask'; + } + break; + + default: + break; + + } + } + + // Check for a required field + + if ($required && $in == '') + $reason .= ($reason != '' ? ' and is ':'').'required'; + + $GLOBALS[$var_name] = $in; + return $reason; + +} + +// Alternative strong credit card check function. +// NOTE: The $si_cc_verify stuff SHOULD be passed rather than use a global to avoid issues with changes in the global values + +function credit_card_check( $Num, $si_cc_verify, $accepted = 0 ) +{ + + $Num = preg_replace("/[^[:digit:]]/", "", $Num); + + // Check for Accepted Card List + $cc_accepted = ($accepted - 0); + if( $cc_accepted == 0 ) + { + echo "

    ERROR: credit_card_check() requires bitmap for accepted cards

    "; + exit; + } + + // Permit secret test code + if( $Num == "0011001100110011" || $Num == "5454545454545454" ) { + return( "Test" ); + } else { + // Check each selected card type for a pattern match + $Name = ""; + reset( $si_cc_verify ); + $i = 0; + while( list($k, $v) = each($si_cc_verify) ) + if( ( $cc_accepted & pow(2,$i++) ) && preg_match( $v, $Num ) ) + { + $Name = $k; + break; + } + } + + // Fail if nothing matched + + if( $Name == "" ) + return( FALSE ); + + // Now do strong test + + $Num = strrev($Num); + + $Total = 0; + + for ($x=0; $x +

    + Close +
    QuickTip
    +
    +
    +
    '.$t.'
    + '.$message.' +
    +
    + + '.$title.'' ); + +} + +// Returns Title text with QuickEdit Pop-Up support - Uses QuickTip Java functions + +function quick_edit( $key, $prompt, $form ) +{ + if( trim($prompt) == '' || trim($form) == '' ) + return( false ); + + $t = strip_tags( $prompt ); // Get rid of any HTML tags in title + + return( '
    +
    + Close +
    QuickEdit
    +
    +
    + '.$form.' +
    +
    + + '.$prompt.'' ); + +} + + + + + + +/*********************************************************************** + * * + * DATABASE ABSTRACTION FUNCTIONS * + * * + ***********************************************************************/ + + +// Create a connection to database specified $conn_str, + + function reg_db_connect( $conn_str, $fail_mode ) + { + static $last_connect = ''; + static $ret = 0; + + // forcing static data connection + if( $ret != 0 ) { + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_connect() - Using existing connection - \$conn_str = ".$conn_str."

    "; + return($ret); + } + + // If we're using static connections, check to see if this is trying to open the same connection again + + if( DB_STATIC ) + { + + // Check to see if this is trying to open the same connection again + + if( $last_connect == $conn_str ) + { + // If so just use the current connection + + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_connect() - Using existing connection - \$conn_str = ".$conn_str."

    "; + return( $ret ); + } + + // If we need to open a different connection, close the current one first + + if( $ret != 0 ) + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_connect() - Closing current database connection

    "; + reg_db_close( $ret ); + + $last_connect = $conn_str; + + } + + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_connect()[".__LINE__."]: \$conn_str = ".$conn_str."

    "; + + switch( DB_TYPE ) + { + case "postgres": + $ret = pg_connect( $conn_str ); + pg_query($ret, 'set search_path to registrations,public;'); + break; + default: + return( 0 ); + } + + if( !$ret && $fail_mode ) + html_error( DB_ERROR_MSG, 1 ); + + return( $ret ); + + } + +// Close the connection to database specified by the handle dbd + + function reg_db_close( $dbd ) + { + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_close() - Not set to close connections current in this code

    "; +/* - We're not closing anything now. + // IF we're using static connections, don't actually close it + + if( DB_STATIC == TRUE ) + return( TRUE ); + + switch( DB_TYPE ) + { + case "postgres": + $ret = pg_close( $dbd ); + break; + default: + return( 0 ); + } + + return( $ret ); +*/ + } + +// Execute an SQL query + + function reg_db_exec( $dbd, $qs ) + { + + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    reg_db_exec()[".__LINE__."]: \$qs = ".$qs."

    "; + + switch( DB_TYPE ) + { + case "postgres": + $ret = pg_query( $dbd, $qs ); + break; + + default: + return( 0 ); + } + + return( $ret ); + } + +// Get data and store in associative indices, using the field names as keys. + + function reg_db_fetch_row( $res, $i ) + { + + if( $GLOBALS['reg_config']['debug'] >= 3 ) echo "
    db_fetch()[".__LINE__."]: Row = ".$i."

    "; + + if( reg_db_numrows($res) == 0 ) + return( FALSE ); + + switch( DB_TYPE ) + { + case "postgres": + $row = pg_fetch_array( $res, $i, PGSQL_ASSOC ); + break; + + default: + return( FALSE ); + } + + return( $row ); + + } + +// Free result memory. + + function reg_db_freeresult( $res ) + { + + switch( DB_TYPE ) + { + case "postgres": + $ret = pg_freeresult( $res ); + break; + + default: + return( 0 ); + } + + return( $ret ); + } + +// Determine number of rows in a result index + + function reg_db_numrows( $res ) + { + + switch( DB_TYPE ) + { + case "postgres": + $ret = pg_numrows( $res ); + break; + + default: + return( -1 ); + } + + return( $ret ); + } + + +/*********************************************************************** + * + * BEGIN Auto functions + * + ***********************************************************************/ + +// Retrieve a result as an array based soley on a query + +function db_auto_get_row( $qs, $i = 0, $conn_str = CONN_STR, $fail_mode = 'FALSE' ) +{ + + if( $GLOBALS['reg_config']['debug'] >= 2 ) echo "
    db_auto_get_row()[".__LINE__."]: \$qs = $qs, Row = $i

    "; + + if( !($dbd = reg_db_connect( $conn_str, $fail_mode )) ) + return( FALSE ); + + if( ($res = reg_db_exec($dbd, DB_SET_DATE_STYLE_STRING.$qs)) ) + { + $row = reg_db_fetch_row( $res, $i ); + reg_db_freeresult( $res ); + } + + reg_db_close( $dbd ); + return( $row ); +} + + // Retrieve a set of results based soley on a query + +function reg_db_auto_get_data( $qs, $conn_str = SI_CONN_STR, $fail_mode = FALSE, $rows = 500, $start = 0 ) +{ + + if( $GLOBALS['reg_config']['debug'] >= 2 ) echo "
    reg_db_auto_get_data()[".__LINE__."]: \$qs = $qs, \$rows = $rows, \$start = $start

    "; + + if( !($dbd = reg_db_connect( $conn_str, $fail_mode)) ) + return( FALSE ); + + if( ($res = reg_db_exec($dbd, SI_DB_SET_DATE_STYLE_STRING.$qs)) ) + { + $totalrows = pg_NumRows( $res ); + $stop = $start + $rows; + if( $stop > $totalrows ) + $stop = $totalrows; + + for( $i=$start ; $i<$stop ; $i++ ) + { + $data["$i|$totalrows"] = reg_db_fetch_row( $res, $i ); + } + } + reg_db_close( $dbd ); + + return( $data ); +} + + // Execute a query. + +function reg_db_auto_exec( $qs, $conn_str = SI_CONN_STR, $fail_mode = 'FALSE' ) +{ + + if( $GLOBALS['reg_config']['debug'] >= 2 ) echo "
    reg_db_auto_exec()[".__LINE__."]: \$qs = $qs, \$conn_str = $conn_str

    "; + + $dbd = reg_db_connect( $conn_str, $fail_mode ); + if( !$dbd ) + return( 0 ); + + + if( !( $result = reg_db_exec($dbd, $qs)) ) + { + reg_db_close( $dbd ); + return( 0 ); + } + else + { + $oid = pg_last_oid( $result ); + reg_db_close( $dbd ); + if( empty($oid) || $oid == -1 ) + return( 1 ); + else + return( $oid ); + } +} + + + +/*********************************************************************** +* * +* IMAGE/FILE FUNCTIONS * +* * +***********************************************************************/ + +function reg_load_imageServer() +{ + if (!class_exists('Reg_Toolkit_Image_Server')) { + include_once GLM_APP_BASE.'Common/Registrations_V3/classes/ImageServer/Server.php'; + } +} + +function reg_process_image($image) +{ + reg_load_imageServer(); + $is = new Reg_Toolkit_Image_Server(); + return $is->imageUpload($image); +} + +function reg_delete_image($image) +{ + reg_load_imageServer(); + $is = new Reg_Toolkit_Image_Server(); + $message = $is->imageDelete($image); +} + + +function reg_load_fileServer() +{ + if (!class_exists('Reg_Toolkit_FileServer_AdapterAbstract')) { + include_once GLM_APP_BASE.'Common/Registrations_V3/classes/FileServer/AdapterAbstract.php'; + } + if (!class_exists('Reg_Toolkit_FileServer_FileAdapter')) { + include_once GLM_APP_BASE.'Common/Registrations_V3/classes/FileServer/FileAdapter.php'; + } +} + +// Store away an uploaded file + +/* + * Save an uploaded file to the image/file server + * + * $form_field is the "name" of the field in the submitted form. + * + * This function returns the name of the file as assigned by the image/file server + */ +function reg_file_upload( $form_field ) +{ + reg_load_fileServer(); + $fs = new Reg_Toolkit_FileServer_FileAdapter(); + $res = $fs->upload($form_field); + return $res['name']; +} + +/* + * Delete a file from the file/image server + * + * $file_name is the name of the file as assigned by the file/image server on upload + */ +function reg_file_delete( $file_name ) +{ + reg_load_fileServer(); + $fs = new Reg_Toolkit_FileServer_FileAdapter(); + $res = $fs->delete($file_name); + return $res; +} + +// Read the specified file from the local virtual server and return the results +function file_get( $file_name, $max_size = 0, $base_path = '' ) +{ + if( !is_readable ( $base_path."/".$file_name ) ) + return( FALSE ); + + $f = fopen( $base_path."/".$file_name, "r" ); + $s = filesize($base_path."/".$file_name); + if( $max_size == 0 || $s <= $max_size ) + $file_contents = fread( $f, $s ); + else + return( FALSE ); + + return( $file_contents ); +} + + +/** + * GENERAL SUPPORT FUNCTIONS / CLASSES + **/ + +class timestampfunc +{ + + function newdate( $timestamp ) + { + $z = date( "m:Y", $timestamp ); + $z = explode( ":", $z ); + return $z; + } + + function first_of_month( $timestamp ) + { + $z = $this->newdate( $timestamp ); + $first_of_month = $z[0]."/1/".$z[1]; + return strtotime( $first_of_month ); + } + + function first_last_month( $timestamp ) + { + $z = $this->newdate( $timestamp ); + $z[0]--; + if( $z[0] <= 0 ) + { + $z[0] = 12; + $z[1]--; + } + $first_of_month = ($z[0])."/1/".$z[1]; + return strtotime( $first_of_month ); + } + + function first_next_month( $timestamp ) + { + $z = $this->newdate( $timestamp ); + $z[0]++; + if( $z[0] > 12 ) + { + $z[0] = 1; + $z[1]++; + } + $first_of_month = ($z[0])."/1/".$z[1]; + return strtotime( $first_of_month ); + } + + function first_of_Xmonth( $timestamp, $x ) + { + $z = $this->newdate( $timestamp ); + $r = mktime( 0,0,0, ($z[0]+$x), 1, $z[1] ); + return $r; + } + +} + + + // Return Positive values only, otherwise 0 + +function pos_value( $value ) +{ + + if( $value > 0 ) + return( $value ); + return( 0 ); +} + + + // Format a number as US Dollars + +function money( $value, $option = "" ) +{ + + if( $option == "NOPREFIX" ) + $prefix = ""; + else + $prefix = "$"; + + // Do value sanity check + + if( !is_numeric( $value ) ) + return( $prefix."0.00" ); + + return( $prefix.number_format($value, 2, ".", "," ) ); +} + + + // Convert "key^value~key^value" string to an array + +function strtoarray( $s ) +{ + + $a = array(); + + // Create array of entries - If there's less than 2 entries, fail + + if( count($ea = explode( '~', $s )) < 2 ) + return( FALSE ); + + foreach( $ea as $e ) + { + // Each entry must have exactly 2 parts + + if( count($d = explode( "^", $e )) != 2 ) + return( FALSE ); + + $a[trim($d[0])] = trim($d[1]); + } + + return( $a ); +} + + + // Convert array to a "key^value~key^value" string + +function arraytostr( $a ) +{ + + $s = ''; + + // Supplied value must be array of 2 or more entries + + if( !is_array($a) || count($a) < 2 ) + return( FALSE ); + + $sep = ""; + + while( list($k,$v) = each($a) ) + { + $s .= $sep."$k^$v"; + $sep = '~'; + } + + return( $s ); +} + + + // Replace {tokens} + +function replace_tokens( $s, $tokens ) +{ + + if( !is_array($tokens) ) + { + echo '

    ERROR: replace_tokens() - Parameter 2 ($tokens) is not an array

    '; + exit; + } + + while( list($k,$v) = each($tokens) ) + { + $s = str_replace( "{".$k."}", $v, $s ); + } + + return( $s ); + +} + + + // Conditionally replace tokens + +function cond_replace_tokens( $s, $tokens, $x="cond" ) +{ + + if( !is_array($tokens) ) + { + echo '

    ERROR: cond_replace_tokens() - Parameter 2 ($tokens) is not an array

    '; + exit; + } + + while( list($k,$v) = each($tokens) ) + { + $p0 = 0; // Reset starting pointer position + + while( ($start = strpos( $s, "", $start )) ) // Find end of {if:} tag + return( "ERROR: cond_replace_tokens() - Can't find end of {if:} tag at $start.

    \n\n".htmlentities(substr($s,$start,500))."
    " ); + + $p = $start + 8 + strlen($k); // Set position where "=" should be if it's used + $cond = substr($s,$p,1); + switch( $cond ) + { + case "=": + case "!": + case ">": + case "<": + $if_val_test = TRUE; // If valid comparison character? + $if_val = substr( $s, $p+1, $if_end-$p-1 ); + break; + default: + $if_val_test = FALSE; + break; + } + + // Separate out strings for both yes and no conditions + + $yes_start = $if_end + 4; // Point past tag + $ci = ""; // Closed {/if} take intro only if there's no {else} + $else_if = strpos( $s, "", $yes_start ); + if( $else_if && ( !$slash_if || ($else_if < $slash_if) ) ) // If there's an {else} + { + $yes_string = substr( $s, $yes_start, $else_if-$yes_start ); + $no_start = $else_if + 11 + strlen($k); // Point past tag + if( !($no_end = strpos( $s, "{/if:$k}-->", $no_start )) ) // If there's no --> end of cond tag + return( "ERROR: cond_replace_tokens() - Matching {/if:} tag not found after {else:} at $start for \"$k\".

    \n\n".htmlentities(substr($s,$start,500))."
    " ); + + $end = $no_end + 9 + strlen($k); + + $no_string = substr( $s, $no_start, $no_end-$no_start ); + } + else + { + $no_string = ""; + if( !($slash_if = strpos( $s, "", $yes_start )) ) // If there's no end of cond tag + return( "ERROR: cond_replace_tokens() - Matching {/if} tag not found at $start for \"$k\".

    \n\n".htmlentities(substr($s,$start,500))."
    " ); + $end = $slash_if + 13 + strlen($k); + $yes_string = substr( $s, $yes_start, $slash_if-$yes_start ); + } + + if( $if_val_test != FALSE ) // If there's a compare value, test with that + switch( $cond ) + { + case "=": + $t = ( trim($v) == trim($if_val) ); + break; + case "!": + $t = ( trim($v) != trim($if_val) ); + break; + case ">": + $t = ( trim($v) > trim($if_val) ); + break; + case "<": + $t = ( trim($v) < trim($if_val) ); + break; + default: + return( "ERROR: cond_replace_tokens() - Internal unknown conditional operator error ($cond)- Code Bad, fix code!" ); + } + else // otherwise just use token value + $t = ( trim($v) != "" ); // if it's not empty use yes_string + + if( $t ) // Replace with appropriate string + $s = substr_replace( $s, $yes_string, $start, $end-$start ); + else + $s = substr_replace( $s, $no_string, $start, $end-$start ); + } + else + $p0 = $start + 1; + } + $p0 = $start; + } + + return( $s ); + +} + + // Replace {file:xxx} token with a file + +function replace_file_tokens( $s ) +{ + + $p0 = 0; // Reset starting pointer position + + while( $p0 < strlen($s) && ($start = strpos( $s, "", $start )) ) // Find end of {file:} tag + return( "ERROR: replace_file_tokens() - Can't find end of {file:} tag at $start.

    \n\n".htmlentities(substr($s,$start,500))."
    " ); + + $filename = substr( $s, $start+10, $file_end-$start-10 ); // Get file name + // Check for a matching tag + + if( ($slash_file = strpos( $s, "", $file_end)) // If there's a {/file} tag + && !($next_file = strpos( $s, "" + } + + $end = $file_end + 4; + + // Check if file name is valid + + if( ($file_contents = file_get( $filename )) == FALSE ) + return( "ERROR: replace_file_tokens() - Can't load specified file '$filename' for {file:} tag.

    \n\n".htmlentities(substr($s,$start,500))."
    " ); + + $s = substr_replace( $s, $file_contents, $start, $end-$start ); + + $p0 = $end; + } + + return( $s ); + +} + + + // Convert an array of data to an HTML table + +function tableize_array($arr, $len=100 ) +{ + // Verify that parameter is actually an array + + if( !is_array($arr) ) + { + $return = "Error: Variable not an array"; + return $return; + } + + // If everything's going fine so far, build out the table + + $return = '

    '; + + foreach( $arr as $key=>$val ) + { + $return .= '\n"; + } + + $return .= "
    '.$key.' '; + if( is_array($val) ) + $return .= tableize_array( $val ); + else + { + if( strlen($val) > $len ) + $x = substr( $val, 0, $len )."......."; + else + $x = $val; + $return .= "
    ".htmlentities( $x )."
    "; + } + + $return .= "
    "; + + return $return; +} + + + + + +/** + * View Processing Functions + */ + + // Parse a "view" file to merge in supplied data + +function parse_view( $file_name, $tokens, $show_unused = TRUE ) + { + if( !($f = file_get( $file_name ) ) ) + { + if( trim($file_name) == '' ) + return( "ERROR: No view file name supplied." ); + else + return( "ERROR: View file '$file_name' not found or unreadable." ); + } + $out = parse_string_view( $f, $tokens, $show_unsued ); + return( $out ); + } + + // Process Lists + +function process_view_lists( $f, $tokens, $pvl_level = 0, $pvl_require_list_data = false ) + { + + // Process list sections + + $out = ""; + + $p = 0; + while( !(($p2 = strpos( $f, "", $p )) || $p2 == $p ) // If there's no }--> following it, then something's wrong + return( "ERROR: parse_view() - Missing name of {list:name} tag at $p.

    ".htmlentities(substr($f,$p,500))."
    " ); + $listname = substr( $f, $p, $p2-$p ); // Get name of this list + + // If list data is required (no empty lists) and we don't have any + + if( $pvl_require_list_data && ( !isset($tokens[$listname]) || !is_array($tokens[$listname]) ) ) + { + $out = "ERROR: parse_view() - No data supplied for list name \"$listname\"."; + if( $GLOBALS['reg_config']['debug_view'] ) + $out .= "

     


    Tags supplied to parse_view() function

    ".tableize_array( $tokens ); + return( $out ); + } + + $p = $p2 + 4; // Move pointer to start of list + if( !($end = strpos( $f, "", $p )) ) // Find end of this list section + return( "ERROR: parse_view() - Matching {/list} tag not found at $p.

    ".htmlentities(substr($f,$p,500))."
    " ); + + // Break up list + + unset( $list ); + $sections = 0; + $sep = ""; + while( ($p2 = strpos( $f, "", $p )) && $p2 < $end ) // While there's still separators in this list + { + $list[$sections] = substr( $f, $p, $p2-$p ); // Save this segment + $p = $p2 + 13 + strlen($listname); // Point past start of separator + if( !($p2 = strpos( $f, "", $p )) || $p2 > $end ) // Find matching {/sep} tag + return( "ERROR: parse_view() - Matching {/sep} tag not found at $p.

    ".htmlentities(substr($f,$p,500))."
    " ); + if( empty($sep) ) // Only use the first separator + $sep = substr( $f, $p, $p2-$p ); + $p = $p2 + 14 + strlen($listname); // Point past end of {/sep} tag + $sections++; // Bump section count + } + + $list[$sections] = substr( $f, $p, $end-$p ); // Store last section of list + $p = $end + 15 + strlen($listname); // Point past this list + $sections++; // Bump section count + + // For each token expected in this list - Compile output + + if( !empty( $tokens[$listname] ) ) // That is if there's any data for the list + { + $t = count($tokens[$listname]); // Get number of blocks of data + $j = 0; + foreach( $tokens[$listname] as $to ) // For each block of data supplied + { + if( !is_array($to) || count($to) == 0 ) + { + $out = "ERROR: parse_view() - List data contains an empty token array for list $listname."; + if( $GLOBALS['reg_config']['debug_view'] ) + $out .= "

     


    Tags supplied to parse_view() function

    ".tableize_array( $tokens ); + return( $out ); + } + $x = replace_tokens( $list[$j%$sections], $to ); // Replace tokens in appropriate section + $x = process_view_lists( $x, $to, $pvl_level+1, $pvl_require_list_data ); // Process any sub-lists + $out .= cond_replace_tokens( $x, $to ); // Do conditional replacements also + + if( ++$j < $t ) // If there's more data, output sep + $out .= $sep; + } + } + } + + $out .= substr( $f, $p ); // Now add remainder of page + return( $out ); + } + + + // Parse a "view" string to merge in supplied data + +function parse_string_view( $f, $tokens, $show_unused = TRUE ) + { + + if( empty($f) ) + return( "ERROR: View string not provided." ); + + // Replace all {include:filename} + + while( !( ($p2 = strpos( $f, '", $p)) || $p2 == $p ) // If there's no }--> following it, then something's wrong + return ("ERROR: parse_view() - Missing name of {include:filename} tag at $p.

    ".htmlentities(substr($f, $p, 500))."
    "); + + // Read in the specified file + + $filename = substr($f, $p, $p2 - $p); // Get name of the specified file + if( !($inc_file = file_get( BASE_PATH.'/'.$filename)) ) + return ("ERROR: parse_view() - Target of {include:filename} tag does not exist or is unreadable at $p.

    ".htmlentities(substr($f, $p-13, 500))."
    "); + + // Replace the tag with the file contents + + $f = str_replace( '', $inc_file, $f ); + + } + + // Tear out {exclude} ... {/exclude} regions + + $f = preg_replace( "/.*?/s", "", $f ); + + // Remove comments from around any {INCLUDE ... /INCLUDE} regions + + $f = str_replace( "", "", $f ); + + // Insert any specified files + $f = replace_file_tokens( $f ); + + // Replace all global tokens + $f = replace_tokens( $f, $tokens["global"] ); + + // Do conditional replacements for global tokens + + $f = cond_replace_tokens( $f, $tokens["global"] ); + + $out = process_view_lists( $f, $tokens ); + + if( $show_unused ) + $out = preg_replace( "/(\\{\S*?\\})/", "\\1", $out ); + + if( $GLOBALS['reg_config']['debug_view'] ) + $out .= "

     


    Tags supplied to parse_view() function

    ".tableize_array( $tokens ); + + return( $out ); + +} + + +/** + * MagicForms and do_math support in separate file + */ +include_once (GLM_APP_BASE.'Common/Registrations_V3/front-end/magic_forms_function.inc'); + +/** + * Other Misc output functions + */ + +/*======================================================================= + +HIGH LEVEL FUNCTIONS + +=======================================================================*/ + +// Build a numeric picklist + +function build_numeric_picklist( $fieldname, $starting, $ending, $selected="", $option="" ) +{ + if( $starting > $ending ) + return( "*** Picklist generation error: build_numeric_piclist() ***" ); + + $r = ''; + + return( $r ); + +} + +// Build a picklist + +function reg_build_picklist( $fieldname, $data, $selected, $type = "standard", $options = "" ) +{ + + if( !is_array($data) ) + return( "ERROR: reg_build_picklist() data supplied is not an array for field $fieldname.\n" ); + + // Set default option status + + $option_blank = $option_order = $option_numeric = $option_descending = $option_multi = FALSE; + + // Scan for supplied options + + if( !empty($options) ) + { + $opt_array = explode_trim( "~", $options ); + foreach( $opt_array as $opt ) + { + switch( $opt ) + { + case "blank": + $option_blank = TRUE; + break; + + case "numeric": + $option_numeric = TRUE; + $option_order = TRUE; + break; + + case "alpha": + $option_numeric = FALSE; // If it's not numeric, it's alpha + $option_order = TRUE; + break; + + case "descending": + $option_descending = TRUE; + break; + + case "ascending": + $option_descending = FALSE; // If it's not descending, it's ascending + break; + + case "multi": + $option_multi = TRUE; // Permit multiple select with CTRL or SHIFT + break; + + default: + return( "Illegal reg_build_picklist() option\n" ); + break; + } + } + } + + if( $option_order ) + { + if( $option_descending ) + { // Sort Descending + if( $option_numeric ) + arsort( $data, SORT_NUMERIC ); + else + arsort( $data, SORT_STRING ); + } + else + { // Sort Ascending + if( $option_numeric ) + asort( $data, SORT_NUMERIC ); + else + asort( $data, SORT_STRING ); + } + } + + if( $option_multi ) { + $str = ''; + } + + if( $option_blank ) { + + // Check if blank is selected + $sel = false; + if( is_array($selected) ) + { + reset( $selected ); + foreach( $selected as $s ) { + if( $s == '' ) { + $sel = TRUE; + } + } + } + $str .= " \n"; + } + + switch( $type ) + { + case "simple": + for( $i=0 ; $i".$data[$i]."\n"; + } else { + $str .= " \n"; + } + } + break; + + case "standard": + default: + while( list($key, $val) = each($data) ) { + if( $option_multi ) { + $sel = FALSE; + + if( is_array($selected) ) { + reset( $selected ); + foreach( $selected as $s ) { + if( $s != '' && $s == $key ) { + $sel = TRUE; + } + } + } + $str .= " \n"; + } else { + $str .= " \n"; + } + } + break; + } + $str .= ""; + + return( $str ); + +} + +// Build Radio Buttons + +function build_radio_buttons( $fieldname, $data, $selected, $separator = "  ", $type = "standard", $options = "" ) +{ + + // if $data is neither proper array or data string + + if( !is_array($data) ) + if( ($data = strtoarray($data)) == FALSE ) + return( "ERROR: build_radio_buttons() Improper data supplied for field \"$fieldname\".\n" ); + + // Set default option status + + $option_blank = $option_order = $option_numeric = $option_descending = $option_after = FALSE; + + // Scan for supplied options + + if( !empty($options) ) + { + $opt_array = explode_trim( "~", $options ); + foreach( $opt_array as $opt ) + { + switch( $opt ) + { + case 'numeric': + $option_numeric = TRUE; + $option_order = TRUE; + break; + + case 'alpha': + $option_numeric = FALSE; // If it's not numeric, it's alpha + $option_order = TRUE; + break; + + case 'descending': + $option_descending = TRUE; + break; + + case 'ascending': + $option_descending = FALSE; // If it's not descending, it's ascending + break; + + case 'after': + $option_after = TRUE; + break; + + default: + // return( "ERROR: build_radio_buttons() Illegal option \"$opt\".\n" ); + break; + } + } + } + + if( $option_order ) + { + if( $option_descending ) + { // Sort Descending + if( $option_numeric ) + arsort( $data, SORT_NUMERIC ); + else + arsort( $data, SORT_STRING ); + } + else + { // Sort Ascending + if( $option_numeric ) + asort( $data, SORT_NUMERIC ); + else + asort( $data, SORT_STRING ); + } + } + + $str = $sep = ''; + while( list($key, $val) = each($data) ) + { + $str .= $sep; + + if( !$after ) + $str .= $val.' '; + + switch( $type ) + { + case "simple": + $str .= ''; + break; + case "standard": + $str .= ''; + break; + default: + break; + } + + if( $after ) + $str .= ' '.$val; + + $sep = $separator; + } + return( $str ); +} + + + // Create a date input form with a link to a pop-up calendar + +function calendar_date_select( $default_value, $selected_date, $start_date, +$end_date, $form_name, $field_name, $options = "", +$no_earlier = "" ) +{ + + GLOBAL $si_month_array; + + $months = array( 1=>"Jan",2=>"Feb",3=>"Mar",4=>"Apr",5=>"May",6=>"Jun",7=>"Jul",8=>"Aug",9=>"Sep",10=>"Oct",11=>"Nov",12=>"Dec" ); + + $start = getdate( $start_date ); + $end = getdate( $end_date ); + + $form = " + "; + + // Handle default date whether it's a string date or a timestamp + + if( is_numeric($default_value) ) + { + $default_timestamp = $default_value; + $default_value = date( 'n/j/Y', $default_value ); + } + else + $default_timestamp = strtotime( $default_value ); + + $default_month = date( "n", $default_timestamp ); + $default_day = date( "j", $default_timestamp ); + $default_year = date( "Y", $default_timestamp ); + + if( preg_match( "/PICK/", $options ) ) + { + $form .= reg_build_picklist( $field_name."_month", $months, $default_month ); + $form .= build_numeric_picklist( $field_name."_day", 1, 31, $default_day ); + if( preg_match( "/HIDE_YEAR/", $options ) ) + $form .= ''; + else + $form .= build_numeric_picklist( $field_name."_year", date("Y"), date("Y",$end_date), $default_year ); + $form .= ''; + } + else + $form .= ''; + + if( !preg_match( "/NO_PROMPT/", $options ) ) + $form .= " (month/day/year) "; + $form .= ' + '; + + return($form); +} + +// Build an HTML calendar with data from the array in each date + +function calendar_display( $month, $year, $date_data, $headerinfo='', $monthinfo='' ) +{ + $MonthNames = array(1=>'January','February','March','April','May','June','July','August','September','October','November','December'); + + /* This seems to be unnecessary + + $calendar =' + */ + + $calendar = ' + + + + + + + '; + + if( !empty($headerinfo) ) + { + $calendar.= ' + '; + } + + $calendar.=' + + + + + + + + + + '; + + // Display blanks up to first day of the month + + $offset = date( "w", mktime( 0, 0, 0, $month, 1, $year ) ); + if( $offset > 0 ) + $calendar .= str_repeat( "\n",$offset ); + + // For each day of the month + + $NumberOfDays = date( "t", mktime( 0, 0, 0, $month, 1, $year ) ); + for( $i=1 ; $i<=$NumberOfDays ; $i++ ) + { + $this_date = mktime( 0, 0, 0, $month, $i, $year ); + $DayOfWeek = date( "w", $this_date ); + + // Start a new row each Sunday, unless it's the 1st of the month + + if( $DayOfWeek == 0 && $i != 1 ) + { + $calendar .= ''; + } + + if( !empty($date_data[$i]["color"]) ) + $color = $date_data[$i]["color"]; + else + $color = SI_CAL_DATE; + + $calendar .= '\n"; + } + + + if( ( ($offset == 5) && ($NumberOfDays > 30) ) || ( ($offset == 6) && ($NumberOfDays > 29) ) ) + { + if( 42-$NumberOfDays-$offset > 0 ) + { + $calendar .= str_repeat( "\n",42-$NumberOfDays-$offset ); + } + $calendar .= "\n"; + } + elseif( ($NumberOfDays != 28) || ($offset > 0) ) + { + if (35-$NumberOfDays-$offset > 0) + { + $calendar .= str_repeat("\n",35-$NumberOfDays-$offset); + $calendar .= "\n"; + } + } + + $calendar .= "
    '.(empty($monthinfo)?$MonthNames[$month].' '.$year:$monthinfo).'
    +
    '.$headerinfo.' +
    SunMonTueWedThuFriSat
     
    '; + + if( !empty($date_data[$i]["link"]) ) + $calendar .= ''.$i.''; + else + $calendar .= $i; + + $calendar .= '
    '; + + if( !empty($date_data[$i]["cell"]) ) + $calendar .= $date_data[$i]["cell"]; + + $calendar .= "
     
     
    \n"; + return $calendar; +} + + + + +/** + * Admin Menus + */ + +// Select field data from an array based on which function it will be used for +// returning a string suitable for the admin_ functions + +function admin_field_select( $fields, $filter ) +{ + + $r = ''; + $sep = ''; + + if( ! is_array($fields) || trim($filter) == '' ) + { + echo "

    ERROR: admin_field_select() - No Field or Filter data supplied!

    "; + return( FALSE ); + } + + foreach( $fields as $f ) + { + $x = explode( ',', $f ); + if( strstr( $x[5], $filter ) ) { + if( $filter == 'f' ) { // List filters require slight difference in fields + $r .= $sep.$x[0].','.$x[1].','.$x[2].','.$x[4]; + } else { + $r .= $sep.$x[0].','.$x[1].','.$x[2].','.$x[3].','.$x[4]; + } + $sep = '|'; + } + } + + return( $r ); +} + +// Select field data from an array based on which function it will be used for +// returning an array of arrays of data. + +function admin_fields_select_array( $fields, $filter ) +{ + + $r = array(); + + if( ! is_array($fields) || trim($filter) == '' ) + { + echo "

    ERROR: admin_field_select_array() - No Field or Filter data supplied!

    "; + return( FALSE ); + } + + while( list($key, $val) = each($fields) ) + { + $x = explode( ',', $val ); + if( strstr( $x[5], $filter ) ) + { + $r[$key]['name'] = trim($x[0]); + $y = explode( '.', trim($x[1]) ); + foreach( $y as $z ) + $r[$key]['type'][] = trim($z); + $r[$key]['title'] = trim($x[2]); + $r[$key]['required'] = trim($x[3]); + $r[$key]['variable'] = trim($x[4]); + $r[$key]['sample'] = trim($x[6]); + } + } + + return( $r ); +} + +// Generate standard admin low-level menu + +// New version using standard HTML (

    's) for admin sections +function admin_menu_std( $action, $a_title, $id, $opt, $options = 'lveda', $add_menu = '', $params = '' ) +{ + + $m = ''; + $nl = "\n"; + + // if( $a_title != '' ) + // $m .= ''.$a_title.':'; + + $link = THIS_SCRIPT.'?Action='.urlencode($action); + if( trim($params) != '' ) + $link .= '&'.$params; + + if( strstr($options,'l') ) + { + if( $opt == "List" ) + $m .= '
  • [List]
  • '.$nl; + else + $m .= '
  • [List]
  • '.$nl; + } + + if( strstr($options,'v') ) + { + if( $opt == "View" ) + $m .= '
  • [View]
  • '.$nl; + elseif( empty($id) ) + $m .= '
  • [View]
  • '.$nl; + else + $m .= '
  • [View]
  • '.$nl; + } + + if( strstr($options,'e') ) + { + if( $opt == "Edit" ) + $m .= '
  • [Edit]
  • '.$nl; + elseif( empty($id) ) + $m .= '
  • [Edit]
  • '.$nl; + else + $m .= '
  • [Edit]
  • '.$nl; + } + + if( strstr($options,'d') ) + { + if( $opt == "Delete" ) + $m .= '
  • [Delete]<
  • '.$nl; + elseif( empty($id) ) + $m .= '
  • [Delete]
  • '.$nl; + else + $m .= '
  • [Delete]
  • '.$nl; + } + + if( strstr($options,'a') ) + { + if( $opt == "Add" ) + $m .= '
  • [Add]
  • '.$nl; + else + $m .= '
  • [Add]
  • '.$nl; + } + + if( $add_menu != '' ) + $m .= " - $add_menu".$nl; + + return( $m ); +} +// Standard version +function admin_menu( $action, $a_title, $id, $opt, $options = 'lveda', $add_menu = '', $params = '' ) +{ + + $m = ''.$a_title.': '; + + $link = THIS_SCRIPT.'?Action='.urlencode($action); + if( trim($params) != '' ) + $link .= '&'.$params; + + if( strstr($options,'l') ) + { + if( $opt == "List" ) + $m .= '[List] '; + else + $m .= '[List] '; + } + + if( strstr($options,'v') ) + { + if( $opt == "View" ) + $m .= '[View] '; + elseif( empty($id) ) + $m .= '[View] '; + else + $m .= '[View] '; + } + + if( strstr($options,'e') ) + { + if( $opt == "Edit" ) + $m .= '[Edit] '; + elseif( empty($id) ) + $m .= '[Edit] '; + else + $m .= '[Edit] '; + } + + if( strstr($options,'d') ) + { + if( $opt == "Delete" ) + $m .= '[Delete] '; + elseif( empty($id) ) + $m .= '[Delete] '; + else + $m .= '[Delete] '; + } + + if( strstr($options,'a') ) + { + if( $opt == "Add" ) + $m .= '[Add] '; + else + $m .= '[Add] '; + } + + if( $add_menu != '' ) + $m .= " - $add_menu"; + + return( $m ); +} + + +/*********************************************************************** + * * + * Support funtions for High Level Admin Functions * + * * + ***********************************************************************/ + + +// Explode a string into pieces and trims whitespace from ends of each piece. + +function explode_trim( $separator, $string ) +{ + + $a = explode( $separator, $string ); + + foreach( $a as $key => $data ) + $a[$key] = trim($data); + + return( $a ); + +} + + +/*********************************************************************** + * * + * High Level Admin Functions * + * * + ***********************************************************************/ + +// The "JFDI" function - Fully process a data table + +function admin_process_records_r( $table, $where, $order, $conn_str, $id, $fields, +$options, $rows, $url, $action, $params, $a_title, $view, $Option, $start, $other_options = '', $a_title_view = '', $quick_tip = '', $id_field = '' ) +{ + $a_title_view = preg_replace( "/\\{action\\}/", $Option, $a_title_view ); + + switch( $Option ) + { + + case "Add": + + return( admin_new_record_r + ( + $table, + $conn_str, + admin_field_select( $fields, 'n' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    New $a_title

    ":$a_title_view), + $view['Add'], + $other_options, + $quick_tip, + $id_field + ) + ); + + break; + + case "Add New": + + $r = admin_add_new_record_r + ( + $table, + $conn_str, + admin_field_select( $fields, 'a' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    Add New $a_title

    ":$a_title_view), + $view['Add New'], + $quick_tip, + $id_field + ); + + // If successfull see if we can get the new record ID and view it + /* Don't do this right now... + * + if( $r['status'] ) + { + // On success Add New returns the OID of the new record - get ID for next call + + if( ($d = db_auto_get_row( "SELECT id FROM $table WHERE oid = ".$r['status'].";" )) ) + $id = $d['id']; + else + return( $r ); // If we can't get ID then just give up and return + + // If all is OK, then call again to do a View + + $r = admin_process_records_r( $table, $where, $order, $conn_str, $id, $fields, $options, $rows, $url, $action, $params, $a_title, $view, 'View', $start, $other_options, $a_title_view, $quick_tip ); + } + */ + + return( $r ); + + break; + + case "Edit": + + return( admin_edit_record_r + ( + $table, + $conn_str, + $id, + admin_field_select( $fields, 'e' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    Edit $a_title

    ":$a_title_view), + $view['Edit'], + $other_options, + $quick_tip, + $id_field + ) + ); + + break; + + case "Update": + + $r = admin_update_record_r + ( + $table, + $conn_str, + $id, + admin_field_select( $fields, 'u' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    Update $a_title

    ":$a_title_view), + $view['Update'], + $quick_tip, + $id_field + ); + + // If successful update then call again to do a View of the updated record + + if( $r['status'] ) + return( admin_process_records_r( $table, $where, $order, $conn_str, $id, $fields, $options, $rows, $url, $action, $params, $a_title, $view, 'View', $start, $other_options, $a_title_view, $quick_tip, $id_field ) ); + + return( $r ); + + break; + + case "Delete": + + return( admin_delete_record_r + ( + $table, + $conn_str, + $id, + admin_field_select( $fields, 'd' ), + $options, + $url, + $action, + $params, + (empty($a_title_view)?"

    Delete $a_title

    ":$a_title_view), + $view['Delete'], + $quick_tip, + $id_field + ) + ); + + break; + + case "Confirm Delete": + + $r = admin_confirm_delete_record_r + ( + $table, + $conn_str, + $id, + admin_field_select( $fields, 'c' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    Confirm Delete $a_title

    ":$a_title_view), + $view['Confirm Delete'], + $quick_tip, + $id_field + ); + + // If successful delete then call again to do a List + + if( $r['status'] ) + return( admin_process_records_r( $table, $where, $order, $conn_str, $id, $fields, $options, $rows, $url, $action, $params, $a_title, $view, 'List', $start, $other_options, $a_title_view, $quick_tip ) ); + + return( $r ); + + break; + + case "View": + + return( admin_view_record_r + ( + $table, + $conn_str, + $id, + admin_field_select( $fields, 'v' ), + $url, + $action, + $params, + (empty($a_title_view)?"

    View $a_title

    ":$a_title_view), + $view['View'], + $other_options, + $quick_tip, + $id_field + ) + ); + + break; + + default: + + return( admin_list_records_r + ( + $table, + $where, + $order, + $conn_str, + admin_field_select( $fields, 'l' ), + $options, + FALSE, + $rows, + $start, + $url, + $action, + $params, + admin_field_select( $fields, 'f' ), + (empty($a_title_view)?"

    List $a_title

    ":$a_title_view), + $view['List'], + $id_field, + $quick_tip + ) + ); + + break; + + } // switch( $Option ) + +} + +function admin_process_records( $table, $where, $order, $conn_str, $id, $fields, +$options, $rows, $url, $action, $params, $a_title, $view, $Option, $start, $other_options = '', $a_title_view = '', $quick_tip = '' ) +{ + $r = admin_process_records_r( $table, $where, $order, $conn_str, $id, $fields, + $options, $rows, $url, $action, $params, $a_title, $view, $Option, $start, $other_options, $a_title_view, $quick_tip ); + echo $r['text']; + return( $r['status'] ); +} + + +// List records from a table + +function admin_list_records_r( $table, $where, $order, $conn_str, $fields, +$options, $fail_mode, $rows = 20, $start = 0, +$url, $action, $params, $filters, $a_title, $view = "", $id_field = "", $quick_tip = '' ) +{ + + $ret = ''; + + // Make all submitted parameters available + + // extract($GLOBALS[HTTP_GET_VARS]); + // extract($GLOBALS[HTTP_POST_VARS]); + + // Make sure we have something rational for rows and start + + if( $rows == '' ) $rows = 20; + if( $start == '' ) $start = 0; + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + foreach( $field_table as $key => $r ) + { + $field_table[$key] = explode_trim( ",", $r ); + $hidden[$key] = preg_match( "/HIDDEN/", $field_table[$key][3] ); + } + + $operation_column = $option_new = $option_view = $option_edit = $option_delete = $option_duplicate = $option_filter = $option_nopaging = $option_noborder = $option_sortlinks = FALSE; + + if( ! empty($options) ) + { + $option_table = explode_trim( ",", $options ); + foreach( $option_table as $option ) + { + switch( $option ) + { + case "new": + $option_new = TRUE; + break; + + case "view": + $option_view = TRUE; + $operation_column = TRUE; + break; + + case "edit": + $option_edit = TRUE; + $operation_column = TRUE; + break; + + case "delete": + $option_delete = TRUE; + $operation_column = TRUE; + break; + + case "duplicate": + $option_duplicate = TRUE; + $operation_column = TRUE; + break; + + case "filter": + $option_filter = TRUE; + break; + + case "sortlinks": + $option_sortlinks = TRUE; + break; + + case "nopaging": + $option_nopaging = TRUE; + break; + + case "noborder": + $option_noborder = TRUE; + break; + + default: + // $ret .= '

    ERROR: Illegal Option Specified: -'.$option.'-

    '; + break; + } + } + } + + // Check for additional parameters that are passed + + $link_params = $form_params = ""; + if( !empty($params) ) { + $param = explode_trim( "|", $params ); // Separate parameters + foreach( $param as $p ) { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + // Check if a column label has been clicked to cause a sort of that column + $sortclicked_new = filter_request('sortclicked_new'); + $list_sort_direction = filter_request('list_sort_direction'); + $sortclicked = filter_request('sortclicked'); + + if( !empty($sortclicked_new) ) { + // Clicking the same column title toggles between ascending and descending sort + if( $list_sort_direction == 'Forward' ) { + $list_sort_direction = "Backward"; + } else { + $list_sort_direction = 'Forward'; + } + + $sortclicked = $sortclicked_new; + $link_params .= '&sortclicked='.$sortclicked."&list_sort_direction=$list_sort_direction"; + $form_params .= ''; + $form_params .= ''; + } elseif( !empty($sortclicked) ) { + $sortclicked = $sortclicked; + $list_sort_direction = $list_sort_direction; + $link_params .= '&sortclicked='.$sortclicked."&list_sort_direction=$list_sort_direction"; + $form_params .= ''; + $form_params .= ''; + } + + // Display optional filter search fields and build query string + + $qs = empty($where) ? "WHERE TRUE " : "WHERE ".$where ; + + if ($option_filter) { + $filter_out = ' +
    + + Select items to list
    + + '; + + $filter_link = ""; // Added to link to pass on filter data + $filter = explode_trim( "|", $filters ); + foreach( $filter as $filter_field ) + { + $f = explode_trim( ",", $filter_field ); // Split field specs + $ft = explode_trim( "~", $f[2] ); // Separate QuickTips from titles + $w = explode_trim( "`", $f[1] ); // Separate out any format spec + $x = explode_trim( ".", $w[0] ); // Split type specs + $option = $x[1]!="" ? $x[1] : "none" ; + $filter_value = filter_request($f[3]); + + // Display Filter Title - With QuickTip if specified + + if (count($ft) > 1) { + $filter_out .= ' + '; + } + $filter_out .= '
    '.quick_tip( $ft[0], $ft[1] ).''; + } else { + $filter_out .= '
    '.$ft[0].''; + } + + // Add any filter value to $filter_link + $fvc = 0; + if (is_array($_REQUEST[$f[3]]) || !empty($filter_value)) { + if( is_array($_REQUEST[$f[3]]) ) + { + $req = $_REQUEST[$f[3]]; + foreach( $req as $fv ) { + $filter_link .= "&".$f[0]."[$fvc]=".$fv; + $fvc++; + } + } else { + $filter_link .= "&".$f[0]."=".$filter_value; + } + } + + // Display filter field + + switch( $x[0] ) // Handle different field types + { + case "url": + case "text": + case "textbox": + case "inet": + $filter_out .= ''; + if( !empty($filter_value) ) // If a value is passed, add to query + switch( $option ) + { + case "like": + $qs .= " AND ".$f[0]." LIKE '%".$filter_value."%'"; + break; + case "begin": + $qs .= " AND ".$f[0]." ~* '^".$filter_value."'"; + break; + case "any": + default: + $qs .= " AND ".$f[0]." ~* '".$filter_value."'"; + break; + } + break; + + case "state": + $filter_out .= reg_build_picklist( $f[0], $GLOBALS['si_states_array'], $filter_value, 'standard', 'blank' ); + if( $filter_value != '' ) + $qs .= ' AND '.$f[0]." = '".$filter_value."'"; + break; + + case "country": + $filter_out .= reg_build_picklist( $f[0], $GLOBALS['si_countries_array'], $filter_value, 'standard', 'blank' ); + if( $filter_value != '' ) + $qs .= ' AND '.$f[0]." = '".$filter_value."'"; + break; + + case "date": + $filter_out .= ''; + if( !empty($filter_value) ) // If a value is passed, add to query + switch( $option ) + { + default: // Options are not used for date at this time + $qs .= " AND ".$f[0]." = '".$filter_value."'"; + break; + } + break; + + case "daterange": + // Clean up dates + $filter_date_from = trim(filter_request($f[3].'_FROM')); + $filter_date_to = trim(filter_request($f[3].'_TO')); + if ($filter_date_from != '') { + $filter_date_from = date('m/d/Y', strtotime($filter_date_from)); + } + if ($filter_date_to != '') { + $filter_date_to = date('m/d/Y', strtotime($filter_date_to)); + } + + $filter_out .= 'From To '; + // If Dates are not valid + if (($filter_date_from != '' && strtotime($filter_date_from) === -1) || + ($filter_date_to != '' && strtotime($filter_date_to) === -1 ) ) { + $filter_out .= '
    (Note: Invalid date specified)'; + break; + } + else + { + // If we have both dates of a range + if( !empty($filter_date_from) && !empty($filter_date_to) ) { + $qs .= " AND ".$f[0]." BETWEEN '".$filter_date_from."' AND '".$filter_date_to."'"; + // Otherwise check if there's only one date submitted + } elseif( !empty($filter_date_from) || !empty($filter_date_to) ) { + $filter_out .= '
    (Note: both From and To required to specify date range)'; + } + } + break; + + case "order": + case "int": + case "float": + case "fixed": + $filter_out .= ' + '; + if( !empty($filter_value) ) // Note: No filter options on type "int" + $qs .= " AND ".$f[0]." = ".$filter_value.""; + break; + + case "checkbox": + if( empty($filter_value) ) + $x = 1; + else + $x = $filter_value; + $filter_out .= ' + + '; + switch( $x ) + { + case "2": + $qs .= " AND ".$f[0]." = 't'"; + break; + case "3": + $qs .= " AND ".$f[0]." = 'f'"; + break; + case "1": + default: + break; + } + break; + + case "list" : + + // If there's picklist options, sparate them into an array + $opts_table = array (); + $opts = explode_trim("~", $x[1]); + + foreach ($opts as $opt) + { + $z = explode_trim("^", $opt); // Separate value from displayed text + $opts_table[$z[0]] = $z[1]; + } + + $opts_def = ($filter_value == '' ? '-1' : $filter_value); + + // If select doesn't contain anything, also check request + if (!is_array($opts_def)) { + $opts_def = $_REQUEST[$f[0]]; + } + + // Build new picklist + $filter_out .= reg_build_picklist($f[0], $opts_table, $opts_def, 'standard', $x[3]); + + // If there's a list of selected options - multi-select + if( is_array($opts_def) ) { + + $qss .= ' AND ( '; + $sep = ''; + foreach( $opts_def as $v ) // For each option specified + { + if( trim($v) != '' ) // If the option is something other than '' + { + $qss .= $sep.$f[0]." = ".$v.""; + $sep = ' OR '; + } + } + + if( $sep != '' ) { // If there were options selected other than '' + $qs .= $qss.' )'; // add to the query + } + + // Otherwise it's a single value + } else { + if( $filter_value != '' ) { + $qs .= ' AND '.$f[3].' = '.$filter_value; + } + } + + break; + + + case "category": + + // If picklist is selected - use that for selection + + if (strstr($x[3],'picklist')) { + if (($nodes = cat_get_nodes($x[1]))) { + + $filter_out .= ''; + } + else + $filter_out .= 'No categories listed.'; + + } else { // Otherwise use pop-up + + // Check if a value for this field is supplied + if (!empty($filter_value)) { + if (($cval = cat_get_node( $x[1], "id = ".$filter_value ) )) { + $cat_id = $filter_value; + if( strstr($x[3],'fullpath') ) + $cat_name = $cval['cat_fullpath']; + else + $cat_name = $cval['cat_name']; + } + } else { + $cat_id = 0; + $cat_name = "   "; + } + + $pop_width = !empty($x[4]) ? $x[4] : 200 ; + $pop_height = !empty($x[5]) ? $x[5] : 300 ; + $edit_width = !empty($x[6]) ? $x[6] : 400 ; + $edit_height = !empty($x[7]) ? $x[7] : 500 ; + + $filter_out .= " + + "; + + $filter_out .= ' + + [Change] + '; + } + + if( $filter_value != '' ) + $qs .= ' AND '.$f[0]." = '".$filter_value."'"; + + break; + + case "pointer": + + // Get values from other table + + $w = !empty($x[4]) ? " WHERE ".$x[4] : "" ; + $d = reg_db_auto_get_data( "SELECT * FROM ".$x[1].$w." ORDER BY ".$x[2].";", $conn_str, FALSE, 500 ); + + $p_id_field = !empty($x[3]) ? $x[3] : 'id'; // If no id field supplied, assume "id" + + // Build picklist data + + unset( $da ); + if (!empty($d)) { + while (list($key, $val) = each($d)) { + $da[$val[$p_id_field]] = $val[$x[2]]; + } + $filter_out .= reg_build_picklist( $f[0], $da, $filter_value, "standard", "blank" ); + } else { + $filter_out .= 'No records from which to build picklist.'; + } + + // If value supplied, add to query WHERE clause + + if (!empty($filter_value)) { + switch ($option) { + case "like": + case "begin": + case "any": + $filter_out .= 'Filter option for type "pointer" not valid. Must use "exact" for type pointer.'; + break; + case "exact": + default: + $qs .= " AND ".$f[0]." = '".$filter_value."'"; + break; + } + } + break; + + case 'multipointer': + + echo "multipointer is not available for Filter functions yet."; + exit; + break; + + default: + $filter_out .= 'UNKNOWN FILTER FIELD TYPE'; + break; + + } + $filter_out .= '
    + + + '.$form_params.' +
    +
     
    + '; + } + + // If "new" option selected display link + + if( $option_new ) + $new_out = '[Add New Entry]
    + '; + else + $new_out = ""; + + + // Add in any ORDER BY clause (ignore anything after ".", which are nav options) + + if( !empty($sortclicked) ) // Check if user clicked a column title + { + $qs .= ' ORDER BY '.$sortclicked; + if( $list_sort_direction == 'Backward' ) + $qs .= " DESC"; + } + else + if( !empty($order) ) + { + $qs .= " ORDER BY "; + $ob_comma = ""; + $order_array = explode_trim( ",", $order ); // Break out multiple order by field names + foreach( $order_array as $of ) + { + $x = explode_trim( ".", $of ); // Break out field name from options + $qs .= $ob_comma.$x[0]; // Add field name to ORDER BY + if( preg_match("/order_descending/", $of) ) // If order_descending use DESC order in ORDER BY for this field + $qs .= " DESC"; + $ob_comma = ", "; // Next order by field will have a comma in front of it + } + } + + // Get the data + + $what_fields = "*"; + if( $id_field != "" ) + $what_fields = "*, ".$id_field." AS id"; + + $query_string = "SELECT ".$what_fields." FROM ".$table." ".$qs.";"; + + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_list_records()[".__LINE__."]: Query String = $query_string

    "; + + $data = reg_db_auto_get_data( $query_string, $conn_str, $fail_mode, $rows, $start ); + + if( $data ) + { + + // Determine how much data we got back + + reset( $data ); + $return_counts = explode( "|", key($data) ); + $num = $return_counts[1]; + + // Calculate last entry on page + + $end_list = $num>($start+$rows) ? $start+$rows : $num; + + + // Display page navigation + + $nav_out = ""; + if( $num > 0 && $option_nopaging == FALSE ) + { + if( $start > 0 ) + $nav_out .= 'previous + '; + else + $nav_out .= "previous \n"; + + $nav_out .= ' <- Results '.($start+1).' to '.($end_list).' of '.$num.' -> + '; + + if( $num > $end_list ) + $nav_out .= 'next + '; + else + $nav_out .= " next\n"; + } + + + // Build field titles + + $fieldcount = 0; + $down_img = ''; + $up_img = ''; + foreach( $field_table as $field ) + { + $f2 = explode_trim( "~", $field[2] ); // Only use name, don't include QuickTip text. + $f2_name = $f2[0]; + switch( $field[1] ) + { + default: + if( $option_sortlinks ) + { + $scd = ''; + + // Check if a column title has been clicked to cause a sort + if( $sortclicked == $field[0] ) + { + // Indicate sort direction + + if( $list_sort_direction == 'Forward' ) + $scd = $down_img; + else + $scd = $up_img; + } + $outnames[$fieldcount++] = $scd.''.$f2_name.''; + + } + else + $outnames[$fieldcount++] = $f2_name; + break; + } + } + + $sort_prompt = ''; + if( $option_sortlinks ) { + $sort_prompt .= "
    (click table headers to sort column $down_img ascending or $up_img descending)"; + } + + if( $operation_column ) + $outnames[$fieldcount++] = 'Operation'; + + + // For each result we're going to display + + $reccount = 0; + foreach( $data as $key => $r ) + { + + // For each field in the result + + $fieldcount = 0; + foreach( $field_table as $field ) + { + $w = explode_trim( "`", $field[1] ); // Separate out any format spec + $f = explode_trim( ".", $w[0] ); // break out the field type specs + + // If there's any field format spec, save that in our $outvals array + + if( isset($w[1]) && trim($w[1]) != '' ) + { + // Replace each {field_name} tag with {#} as needed to reference the correct $outvals[$reccount][#] entry + + for( $i=0 ; $i 0 ) + $fw = $f[1]; + $ns = 'N'; + if( $r[$field[0]] < 0 ) + { + $ns = 'S'; + $r[$field[0]] = -1 * $r[$field[0]]; + } + $dv = (int) $r[$field[0]]; + $mv = ( $r[$field[0]] - $dv ) * 60; + $outvals[$reccount][$fieldcount]['data'] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + break; + + case "lon": + $fw = 2; + if( $f[1] > 0 ) + $fw = $f[1]; + $ns = 'E'; + if( $r[$field[0]] < 0 ) + { + $ns = 'W'; + $r[$field[0]] = -1 * $r[$field[0]]; + } + $dv = (int) $r[$field[0]]; + $mv = ( $r[$field[0]] - $dv ) * 60; + $outvals[$reccount][$fieldcount]['data'] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + break; + + case "order": + case "int": + case "float": + $outvals[$reccount][$fieldcount]['data'] = $r[$field[0]]; + break; + + case "money": + $outvals[$reccount][$fieldcount]['data'] = "$".sprintf( "%01.2f", $r[$field[0]] ); + break; + + case "fixed": + $outvals[$reccount][$fieldcount]['data'] = sprintf( "%01.".$f[1]."f", $r[$field[0]] ); + break; + + case "date": + case "text": + case "textbox": + case "richtext": + case "inet": + $outvals[$reccount][$fieldcount]['data'] = $r[$field[0]]; + break; + + case "state": + $outvals[$reccount][$fieldcount]['data'] = $GLOBALS['si_states_array'][$r[$field[0]]]; + break; + + case "country": + $outvals[$reccount][$fieldcount]['data'] = $GLOBALS['si_countries_array'][$r[$field[0]]]; + break; + + case "url": + $outvals[$reccount][$fieldcount]['data'] = ''.$r[$field[0]].''; + break; + + case "category": + // Get the category name for this field is supplied + if( !empty($r[$field[0]]) ) + { + if( $cval = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE id = ".$r[$field[0]].";", 0, $conn_str, FALSE ) ) + $outvals[$reccount][$fieldcount]['data'] = $cval['name']; + else + $outvals[$reccount][$fieldcount]['data'] = 'Unknown Category'; + } + else + { + $outvals[$reccount][$fieldcount]['data'] = " "; + } + break; + + case "pointer": + // If {value_field} supplied use that, otherwise use id of record as value to match + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} supplied use that, otherwise match {value_field} or "id" field + $w = ''; + if( !empty($f[4]) ) + $w = " WHERE ".$f[4]; + elseif( trim($r[$field[0]]) != '' ) + $w = " WHERE ".$value_field." = ".$r[$field[0]]; + + if( $w != '' ) + { + $pval = db_auto_get_row( "SELECT * FROM ".$f[1].$w.";", 0, $conn_str, $fail_mode ); + $outvals[$reccount][$fieldcount]['data'] = $pval[$f[2]]; + } + else + $outvals[$reccount][$fieldcount]['data'] = ''; + break; + + case 'multipointer': + + echo "multipointer is not available for List functions yet."; + exit; + break; + + case "checkbox": + $outvals[$reccount][$fieldcount]['data'] = $r[$field[0]] == "t" ? "Yes" : "No" ; + break; + + case "image": + if( !empty($r[$field[0]]) ) + { + switch( $f[1] ) + { + case "o": $img_url = ORIGINAL; break; + case "r": $img_url = RESIZED; break; + case "m": $img_url = MIDSIZED; break; + case "t": $img_url = THUMB; break; + default: $img_url = "none"; break; + } + if( $img_url != "none" ) + $outvals[$reccount][$fieldcount]['data'] = ''; + else + $outvals[$reccount][$fieldcount]['data'] = 'Invalid Image Size'; + } + else + $outvals[$reccount][$fieldcount]['data'] = '(no image)'; + break; + + case "file": + if( !empty($r[$field[0]]) ) + $outvals[$reccount][$fieldcount]['data'] = ''.$r[$field[0]].''; + else + $outvals[$reccount][$fieldcount]['data'] = '(no file)'; + break; + + case "list": + $opts_table = array (); + $opts = explode_trim( "~", $f[1] ); // Separate list options + foreach( $opts as $opt ) + { + $z = explode_trim("^", $opt); // Separate value from displayed text + $opts_table[$z[0]] = $z[1]; + } + + // In case there's multiple selected options, display results of all selected options with comma separators + + $x = explode( '~', $r[$field[0]] ); + $outvals[$reccount][$fieldcount]['data'] = $sep = ''; + if( is_array($x) ) + foreach( $x as $y ) + { + $outvals[$reccount][$fieldcount]['data'] .= $sep.$opts_table[$y]; + $sep = ', '; + } + + break; + + default: + $outvals[$reccount][$fieldcount]['data'] = 'UNKNOWN FIELD TYPE: '.$f[0].' for '.$field[0].''; + break; + + } // switch( field ) + $fieldcount++; + } // foreach( field ) + + if( $operation_column ) + { + $outvals[$reccount][$fieldcount]['data'] = ""; + if( $option_view ) + $outvals[$reccount][$fieldcount]['data'] .= '[view] '; + if( $option_edit ) + $outvals[$reccount][$fieldcount]['data'] .= '[edit] '; + if( $option_delete ) + $outvals[$reccount][$fieldcount]['data'] .= '[delete] '; + if( $option_duplicate ) + $outvals[$reccount][$fieldcount]['data'] .= '[duplicate] '; + $fieldcount++; + } + + $reccount++; + } // foreach( record ) + + // Replace parameters in Title - {n} represents the field names in the page title + + } // if( $data ) + + for( $i=0 ; $i<$fieldcount ; $i++ ) + { + $a_title = preg_replace( "/\\{".$i."\\}/", $outnames[$i], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($outnames[$i]), $a_title ); + } + $a_title = preg_replace( "/\\{filter\}/", $filter_out, $a_title ); + $a_title = preg_replace( "/\\{link_params\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\}/", $form_params, $a_title ); + $a_title = preg_replace( "/\\{new\}/", $new_out, $a_title ); + $a_title = preg_replace( "/\\{nav\}/", $nav_out, $a_title ); + + $ret .= "
    \n"; + + if( empty($view) ) // If $view is not supplied + { + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + // Display title, filter, and optional "new" link + + $ret .= $a_title.' + '.$filter_out.' + '.$new_out; + + // If there were results listed, display the results + + if( $data && ($fields != "") ) + { + $ret .= $nav_out.$sort_prompt.$nav_initials.' + + + '; + + // Display the titles for all columns + + for( $i=0 ; $i<$fieldcount ; $i++ ) + { + if( !$hidden[$i] ) + $ret .= ""; + } + + // Display the data for each result + + for( $i=0 ; $i<$reccount ; $i++ ) + { + $ret .= ""; + + for( $j=0 ; $j<$fieldcount ; $j++ ) + { + // If the field is supposed to be seen + + if( !$hidden[$j] ) + { + // If there's a format spec, use that + if( $outvals[$i][$j]['format'] != '' ) + { + $out = $outvals[$i][$j]['format']; + for( $k=0 ; $k<$fieldcount ; $k++ ) + $out = str_replace( '{'.$k.'}', $outvals[$i][$k]['data'] , $out ); + $ret .= ""; + } + else // Otherwise just output the value + $ret .= ""; + } + } + $ret .= "\n"; + + } + $ret .= '
    ".$outnames[$i]." 
    $out".$outvals[$i][$j]['data']." 
    + '.$nav_out; + } + else + $ret .= '
    (No results found)
    + '; + + } + else // IF$view is supplied + { + + // Replace any reference to {filter}, {new}, and {nav} in $view + + $view = preg_replace( "/\\{filter\\}/", $filter_out, $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $view = preg_replace( "/\\{new\\}/", $new_out, $view ); + $view = preg_replace( "/\\{nav\\}/", $nav_out, $view ); + + // Separate the header, body, and footer + + $head = $body = $foot = ""; + $x = explode( "{body}", $view ); + if( count($x) == 2 ) // if {body} found then we have the head and the rest + { + $head = $x[0]; + $view = $x[1]; + } + $x = explode( "{/body}", $view ); + if( count($x) == 2 ) // If {/body} found then we have the body and the foot + { + $body = $x[0]; + $foot = $x[1]; + } + else + $body = $view; + + // Replace the values $head & $foot - {n} in Header and footer get names of fields + + for( $i=0 ; $i<$fieldcount ; $i++ ) + { + $head = preg_replace( "/\\{".$i."\\}/", $outnames[$i], $head ); + $foot = preg_replace( "/\\{".$i."\\}/", $outnames[$i], $foot ); + $head = preg_replace( "/\\{encode:".$i."\\}/", urlencode($outnames[$i]), $head ); + $foot = preg_replace( "/\\{encode:".$i."\\}/", urlencode($outnames[$i]), $foot ); + } + + $ret .= $a_title.$head; // Output title & head sections + + if( $data ) + { + // Break up body into sections + + $body_parts = explode( "{section}", $body ); // Did I really write it that way??? + + // For each body_part + + $bp = 0; + + for( $i=0 ; $i<$reccount ; $i++ ) // For each Record + { + $b = $body_parts[$bp++]; // Get body section and point to next + if( $bp == count($body_parts) ) // if last available body section, start back at first + $bp = 0; + + for( $j=0 ; $j<$fieldcount ; $j++ ) // For each field + { + $b = preg_replace( "/\\{".$j."\\}/", $outvals[$i][$j]['data'], $b ); // Replace value for that field + $b = preg_replace( "/\\{encode:".$j."\\}/", urlencode($outvals[$i][$j]['data']), $b ); // Replace value for that field + } + + $ret .= $b; // Output this body section + } + } + else + $ret .= "(No results found)\n"; + + // Output foot + + $ret .= $foot; + + } + + $ret .= "
    \n"; + + return( array( 'text' => $ret, 'status' => true ) ); + +} + +function admin_list_records( $table, $where, $order, $conn_str, $fields, +$options, $fail_mode, $rows = 20, $start = 0, +$url, $action, $params, $filters, $a_title, $view = "", $id_field = "", $quick_tip = "", $id_field = "" ) +{ + $r = admin_list_records_r( $table, $where, $order, $conn_str, $fields, + $options, $fail_mode, $rows, $start, + $url, $action, $params, $filters, $a_title, $view, $id_field, $quick_tip ); + + echo $r['text']; + return( $r['status'] ); +} + + + + +// Ask for a new record for a table + +function admin_new_record_r( $table, $conn_str, $fields, $url, $action, $params, $a_title, +$view = "", $options = "", $quick_tip = "", $id_field = "" ) +{ + + $ret = ''; + + $form_name = "edit"; + $richtext_used = FALSE; // Indicates whether richtext field type has been specified + $category_used = FALSE; // Indicates whether categroy field type has been specified + + // Make all submitted parameters available + + // extract($GLOBALS[HTTP_GET_VARS]); + // extract($GLOBALS[HTTP_POST_VARS]); + + // Check for any options + + $borders = strstr( $options, "borders" ) == FALSE ? 0 : 1; + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + foreach( $field_table as $key => $r ) + $field_table[$key] = explode_trim( ",", $r ); + + // Check for additional parameters that are passed + + if( !empty($params) ) + { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) + { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + + // For each field in the result + + $outcount = 0; + foreach( $field_table as $field ) + { + + // Get supplied field value + $field_val = ${$field[4]}; + + + $f = explode_trim( ".", $field[1] ); + + $out[$outcount]["display"] = TRUE; + $out[$outcount]["field"] = $field[0]; + + // Display title fields + + $n = explode_trim( '~', $field[2] ); // Separate QuickTip from title + $field_name_color = 'black'; + switch( $field[3] ) + { + case "TRUE": + case "UNIQUE": + $field_name_color = 'red'; + case "FALSE": + case "SUPPLIED": + case "DISPLAY": + case "UNIQUE_NOT_REQ": + + // setup tip display - requires show_QuickTip() and hide_QuickTip() functions from java_functions.js + + if( count($n) > 1 ) { + $out[$outcount]["name"] = quick_tip( ''.$n[0].'', $n[1] ); + } else { + $out[$outcount]["name"] = ''.$field[2].''; + } + + break; + + case "HIDDEN": + $out[$outcount]["name"] = ''; + break; + + default: + $out[$outcount]["name"] = 'Invalid {required} field specification'; + break; + } + + // Display input fields + + switch( $f[0] ) + { + case "money": + case "int": + case "order": + case "url": + case "text": + case "inet": + case "float": + case "fixed": + $v = ""; + $prefix = ""; + $s = $f[1]; // Field Input Size + + if( $f[0] == "int" ) { // If it's an integer, default to 0 + $v = 0; + } elseif( $f[0] == "order" ) { // If it's an "order" field, default to 9999 - last in list + $v = 9999; + } elseif( $f[0] == "money" ) { // If it's money, default to 0.00 + $prefix = "$"; + $v = "0.00"; + } elseif( $f[0] == "fixed" ) { // If it's fixed, default to specified precision + + $prefix = ""; + $v = "0"; + if( $f[1] > 0 ) + { + $v .= '.'; + for( $i=0 ; $i<$f[1] ; $i++ ) + $v .= '0'; + $s = $f[1] + 4; + } + } else { + $v = $field_val; + } + + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + case "FALSE": + $out[$outcount]["value"] = $prefix.''; + break; + case "SUPPLIED": + $out[$outcount]["value"] = $prefix.''; + break; + case "DISPLAY": + $out[$outcount]["value"] = $prefix.''.$v; + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "lat": + + $fw = 2; + if( $f[1] > 0 ) + $fw = $f[1]; + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + case "FALSE": + $out[$outcount]["value"] = ' + ° + \''; + break; + case "SUPPLIED": + case "DISPLAY": + $ns = 'N'; + $lat = $field_val; + if( $lat < 0 ) + { + $ns = 'S'; + $lat = -1 * $lat; + } + $dv = (int) $lat; + $mv = ( $lat - $dv ) * 60; + if( $field[3] == "SUPPLIED" ) + $out[$outcount]["value"] = ' + ° + \''; + else + $out[$outcount]["value"] = '' + .sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "lon": + + $fw = 2; + if( $f[1] > 0 ) + $fw = $f[1]; + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + case "FALSE": + $out[$outcount]["value"] = ' + ° + \''; + break; + case "SUPPLIED": + case "DISPLAY": + $ns = 'E'; + $lon = $field_val; + if( $lon < 0 ) + { + $ns = 'W'; + $lon = -1 * $lon; + } + $dv = (int) $lon; + $mv = ( $lon - $dv ) * 60; + if( $field[3] == "SUPPLIED" ) + $out[$outcount]["value"] = ' + ° + \''; + else + $out[$outcount]["value"] = '' + .sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "date": + + $date_f = !empty( $f[1] ) ? time()-$f[1]*86400 : time() ; // Set datestamp of first day to allow + $date_t = !empty( $f[2] ) ? time()+$f[2]*86400 : time() ; // Set datestamp of last day to allow + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = calendar_date_select( "", time(), $date_f, $date_t, $form_name, $field[0], $f[3], $f[4] ); + break; + case "SUPPLIED": + $out[$outcount]["value"] = calendar_date_select( $field_val, time(), $date_f, $date_t, $form_name, $field[0], $f[3], $f[4] ); + break; + case "DISPLAY": + $out[$outcount]["value"] = $prefix.''.$field_val; + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "textbox": + switch( $field[3] ) // {required} setting + { + case "TRUE"; + case "FALSE"; + $out[$outcount]["value"] = ''; + break; + case "SUPPLIED": + $out[$outcount]["value"] = ''; + break; + case "DISPLAY": + $out[$outcount]["value"] = ''.filter_request($field[4]); + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "richtext": + $def_text = ''; + switch( $field[3] ) // {required} setting + { + case "SUPPLIED": + $def_text = $field_val; + // no break, dropps through + case "TRUE"; + case "FALSE"; + if( SI_RICHTEXT_TYPE_ENABLED ) + { + + if( !$richtext_used ) + { + $richtext_used = TRUE; + } + $out[$outcount]["value"] = ' + + + + +
    + +
    + + '; + + } + else + $out[$outcount]["value"] = ''; + break; + case "DISPLAY": + $out[$outcount]["value"] = ''.$field_val; + break; + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "multifield": // multitext.numb_fields.new_line_string + + // THIS FIELD TYPE REQUIRES java_functions.js + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ' + '; + + // If there's data, then build existing input lines with data + if( ( $x = trim($data[$field[0]]) ) != '' ) + { + $field_data = unserialize( $data[$field[0]] ); + + if( $field_data != false && is_array( $field_data ) ) + { + // For each line of inputs + for( $i=1 ; $i<=count($field_data) ; $i++ ) + { + $f_line = str_replace( '{line_numb}', $i, $f[2] ); // Set line number in output text + // For each input field on the line + for( $j=1 ; $j<=$f[1] ; $j++ ) + $f_line = str_replace( '{field_'.$j.'}', '', $f_line ); + + $out[$outcount]["value"] .= $f_line."\n"; + } + } + + } + else + $i = 1; // If no data blank line is #1 + + // Build 1 spare input line + $f_line = str_replace( '{line_numb}', $i, $f[2] ); // Set line number in output text + for( $j=1 ; $j<=$f[1] ; $j++ ) + $f_line = str_replace( '{field_'.$j.'}', '', $f_line ); + $out[$outcount]["value"] .= $f_line."\n"; + + break; + + case "HIDDEN": + case "DISLPLAY": + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "image": + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + break; + case "SUPPLIED": + case "DISPLAY": + case "HIDDEN": + $out[$outcount]["value"] = 'SUPPLIED/DISPLAY/HIDDEN not allowed here for image'; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "images": + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + $im_num = 0; + + if( empty($f[1]) ) + $spare = 2; + else + $spare = $f[1]; + + // Check for options + + $im_des = strstr( $f[2], 'descr' ); + $im_align = strstr( $f[2], 'align' ); + $im_size = strstr( $f[2], 'size' ); + if( !empty( $f[3] ) ) + $im_des_s = $f[3]; + else + $im_des_s = 40; + if( !empty( $f[4] ) ) + $im_des_t = $f[4]; + else + $im_des_t = "Text"; + + for( $i=0 ; $i<$spare ; $i++ ) + { + $out[$outcount]["value"] .= ' + Image #'.($im_num+1).'
    + + + + + '.( $im_des ? '' : '' ).' +
    + '.( $im_align ? ' + Align image + ' : '' ).' + '.( $im_size ? ' + Size + + ' : '' ).' +
    '.$im_des_t.'
    +
    '; + $im_num++; + } + break; + + case "HIDDEN": + case "DISLPLAY": + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + + case "file": + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + break; + case "SUPPLIED": + case "DISPLAY": + case "HIDDEN": + $out[$outcount]["value"] = 'SUPPLIED/DISPLAY/HIDDEN not allowed here for file'; + break; + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "category": + + // If picklist is selected - use that for selection + + if( strstr($f[3],'picklist') ) + { + if( ($nodes = cat_get_nodes($f[1])) ) + { + $out[$outcount]["value"] .= ''; + } + else + $out[$outcount]["value"] .= 'No categories listed.'; + } + else // Otherwise use pop-up + { + + // Check if a value for this field is supplied + if( !empty($field_val) ) + { + if( ($cval = cat_get_node( $f[1], "id = ".$field_val ) ) ) + { + $cat_id = $field_val; + if( strstr($f[3],'fullpath') ) + $cat_name = $cval['cat_fullpath']; + else + $cat_name = $cval['cat_name']; + } + } + else + { + $cat_id = 0; + $cat_name = "   "; + } + + $pop_width = !empty($f[4]) ? $f[4] : 200 ; + $pop_height = !empty($f[5]) ? $f[5] : 300 ; + $edit_width = !empty($f[6]) ? $f[6] : 400 ; + $edit_height = !empty($f[7]) ? $f[7] : 500 ; + + $out[$outcount]["value"] .= " + + "; + + $out[$outcount]["value"] .= ' + + [Change] + '; + } + break; + + case "pointer": + + // If {value_field} type option supplied use that, otherwise use id of record as VALUE + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} type option supplied use that, otherwise get all possibilities from other table + $w = !empty($f[4]) ? " WHERE ".$f[4] : "" ; + + // If picklist options + $p = !empty($f[5]) ? $f[5] : "" ; + + // Sort field for query + $s = !empty($f[6]) ? $f[6] : "id" ; + + // Pointer options + + $pointer_option_add_field = FALSE; + if( ! empty($f[7]) ) + { + $option_table = explode_trim( ",", $f[7] ); + foreach( $option_table as $option ) + { + switch( $option ) + { + case "add_field": // Option to display a field for entering a new target + $pointer_option_add_field = TRUE; + break; + + default: + break; + } + } + } + + // ID field name + $s = !empty($f[6]) ? $f[6] : "id" ; + + // Check if a value for this field is supplied + if( !empty($field_val) ) { + $supplied = $field_val; + } else { + $supplied = ""; + } + + switch( $field[3] ) + { + // These require us to build a pick list + case "TRUE": + case "FALSE": + case "SUPPLIED": + + $d = reg_db_auto_get_data( "SELECT * FROM ".$f[1].$w." ORDER BY ".$s.";", $conn_str, FALSE, 500 ); + + if( !$d ) + { + $out[$outcount]["value"] = 'No records from which to build picklist'; + } + else + { + // Create table of possibilities for pick list + + unset( $da ); + while( list($key, $val) = each($d) ) + { + $da[$val[$value_field]] = $val[$f[2]]; + + // If {required} setting is "SUPPLIED" + if( $field[3] == "SUPPLIED" && $val[$value_field] == $field_val ) + $dkey = $val[$value_field]; // Get id of record we're refering to + } + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $da, $dkey, "standard", $p ); + } + + // Provide an additional input field to permit adding a new target value + + if( $pointer_option_add_field ) + $out[$outcount]["value"] .= ' or add new value '; + + break; + + // These require us to just get the data for the specific index + + case "DISPLAY": + case "HIDDEN": + if( empty($field_val) ) + { + $out[$outcount]["value"] = 'Missing value for DISPLAY & HIDDEN'; + break; + } + $d = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE ".$value_field." = ".$field_val." ORDER BY ".$s.";", 0, $conn_str, $fail_mode ); + if( !$d ) + { + $out[$outcount]["value"] = 'Specified value for DISPLAY/HIDDEN not found in table'; + break; + } + else + $out[$outcount]["value"] = ''; + + if( $field[3] == "DISPLAY" ) // If DISPLAY add the visible data after the hidden field + { + if( $f[5] == "checkbox" ) + $out[$outcount]["value"] .= ($d[$f[2]]=='t'?"Yes":"No"); + else + $out[$outcount]["value"] .= $d[$f[2]]; + } + + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case 'multipointer': + + // If {value_field} type option supplied use that, otherwise use id of record as VALUE + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} type option supplied use that, otherwise get all possibilities from other table + $w = !empty($f[4]) ? " WHERE ".$f[4] : "" ; + + // If picklist options + $p = !empty($f[5]) ? $f[5] : "" ; + + // Sort field for query + $s = !empty($f[6]) ? $f[6] : "id" ; + + // ID field name + $s = !empty($f[6]) ? $f[6] : "id" ; + + switch( $field[3] ) { + + // These require us to build a pick list + case "TRUE": + case "FALSE": + case "SUPPLIED": + + $d = reg_db_auto_get_data( "SELECT * FROM ".$f[1].$w." ORDER BY ".$s.";", $conn_str, FALSE, 500 ); + + if( !$d ) { + $out[$outcount]["value"] = 'No records from which to build picklist'; + } else { + + // Create table of possibilities for pick list + unset( $da ); + while( list($key, $val) = each($d) ) { + $da[$val[$value_field]] = $val[$f[2]]; + + // If {required} setting is "SUPPLIED" + if( $field[3] == "SUPPLIED" && $val[$value_field] == $field_val ) + $dkey = $val[$value_field]; // Get id of record we're refering to + } + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $da, $dkey, "standard", $p." multi" ); + } + + break; + + // These require us to just get the data for the specific index + case "DISPLAY": + case "HIDDEN": +echo "multipointer DISPLAY/HIDDEN not available yet."; exit; + if( empty($field_val) ) { + $out[$outcount]["value"] = 'Missing value for DISPLAY & HIDDEN'; + break; + } + $d = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE ".$value_field." = ".$field_val." ORDER BY ".$s.";", 0, $conn_str, $fail_mode ); + if( !$d ) { + $out[$outcount]["value"] = 'Specified value for DISPLAY/HIDDEN not found in table'; + break; + } else { + $out[$outcount]["value"] = ''; + } + if( $field[3] == "DISPLAY" ) { // If DISPLAY add the visible data after the hidden field + if( $f[5] == "checkbox" ) { + $out[$outcount]["value"] .= ($d[$f[2]]=='t'?"Yes":"No"); + } else { + $out[$outcount]["value"] .= $d[$f[2]]; + } + } + + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + + break; + + case "list": + // If picklist options + $p = !empty($f[3]) ? $f[3] : "" ; + + $option_table = ""; + $opts = explode_trim( "~", $f[1] ); // Separate list options + $def_value = !empty($f[2]) ? $f[2] : "" ; + foreach( $opts as $opt ) + { + $os = explode_trim( "^", $opt ); // Separate value from displayed text + $option_table[$os[0]] = $os[1]; + } + $out[$outcount]["value"] = reg_build_picklist( $field[0], $option_table, $def_value, "standard", $p ); + if( $out[$outcount]["value"] == '' ) + $out[$outcount]["value"] = '(no options listed)'; + break; + + case "state": // Special case of list + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $GLOBALS['si_states_array'], $f[1], "standard", $f[2] ); + break; + + case "country": // Special case of list + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $GLOBALS['si_countries_array'], $f[1], "standard", $f[2] ); + break; + + case "checkbox": + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ''; + break; + + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + + case "DISPLAY": + $out[$outcount]["value"] = 'DISPLAY/HIDDEN not available for type checkbox at this time'; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "bitmap": + + $bmap = explode_trim( "~", $f[1] ); + $out[$outcount]["value"] = ""; + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + for( $i=0 ; $i'.$bmap[$i].'
    '; + break; + + case "SUPPLIED": + case "DISPLAY": + case "HIDDEN": + for( $i=0 ; $i'.$bmap[$i].'
    '; + } + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + if( $out[$outcount]["value"] == '' ) + $out[$outcount]["value"] = '(no options listed)'; + break; + + case "break": + if( !empty($f[1]) ) // if {t1} is supplied + $out[$outcount]["value"] = $f[1]; + else + $out[$outcount]["value"] = 'No {text} supplied for type "break"'; + break; + + default: + $out[$outcount]["value"] = 'UNKNOWN FIELD TYPE: '.$f[0].' for '.$field[0].''; + break; + + } // switch( field ) + + $outcount++; + } // foreach( field ) + + // Build submit button and hidden action and put in {submit} + + $submit = ' + + '.$form_params.' + + '; + + // Replace parameters in Title + + for( $i=0 ; $i<$outcount ; $i++ ) + { + $a_title = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $a_title ); + } + + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + // Output results + + // Display top of page and open form + + $ret .= '
    +
    + '; + + $hidden_data = ''; + if( empty($view) ) // If there's no format spec in $view + { + + $ret .= $a_title.' + (Required fields in red)
    + 0?' CELLPADDING="5"':"").'> + '; + + for( $i=0 ; $i<$outcount ; $i++ ) + { + if( $out[$i]["name"] != '' ) + $ret .= ' + '; + else + $hidden_data .= $out[$i]["value"]; + } + + $ret .= '

    +

    '.$out[$i]["name"] + .' '.$out[$i]["value"].' 
    '.$hidden_data.$submit; // Output the Confirm field and submit button + + } + else // Otherwise use $view to output data + { + reset( $out ); + while( list ($k, $v) = each($out) ) + { + $a_title = preg_replace( "/\\{".$v['field']."\\}/", $v["value"], $a_title ); + $view = preg_replace( "/\\{".$v['field']."\\}/", $v["value"], $view ); + $a_title = preg_replace( "/\\{encode:".$v['field']."\\}/", urlencode($v["value"]), $a_title ); + $view = preg_replace( "/\\{encode:".$v['field']."\\}/", urlencode($v["value"]), $view ); + } + + for( $i=0 ; $i<$outcount ; $i++ ) + { + $view = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $view ); + $view = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $view ); + } + $view = preg_replace( "/\\{submit\\}/", $submit, $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $ret .= $a_title.$view; + } + + // Display bottom of page and close form + $ret .= '
    +
    + '; + + return( array( 'text' => $ret, 'status' => true ) ); +} + +function admin_new_record( $table, $conn_str, $fields, $url, $action, $params, $a_title, $view = "", $options = "", $quick_tip = "", $id_field = "" ) +{ + $r = admin_new_record_r( $table, $conn_str, $fields, $url, $action, $params, $a_title, $view, $options, $quick_tip ); + + echo $r['text']; + return( $r['status'] ); + +} + + + + +// Add new record to a table + +function admin_add_new_record_r( $table, $conn_str, $fields, $url, $action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + + $ret = ''; + + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_add_new_record()[".__LINE__."]: Table = $table, Action = $action

    "; + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + foreach( $field_table as $key => $r ) + $field_table[$key] = explode_trim( ",", $r ); + + // Check for additional parameters that are passed + if( !empty($params) ) + { + if( $GLOBALS['reg_config']['debug'] >= 2 ) $ret .= "
    admin_add_new_record()[".__LINE__."]: Additional Passed Parameters = $params

    "; + + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) + { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + $names = $values = $not_supplied = $problem = $mp_qs = ""; + + // For each field in the result + + $comma = ""; // first parameter doesn't need a comma in front of it + $outcount = 0; + foreach( $field_table as $field ) + { + + $f = explode_trim( ".", $field[1] ); // Break out optional parameters from field type + // Don't add any multipointer fields to field list since it's stored in a separate table. + if ($f[0] != 'multipointer') { + $names .= $comma.$field[0]; // Add field name to $names for INSERT + } + $out[$outcount]["name"] = $field[0]; // Make name available to view + $fta = explode_trim( "~", $field[2] ); + $field_title_only = $fta[0]; + + + // Get submitted value + if ($f[0] == 'richtext' && $f[3] != '') { + switch ($f[3]) { + case 'encoded': + $filter = FILTER_SANITIZE_ENCODED; + break; + default: + $filter = FILTER_SANITIZE_STRING; + } + $field_val = filter_request($field[4],$filter); + } else { + $field_val = filter_request($field[4]); + } + + if( $GLOBALS['reg_config']['debug'] >= 2 ) $ret .= "
            Field = ".$field[0].", value = ".$field_val."

    "; + + switch( $f[0] ) + { + case "money": + case "order": + case "int": + case "float": + case "fixed": + case "pointer": + case "category": + + // Handle special cases in this group of types + switch( $f[0] ) + { + + case "money": + + // Get rid of "$" and "," from silly users + + $field_val = preg_replace( "/[\$,]/", "", $field_val ); + break; + + case "pointer": + + // Check for add_field values - Add new value to pointer target record + + if( ($add_value = trim(filter_request($field[4].'_add_field'))) != '' ) + { + // If value already exists warn user. + + if( db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE ".$f[2]." = '".trim(filter_request($field[4].'_add_field'))."';", 0, $conn_str, $fail_mode ) ) + $not_supplied .= $field_title_only.": Value already exists in pick list, don't try to add it again.
    "; + else + { + // Otherwise, add new value and use pointer to that + + $add_result = db_auto_get_row( "INSERT INTO ".$f[1]." ( ".$f[2]." ) VALUES ( '".trim(filter_request($field[4].'_add_field'))."' ); + SELECT currval( '".$f[1]."_id_seq' ) AS id;", 0, $conn_str, $fail_mode ); + $field_val = $add_result['id']; + } + } + + break; + + default: + break; + } + + + $out[$outcount]["value"] = $field_val; + if( !empty($field_val) && !is_numeric($field_val) ) + $not_supplied .= $field_title_only.': "'.$field_val.'" Is not an Integer Number
    '; + + switch( $field[3] ) + { + case "SUPPLIED": + $values .= $comma.$field_val; + break; + + case "TRUE": + if( !is_numeric($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma.$field_val; + } + break; + + case "FALSE": + if( is_numeric($field_val) ) { + $values .= $comma.$field_val; + } else { + $values .= $comma."0"; // Default to 0 + } + break; + + case "UNIQUE": + if( empty($field_val) && $field_val != 0 ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma.$field_val; + } + + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = ".trim($field_val).";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + break; + + case "UNIQUE_NOT_REQ": + if( is_numeric($field_val) ) { + $values .= $comma.$field_val; + } else { + $values .= $comma."0"; // Default to 0 + } + + if( !empty($field_val) && $field_val != 0 && + db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = ".trim($field_val).";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "multipointer": + + // Insert any new selections + if (is_array($_REQUEST[$field[0]]) && count($_REQUEST[$field[0]]) > 0) { + foreach ($_REQUEST[$field[0]] as $mps) { + $mp_qs .= "INSERT INTO ".$f[7]." (".$f[8].",".$f[9].") VALUES ({mp_rec_id},".($mps-0).");\n"; + } + + } + + $out[$outcount]["value"] = $field_val; +/*** NOT DOING REQUIRED for multipointer yet + if( !empty($field_val) && !is_numeric($field_val) ) + $not_supplied .= $field_title_only.': "'.$field_val.'" Is not an Integer Number
    '; +*/ + + break; + + + case "lat": + // If we've been passed a decimal degree value + $v = $field_val; + if( empty($v) ) { + if( filter_request($field[4].'_DEG') > 90 || filter_request($field[4].'_DEG') < 0 || filter_request($field[4].'_MIN') >= 60 || filter_request($field[4].'_MIN') < 0 ) + { + $not_supplied .= $field_title_only.": Invalid entry. Degrees must be 0 to 90 and Minutes must be 0 to less than 60
    "; + break; + } + $v = ( filter_request($field[4].'_NS') == "N" ? 1 : -1 ) * ( filter_request($field[4].'_DEG') + ( filter_request($field[4].'_MIN') / 60 ) ); + } + $fw = 2; + // Rebuild value for display + if( $f[1] > 0 ) { + $fw = $f[1]; + } + $ns = 'N'; + if( ($v2=$v) < 0 ) { + $ns = 'S'; + $v2 = -1 * $v2; + } + $dv = (int) $v2; + $mv = ( $v2 - $dv ) * 60; + $out[$outcount]["value"] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + switch( $field[3] ) + { + case "SUPPLIED": + $values .= $comma.$v; + break; + + case "TRUE": + if( empty($v) ) + $not_supplied .= $field_title_only.": Not Supplied
    "; + else + $values .= $comma.$v; + break; + + case "FALSE": + $values .= $comma.$v; + break; + + case "UNIQUE": + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + $values .= $comma.$v; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($field_val) && $field_val != 0 && + db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma.$v; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "lon": + // If we've been passed a decimal degree value + $v = $field_val; + if( empty($v) ) { + if( filter_request($field[4].'_DEG') > 180 || filter_request($field[4].'_DEG') < 0 || filter_request($field[4].'_MIN') >= 60 || filter_request($field[4].'_MIN') < 0 ) + { + $not_supplied .= $field_title_only.": Invalid entry. Degrees must be 0 to 180 and Minutes must be 0 to less than 60
    "; + break; + } + $v = ( filter_request($field[4].'_NS') == "E" ? 1 : -1 ) * ( filter_request($field[4].'_DEG') + ( filter_request($field[4].'_MIN') / 60 ) ); + } + $fw = 2; + // Rebuild value for display + if( $f[1] > 0 ) { + $fw = $f[1]; + } + $ns = 'E'; + if( ($v2=$v) < 0 ) { + $ns = 'W'; + $v2 = -1 * $v2; + } + $dv = (int) $v2; + $mv = ( $v2 - $dv ) * 60; + $out[$outcount]["value"] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + switch( $field[3] ) + { + case "SUPPLIED": + $values .= $comma.$v; + break; + + case "TRUE": + if( empty($v) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma.$v; + } + break; + + case "FALSE": + $values .= $comma.$v; + break; + + case "UNIQUE": + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma.$v; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($field_val) && $field_val != 0 + && db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma.$v; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + + break; + + + case "list": + case "text": + case "inet": + case "state": + case "country": + case "url": + case "richtext": + case "textbox": + + // Check for special cases + switch( $f[0] ) + { + case "inet": + if( ($r = clean_input( $field_val, 'inet' )) != '' ) { + $problem .= ''.$field_title_only.': Not a valid IP address or netmask.
    '; + } + break; + + case "list": + // If 'multi' is selected for picklist option, then compile results from array + if( strstr( $f[3], 'multi' ) ) + { + $m_val = $sep = ''; + + // Place results in '~' separated string for storage. - Use unfiltered input + $field_val2 = $_REQUEST[$field[4]]; + if( is_array($field_val2) ) { + foreach( $field_val2 as $m ) + { + $m_val .= $sep.$m; + $sep = '~'; + } + } + $cv = $m_val; + } + + break; + + default: + break; + } + + $v = str_replace( "%27", "\'", $field_val ); + if( trim(strip_tags($v)) == '' ) { + $v = ''; + } + $out[$outcount]["value"] = $v; + switch( $field[3] ) + { + case "SUPPLIED": + $values .= $comma."'".rawurldecode( $v )."'"; + break; + + case "TRUE": + if( empty($v) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma."'".rawurldecode( $v )."'"; + } + break; + + case "FALSE": + $values .= $comma."'".rawurldecode( $v )."'"; + break; + + case "UNIQUE": + if( empty($v) ) + $not_supplied .= $field_title_only.": Not Supplied
    "; + else + { + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim($v)."';", 0, $conn_str, $fail_mode ) ) + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma."'".rawurldecode( $v )."'"; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($v) ) + { + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim($v)."';", 0, $conn_str, $fail_mode ) ) + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma."'".$v."'"; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "date": + + // If a date is supplied, correct any date errors + if ($field_val != '') { + $field_val = date('m/d/Y', strtotime($field_val)); + } + + $out[$outcount]["value"] = $field_val; + + if( trim($field_val) == "" ) { // Blank dates must be "NULL" + $dval = "NULL"; + } else { + $dval = "'".$field_val."'"; + } + + switch( $field[3] ) + { + case "SUPPLIED": + $values .= $comma.$dval; + break; + + case "TRUE": + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma.$dval; + } + break; + + case "FALSE": + $values .= $comma.$dval; + break; + + case "UNIQUE": + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim($field_val)."';", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma.$dval; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($field_val) && db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim($field_val)."';", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $values .= $comma.$dval; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "multifield": + + $line = 0; + $empty = TRUE; + $m_data = array(); + + // Build array of data to store + while( isset($_REQUEST[$field[4].'_'.($line+1).'_1']) ) + { + $line++; + $cv2 = filter_request($field[4].'_'.$line.'_1'); + if( trim($cv2) != '' ) + { + $a = array(); + for( $i=1 ; $i<=$f[1] ; $i++ ) + { + $a[$i-1] = trim( stripslashes(str_replace("%27", "\'", filter_request($field[4].'_'.($line).'_'.$i) ) )); + if( $a[$i-1] != '' ) + $empty = FALSE; + } + array_push( $m_data, $a ); + } + } + + if( !$empty ) { + $v = serialize( $m_data ); + } else { + $v = ''; + } + + $out[$outcount]["value"] = $v; + + switch ($field[3]) + { + case "TRUE" : + if( $empty ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $values .= $comma."'".$v."'"; + } + break; + + case "FALSE" : + $values .= $comma."'".$v."'"; + break; + + default : + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + + break; + + case "image": + + $out[$outcount]["value"] = "IMAGES Not Available for View at this time"; + $img = filter_request($field[4]); + + switch( $field[3] ) + { + case "SUPPLIED": + $problem .= 'ERROR: "SUPPLIED" not permitted as option for image input
    '; + break; + + case "TRUE": + if ($img['name'] != '') { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } + // no break; here - falls through to FALSE + + case "FALSE": + if ($img['name'] != '') { + $values .= $comma."'".reg_process_image( $field[4] )."'"; + } else { + $values .= $comma."''"; + } + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "images": +/* NOT CONFIGURED FOR ImageServer + // Note that the image field is only updated when required so field name is set below along with value + + $out[$outcount]["value"] = "IMAGES Not Available for View at this time"; + switch( $field[3] ) + { + case "FALSE": + if( is_array( ($im_data = filter_request($field[4])) ) ) + { + $im_cur = unserialize( $data[$field[0]] ); // Convert existing data to an array + $im_new = array(); + $im_new_num = 0; + for( $im_num=0 ; $im_num
    '; + break; + } +*/ + break; + + case "file": + + $out[$outcount]["value"] = "FILES Not Available for View at this time"; + switch( $field[3] ) + { + case "SUPPLIED": + $problem .= 'ERROR: "SUPPLIED" not permitted as option for file input
    '; + break; + + case "TRUE": + if( filter_request($field[4]."_name") == "" ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } + // no break; here - falls through to FALSE + + case "FALSE": + if( filter_request($field[4]."_name") != "" ) { + if( isset( $f[1] ) && $f[1] != "" && !preg_match( "/.".$f[1]."$/i",filter_request($field[4]."_name")) ) { + $not_supplied .= $field_title_only.': "'.filter_request($field[4]."_name").'" is not correct file type. Must be: '.$f[1]."
    "; + } else { + $values .= $comma."'". reg_file_upload($field[4])."'"; + } + } else { + $values .= $comma."''"; + } + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "checkbox": + if( $field_val == "on" ) + { + $out[$outcount]["value"] = "Yes"; + $values .= $comma."'t'"; + } + else + { + $out[$outcount]["value"] = "No"; + $values .= $comma."'f'"; + } + break; + + case "bitmap": + $out[$outcount]["value"] = "Bitmaps not available for view at this time"; + $bm = $field_val; + $b = 0; // Start with clear bitmap + for( $i=0 ; $i
    '; + break; + + } // switch( field ) + + $comma = ", "; // All subsequent names/values must have a preceeding comma + + $outcount++; + } // foreach( field ) + + // Replace parameters in Title + + for( $i=0 ; $i<$outcount ; $i++ ) + { + $a_title = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $a_title ); + } + + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + $oid = 0; // Assume we don't get anything + + $ok_to_save = true; + + if( !empty($not_supplied) ) + { + $results .= ' +

    Required fields not supplied

    + '.$not_supplied.'

    + Use "BACK" button on browser, add missing data and resubmit.

    + '; + $ok_to_save = false; + } + + if( !empty($problem) ) + { + $results .= $problem.'

    + Use "BACK" button on browser, correct problem field, and resubmit.

    + '; + $ok_to_save = false; + } + + if( $ok_to_save ) + { + $results = ' 

    New data saved.

    '; + $qs = "INSERT INTO $table ($names) VALUES ($values) returning id;"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) { + $ret .= "

    admin_add_new_record()[".__LINE__."]: Query String = $qs

    "; + } + $d = db_auto_get_row( $qs, 0, $conn_str, FALSE ); + $id = $d['id']; + + // If needed, add multipointer data + if ($mp_qs != '') { + $mp_qs = str_replace("{mp_rec_id}", $id, $mp_qs); + reg_db_auto_exec( $mp_qs, $conn_str, FALSE ); + } + } + + // Display top of page + + $ret .= '
    + '.$a_title.' + '; + + if( empty($view) ) // If there's no spec in $view + $ret .= $results; + else + { + for( $i=0 ; $i<$outcount ; $i++ ) + { + $view = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $view ); + $view = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $view ); + } + $view = preg_replace( "/\\{results\\}/", $results, $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $ret .= $view; + } + + $ret .= ' +
    + '; + + return( array( 'text' => $ret, 'status' => $oid, 'id' => $id ) ); +} + +function admin_add_new_record( $table, $conn_str, $fields, $url, $action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + $r = admin_add_new_record_r( $table, $conn_str, $fields, $url, $action, $params, $a_title, $view, $quick_tip ); + echo $r['text']; + return( $r['status'] ); +} + + + + +// Edit a record + +function admin_edit_record_r( $table, $conn_str, $id, $fields, $url, $action, +$params, $a_title, $view = "", $options = "", $quick_tip = "", $id_field = "" ) +{ + + $ret = ''; + + if( empty($id_field) ) + $id_field = 'id'; + + $form_name = "admin_new_form"; + $richtext_used = FALSE; + + // Check for any options + + $borders = strstr( $options, "borders" ) == FALSE ? 0 : 1; + + // Check for additional parameters that are passed + + if( !empty($params) ) + { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) + { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + + // Get the data + + $query_string = "SELECT * FROM ".$table." WHERE ".$id_field." = ".$id.";"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_edit_record()[".__LINE__."]: Query String = $query_string

    "; + $data = db_auto_get_row( $query_string, 0, $conn_str, $fail_mode ); + + if( $data ) + { + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + foreach( $field_table as $key => $r ) + $field_table[$key] = explode_trim( ",", $r ); + + // For each field in the result + + $outcount = 0; + foreach( $field_table as $field ) + { + + $field_val = filter_request($field[4]); + + // Display title fields + $out[$outcount]["hidden"] = FALSE; + + // Check for pop-up-tips + + $n = explode_trim( '~', $field[2] ); + + $field_name_color = 'black'; + + switch( $field[3] ) + { + case "TRUE": + case "UNIQUE": + $field_name_color = 'red'; + case "FALSE": + case "DISPLAY": + case "UNIQUE_NOT_REQ": + + // setup tip display - requires show_QuickTip() and hide_QuickTip() functions from java_functions.js + + if( count($n) > 1 ) { + $out[$outcount]["name"] = quick_tip( ''.$n[0].'', $n[1] ); + } else { + $out[$outcount]["name"] = ''.$field[2].''; + } + + break; + case "SUPPLIED": + $out[$outcount]["name"] = ''; + break; + case "HIDDEN": + $out[$outcount]["name"] = ''; + $out[$outcount]["hidden"] = TRUE; + break; + default: + $out[$outcount]["name"] = 'Invalid {required} field specification'; + break; + } + + // Display input fields + $f = explode_trim( ".", $field[1] ); + switch( $f[0] ) + { + case "money": + case "int": + case "text": + case "inet": + case "url": + case "order": + case "float": + case "fixed": + $prefix = ""; + $s = $f[1]; + $v = $data[$field[0]]; + $prefix = ""; + + if( $f[0] == "money" ) { // If it's money, default to 0.00 + $v = sprintf( "%01.2f", $data[$field[0]] ); + $prefix = "$"; + } + + if( $f[0] == "fixed" ) { // If it's fixed, set precision + $v = sprintf( "%01.".$f[1]."f", $data[$field[0]] ); + $s = $f[1] + 4; + } + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + $out[$outcount]["value"] = $prefix.''; + break; + + case "HIDDEN": + case "DISPLAY": + $out[$outcount]["value"] = $prefix.$v; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "lat": + $fw = 2; + if( $f[1] > 0 ) { + $fw = $f[1]; + } + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + case "FALSE": + case "DISPLAY": + $ns = 'N'; + if( $data[$field[0]] < 0 ) { + $ns = 'S'; + $data[$field[0]] = -1 * $data[$field[0]]; + } + $dv = (int) $data[$field[0]]; + $mv = ( $data[$field[0]] - $dv ) * 60; + if( $field[3] != "DISPLAY" ) { + $out[$outcount]["value"] = ' + ° + \''; + } else { + $out[$outcount]["value"] = '' + .sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + } + break; + + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "lon": + $fw = 2; + if( $f[1] > 0 ) { + $fw = $f[1]; + } + + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "UNIQUE": + case "UNIQUE_NOT_REQ": + case "FALSE": + case "DISPLAY": + $ns = 'E'; + if( $data[$field[0]] < 0 ) + { + $ns = 'W'; + $data[$field[0]] = -1 * $data[$field[0]]; + } + $dv = (int) $data[$field[0]]; + $mv = ( $data[$field[0]] - $dv ) * 60; + if( $field[3] != "DISPLAY" ) + $out[$outcount]["value"] = ' + ° + \''; + else + $out[$outcount]["value"] = '' + .sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + break; + + case "HIDDEN": + $out[$outcount]["value"] = ''; + break; + + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "date": + + $date_f = !empty( $f[1] ) ? time()-$f[1]*86400 : time() ; // Set datestamp of first day to allow + $date_t = !empty( $f[2] ) ? time()+$f[2]*86400 : time() ; // Set datestamp of last day to allow + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = calendar_date_select( $data[$field[0]], strtotime($data[$field[0]]), $date_f, $date_t, $form_name, $field[0], $f[3], $f[4] ); + break; + + case "HIDDEN": + case "DISPLAY": + $out[$outcount]["value"] = $data[$field[0]]; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "richtext": + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + if( SI_RICHTEXT_TYPE_ENABLED ) + { + + if( !$richtext_used ) + { + $richtext_used = TRUE; + } + $out[$outcount]["value"] = ' + + + + +
    + +
    + + '; + + } + else + $out[$outcount]["value"] = ''; + break; + + case "HIDDEN": + case "DISPLAY": + $out[$outcount]["value"] = $data[$field[0]]; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "textbox": + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + if( isset($f[1]) ) + { + $cols = $f[1]; + $rows = $f[2]; + } + else + { + $cols = SI_DEFAULT_TEXTBOX_COLS; + $rows = SI_DEFAULT_TEXTBOX_ROWS; + } + $out[$outcount]["value"] = ''; + break; + + case "HIDDEN": + case "DISPLAY": + $out[$outcount]["value"] = rawurldecode( $data[$field[0]] ); + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "multifield": // NOT TESTED multitext.numb_fields.new_line_string + + // THIS FIELD TYPE REQUIRES java_functions.js + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ' + '; + + // If there's data, then build existing input lines with data + if( ( $x = trim($data[$field[0]]) ) != '' ) + { + $field_data = unserialize( $data[$field[0]] ); + + if( $field_data != false && is_array( $field_data ) ) + { + // For each line of inputs + for( $i=1 ; $i<=count($field_data) ; $i++ ) + { + $f_line = str_replace( '{line_numb}', $i, $f[2] ); // Set line number in output text + // For each input field on the line + for( $j=1 ; $j<=$f[1] ; $j++ ) + $f_line = str_replace( '{field_'.($j).'}', '', $f_line ); + + $out[$outcount]["value"] .= $f_line."\n"; + } + } + + } + else + $i = 1; // If no data blank line is #1 + + // Build 1 spare input line + $f_line = str_replace( '{line_numb}', $i, $f[2] ); // Set line number in output text + for( $j=1 ; $j<=$f[1] ; $j++ ) + $f_line = str_replace( '{field_'.$j.'}', '', $f_line ); + $out[$outcount]["value"] .= $f_line."\n"; + + break; + + case "HIDDEN": + case "DISLPLAY": + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "image": + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + + if( $data[$field[0]] != "" ) // If an image already exists + { + $out[$outcount]["value"] .= ' + + '; + } + + $out[$outcount]["value"] .= ' + + +
    '; + + if( $field[3] == "TRUE" ) // If this field is required + $out[$outcount]["value"] .= 'This image may be replaced using the input field below.'; + else + $out[$outcount]["value"] .= ' Delete this image'; + + $out[$outcount]["value"] .= '
    '; + break; + + case "HIDDEN": + case "DISLPLAY": + $out[$outcount]["value"] = ''; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "multitext": // NOT TESTED multitext.{size}.{spares} + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + $txt_num = 0; + + if( ( $x = trim($data[$field[0]]) ) != '' ) + { + $txt_data = unserialize( $data[$field[0]] ); + + // Do existing images + + foreach( $txt_data as $txt ) + { + $out[$outcount]["value"] .= '#'.($txt_num+1).' 
    '; + $im_num++; + } + } + + if( empty($f[1]) ) + $spare = 2; + else + $spare = $f[2]; + for( $i=0 ; $i<$spare ; $i++ ) + { + $out[$outcount]["value"] .= '#'.($txt_num+1).' 
    '; + $im_num++; + } + break; + + case "HIDDEN": + case "DISLPLAY": + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "images": +/* NOT FOR Image Server + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + $im_num = 0; + + if( ( $x = trim($data[$field[0]]) ) != '' ) + { + $im_data = unserialize( $data[$field[0]] ); + $im_des = strstr( $f[2], 'descr' ); + $im_align = strstr( $f[2], 'align' ); + $im_size = strstr( $f[2], 'size' ); + if( !empty( $f[3] ) ) + $im_des_s = $f[3]; + else + $im_des_s = 40; + if( !empty( $f[4] ) ) + $im_des_t = $f[4]; + else + $im_des_t = "Text"; + + // Do existing images + + foreach( $im_data as $im ) + { + $out[$outcount]["value"] .= ' + Image #'.($im_num+1).'
    + + + + + + + + + '.( $im_des ? '' : '' ).' +
    + This image may be replaced using the input field below.
    + Or you may Delete this image. +

    + '.( $im_align ? ' + Align image + + ' : '' ).' + '.( $im_size ? ' + Size + + ' : '' ).' +

    Select Image
    '.$im_des_t.'
    +
    '; + $im_num++; + } + } + + if( empty($f[1]) ) + $spare = 2; + else + $spare = $f[1]; + for( $i=0 ; $i<$spare ; $i++ ) + { + $out[$outcount]["value"] .= ' + Image #'.($im_num+1).'
    + + + + + '.( $im_des ? '' : '' ).' +
    + '.( $im_align ? ' + Align image + ' : '' ).' + '.( $im_align ? ' + Size + + ' : '' ).' +
    '.$im_des_t.'
    +
    '; + $im_num++; + } + + break; + + case "HIDDEN": + case "DISLPLAY": + case "SUPPLIED": + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } +*/ + break; + + case "file": + + switch( $field[3] ) + { + case "TRUE": + case "FALSE": + $out[$outcount]["value"] = ''; + + if( $data[$field[0]] != "" ) // If a file already exists + { + $out[$outcount]["value"] .= ' + + '; + } + + $out[$outcount]["value"] .= ' + + +
    + '.$data[$field[0]].' + '; + + if( $field[3] == "TRUE" ) // If this field is required + $out[$outcount]["value"] .= 'This file may be replaced using the input field below.'; + else + $out[$outcount]["value"] .= ' Delete this file'; + + $out[$outcount]["value"] .= '
    '; + break; + + case "HIDDEN": + case "DISLPLAY": + $out[$outcount]["value"] = ''.$data[$field[0]].''; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + } + break; + + case "category": + + // If picklist is selected - use that for selection + + if( strstr($f[3],'picklist') ) + { + if( ($nodes = cat_get_nodes($f[1])) ) + { + $out[$outcount]["value"] .= ''; + } + else + $out[$outcount]["value"] .= 'No categories listed.'; + } + else // Otherwise use pop-up + { + + // Get the category name for this field is supplied + if( !empty($data[$field[0]]) ) + { + if( ($cval = cat_get_node( $f[1], "id = ".$data[$field[0]] ) ) ) + { + $cat_id = $data[$field[0]]; + if( strstr($f[3],'fullpath') ) + $cat_name = $cval['cat_fullpath']; + else + $cat_name = $cval['cat_name']; + } + } + else + { + $cat_id = 0; + $cat_name = "   "; + } + + $pop_width = !empty($f[4]) ? $f[4] : 200 ; + $pop_height = !empty($f[5]) ? $f[5] : 300 ; + $edit_width = !empty($f[6]) ? $f[6] : 400 ; + $edit_height = !empty($f[7]) ? $f[7] : 500 ; + + $out[$outcount]["value"] .= " + + "; + + $out[$outcount]["value"] .= ' + + [Change] + '; + } + + break; + + + case "pointer": + + // If {value_field} supplied use that, otherwise use id of record as VALUE + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} supplied use that, otherwise get all possibilities from other table + $w = !empty($f[4]) ? " WHERE ".$f[4] : "" ; + + // If picklist options + $p = !empty($f[5]) ? $f[5] : "" ; + + // Sort order + $s = !empty($f[6]) ? $f[6] : "id" ; + + // Pointer options + $pointer_option_add_field = FALSE; + if( ! empty($f[7]) ) + { + $option_table = explode_trim( ",", $f[7] ); + foreach( $option_table as $option ) + { + switch( $option ) + { + case "add_field": // Option to display a field for entering a new target + $pointer_option_add_field = TRUE; + break; + + default: + break; + } + } + } + + switch( $field[3] ) + { + + case "TRUE": + case "FALSE": + + $d = reg_db_auto_get_data( "SELECT * FROM ".$f[1].$w." ORDER BY ".$s.";", $conn_str, FALSE, 500 ); + + if( is_array( $d ) ) + { + unset( $da ); + while( list($key, $val) = each($d) ) + $da[$val[$value_field]] = $val[$f[2]]; + + // If there's a supplied value, use that to match for selected + + if( !empty($field_val) ) { + $z = $field_val; + } else { + $z = $data[$field[0]]; + } + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $da, $data[$field[0]], "standard", $p ); + } + else + $out[$outcount]["value"] = '(no values available)'; + + // Provide an additional input field to permit adding a new target value + + if( $pointer_option_add_field ) + $out[$outcount]["value"] .= ' or add new value '; + + break; + + case "HIDDEN": + case "DISPLAY": + + // Get specific data requested + if( ($d = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE id = ".$data[$field[0]]." ORDER BY ".$s.";", 0, $conn_str, $fail_mode )) ); + + $out[$outcount]["value"] = $d[$f[2]]; + + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + + } + break; + + + case "multipointer": + + // If {value_field} supplied use that, otherwise use id of record as VALUE + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} supplied use that, otherwise get all possibilities from other table + $w = !empty($f[4]) ? " WHERE ".$f[4] : "" ; + + // If picklist options + $p = !empty($f[5]) ? $f[5] : "" ; + + // Sort order + $s = !empty($f[6]) ? $f[6] : "id" ; + + // Get currently selected fields + $mp_selected = reg_db_auto_get_data( "SELECT * FROM ".$f[7]." WHERE ".$f[8]." = ".$id." ORDER BY ".$s.";", $conn_str, FALSE, 500 ); + $mp_sel = array(); + if (is_array($mp_selected) && count($mp_selected) > 0) { + foreach ($mp_selected as $mp) { + $mp_sel[] = $mp[$f[9]]; + } + } + + switch( $field[3] ) + { + + case "TRUE": + case "FALSE": + + $d = reg_db_auto_get_data( "SELECT * FROM ".$f[1].$w." ORDER BY ".$s.";", $conn_str, FALSE, 500 ); + + if( is_array( $d ) ) { + unset( $da ); + while( list($key, $val) = each($d) ) { + $da[$val[$value_field]] = $val[$f[2]]; + } + + // If there's a supplied value, use that to match for selected + + if( !empty($field_val) ) { + $z = $field_val; + } else { + $z = $data[$field[0]]; + } + + $out[$outcount]["value"] = reg_build_picklist( $field[0], $da, $mp_sel, "standard", $p." multi" ); + } else { + $out[$outcount]["value"] = '(no values available)'; + } + + // Provide an additional input field to permit adding a new target value + if( $pointer_option_add_field ) { + $out[$outcount]["value"] .= ' or add new value '; + } + + break; + + case "HIDDEN": + case "DISPLAY": +echo "multipointer DISPLAY HIDDEN not available yet."; exit; + + // Get specific data requested + if( ($d = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE id = ".$data[$field[0]]." ORDER BY ".$s.";", 0, $conn_str, $fail_mode )) ); + + $out[$outcount]["value"] = $d[$f[2]]; + + break; + + case "SUPPLIED": +echo "multipointer SUPPLIED not available yet."; exit; + + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + + + } + + break; + + case "checkbox": + + // Check for null value + + if( empty($data[$field[0]]) ) + $data[$field[0]] = "f"; + + switch( $field[3] ) // {required} setting + { + + case "TRUE": + case "FALSE": + $x = $data[$field[0]] == "t" ? " CHECKED" : ""; + $out[$outcount]["value"] = ''; + break; + + case "HIDDEN": + case "DISPLAY": + $x = $data[$field[0]] == "t" ? "Yes" : "No"; + $out[$outcount]["value"] = $x; + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + break; + + case "bitmap": + $bmap = explode_trim( "~", $f[1] ); + $out[$outcount]["value"] = ""; + switch( $field[3] ) // {required} setting + { + case "TRUE": + case "FALSE": + for( $i=0 ; $i'.$bmap[$i].'
    '; + } + break; + + case "HIDDEN": + case "DISPLAY": + for( $i=0 ; $i'; + } + break; + + case "SUPPLIED": + $out[$outcount]["value"] = ""; + break; + + default: + $out[$outcount]["value"] = 'Invalid {required} field specification'; + break; + } + if( $out[$outcount]["value"] == '' ) + $out[$outcount]["value"] = '(no options listed)'; + break; + + case "list": + + // If picklist options + $p = !empty($f[3]) ? $f[3] : "" ; + + $option_table = ""; + $opts = explode_trim( "~", $f[1] ); // Separate list options + $def_value = !empty($f[2]) ? $f[2] : "" ; + + // If there's no current value, use default for current picklist option + + if( trim($data[$field[0]]) == "" ) + $current_value = $f[2]; + else + $current_value = $data[$field[0]]; + + foreach( $opts as $opt ) + { + $os = explode_trim( "^", $opt ); // Separate value from displayed text + $option_table[$os[0]] = $os[1]; + } + + switch( $field[3] ) // {required} setting + { + case "DISPLAY": + $out[$outcount]['value'] = $option_table[$data[$field[0]]]; + break; + default: + if( strstr( 'multi', $f[3] ) ) + $data[$field[0]] = explode( '~', $data[$field[0]] ); + $out[$outcount]["value"] = reg_build_picklist( $field[0], $option_table, $data[$field[0]], "standard", $p ); + break; + } + break; + + case "state": + switch( $field[3] ) // {required} setting + { + case "DISPLAY": + $out[$outcount]['value'] = $GLOBALS['si_states_array'][$data[$field[0]]]; + break; + default: + $out[$outcount]["value"] = reg_build_picklist( $field[0], $GLOBALS['si_states_array'], $data[$field[0]], "standard", $f[2] ); + } + break; + + case "country": + switch( $field[3] ) // {required} setting + { + case "DISPLAY": + $out[$outcount]['value'] = $GLOBALS['si_states_array'][$data[$field[0]]]; + break; + default: + $out[$outcount]["value"] = reg_build_picklist( $field[0], $GLOBALS['si_countries_array'], $data[$field[0]], "standard", $f[2] ); + } + break; + + case "break": + if( !empty($f[1]) ) // if {t1} is supplied + $out[$outcount]["value"] = $f[1]; + else + $out[$outcount]["value"] = 'No {text} supplied for type "break"'; + break; + + default: + $out[$outcount]["value"] = 'UNKNOWN FIELD TYPE: '.$f[0].' for '.$field[0].''; + break; + + } // switch( field ) + + $outcount++; + } // foreach( field ) + + } + else + { + $ret .= '
    (No results found)
    +

    + '; + return; + } + + $submit = ' + + + '; + + // Replace parameters in Title + + for( $i=0 ; $i<$outcount ; $i++ ) + { + $a_title = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $a_title ); + } + + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + // Output Results + + // Display top of page + + $ret .= '

    +
    + + '; + + if( empty($view) ) // If there's no format spec in $view + { + $ret .= '
    '.$a_title.' + (Required fields in red)
    + 0?' CELLPADDING="5"':'').'> + '; + + for( $i=0 ; $i<$outcount ; $i++ ) + { + if( !$out[$i]["hidden"] ) + $ret .= ' + '; + } + $ret .= '

    +

    '.$out[$i]["name"] + .' '.$out[$i]["value"].' 
    '.$form_params.$submit; // Output the Update submit button + + } + else // Otherwise use $view to output data + { + for( $i=0 ; $i<$outcount ; $i++ ) + { + $view = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $view ); + $view = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $view ); + } + $view = preg_replace( "/\\{submit\\}/", $submit, $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $ret .= '
    '.$a_title.$view; + } + + $ret .= ' + +
    + '; + + return( array( 'text' => $ret, 'status' => true ) ); + +} + + +function admin_edit_record( $table, $conn_str, $id, $fields, $url, $action, +$params, $a_title, $view = "", $options = "", $quick_tip = "", $id_field = "" ) +{ + + $r = admin_edit_record_r( $table, $conn_str, $id, $fields, $url, $action, + $params, $a_title, $view, $options, $quick_tip ); + echo $r['text']; + return( $f['status'] ); +} + + + + +// Update an edited record + +function admin_update_record_r( $table, $conn_str, $id, $fields, $url, $action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + + $ret = ''; + + if( empty($id_field) ) + $id_field = 'id'; + + + // Make all submitted parameters available + + // extract($GLOBALS[HTTP_POST_VARS]); + // extract($GLOBALS[HTTP_GET_VARS]); + // extract($GLOBALS[HTTP_POST_FILES]); + + // Check for additional parameters that are passed + + if( !empty($params) ) + { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) + { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + // Get the current data for reference and to make sure it exists + $query_string = "SELECT * FROM ".$table." WHERE ".$id_field." = ".$id.";"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_update_record()[".__LINE__."]: Get old record = $query_string

    "; + $data = db_auto_get_row( $query_string, 0, $conn_str, $fail_mode ); + + $update_record = true; // Assume update is going to succeed. + + if( $data ) + { + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + foreach( $field_table as $key => $r ) + $field_table[$key] = explode_trim( ",", $r ); + + $result = $problem = $not_supplied = ""; + $qs = ''; + + // For each field in the result + + $comma = ""; // first parameter doesn't need a comma in front of it + + $outcount = 0; + foreach( $field_table as $field ) + { + + $f = explode_trim( ".", $field[1] ); + $fta = explode_trim( "~", $field[2] ); + $field_title_only = $fta[0]; + + if ($f[0] == 'richtext' && $f[3] != '') { + switch ($f[3]) { + case 'encoded': + $filter = FILTER_SANITIZE_ENCODED; + break; + default: + $filter = FILTER_SANITIZE_STRING; + } + $field_val = filter_request($field[4],$filter); + } else { + $field_val = filter_request($field[4]); + } + + if( $field[3] != 'DISPLAY' ) // Don't even try to process a DISPLAY only field. No point to it! + switch( $f[0] ) + { + + case "order": + case "int": + case "float": + case "fixed": + case "money": + case "pointer": + case "category": + + // Handle special cases + switch( $f[0] ) + { + case "money": + $field_val = preg_replace( "/[\$,]/", "", $field_val ); // Get rid of "$" and "," from silly users + break; + + case "pointer": + + // Check for add_field values - Add new value to pointer target record + + if( ($add_value = trim(filter_request($field[4].'_add_field'))) != '' ) + { + // If value already exists warn user. + + if( db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE ".$f[2]." = '".trim(filter_request($field[4].'_add_field'))."';", 0, $conn_str, $fail_mode ) ) + $not_supplied .= $field_title_only.": Value already exists in pick list, don't try to add it again.
    "; + else + { + // Otherwise, add new value and use pointer to that + + $add_result = db_auto_get_row( "INSERT INTO ".$f[1]." ( ".$f[2]." ) VALUES ( '".trim(filter_request($field[4].'_add_field'))."' ); + SELECT currval( '".$f[1]."_id_seq' ) AS id;", 0, $conn_str, $fail_mode ); + $cv = $add_result['id']; + } + } + + break; + } + + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + $out[$outcount]["value"] = $field_val; + switch( $field[3] ) + { + case "SUPPLIED": + $qs .= $field_val; + break; + + case "TRUE": + if( !is_numeric($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= $field_val; + } + break; + + case "FALSE": + if( is_numeric($field_val) ) { + $qs .= $field_val; + } else { + $qs .= "0"; // Default to 0 + } + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "lat": + $qs .= $comma." ".$field[0]." = "; + $comma = ","; + + // If we've been passed a decimal degree value + if( empty($field_val) ) { + if( filter_request($field[4].'_DEG') > 90 || filter_request($field[4].'_DEG') < 0 || filter_request($field[4].'_MIN') >= 60 || filter_request($field[4].'_MIN') < 0 ) + { + $not_supplied .= $field_title_only.": Invalid entry. Degrees must be 0 to 90 and Minutes must be 0 to less than 60
    "; + break; + } + $v = ( filter_request($field[4].'_NS') == "N" ? 1 : -1 ) * ( filter_request($field[4].'_DEG') + ( filter_request($field[4].'_MIN') / 60 ) ); + } + $fw = 2; + // Rebuild value for display + if( $f[1] > 0 ) { + $fw = $f[1]; + } + $ns = 'N'; + if( ($v2=$field_val) < 0 ) { + $ns = 'S'; + $v2 = -1 * $v2; + } + $dv = (int) $v2; + $mv = ( $v2 - $dv ) * 60; + $out[$outcount]["value"] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + switch( $field[3] ) + { + case "SUPPLIED": + case "FALSE": + $qs .= $field_val; + break; + + case "TRUE": + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= $field_val; + } + break; + + case "UNIQUE": + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $field_val;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $qs .= $field_val; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($field_val) && db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $qs .= $field_val; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "lon": + $qs .= $comma." ".$field[0]." = "; + $comma = ","; + + // If we've been passed a decimal degree value + if( empty($field_val) ) { + if( filter_request($field[4].'_DEG') > 180 || filter_request($field[4].'_DEG') < 0 || filter_request($field[4].'_MIN') >= 60 || filter_request($field[4].'_MIN') < 0 ) + { + $not_supplied .= $field_title_only.": Invalid entry. Degrees must be 0 to 180 and Minutes must be 0 to less than 60
    "; + break; + } + $v = ( filter_request($field[4].'_NS') == "N" ? 1 : -1 ) * ( filter_request($field[4].'_DEG') + ( filter_request($field[4].'_MIN') / 60 ) ); + } + $fw = 2; + // Rebuild value for display + if( $f[1] > 0 ) { + $fw = $f[1]; + } + $ns = 'E'; + if( ($v2=$field_val) < 0 ) { + $ns = 'W'; + $v2 = -1 * $v2; + } + $dv = (int) $v2; + $mv = ( $v2 - $dv ) * 60; + $out[$outcount]["value"] = sprintf( "%s %d° %01.".$fw."f'", $ns, $dv, $mv ); + switch( $field[3] ) + { + case "SUPPLIED": + case "FALSE": + $qs .= $field_val; + break; + + case "TRUE": + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= $field_val; + } + break; + + case "UNIQUE": + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $field_val;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $qs .= $field_val; + break; + + case "UNIQUE_NOT_REQ": + if( !empty($field_val) && db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = $v;", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + $qs .= $field_val; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + + break; + + case "text": + case "inet": + case "list": + case "state": + case "country": + case "url": + case "textbox": + case "richtext": + + // Check for special cases + switch( $f[0] ) + { + case "inet": + if( ($r = clean_input( $field[0], 'inet' )) != '' ) { + $problem .= ''.$field_title_only.': Not a valid IP address or netmask.
    '; + } + break; + + case "list": + // If 'multi' is selected for picklist option, then compile results from array + if( strstr( $f[3], 'multi' ) ) + { + $m_val = $sep = ''; + + // Place results in '~' separated string for storage. + + $cv = $_REQUEST[$field[4]]; + if( is_array($cv) ) + foreach( $cv as $m ) + { + $m_val .= $sep.$m; + $sep = '~'; + } + $field_val = $m_val; + } + + break; + + default: + break; + } + + $v = str_replace( "%27", "\'", $field_val ); + if( trim(strip_tags($v)) == '' ) { + $v = ''; + } + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + $out[$outcount]["value"] = $v; + + switch( $field[3] ) + { + case "SUPPLIED": + $qs .= "'".rawurldecode( $v )."'"; + break; + + case "TRUE": + if( empty($v) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= "'".rawurldecode( $v )."'"; + } + break; + + + case "UNIQUE": + if( $f[0] != text ) { + $problem .= 'ERROR: UNIQUE only available for type "text"
    '; + break; + } + + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= "'".rawurldecode($field_val)."'"; + } + + // Check if value is used anywhere other than current record + + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".rawurldecode( trim($v) )."' AND ".$id_field." != ".$id.";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + + break; + + case "UNIQUE_NOT_REQ": + if( $f[0] != text ) { + $problem .= 'ERROR: UNIQUE only available for type "text"
    '; + break; + } + + if( !empty($field_val) ) { + $qs .= "'".rawurldecode($field_val)."'"; + + // Check if value is used anywhere other than current record + + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".rawurldecode( trim($v) )."' AND ".$id_field." != ".$id.";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + } else { + $qs .= "''"; + } + + break; + + + case "FALSE": + $qs .= "'".rawurldecode( $v )."'"; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + + break; + + case "date": + + // If a date is supplied, correct any date errors + if ($field_val != '') { + $field_val = date('m/d/Y', strtotime($field_val)); + } + + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + $out[$outcount]["value"] = $field_val; + + if( trim($field_val) == "" ) { // Empty dates must be "NULL" + $dval = "NULL"; + } else { + $dval = "'".$field_val."'"; + } + + switch( $field[3] ) + { + case "SUPPLIED": + $qs .= $dval; + break; + + case "TRUE": + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= $dval; + } + break; + + + case "UNIQUE": + if( $field[1] != text ) { + $problem .= 'ERROR: UNIQUE only available for type "text"
    '; + break; + } + + if( empty($field_val) ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + } else { + $qs .= $dval; + + // Check if value is used anywhere other than current reccord + + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim($field_val)."' AND ".$id_field." <> ".$id.";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + } + + break; + + case "UNIQUE_NOT_REQ": + if( $field[1] != text ) { + $problem .= 'ERROR: UNIQUE only available for type "text"
    '; + break; + } + + if( !empty($field_val) ) + { + $qs .= $dval; + + // Check if value is used anywhere other than current reccord + + if( db_auto_get_row( "SELECT * FROM $table WHERE ".$field[0]." = '".trim(filter_request($field[4]))."' AND ".$id_field." <> ".$id.";", 0, $conn_str, $fail_mode ) ) { + $not_supplied .= $field_title_only.": Already exists, must be unique
    "; + } + } else { + $qs .= $dval; + } + + break; + + + case "FALSE": + $qs .= $dval; + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "multifield": + + $line = 0; + $empty = TRUE; + $m_data = array(); + + // Build array of data to store + while( isset( $_REQUEST[$field[4].'_'.($line+1).'_1'] ) ) { + $line++; + if( trim(filter_request($field[4].'_'.$line.'_1')) != '' ) { + $a = array(); + for( $i=1 ; $i<=$f[1] ; $i++ ) { + $a[$i-1] = stripslashes(trim( str_replace("%27", "\'", filter_request($field[4].'_'.($line).'_'.$i) ) )); + if( $a[$i-1] != '' ) + $empty = FALSE; + } + array_push( $m_data, $a ); + } + } + + if( !$empty ) { + $v = serialize( $m_data ); + } else { + $v = ''; + } + + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + $out[$outcount]["value"] = $v; + + switch ($field[3]) + { + case "TRUE" : + if (empty ($v)) + $not_supplied .= $field_title_only.": Not Supplied
    "; + else + $qs .= "'".rawurldecode($v)."'"; + break; + + case "FALSE" : + $qs .= "'".rawurldecode($v)."'"; + break; + + default : + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + + break; + + case "image": + // Note that the image field is only updated when required so field name is set below along with value + $out[$outcount]["value"] = "IMAGES Not Available for View at this time"; + $img = filter_request($field[4]); + + switch( $field[3] ) + { + case "SUPPLIED": + $problem .= 'ERROR: "SUPPLIED" not permitted as option for image input'; + break; + + case "TRUE": + + // If no image is supplied and there's no image in the database + if( !is_array($img) && $data[$field[0]] == "" ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + break; + } + + // If new image is supplied, replace old one + if( $img['name'] != '' ) { + if( $data[$field[0]] != "" ) { + reg_delete_image( $data[$field[0]] ); + } + $qs .= $comma." ".$field[0]." = '".reg_process_image($field[4])."'"; + $comma = ","; + } + break; + + case "FALSE": + + // If new image is supplied, store it + if( $img['name'] != '' ) { + if( $data[$field[0]] ) { // If there's already an image, delete it before storing the new one + reg_delete_image( $data[$field[0]] ); + } + $qs .= $comma." ".$field[0]." = '".reg_process_image($field[4])."'"; + $comma = ","; + + // Else, if there's an image in the database and we're deleting + } elseif( $data[$field[0]] != "" && isset($_REQUEST[$field[0]."_DELETE"]) ) { + reg_delete_image( $data[$field[0]] ); + $qs .= $comma." ".$field[0]." = ''"; // Clear image name in database + $comma = ","; + } + + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + case "images": +/* NOT CONFIGURED FOR Image Server + // Note that the image field is only updated when required so field name is set below along with value + + $out[$outcount]["value"] = "IMAGES Not Available for View at this time"; + switch( $field[3] ) + { + case "FALSE": + if( is_array( ($im_data = filter_request($field[4])) ) ) + { + $im_cur = unserialize( $data[$field[0]] ); // Convert existing data to an array + $im_new = array(); + $im_new_num = 0; + for( $im_num=0 ; $im_num
    '; + break; + } +*/ + break; + + case "file": + + // Note that the file field is only updated when required so field name is set below along with value + + $out[$outcount]["value"] = "FILES Not Available for View at this time"; + + // Check if file type is specified and if so does it match + + if( isset($f[1]) && (filter_request($field[4]."_name") != "") && !preg_match( "/.".$f[1]."$/i",filter_request($field[4]."_name")) ) { + $not_supplied .= $field_title_only.': "'.filter_request($field[4]."_name").'" is not correct file type. Must be: '.$f[1]."
    "; + break; + } + + switch( $field[3] ) + { + case "SUPPLIED": + $problem .= 'ERROR: "SUPPLIED" not permitted as option for file input'; + break; + + case "TRUE": + + // If no file is supplied and there's no file in the database + + if( filter_request($field[4]."_name") == "" && $data[$field[0]] == "" ) { + $not_supplied .= $field_title_only.": Not Supplied
    "; + break; + } + + // If new file is supplied, replace old one + if( filter_request($field[4]."_name") != "" ) { + if( $data[$field[0]] != "" ) { + reg_file_delete( $data[$field[0]] ); + } + $qs .= $comma." ".$field[0]." = '".reg_file_upload($field[4])."'"; + $comma = ","; + } + break; + + case "FALSE": + + // If new file is supplied, store it + + if( filter_request($field[4]."_name") != "" ) { + if( $data[$field[0]] ) { // If there's already a file, delete it before storing the new one + reg_file_delete( $data[$field[0]] ); + } + $qs .= $comma." ".$field[0]." = '".reg_file_upload($field[4])."'"; + $comma = ","; + // Else, if there's a file in the database and we're deleting + } elseif( $data[$field[0]] != "" && isset($GLOBALS[$field[0]."_DELETE"]) ) { + reg_file_delete( $data[$field[0]] ); + $qs .= $comma." ".$field[0]." = ''"; // Clear file name in database + $comma = ","; + } + + break; + + default: + $problem .= 'ERROR: Invalid "Required" field name "'.$field[3].'" in function call
    '; + break; + } + break; + + + case "checkbox": + // Doesn't matter whether it's required or not, or whatever + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + if( filter_request($field[4]) == "on" ) { + $out[$outcount]["value"] = "Yes"; + $qs .= "TRUE"; + } else { + $out[$outcount]["value"] = "No"; + $qs .= "FALSE"; + } + break; + + + case "bitmap": + $out[$outcount]["value"] = "Bitmaps not available for view at this time"; + $qs .= $comma." ".$field[0]." = "; // Add field name to update to query string + $comma = ","; + $bm = $field_val; + $b = 0; // Start with clear bitmap + for( $i=0 ; $i 0) { + foreach ($_REQUEST[$field[0]] as $mps) { + $m_qs .= "INSERT INTO ".$f[7]." (".$f[8].",".$f[9].") VALUES (".$id.",".($mps-0).");\n"; + } + + } + reg_db_auto_exec( $m_qs, $conn_str, FALSE ); + + break; + + default: + $problem .= 'UNKNOWN FIELD TYPE: '.$field[1].' for '.$field[0].'
    '; + break; + + } // switch( field ) + + $outcount++; + } // foreach( field ) + + } else { + $ret .= '
    (Record not found)
    +

    + '; + return( array( 'text' => $ret, 'status' => false ) ); + } + + if( !empty($not_supplied) ) { + $result .= '

    Required fields not supplied

    + '.$not_supplied.'

    + Use "BACK" button on browser, add missing data and resubmit.

    + '; + $update_record = false; + } + + if( !empty($problem) ) { + $result .= $problem.'

    + Use "BACK" button on browser, correct problem field, and resubmit.

    + '; + $update_record = false; + } + + if( $update_record && $qs != '' ) { + $qs = "UPDATE $table SET $qs WHERE ".$id_field." = $id;"; + if ($GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "

    admin_update_record()[".__LINE__."]: Update record = $qs

    "; + reg_db_auto_exec( $qs, $conn_str, FALSE ); + $result .= '

    Data updated.

    '; + } + + // Replace parameters in Title + + for( $i=0 ; $i<$outcount ; $i++ ) { + $a_title = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $a_title ); + } + + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + $a_title = preg_replace( "/\\{result\\}/", $result, $a_title ); + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + // Display top of page + + $ret .= '

    + '.$a_title."\n"; + + if( empty($view) ) { // If there's no spec in $view + $ret .= $result; + } else { + for( $i=0 ; $i<$outcount ; $i++ ) + { + $view = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $view ); + $view = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $view ); + } + $view = preg_replace( "/\\{999\\}/", $out[999]["value"], $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $view = preg_replace( "/\\{result\\}/", $result, $view ); + $ret .= $view; + } + + $ret .= ' +
    + '; + + return( array( 'id' => $id, 'text' => $ret, 'status' => $update_record ) ); + +} + +function admin_update_record( $table, $conn_str, $id, $fields, $url, $action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + $r = admin_update_record_r( $table, $conn_str, $id, $fields, $url, $action, $params, $a_title, $view, $quick_tip ); + echo $r['text']; + return( $r['status'] ); +} + + + + +// Ask for the deletion of a record + +function admin_delete_record_r( $table, $conn_str, $id, $fields, +$options, $url, $action, $params, $a_title, $view="", $quick_tip="" ) +{ + + $ret = ''; + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) { + array_pop( $field_table ); + } + + foreach( $field_table as $key => $r ) { + $field_table[$key] = explode_trim( ",", $r ); + } + + // Check for additional parameters that are passed + + if( !empty($params) ) { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + // Scan options + + $option_strong = FALSE; + if( !empty($options) ) { + $option_table = explode_trim( ",", $options ); + foreach( $option_table as $option ) { + switch( $option ) { + case "strong": + $option_strong = TRUE; + break; + + default: + // $ret .= '

    ERROR: Illegal Option Specified

    '; + break; + } + } + } + + + // Get the data + + $query_string = "SELECT * FROM ".$table." WHERE id = $id;"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_delete_record()[".__LINE__."]: Record to delete = $query_string

    "; + $data = db_auto_get_row( $query_string, 0, $conn_str, $fail_mode ); + $problem = ''; + + if( $data ) + { + + // For each field in the result + + $outcount = 0; // replaceable field data table pointer + foreach( $field_table as $field ) + { + $f2 = explode_trim( "~", $field[2] ); + $out[$outcount]["name"] = $f2[0]; + $out[$outcount]["display"] = $field[3] != "HIDDEN" ? TRUE : FALSE; + $f = explode_trim( ".", $field[1] ); // Extract type options + switch( $f[0] ) + { + // Check other tables for references to this record + + case "check": + if( $f[1] == '' || $f[2] == '' ) + { + $problem .= ''.$field[0].': Table or Field name not supplied for reference check.
    '; + break; + } + if( ($c = db_auto_get_row( "SELECT count(".$f[2].") FROM ".$f[1]." WHERE ".$f[2]." = $id;" )) && $c['count'] > 0 ) + { + $problem .= 'This reccord is referenced '.$c['count'].' time(s) by "'.$f2[0].'". Delete References first.
    '; + break; + } + + break; + + case "money": + $out[$outcount]["value"] = "$".sprintf( "%01.2f", $data[$field[0]] ); + break; + + case "order": + case "int": + case "float": + case "fixed": + $out[$outcount]["value"] = $data[$field[0]]; + break; + + case "checkbox": + $out[$outcount]["value"] = $data[$field[0]] == 't' ? 'Yes' : 'No'; + break; + + case "text": + case "inet": + case "state": + case "country": + case "textbox": + case "richtext": + case "date": + $out[$outcount]["value"] = $data[$field[0]]; + break; + + case "checkbox": + $out[$outcount]["value"] = $data[$field[0]] == "t" ? "Yes" : "No" ; + break; + case "url": + $out[$outcount]["value"] = ''.$data[$field[0]].''; + break; + + case "category": + // Get the category name for this field if supplied + if( !empty($data[$field[0]]) ) + { + if( $cval = db_auto_get_row( "SELECT * FROM ".$f[1]." WHERE id = ".$data[$field[0]].";", 0, $conn_str, FALSE ) ) + $out[$outcount]["value"] = $cval['name']; + else + $out[$outcount]["value"] = 'Unknown Category'; + } + else + { + $out[$outcount]["value"] = " "; + } + break; + + case "pointer": + // If {value_field} supplied use that, otherwise use id of record as value to match + $value_field = !empty($f[3]) ? $f[3] : "id" ; + + // If {where} supplied use that, otherwise get all possibilities from other table + $w = !empty($f[4]) ? " WHERE ".$f[4] : " WHERE ".$value_field." = ".$data[$field[0]] ; + + $pval = db_auto_get_row( + "SELECT * FROM ".$f[1].$w.";", + 0, $conn_str, $fail_mode ); + $out[$outcount]["value"] = $pval[$f[2]]; + break; + + default: + $out[$outcount]["value"] = 'UNKNOWN FIELD TYPE: '.$f[0].' for '.$field[0].''; + break; + + } // switch( field ) + $outcount++; + } // foreach( field ) + + // Confirm field and Submit button go into {submit} + + if( $option_strong ) + $submit = '
    + To confirm, type "Delete" below.
    +
    + + +
    + + + '.$form_params.' +
    + '; + else + $submit = ' +
    + + +
    + + + '.$form_params.' +
    + '; + + // Replace parameters in Title + + for( $i=0 ; $i<$outcount ; $i++ ) + { + $a_title = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $a_title ); + $a_title = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $a_title ); + } + + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + $a_title = preg_replace( "/\\{submit\\}/", $submit, $a_title ); + $a_title = preg_replace( "/\\{result\\}/", $result, $a_title ); + + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + + // Output results + + if( empty($view) ) // If there's no format spec in $view + { + $ret .= '
    '.$a_title.' +

    +

    Are you sure you want to delete this information?

    + + '; + for( $i=0 ; $i<$outcount ; $i++ ) + { + if( $out[$i]["display"] ) + $ret .= ' + '; + } + $ret .= '

    +

    '.$out[$i]["name"] + .' '.$out[$i]["value"].' 
    '.$submit; // Output the Confirm field and submit button + + } + else // Otherwise use $view to output data + { + for( $i=0 ; $i<$i ; $i++ ) + { + $view = preg_replace( "/\\{".$i."\\}/", $out[$i]["value"], $view ); + $view = preg_replace( "/\\{encode:".$i."\\}/", urlencode($out[$i]["value"]), $view ); + } + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $view = preg_replace( "/\\{submit\\}/", $submit, $view ); + $view = preg_replace( "/\\{result\\}/", $result, $view ); + $ret .= '
    '.$a_title.$view; + } + + if( $problem != '' ) + { + $ret = '
    '.$a_title.$problem.'
    '; + return( array( 'text' => $ret, 'status' => false ) ); + } + + } // if( $data ) + else + $ret .= '
    (No results found)
    +

    + '; + + + + $ret .= '

    + '; + + return( array( 'text' => $ret, 'status' => true ) ); + +} + +function admin_delete_record( $table, $conn_str, $id, $fields, +$options, $url, $action, $params, $a_title, $view="", $quick_tip="" ) +{ + $r = admin_delete_record_r( $table, $conn_str, $id, $fields, + $options, $url, $action, $params, $a_title, $view, $quick_tip ); + echo $r['text']; + return( $r['status'] ); +} + + +// Delete a record if confirmed + +function admin_confirm_delete_record_r( $table, $conn_str, $id, $fields, $url, +$action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + + $ret = ''; + + // Make all submitted parameters available + + // extract($GLOBALS[HTTP_POST_VARS]); + // extract($GLOBALS[HTTP_GET_VARS]); + + // Check for additional parameters that are passed + if( !empty($params) ) { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + // Check "Confirm" field for correct text + + $result = ""; + $delete_record = TRUE; // Assume that we're going to delete this record + if( $_REQUEST['Confirm'] == "Delete" ) + { + + // Get the current data for reference and to make sure it exists + + $query_string = "SELECT * FROM $table WHERE id = $id;"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_confirm_delete_record()[".__LINE__."]: Record to delete = $query_string

    "; + $data = db_auto_get_row( $query_string, 0, $conn_str, $fail_mode ); + + // Separate field title from QuickTip in case we need it + $fta = explode_trim( "~", $field[2] ); + $field_title_only = $fta[0]; + + + if( $data ) { + + $not_delete_message = ""; + + if( trim($fields) != "" ) { // If there's any check fields + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) { + array_pop( $field_table ); + } + + foreach( $field_table as $key => $r ) { + $field_table[$key] = explode_trim( ",", $r ); + } + + // For each check field specified + + foreach( $field_table as $field ) { + $f = explode_trim( ".", $field[1] ); + switch( $f[0] ) + { + case "reference": // Check to see if this record is referenced + if( db_auto_get_row( "SELECT id FROM ".$f[1]." WHERE ".$f[2]." = $id;", 0, $conn_str, $fail_mode ) ) + { + $result .= 'Can\'t delete this information. You must delete '.$field[2].' first.
    '; + $delete_record = FALSE; + } + break; + + case "image": + reg_delete_image( $data[$field[0]] ); + break; + + default: + $result .= 'UNKNOWN FIELD TYPE: '.$f[0].' for '.$field[0].'
    '; + $delete_record = FALSE; + break; + + } // switch( field ) + + } // foreach( field ) + } + } // if data + else + { + $result .= '

    Record not found


    '; + $delete_record = FALSE; + } + + + } // if Confirm + else + { + $result .= '

    Delete NOT Confirmed.

    '; + $delete_record = FALSE; + } + + + if( $delete_record ) + { + $qs = "DELETE FROM ".$table." WHERE id = ".$id.";"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_confirm_delete_record()[".__LINE__."]: Delete Record = $qs

    "; + reg_db_auto_exec( $qs, $conn_str, FALSE ); + $result .= '

    Record Deleted.

    '; + } + else + $result .= '

    Not deleting this record

    + '.$not_delete_message.'

    + '; + + // Make replacements in $a_title + + $a_title = preg_replace( "/\\{result\\}/", $result, $a_title ); + $a_title = preg_replace( "/\\{link_params\\}/", $link_params, $a_title ); + $a_title = preg_replace( "/\\{form_params\\}/", $form_params, $a_title ); + + // Add QuickTip if provided + + if( trim($quick_tip) != '' ) + $a_title = quick_tip( $a_title, $quick_tip ); + + // Display top of page + + $ret .= '

    + '.$a_title.' + '; + + if( empty($view) ) + $ret .= $result; + else + { + $view = preg_replace( "/\\{result\\}/", $result, $view ); + $view = preg_replace( "/\\{link_params\\}/", $link_params, $view ); + $view = preg_replace( "/\\{form_params\\}/", $form_params, $view ); + $ret .= $view; + } + + $ret .= ' +
    + '; + + + return( array( 'text' => $ret, 'status' => $delete_record ) ); + + +} + +function admin_confirm_delete_record( $table, $conn_str, $id, $fields, $url, +$action, $params, $a_title, $view = "", $quick_tip = "", $id_field = "" ) +{ + $r = admin_confirm_delete_record_r( $table, $conn_str, $id, $fields, $url, + $action, $params, $a_title, $view, $quick_tip ); + echo $r['text']; + return( $r['status'] ); +} + + + + +// View the data in a record + +function admin_view_record_r( $table, $conn_str, $id, $fields, +$url, $action, $params, $a_title, $view="", $options = "", $quick_tip = "", $id_field = '' ) +{ + + $ret = ''; + + if( empty($id_field) ) + $id_field = 'id'; + + // Check for any options + + $borders = strstr( $options, "borders" ) ? 1 : 0; // Show table borders + $nocenter = strstr( $options, "nocenter" ) ? 1 : 0; // Don't output
    tags around content + + // Break out configuration data + + $field_table = explode_trim( "|", $fields ); + + // Don't be surprised if last field is blank + + if( trim($field_table[count($field_table)-1]) == "" ) + array_pop( $field_table ); + + // Check for additional parameters that are passed + + if( !empty($params) ) + { + $param = explode_trim( "|", $params ); // Separate parameters + $link_params = $form_params = ""; + foreach( $param as $p ) + { + $x = explode_trim( ".", $p ); // Separate Names from Values + $link_params .= "&".$x[0]."=".urlencode($x[1]); + $form_params .= ''; + } + } + + // Get the data + + $qs = "SELECT * FROM $table WHERE ".$id_field." = $id;"; + if( $GLOBALS['reg_config']['debug'] >= 1 ) $ret .= "
    admin_view_record()[".__LINE__."]: View Record = $qs

    "; + $data = db_auto_get_row( $qs, 0, $conn_str, $fail_mode ); + + if( $data ) + { + // For each field in the result + + for( $res_field=0 ; $res_field