<?php
date_default_timezone_set('America/Chicago');

header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');

date_default_timezone_set('America/Chicago');
include('zf_PF2.php');
include('zf_PFvars.php');
include('zf_PFmon.php');

if(isset($_POST['searchString'])){
	$mSS = trim($_POST['searchString']);
} else {
	$mSS = '';
}
$sql = "SELECT `cstID`, `FAsn_Code`, `Name`, `MailToCity`, `MailToState` FROM `Customers` WHERE INSTR(`Name`, '".$mSS."') ORDER BY `MailToState`, `MailToCity`";
$arrCst = GetTable($sql);
for ($i = 0; $i < count($arrCst); $i++) {
	//$maName[] = $arrCst[$i]['Name'];
	//$maName[] = '<a href="http://www.horseweblog.com/PF/eCstInfo.php?FAsn_Code='.$row[1].'&cstID='.$row[0].'&name='.$row[2].'">'.$row[2].'</a>';
	//$maName[] = '<a href="http://www.horseweblog.com/PF/eCstInfo.php?name='.$arrCst[$i]['Name'].'>abc"</a>';
	//$maName[] = '<a href="http://www.horseweblog.com/PF/eCstInfo.php?FAsn_Code=1.'">'.$arrCst[$i]['Name'].'</a>';
	$maName[] = '<a href="http://www.horseweblog.com/PF/eCstInfo.php?FAsn_Code='.$arrCst[$i]['Name'].'&cstID='.$arrCst[$i]['Name'].'&name='.$arrCst[$i]['Name'].'">'.$arrCst[$i]['Name'].'</a>';
	$maCity[] = $arrCst[$i]['MailToCity'];
	$maState[] = $arrCst[$i]['MailToState'];
}

/*
$showText = 'There are no orders to be shipped.';
$hostdb = 'localhost';
$namedb = 'horseweb_HG_Forms';
$userdb = 'horseweb_johnb';
$passdb = 'cobB)1(2';

  try {
  // Connect and create the PDO object
  $conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
  $conn->exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8

	$stmt = $conn->query($sql);

	//$resultText = "<pre>";
	$resultText = "";
	$count = 0;
 	while($row = $stmt->fetch(PDO::FETCH_NUM)) {
		$count++;
		for ($i = 0; $i < 5; $i++){
			$isShip = "yes";
//			$resultText .= "   ".$row[$i];
			$resultText .= $row[$i]."|";
		}
		$resultText .= "^";
		$maID[] = $row[0];
		$maAsnCode[] = $row[1];
		//$maName[] = '<a href="http://www.pinnacleforms.com/a_order1.php">Hard Coded</a>';
		//$maName[] = '<a href="a_order1.php">Hard Coded</a>';
		//$maName[] = '<a href="b_order1.php?FAsn_Code='.$row[1].'&cstID='.$row[0].'&name='.$row[2].'">'.$row[2].'</a>';
		//$maName[] = '<a href="a_order1.php?FAsn_Code='.$row[1].'>'.$row[2].'</a>';
		//$maName[] = '<a href="qRptChangeOut.php?Book='.$book.'&Order=Sequence" target="_blank">'.$str_book.' ChangeOut</a>';
		//$maName[] = $row[2];
		//$maName[] = '<a href="http://www.pinnacleforms.com/'.$mPlace0.'.php?FAsn_Code='.$row[1].'&cstID='.$row[0].'&name='.$row[2].'">'.$row[2].'</a>';
		$maName[] = '<a href="http://www.horseweblog.com/PF/eCstInfo.php?FAsn_Code='.$row[1].'&cstID='.$row[0].'&name='.$row[2].'">'.$row[2].'</a>';
		$maCity[] = $row[3];
		$maState[] = $row[4];
	}
	//$resultText .= "</pre>";

  $conn = null;        // Disconnect
}
catch(PDOException $e) {
  echo $e->getMessage();
}
if ($count > 0){
	$showText = $resultText;
}
$asOf = "As Of > ".date('Y-m-d H:i:s');
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style>
table, th, td {border: 1px solid black; border-collapse: collapse;}
th, td {padding: 10}

p {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.4em; /* 40px/16=2.5em */
	}
h2 {
text-align:center;
}

.info {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.4em; /* 40px/16=2.5em */
	clear:both;
    border: 2px solid rgb(0, 100, 150);
	border-radius: 6px;
	margin: 20px;
	padding: 10px;
}
.infoL {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.4em; /* 40px/16=2.5em */
	float:left;
	width:40%;
    border: 2px solid rgb(0, 100, 150);
	border-radius: 6px;
	margin: 20px;
	padding: 10px;
}
.infoR {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.4em; /* 40px/16=2.5em */
	float:right;
	width:40%;
    border: 2px solid rgb(0, 100, 150);
	border-radius: 6px;
	margin: 20px;
	padding: 10px;
}
#placeorder {
	height: 2em;
    font-size: 1.8em;
	float: center;
	}
.order {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.1em; /* 40px/16=2.5em */
	clear:right;
    text-align:center;
    border: 2px solid rgb(0, 100, 150);
	border-radius: 6px;
	margin: 30px;
	padding: 10px;
}
#header {
    background-color:rgb(0, 100, 150);
    color:white;
    text-align:center;
    padding:5px;
}
#footer {
    background-color:rgb(0, 100, 150);
    color:white;
    clear:both;
    text-align:center;
    padding:5px;
}
#formtext {
	font-size:18pt;
	height:45px;
	width:200px;
}
</style>

<body style="font-size:200%">

<div class="order">

<form action="ePickList.php" method="post">
	xOeSearch String  <input type="text" name="searchString" value ="" id="formtext"><br>
  <br>
  <input type="submit" value="Submit" id="formtext">
</form>
</div> 

<div align="center">
<?php
	echo '<table>';
  echo '<td align="left">Name</td>';
  echo '<td align="left">City</td>';
  echo '<td align="left">State</td>';
  for ($i = 0; $i < count($maName); $i++) {
		echo '<tr>';
	  echo '<td align="left">'.$maName[$i].'</td>';
	  echo '<td align="left">'.$maCity[$i].'</td>';
	  echo '<td align="left">'.$maState[$i].'</td>';
		echo '</tr>';
  }
	echo '</table>';
?> 
</div>

</body>
</html>