<?php

// index.php
// -----------------------------------------------------------------------------
// The test harness for the EDI automation hub
//
// Project    > dmClubNewYear08:C37
// Copyright  > (C) Digital Mail Limited (2005-2008)
// Author     > RAK for DML
// -----------------------------------------------------------------------------

// INITIALISE VARIABLES

// Call in the XComponents options file
define('MOD_PHP', substr(PHP_SAPI, 0, 3) != 'cgi'); // Are we running as mod_php?
define('DOCROOT', 
	MOD_PHP && isset($_SERVER['DOCUMENT_ROOT']) ? 
		$_SERVER['DOCUMENT_ROOT'] : 
			(MOD_PHP && isset($_SERVER['SCRIPT_FILENAME']) ? 
				substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])) : 
				substr(str_repeat('../', count(explode('/', preg_replace('_/+_', '/', $_SERVER['PHP_SELF'])))-2), 0, -1))
	);
include(DOCROOT . '/dmx/dmx_options.php');

// The absolute URL of edi_automation_hub.php
$edi_hub_url = 'http://' . $_SERVER['HTTP_HOST'] . '/dmx/edi/edi_automation_hub.php';

// Comma separated list of tariffs to put in form
$tariffs = 'Public.EC-UK-PN-D-Entry,Public.EC-UK-PN-K-Entry,Public.EC-UK-PN-PN2-Entry,Public.EC-UK-GEO-All-Entry,Public.EC-UK-NGN-Free-Entry,Public.EC-UK-NGN-G6-Entry,Public.EC-UK-NGN-G7-Entry,Public.EC-UK-NGN-Local-Entry,Public.EC-UK-NGN-Nat-Entry,INVALID';

// Comma separated list of services to put in form
$services = ',voice,fax,switchboard,INVALID';

// For display of results on this HTML test page
$disp_request_url  = '';
$disp_response_xml = '';
$disp_eng          = '';
$disp_debug        = '';

// PRESERVE VALUES IN FORM, SO THE FORM DISPLAYS ANY PREVIOUSLY SUBMITTED VALUES
$fv = $_GET; // 'fv' = form values
if (get_magic_quotes_gpc()) { // Handle PHP magic quotes
	function strip_slashes($element) {
		if (is_array($element))	return array_map('strip_slashes', $element);
		else return stripslashes($element);
	}
	// Strip slashes 
	$fv = array_map('strip_slashes', $fv);
}
$fv = create_empty_form_variables('dealer_id,goldval,email,pin,dob,mmn,firstname,lastname,divert_home,divert_day,divert_mob', $fv);
if (!$fv['dealer_id']) $fv['dealer_id'] = $dmx_options['dealer_id'];
$fv['tariff']      = generate_optionlist(explode(',', $tariffs),  isset($fv['tariff'])  ? $fv['tariff']  : '');
$fv['service']     = generate_optionlist(explode(',', $services), isset($fv['service']) ? $fv['service'] : '');
$fv['debug']       = isset($fv['debug'])       ? 'checked' : '';
$fv['skip_verify'] = isset($fv['skip_verify']) ? 'checked' : '';

// -----------------------------------------------------------------------------

if (isset($_GET['edi_action'])) {
	// IF edi_action PARAMETER IS SET, SEND REQUEST TO THE EDI AUTOMATION HUB
	//
	// First construct the request URL
	$query_string = preg_replace('/\w+=(&|$)/', '', $_SERVER['QUERY_STRING']); // Strip empty parameters from query string, for clarity
	$query_string = preg_replace('/&$/', '', $query_string); // Now strip trailing &, if present
	$request_url = $edi_hub_url . '?' . $query_string;
	
	// Now do the request
	$response_xml = file_get_contents($request_url);
	
	// Decode the XML response, parsing it into a native PHP array
	$objXML         = new xml2Array();
	$response_array = $objXML->parse($response_xml);
}

// -----------------------------------------------------------------------------

if (isset($response_xml)) {
	// IF WE OBTAIN A RESPONSE, EXTRACT REQUEST AND RESPONSE AND FORMAT FOR ELEGANT DISPLAY ON TEST PAGE
	//
	$res_array = array(); // Convenient container for inner nodes of XML response
	$disp_request_url  = wordwrap($request_url, 140, '<br>', 1);
	$disp_response_xml = str_replace("\n", '<br>', htmlentities($response_xml));
	$disp_response_xml = preg_replace('/(&lt;.+?&gt;)/', '<span class="tag">$1</span>', $disp_response_xml);
	$inner_nodes = $response_array[0]['children'];
	for ($i=0; $i<count($inner_nodes); $i++) {
		if (strtolower($inner_nodes[$i]['name']) == 'debug') {
			$disp_debug = isset($inner_nodes[$i]['tagData']) ? utf8_decode($inner_nodes[$i]['tagData']) : ''; // Decoded debugging
		} else {
			$res_array[strtolower($inner_nodes[$i]['name'])] = utf8_decode($inner_nodes[$i]['tagData']); // Other inner nodes of XML response
		}
	}
	
	// Produce english language interpretation of result
	if ($res_array['status'] == 'FAIL') {
		$disp_eng = '<strong>AutoNumSignup failed.</strong>';
	} else {
		$disp_eng  = '<strong>AutoNumSignup succeeded.</strong><br>';
		$disp_eng .= 'The number assigned for ' . $_GET['email'] . ' is <b>' . $res_array['numberfmt'] . '</b>';
	}
	
}

// -----------------------------------------------------------------------------
// UTILITY FUNCTIONS USED BY THIS TEST HARNESS
// -----------------------------------------------------------------------------

class xml2Array {
	// Parse XML into a PHP array
  
	var $arrOutput = array();
	var $resParser;
	var $strXmlData;
  
	// -----------------------------------------------------------------------------
	
	function parse($strInputXML) {
  
		$this->resParser = xml_parser_create();
		xml_set_object($this->resParser,$this);
		xml_set_element_handler($this->resParser, 'tagOpen', 'tagClosed');
          
		xml_set_character_data_handler($this->resParser, 'tagData');
      
		$this->strXmlData = xml_parse($this->resParser,$strInputXML );
		if (!$this->strXmlData) {
			die(sprintf("XML error: %s at line %d",
			xml_error_string(xml_get_error_code($this->resParser)),
			xml_get_current_line_number($this->resParser)) .
			'<hr>' .
			$strInputXML);
 		}
                          
		xml_parser_free($this->resParser);
          
		return $this->arrOutput;
	}
   
	function tagOpen($parser, $name, $attrs) {
		$tag = array('name'=>$name, 'attrs'=>$attrs);
		array_push($this->arrOutput,$tag);
	}
  
	function tagData($parser, $tagData) {
		if (trim($tagData)) {
			if (isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) {
				$this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $tagData;
			}
			else {
				$this->arrOutput[count($this->arrOutput)-1]['tagData'] = $tagData;
			}
		}
	}
  
	function tagClosed($parser, $name) {
		$this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1];
		array_pop($this->arrOutput);
	}
}

// -----------------------------------------------------------------------------

function create_empty_form_variables($names, $fv=array()) {
	// Create empty form variables
	// This prevents errors being displayed in forms when PHP error reporting is set to maximum,
	// and the script tries to display the values of non-existant variables in form fields
	//
	// $names is a comma separated list of variable names
	// $fv (optional) is an array containing the results of the previous form submission, if any
	// Values that exist in $fv are not overwritten
	//
	$vars = explode(',', $names);
	foreach ($vars as $var_name) if (!isset($fv[$var_name])) $fv[$var_name] = '';
	return $fv;
}

// -----------------------------------------------------------------------------

function generate_optionlist($values, $selected='', $tabs=0) {
	// Generate an <option> list from the supplied array of $values
	// If a value contains a colon, use the first part as the value attribute, and the second
	// as the text node eg. 1st:First generates <option value="1st">First</option>
	// $selected specifies the option to mark as selected, if any
	// $tabs specifies the number of tabs to insert, for neat formatting
	//
	$t = '';
	while ($tabs > 0) {
		$t .= "\t";
		$tabs--;
	}
	$options = '';
	$loop = count($values);
	for ($i=0; $i<$loop; $i++) {
		$data = split(':', $values[$i]);
		$sel = trim($data[0]) == $selected ? ' selected' : '';
		if (!isset($data[1])) $data[1] = $data[0];
		$options .= "$t<option value=\"". trim($data[0]) . "\"$sel>" . htmlentities(trim($data[1])) . "</option>\n";
	}
	return $options;
}

// -----------------------------------------------------------------------------

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>EDI Demo</title>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<meta name="Copyright" content="Digital Mail Limited 2005-2010">

	<link href="/dmx/core/b0/css/core_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/over_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/print.css" rel="stylesheet" type="text/css" media="Print">
	
	<script language="Javascript" type="text/javascript">
	<!--
	
	var edi_run_via_test_harness;
	
	function run_directly() {
		// Hit EDI Automation Hub directly
		// Show the results in a new browser window
		var url = '<?=$edi_hub_url;?>' + generate_url();
		window.open(url, '');
	}

	function run_in_test_harness() {
		var curr = window.location.toString();
		if (curr.indexOf('#') != -1) curr = curr.substring(0, curr.indexOf('#'));
		if (curr.indexOf(edi_run_via_test_harness) != -1) {
			location.reload(true);
		} else {
			window.location = edi_run_via_test_harness + '#ra';	
		}
	}
	
	function display_request_url() {
		var query_string = generate_url();
		var edi_request_url = '<?=$edi_hub_url;?>' + query_string;
		edi_run_via_test_harness = '<?=$_SERVER['PHP_SELF'];?>' + query_string;
		var u = $('gen_url_container');
		u.innerHTML = edi_request_url;
		res_area.display_none();
		url_area.display_block();
		window.location.hash = 'bottom';
	}

	function generate_url() {
		// 	Scan input form, build request URL, and return request URL
		var p = new Object();
		var f = document.autonumsignup_form.elements;
		for (i=0; i<f.length; i++) {
			var el = f[i];
			switch (el.type) {
				case 'text':
				case 'password':
				case 'hidden':
					if (el.value) p[el.name] = el.value;
					break;
				case 'select-one':
					if (el.options[el.selectedIndex].value) p[el.name] = el.options[el.selectedIndex].value;
					break;
				case 'checkbox':
					if (el.checked) p[el.name] = 'on';
					break;
				default:
			}
		}		
		return append_params_to_url('', p);
	}

	function append_params_to_url(url, params) {
		// Append one of more parameters to a url
		// Expects the URL as its first argument, and an object containing
		// a variable number of name-value pairs as its second
	
		// If the URL contains an anchor extract it, then concatenate to the modified URL later
		// Anchors should always be the last part of a URL, after the query string (if any)
		// URL ? name=value&name=value # anchor
		if (url.indexOf('#') != -1) {
			var anchor = url.slice(url.indexOf('#'));
			url = url.slice(0, url.indexOf('#'));
		} else {
			var anchor = '';
		}
		
		for (name in params) {
			url += '&' + name +'=' + encodeURIComponent(params[name]);
		}
		
		// If the url does not contain a '?' already, change the first '&' to '?'
		if (url.indexOf('?') == -1 && url.indexOf('&') != -1) {
			url = url.substr(0, url.indexOf('&')) + '?' + url.substr(url.indexOf('&') + 1);
		}
		url = url + anchor;
		return url;
	}

	function insert_sample_params(arg) {
		// Quickly fill the test harness form with sample data
		var f = document.autonumsignup_form.elements;
		if (arg == 'new') {
			f.dealer_id.value 		= '9222';
			f.tariff.value 			= 'Public.EC-UK-PN-D-Entry';
			f.service.value 		= 'voice';
			f.goldval.value 		= '0-0';
			f.email.value 			= generate_email_prefix() + '@test.com';
			f.pin.value 			= '';
			f.dob.value 			= '11/10/1990';
			f.mmn.value 			= 'secret';
			f.firstname.value 		= f.email.value.charAt(0).toUpperCase() + f.email.value.substring(1, f.email.value.indexOf('_'));
			f.lastname.value 		= 'Tester';
			f.divert_home.value 	= '020 1234 5678';
			f.divert_day.value 		= '020 8765 4321';
			f.divert_mob.value 		= '07123 456 789';
			f.skip_verify.checked 	= 1;
			f.debug.checked 		= 1;
		} else {
			f.dealer_id.value 		= '9222';
			f.tariff.value 			= 'Public.EC-UK-GEO-All-Entry';
			f.service.value 		= 'switchboard';
			f.goldval.value 		= '100-100';
			f.email.value 			= 'tom_tester@test.com';
			f.pin.value 			= '1686';
			f.dob.value 			= '';
			f.mmn.value 			= '';
			f.firstname.value 		= '';
			f.lastname.value 		= '';
			f.divert_home.value 	= '';
			f.divert_day.value 		= '';
			f.divert_mob.value 		= '';
			f.skip_verify.checked 	= 0;
			f.debug.checked 		= 1;
		}
	}
	
	function generate_email_prefix() {
		// Return a random email prefix
		var names = ['alice', 'bert', 'charles', 'dan', 'edith', 'fred', 'gregory', 'henry', 'isambard', 'june', 'ken', 'lucy', 'martin', 'nelly', 'oscar', 'polly', 'quentin', 'rob', 'sam', 'tim', 'unwin', 'victor', 'will', 'xan', 'yves', 'zach'];
		var junkc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890';
		var name = names[Math.floor(Math.random() * 26)];
		for (var i=0, junk = ''; i<10; i++) {
			junk += junkc.charAt(Math.floor(Math.random() * 36));
		}
		return name + '_' + junk;
	}
	
	//-->
	</script>

	<style type="text/css">
	<!--
	.dmb0 .limit_width_1000
	{
		max-width: 1000px !important;
		width: expression(document.body.clientWidth > 1000 ? "1000px" : "auto" ) !important;
		text-align: left;
	}
	
	.tag { color: purple; }
	
	-->
	</style>
	
<?php
// Start XComponents: Initialise XComponents session in page, and add TST libraries
dmx_initialise_trolley();
dmx_include_tst();
?>
</head> <!-- XCom & TST modifications added -->

<body>
<div class="dmb0">
<a name="top"></a>

<!-- ************** -->
<!-- HEADER SECTION -->
<!-- ************** -->

<!-- MAIN HEADER BAR AND BRANDING -->
<div id="header_bar">
	<div class="content" align="center">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="limit_width_1000">
			<tr>
				<td style="width: 99%; vertical-align: middle;" class="title">EDI Test Harness</td>
				<td><img src="/dmx/core/b0/images/dmclub_header/dmclub_better_biz.gif" alt="better business through  innovative telecoms" width="164" height="71" border="0"></td>
				<td><img src="/dmx/core/b0/images/dmclub_header/dmclub_logo.gif" alt="dmClub logo" width="63" height="71" border="0"></td>
			</tr>
			<tr>
				<td></td>
				<td colspan="2"><img src="/dmx/core/b0/images/dmclub_header/dmclub_highlight.gif" alt="" width="227" height="8" border="0"></td>
			</tr>
		</table>
	</div>
</div>
<!-- END MAIN HEADER BAR AND BRANDING -->

<!-- NAV BAR -->
<div id="nav_bar">
	<div class="content" align="center">
		<div class="limit_width_1000">
		 	<div style="float: right">
		 		<!-- RHS NAV BAR CONTENT -->
		 				 		
		 		<!-- END RHS NAV BAR CONTENT -->
		 	</div>
		 	<!-- LHS NAV BAR CONTENT -->
		 	<a href="/dmx/demo/index.php">XCom Demo</a><a href="/dmx/edi/index.php">EDI Demo</a><a href="/dmx/server/index.php">XCom Diagnostics</a><a href="/dmx/tst/index.html">TST Diagnostics</a><a href="/dmx/core/b0/demo/index.html">Brand Zero</a>
		 	<!-- END LHS NAV BAR CONTENT -->
		 	&nbsp;
		</div>
	</div>
</div>
<!-- END NAV BAR -->

<!-- ERROR MESSAGE BAR -->
<div id="err_msg_bar" style="display: none;">
	<div class="content" align="center">
		<div class="limit_width_1000"></div>
	</div>
</div>
<!-- END ERROR MESSAGE BAR -->

<!-- ****************** -->
<!-- END HEADER SECTION -->
<!-- ****************** -->


<!-- ******************* -->
<!-- PAGE BODY CONTAINER -->
<!-- ******************* -->

<div class="content" align="center">
<div class="limit_width_1000 dmb0">

<!-- BODY CONTENT STARTS HERE -->

<h1>(1) Enter EDI Parameters: AutoNumSugnup</h1>

<p>
<b>This EDI action automatically assigns a number to a customer. Note how the examples differ between new and existing customers.</b><br>
In the examples, mandatory parameters are displayed in bold, and parameters that should be omitted are indicated by the dark boxes.<br>
<strong>For the request to succeed you must submit <i>either</i></strong>:
</p>

<ul>
	<li><strong>a correct email and PIN</strong> (existing dmClub members)</li>
	<li><strong>or an email, dob and mmn, but no PIN</strong> (new dmClub members) &ndash; a PIN will be automatically assigned,<br>
	and if contact numbers are specified, these will be used as initial divert destinations</li>
</ul>

<form name="autonumsignup_form" action="<?=$_SERVER['PHP_SELF'];?>" method="GET">
	<input type="hidden" name="edi_action" value="AutoNumSignup">
		<table style="width: 100%;" class="detailed">
		<tr><td colspan="5" class="divider"><img src="/dmx/core/b0/images/clear.gif" width="1" height="1" alt=""></td></tr>
			<td class="cell2i_thin">Parameter</td>
			<td class="cell2f_thin"></td>
			<td class="cell1f_thin">Parameter Description</td>
			<td class="cell1f_thin">New Customer Example</td>
			<td class="cell1f_thin">Existing Customer Example</td>
		</tr>
		<tr><td colspan="5" class="divider"><img src="/dmx/core/b0/images/clear.gif" width="1" height="1" alt=""></td></tr>
		<tr>
			<td class="cell2i_thin"><strong>edi_action</strong></td>
			<td class="cell2f_thin"><strong>AutoNumSignup</strong></td>
			<td class="cell1f_thin">The EDI action to perform</td>
			<td class="cell1f_thin"><strong>AutoNumSignup</strong></td>
			<td class="cell1f_thin"><strong>AutoNumSignup</strong></td>
		</tr>
		<tr>
			<td class="cell2i_thin">dealer_id</td>
			<td class="cell2f_thin"><input type="text" name="dealer_id" value="<?=$fv['dealer_id'];?>" class="form_text_field" size="6" maxlength="6"></td>
			<td class="cell1f_thin">Dealer ID used for signups (default from <i>dmx_options.php</i>)</td>
			<td class="cell1f_thin"><strong>9222</strong></td>
			<td class="cell1f_thin"><strong>9222</strong></td>
		</tr>
		<tr>
			<td class="cell2i_thin">tariff</td>
			<td class="cell2f_thin">
				<select name="tariff" class="form_select"><?=$fv['tariff'];?></select>
			</td>
			<td class="cell1f_thin">Sets number range to use</td>
			<td class="cell1f_thin"><strong>Public.EC-UK-PN-D-Entry</strong></td>
			<td class="cell1f_thin"><strong>Public.EC-UK-GEO-All-Entry</strong></td>
		</tr>
		<tr>
			<td class="cell2i_thin">service</td>
			<td class="cell2f_thin">
				<select name="service" class="form_select"><?=$fv['service'];?></select>
			</td>
			<td class="cell1f_thin">Leave blank for dmConnect</td>
			<td class="cell1f_thin">voice</td>
			<td class="cell1f_thin">switchboard</td>
		</tr>
		<tr>
			<td class="cell2i_thin">goldval</td>
			<td class="cell2f_thin"><input type="text" name="goldval" value="<?=$fv['goldval'];?>" class="form_text_field"></td>
			<td class="cell1f_thin">The gold value to select from, eg. 0-0, 0-100, etc</td>
			<td class="cell1f_thin">0-0</td>
			<td class="cell1f_thin">100-100</td>
		</tr>
		<tr>
			<td class="cell2i_thin">email</td>
			<td class="cell2f_thin"><input type="text" name="email" value="<?=$fv['email'];?>" class="form_text_field" size="35" maxlength="60"></td>
			<td class="cell1f_thin">The customer's email, used as their dmClub DMID</td>
			<td class="cell1f_thin"><strong>&#60;NAME&#62;@test.com</strong></td>
			<td class="cell1f_thin"><strong>tom_tester@test.com</strong></td>
		</tr>
		<tr>
			<td class="cell2i_thin">pin</td>
			<td class="cell2f_thin"><input type="text" name="pin" value="<?=$fv['pin'];?>" class="form_text_field" size="6" maxlength="4"></td>
			<td class="cell1f_thin">A 4-digit PIN number, eg. 2588</td>
			<td class="cell1i_thin"></td>
			<td class="cell1f_thin"><strong>2140</strong></td>
		</tr>
		<tr>
			<td class="cell2i_thin">dob</td>
			<td class="cell2f_thin"><input type="text" name="dob" value="<?=$fv['dob'];?>" class="form_text_field" size="12" maxlength="10"></td>
			<td class="cell1f_thin">A memorable date in format DD/MM/YYYY</td>
			<td class="cell1f_thin"><strong>11/10/1990</strong></td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">mmn</td>
			<td class="cell2f_thin"><input type="text" name="mmn" value="<?=$fv['mmn'];?>" class="form_text_field"></td>
			<td class="cell1f_thin">A memorable word, eg. Evans</td>
			<td class="cell1f_thin"><strong>secret</strong></td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">firstname</td>
			<td class="cell2f_thin"><input type="text" name="firstname" value="<?=$fv['firstname'];?>" size="20" class="form_text_field"></td>
			<td class="cell1f_thin">The customer's first name, eg. Edith</td>
			<td class="cell1f_thin">Tom</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">lastname</td>
			<td class="cell2f_thin"><input type="text" name="lastname" value="<?=$fv['lastname'];?>" size="20" class="form_text_field"></td>
			<td class="cell1f_thin">The customer's first name, eg. Eye</td>
			<td class="cell1f_thin">Tester</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">divert_home</td>
			<td class="cell2f_thin"><input type="text" name="divert_home" value="<?=$fv['divert_home'];?>" size="20" class="form_text_field"></td>
			<td class="cell1f_thin">Divert (Connect/Voice/Switchboard) - Home no.</td>
			<td class="cell1f_thin">020 1234 5678</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">divert_day</td>
			<td class="cell2f_thin"><input type="text" name="divert_day" value="<?=$fv['divert_day'];?>" size="20" class="form_text_field"></td>
			<td class="cell1f_thin">Divert (Voice/Switchboard) - Daytime no.</td>
			<td class="cell1f_thin">020 8765 4321</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">divert_mob</td>
			<td class="cell2f_thin"><input type="text" name="divert_mob" value="<?=$fv['divert_mob'];?>" size="20" class="form_text_field"></td>
			<td class="cell1f_thin">Divert (Voice/Switchboard) - Mobile no.</td>
			<td class="cell1f_thin">07123 456 789</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">skip_verify</td>
			<td class="cell2f_thin"><input type="checkbox" name="skip_verify"<?=$fv['skip_verify'];?>></td>
			<td class="cell1f_thin">Skip email verification prior to number activation</td>
			<td class="cell1f_thin">on</td>
			<td class="cell1i_thin"></td>
		</tr>
		<tr>
			<td class="cell2i_thin">debug</td>
			<td class="cell2f_thin"><input type="checkbox" name="debug"<?=$fv['debug'];?>></td>
			<td class="cell1f_thin">Check to see dmShop debugging</td>
			<td class="cell1f_thin">on</td>
			<td class="cell1f_thin">on</td>
		</tr>
		<tr>
			<td class="cell2i_thin"></td>
			<td class="cell2f_thin" colspan="2">
				<input type="submit" value="Generate URL" class="form_submit" onclick="display_request_url(); return false;"> &nbsp; &nbsp;
				<!-- <input type="submit" value="Run Directly" class="form_submit" onclick="run_directly(); return false;"> -->
			</td>
			<td class="cell1f_thin">&#60;&#60;&#60; <a href="#" onclick="insert_sample_params('new'); return false">insert sample data</a></td>
			<td class="cell1f_thin">&#60;&#60;&#60; <a href="#" onclick="insert_sample_params('existing'); return false">insert sample data</a></td>
		</tr>
		<tr><td colspan="5" class="divider"><img src="/dmx/core/b0/images/clear.gif" width="1" height="1" alt=""></td></tr>
	</table>
</form>
	
<div id="gen_url_area" style="display: none;">

<h2>(2) Generated URL</h2>

<p id="gen_url_container"></p>

<form>
<input type="submit" value="Send EDI Request" class="form_submit" onclick="run_in_test_harness(); return false;">
</form>

</div>

<div id="results_area">

<?php if ($disp_response_xml) : ?>
<a name="ra"></a>

<h2>(2) Generated URL (request sent to EDI Automation Hub)</h2>

<pre style="margin-top: 0px;"><?=$disp_request_url;?></pre>

<h2>(3) Results from EDI request</h2>

<p>
<b>WHAT HAPPENED? (english language interpretation)</b><br>
<?=$disp_eng;?>
</p>

<p>
<b>RESPONSE (SHOWN AFTER DECODING XML)</b>
</p>

<table width="100%" cellspacing="0" cellpassing="3" border="1">
<?php foreach($res_array as $key => $value) : ?>
<tr>
	<td><?=$key;?></td>
	<td><?=$value;?></td>
</tr>
<?php endforeach; ?>
</table>

<p>
<b>XML RESPONSE FROM EDI AUTOMATION HUB</b>
</p>

<pre style="margin-top: 0px;"><?=$disp_response_xml;?></pre>

<?php endif; ?>

<?php if ($disp_debug) : ?>

<h2>dmShop Debugging Messages</h2>

<?=$disp_debug;?>

<?php endif; ?>

</div>

<a name="bottom"></a>

<!-- END BODY CONTENT -->

</div>
</div>

<!-- *********************** -->
<!-- END PAGE BODY CONTAINER -->
<!-- *********************** -->

<!-- ********** -->
<!-- FOOTER BAR -->
<!-- ********** -->

<br style="clear: both;">
<div id="footer_bar">
	<div class="content" align="center">
		<div class="limit_width_1000">
		 	<div style="float: right">
		 		<!-- RHS FOOTER CONTENT -->
		 		<!-- Standard back to top link -->
		 		&nbsp;&nbsp;&nbsp;<a href="#top">back to top</a>
		 		<!-- END RHS FOOTER CONTENT -->
		 	</div>
		 	<!-- LHS FOOTER CONTENT -->
			dmx:edi:index.php
		 	<!-- END LHS FOOTER CONTENT -->
		</div>
	</div>
</div>

<!-- ************** -->
<!-- END FOOTER BAR -->
<!-- ************** -->

</div>

</body>
</html>