<?php
	
	$links = "<link rel='stylesheet' type='text/css' href='css/index.css'/>";
	
	$toaster = true;
	
	$useQtip = true;
	
	include("/var/www/PHPwebsite/olde_header.php");
	
	// if we want a new case
	if (@$_REQUEST['newCase'] == "Y") {
		
		session_unset();
	}
	
	$fileHTML = "";
	// Parse XML file if one is provided.
	if (isset($_REQUEST['filename'])) {
		
		$data = array();
		$filename = '/opt/client_files/'.$_REQUEST['filename'];
		
		error_reporting(0);
		$xml = simplexml_load_file('zip://'.$filename.'#ClientServerSpecs.xml');
		
		if (@$xml) {
			$server = $xml->Server;
			
			$filesize =  number_format((float) filesize($filename) / (1024 * 1024) , 2, '.', '');
			$fileHTML = "<div class='file client-upload'>1 - ".$_REQUEST['filename']." (".$filesize."MB)</div>";

			$data['serial'] = (string) $server->attributes()->Serial;
			$data['model'] = (string) $server->attributes()->Model;
			$data['server_version'] = (string) $server->attributes()->Version;
			$data['client_version'] = (string) $xml->Client->Config->attributes()->Version;
			$data['mac'] = explode('-', (string) $server->attributes()->MAC);
			
			$xml_os = (string) $server->System->attributes()->OS;
			
			foreach ($OS as $o) {
				if (strpos($xml_os, $o) > -1) {
					$data['os'] = $o;
				}
			}
			
			echo "<div id='zip-extraction' class='ui-exacq-display-none' name='1 - ".$_REQUEST['filename']." (".$filesize."MB)'>File zip extracted successfully from [zip://".$filename."#ClientServerSpecs.xml]!</div>";
		}
		else echo "<div id='zip-extraction' class='ui-exacq-display-none'>Could not open xml file from [zip://".$filename."#ClientServerSpecs.xml]</div>";
	}
	
	include($_SERVER['DOCUMENT_ROOT']."/PHPwebsite/ExacqLibrary/CountriesAndStatesArrays.php"); // $Countries[country]=> abbr, $States[state] => abbr
?>

<div class='page-header'>
	<div class='page-header-img'><img src='/menu/images/exacqVision-logo-gray.png' alt='exacqVision Logo Gray' title='gray version of exacqvision logo'></div>
	<div class='page-header-text'><h1 class='pro'><?php echo _("Support Request Form"); ?></h1></div>
</div>
<br>
<div class='form-header'>
	<p><b><?php echo _("Please fill out the form below with as much information as possible."); ?></b></p>
	<p><i><?php echo _("This form will generate a ticket to Exacq Support, who will answer via email."); ?></i></p>
	<p><?php echo _("The question mark icons will assist you in gathering the requested information."); ?></p><bR>
</div>

<form id='support-form' action='submit/' method='POST' enctype='multipart/form-data'>

	<div class='cf-inner'>
		
		<!-- CUSTOMER INFORMATION -->
		<div class='data-row thead'>
			<div class='label'></div>
			<div class='input'>
				<div id='toaster'></div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label'></div>
			<div class='input'>
				<div class='form-header'>
					<h1><?php echo _("Customer Information"); ?></h1>
				</div>
			</div>
		</div>
		
		<div class='data-row required'>
			<div class='label required-field'><?php echo _("Indicates required field"); ?></div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("Company Name"); ?></div>
			<div class='input'><input type='text' name='ci_company_name' value='<?php if (@$_REQUEST['company_name']) echo $_REQUEST['company_name']; ?>'></div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("Full Name"); ?></div>
			<div class='input'>
				<input type='text' name='ci_full_name' placeholder='John Q. Smith Jr.' value='<?php if (@$_REQUEST['full_name']) echo $_REQUEST['full_name']; ?>'>
			</div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("Email"); ?></div>
			<div class='input'><input type='email' name='ci_email' id='email' placeholder='john.smith@domain.com' value='<?php if (@$_REQUEST['email']) echo $_REQUEST['email']; ?>'></div>
		</div>
                
                  <div class='data-row required'>
			<div class='label'><?php echo _("Phone Number"); ?></div>
                        <div class='input'><input type='tel' name='ci_phone_number' id='phone_number' value='<?php if (@$_REQUEST['phone_number']) echo $_REQUEST['phone_number']; ?>'></div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("You are a(n)"); ?></div>
			<div class='input'>
			
			<select name='ci_customer_type'>
			<?php 
			
				$usertypes = array(
					'' => '',
					'dealer' => 'Dealer',
					'end_user' => 'End User',
					'distributor' => 'Distributor',
					'ae' => 'A&E Firm',
					'manuf_rep' => 'Manufacturer\'s Rep',
					'integration' => 'Integration Partner',
					'other' => 'Other'
				);
				
				foreach ($usertypes as $key => $val) {
				
					if (@$_REQUEST['customer_type'] === $key) echo "<option value='".$key."' selected>".$val."</option>";
					else echo "<option value='".$key."'>".$val."</option>";
				}
			?>
			</select>
			</div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("Country"); ?></div>
			<div class='input'>
			<select name='ci_country' id='country-select'>
			<?php 
				
				foreach ($Countries as $name => $abbr) {
					
					if (@$_REQUEST['country'] === $abbr) echo "<option value='".$abbr."' selected>".$name."</option>";
					else echo "<option value='".$abbr."'>".$name."</option>";
				}
			?>
			</select>
			</div>
		</div>
		
		<div class='data-row required c-trigger'>
			<div class='label'><?php echo _("State"); ?></div>
			<div class='input'>
			<select name='ci_state'>
			<?php 
				
				foreach ($States as $name => $abbr) {
					
					if (@$_REQUEST['state'] === $abbr) echo "<option value='".$abbr."' selected>".$name."</option>";
					else echo "<option value='".$abbr."'>".$name."</option>";
				}
			?>
			</select>
			</div>
		</div>
		
		<div class='data-row required'>
			<div class='label'><?php echo _("City"); ?></div>
			<div class='input'><input type='text' name='ci_city' value='<?php if (@$_REQUEST['city']) echo $_REQUEST['city']; ?>'></div>
		</div>
		
		<div class='data-row'>
			<div class='half'>
				<div class='label'><?php echo _("Existing Case"); ?> #</div>
				<div class='input'><input type='text' name='ci_case_number' value='<?php if (@$_REQUEST['case_number']) echo $_REQUEST['case_number']; ?>'></div>
			</div>
			<div class='half'>
				<div class='label'><?php echo _("Existing RMA"); ?> #</div>
				<div class='input'><input type='text' name='ci_rma_number' value='<?php if (@$_REQUEST['rma_number']) echo $_REQUEST['rma_number']; ?>'></div>
			</div>
		</div>
		
		<!-- SYSTEM INFORMATION -->
		<div class='data-row'>
			<div class='label'></div>
			<div class='input'>
				<div class='form-header'>
					<h1><?php echo _("System Information"); ?></h1>
				</div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label'><span><?php echo _("MAC Address"); ?></span>
				<a href='/kb/?crc=60805' target='_blank'>
					<img src='/products/images/help_icon.png' class='question-mark-button' title='<?php echo _("Cant find the MAC address? Click this button to open the knowledge base article in a new window"); ?>'>
				</a>
			</div>
			<div class='input'>
				<div id='macInputContainer'>
					<?php 
						if (@$_REQUEST['mac0']) $mac0 = $_REQUEST['mac0'];
						else if (@$_REQUEST['mac1']) $mac1 = $_REQUEST['mac1'];
						else if (@$_REQUEST['mac2']) $mac2 = $_REQUEST['mac2'];
						else if (@$_REQUEST['mac3']) $mac3 = $_REQUEST['mac3'];
						else if (@$_REQUEST['mac4']) $mac4 = $_REQUEST['mac4'];
						else if (@$_REQUEST['mac5']) $mac5 = $_REQUEST['mac5'];
						
						if ($data['mac']) {
							
							$mac0 = $data['mac'][0];
							$mac1 = $data['mac'][1];
							$mac2 = $data['mac'][2];
							$mac3 = $data['mac'][3];
							$mac4 = $data['mac'][4];
							$mac5 = $data['mac'][5];
						}
					?>
					<input type='text' id='mac0' class='mac' name='si_mac0' placeholder='00' value='<?php echo $mac0; ?>' maxlength='2'> - 
					<input type='text' id='mac1' class='mac' name='si_mac1' placeholder='11' value='<?php echo $mac1; ?>' maxlength='2'> - 
					<input type='text' id='mac2' class='mac' name='si_mac2' placeholder='22' value='<?php echo $mac2; ?>' maxlength='2'> - 
					<input type='text' id='mac3' class='mac' name='si_mac3' placeholder='99' value='<?php echo $mac3; ?>' maxlength='2'> - 
					<input type='text' id='mac4' class='mac' name='si_mac4' placeholder='AA' value='<?php echo $mac4; ?>' maxlength='2'> - 
					<input type='text' id='mac5' class='mac' name='si_mac5' placeholder='FF' value='<?php echo $mac5; ?>' maxlength='2'>
				</div>
				
				<div class='mac-button-container'>
				
					<button type='button' id='clear-mac'><?php echo _("Clear MAC Fields"); ?></button>
					
					<div class='button-label'><?php echo _("Clear MAC"); ?></div>
				</div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='half'>
				<div class='label'><?php echo _("Serial Number"); ?></div>
				<div class='input' id='check-serial'>
					<input type='text' name='si_serial_number' placeholder='ER1234567890' value='<?php 
						if (@$_REQUEST['serial_number']) echo $_REQUEST['serial_number'];
						else if (@$data['serial']) echo $data['serial'];
					?>'>
					<div class='status'>
						<div class='stat approved ui-exacq-display-none'>
							<img src='images/approved.png' title='<?php echo _("Serial Number Found"); ?>'>
						</div>
						<div class='stat not-approved ui-exacq-display-none'>
							<img src='images/non-approved.png' title='<?php echo _("Serial Number NOT Found"); ?>'>
						</div>
						<div class='stat loading-approved ui-exacq-display-none'>
							<img src='/resources/images/ajax-loader.gif' title='<?php echo _("Serial Number NOT Found"); ?>'>
						</div>
					</div>
				</div>
			</div>
			<div class='half'>
				<div class='label'><?php echo _("Model Number"); ?></div>
				<div class='input' id='check-model'><input type='text' name='si_model_number' placeholder='1608-48-2000-R2' value='<?php 
				
					if (@$_REQUEST['model_number']) echo $_REQUEST['model_number'];
					else if (@$data['model']) echo $data['model'];
				?>'></div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='half'>
				<div class='label'><span><?php echo _("Server Version"); ?></span>
					<a href='/kb/?crc=49846' target='_blank'>
						<img src='/products/images/help_icon.png' class='question-mark-button' title='<?php echo _("Click here to learn how to find your Server and/or Client Version."); ?>'>
					</a>
				</div>
				<div class='input'>
					<input type='text' name='si_server_version' value='<?php 
						if (@$_REQUEST['server_version']) echo $_REQUEST['server_version'];
						else if (@$data['server_version']) echo $data['server_version'];
					?>'>
				</div>
			</div>
			<div class='half'>
				<div class='label'><span><?php echo _("Client Version"); ?></span>
					<a href='/kb/?crc=49846' target='_blank'>
						<img src='/products/images/help_icon.png' class='question-mark-button' title='<?php echo _("Click here to learn how to find your Server and/or Client Version."); ?>'>
					</a>
				</div>
				<div class='input'><input type='text' name='si_client_version' value='<?php 
					if (@$_REQUEST['client_version']) echo $_REQUEST['client_version']; 
					else if (@$data['client_version']) echo $data['client_version'];
				?>'></div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label'><?php echo _("Operating System"); ?></div>
			<div class='input'>
			<select name='si_os'>
			<?php 
				
				$OS_ARRAY = array(
					"",                                    
					"Windows XP Professional",
					"Windows Server 2003",
					"Windows 7 Professional 32-bit",
					"Windows 7 Professional 64-bit",
                                        "Windows 10",
					"Windows Server 2008",
                                        "Windows Server 2012",
                                        "Windows Server 2016",
					"Ubuntu 8.04",
					"Ubuntu 10.04",
					"Ubuntu 12.04",
                                        "Ubuntu 14.04",
                                        "Ubuntu 16.04",
                                        "Ubuntu 18.04",
					"Mobile Device",
					"Other (please list in Problem field)"
				);
				
				foreach ($OS_ARRAY as $name) {
					
					if (@$_REQUEST['os'] === $name) echo "<option value='".$_REQUEST['os']."'>".$_REQUEST['os']."</option>";
					else echo "<option value='".$name."'>".$name."</option>";
				}
			?>
			</select>
			</div>
		</div>
		
		<div class='data-row required'>
			<div class='label label-top'><?php echo _("Problem"); ?></div>
			<div class='input'>
				<textarea rows='5' name='si_problem' placeholder='<?php echo _("Please be sure to include as detailed of a description of the problems as you can, to ensure an expedient solution to your problem."); ?>'></textarea>
			</div>
		</div>
		
		<!-- FILE UPLOADS -->
		<div class='data-row'>
			<div class='label'><span><?php echo _("Support Diagnostics"); ?></span>
				<a href='/kb/?crc=39085' target='_blank'>
					<img src='/products/images/help_icon.png' class='question-mark-button' title='<?php echo _("Click here to learn how to export your System Support Diagnostics"); ?>'>
				</a>
			</div>
			<div class='input'>
				<div class='form-header'>
					<h1><?php echo _("File Uploads"); ?></h1>
				</div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label label-top'></div>
			<div class='input centered'>
				<input type='file' name='file-input[]' id='file-input' multiple>
				<button type='button' id='file-input-button'><?php echo _("Attach File(s)"); ?></button>
				<?php 
				if ($fileHTML != "") {
					
					echo "
					<div id='file-output'>
						<div class='message'>Files over 10 MB will not be uploaded.<br>Attached File(s):</div><div class='file-list'>".$fileHTML."</div></div>";
					
					echo "<input class='ui-exacq-display-none' type='text' name='client-file-upload' value='".$_REQUEST['filename']."'>";
				}
				else echo "<div id='file-output' class='ui-exacq-display-none'></div>";
				?> 
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label'></div>
			<div class='input'>
				<div class="g-recaptcha" data-sitekey="6LfpbQsTAAAAAFp99s5xVa-S1Yjn_5MXzy3333Mf"></div>
			</div>
		</div>
		
		<div class='data-row'>
			<div class='label'></div>
			<div class='input submit'><button type='Submit' id='SubmitForm'><?php echo _("Submit Support Request"); ?></button></div>
		</div>
	</div>
</form>

<?php 

	include("/var/www/PHPwebsite/footer.php");
?>

<script type='text/javascript' src='/js/jquery.fileinput.js'></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type='text/javascript' src='/products/js/exacqVision.js'></script>
<script type='text/javascript' src='/resources/jquery/jquery.smart-highlight.js'></script>
<script type='text/javascript' src='js/index.js'></script>