<?php
include ("../../include/session.php");
include ("../../include/db.php");
if (!$session->isAdmin()) {
	header("Location: ../../main.php");
} else {
	$recipieId = mysql_real_escape_string($_POST['recipieId']);
	$recipieName = mysql_real_escape_string($_POST['recipieName']);
	$perProductId = mysql_real_escape_string($_POST['perPriceId']);
	foreach ($_POST as $key => $value) {
		if ($key != "submitok" && $key != "recipieName" && $value != "" && $key != "recipieId" && $key != "perPriceId") {
			if (preg_match("/Price/i", $key)) {
				$bleh = str_replace("-Price", "", $key);
				$pColumns .= "$bleh = $value,";
//				$pValues .= "'$value',";
			} else {
				$columns .= "$key = $value,";

			}
		}
	}
	//	echo $columns;
	$q = "UPDATE nam_recipie SET $columns recipieName = '$recipieName' WHERE recipieId = '$recipieId'";
	$q1 = "UPDATE nam_perproductprice SET $pColumns recipieName = '$recipieName' WHERE priceId = '$perProductId'";
//	echo $q1;
	$r = execsql($q);
	$r1 = execsql($q1);
	if ($r && $r1) {
		header("Location:../productionMenu.php");
	}
}