All pastes #124223 Raw Edit

Miscellany

public php v1 · immutable
·published 2006-08-09 22:12 UTC
rendered paste body
<?php//Define Vars//======================================$productSearchTerms = array();//List files in the /pickLists directory and define variables//======================================$pickListDirectory = "pickLists";$dh  = opendir($pickListDirectory);while (false !== ($filename = readdir($dh))) {   	$pickListFiles[] = $filename;	}sort($pickListFiles);array_shift($pickListFiles);array_shift($pickListFiles); //Removing the . and .. directories.//Loop through each file and extract info//======================================$k = 0;while ( $k < count($pickListFiles)){	//Open excel file and tabulate//======================================require_once 'Excel/reader.php';$data = new Spreadsheet_Excel_Reader();$data->setOutputEncoding('CP1251');$data->read('pickLists/'.$pickListFiles[$k]);error_reporting(E_ALL ^ E_NOTICE);$pickList = "";for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {		for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {		$pickList[$i][$j] .= $data->sheets[0]['cells'][$i][$j];	}}array_shift($pickList); //Remove heading rowecho "<h1>Despatch Check List</h1><table border=1 cellpadding=2>";	$j = 1;$total = 0;while($j < count($pickList)) //Loop through rows and carry out actions	{		//Look through array for particular product and add to search terms			if (in_array($pickList[$j][12], $productSearchTerms) == false) # if product not present in list, then add.		{		$productSearchTerms[] = $pickList[$j][12];		$searchKey = array_search($pickList[$j][12], $productSearchTerms);		$productSearchTerms[$searchKey][1] = $pickList[$j][11]; # Pick number		$productSearchTerms[$searchKey][2] = $pickList[$j][14]; # Price		}		//Calculate Individual Product Quantities		if (in_array($pickList[$j][12], $productSearchTerms) == true) 		{		$productSearchTerms[$searchKey][3] += $pickList[$j][13]; # Add quantity of that product.		}				//Tabulate Data			echo "<tr>";			echo (	"<td>".$j.".</td>".	"<td><input type=checkbox>".$pickList[$j][2]."</td>".	"<td>".$pickList[$j][3]."</td>".	"<td>".$pickList[$j][9]."</td>".	"<td>".$pickList[$j][11]."</td>".	"<td>".$pickList[$j][12]."</td>".	"<td>".$pickList[$j][13]."</td>".	"<td>".$pickList[$j][14]."</td>"	);				echo "</tr>"; 				$total += $pickList[$j][14];	$j++;		}echo "</table>";echo "<br>";echo "Total £".$total;rename ("pickLists\\".$pickListFiles[$k], "storedPickLists\\".$pickListFiles[$k]);$k++;}//Display individual product quantities//======================================asort($productSearchTerms);$i=0;while ($i < count($productSearchTerms)){//echo ($i.". ".$productSearchTerms[$i]."<br>");	echo ($i.". ".$productSearchTerms[$i]." | ".$productSearchTerms[$i][1]." | ".$productSearchTerms[$i][3].	" | ".$productSearchTerms[$i][3]*$productSearchTerms[$i][2]."<br>");		$i++;	}?>