function recalcOrders() { global $authenticationMgr; $orderID = _post('orderID'); $order = $this->getOrder($orderID); $userData = $authenticationMgr->getUserData($order['userID'], ''); $cnt = _postByPattern('/gc\\d+/'); $del = _postByPattern('/del\\d+/'); foreach ($cnt as $key => $gcount) { $gcount = safe_numeric($gcount); if (preg_match('/gc(\\d+)/', $key, $match)) { $query = "SELECT pm_as_parts.ptID, salePrice, ptPercent FROM pm_as_parts LEFT JOIN pm_as_pricetypes ON (pm_as_parts.ptID = pm_as_pricetypes.ptID) WHERE accID = '" . $match[1] . "'"; //echo $query.'<br>'; $result = mysql_query($query); $cartRow = mysql_fetch_assoc($result); //print_r($cartRow); switch ($cartRow['ptID']) { case 1: if ($userData['cardID']) { $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * 5 / 100); } else { $curPrice = $cartRow['salePrice']; } $cardPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * 5 / 100); break; case 2: if ($userData['cardID']) { $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); } else { $curPrice = $cartRow['salePrice']; } break; case 3: if ($userData['cardID']) { $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); } else { $curPrice = $cartRow['salePrice']; } break; case 4: if ($userData['cardID']) { $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); } else { $curPrice = $cartRow['salePrice']; } break; case 5: $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); break; case 6: $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); break; case 7: $curPrice = round($cartRow['salePrice'] - $cartRow['salePrice'] * $cartRow['ptPercent'] / 100); break; default: $curPrice = $cartRow['salePrice']; break; } $curPrice *= $gcount; if (isset($del['del' . $match[1]]) || $gcount <= 0) { mysql_query("DELETE FROM pm_order_parts WHERE orderID='{$orderID}' AND accID={$match['1']}"); } else { mysql_query("UPDATE pm_order_parts SET accCount='" . $gcount . "', price='" . $curPrice . "' WHERE orderID='" . $orderID . "' && accID={$match['1']}"); } if (mysql_error()) { trigger_error(mysql_error(), PM_FATAL); } } } header('location: /carorders?cmd=orders&act=order&orderID=' . $orderID); }
function recalcCart() { global $structureMgr, $authenticationMgr; $sessionID = $authenticationMgr->getSessionID(); $cnt = _postByPattern("/gc\\d+/"); $del = _postByPattern("/del\\d+/"); foreach ($cnt as $key => $gcount) { $gcount = safe_numeric($gcount); if (preg_match("/gc(\\d+)/", $key, $match)) { if (isset($del["del" . $match[1]]) || $gcount <= 0) { mysql_query("DELETE FROM pm_as_cart WHERE sessionID='{$sessionID}' AND accID={$match['1']}"); } else { mysql_query("UPDATE pm_as_cart SET accCount={$gcount} WHERE sessionID='{$sessionID}' AND accID={$match['1']}"); } //echo "DELETE FROM pm_as_cart WHERE sessionID='$sessionID' AND accID=$match[1]"; if (mysql_error()) { trigger_error(mysql_error(), PM_FATAL); } } } header("Status: 302 Moved"); header("Location: " . getenv("HTTP_REFERER")); exit(0); }