function main() { if (hasPrivilege('customer')) { // Check customer Loged in $userId = $_SESSION[getSpKey()]['customer']; $sql = "SELECT * FROM `customers` WHERE `id` = '{$userId}' "; $result = dbQuery($sql); while (($records = mysql_fetch_assoc($result)) !== false) { $customerDetails = array('id' => $records['id'], 'customer_name' => $records['customer_name'], 'customer_family' => $records['customer_family'], 'customer_email' => $records['customer_email'], 'customer_gender' => $records['customer_gender'], 'customer_mobile' => $records['customer_mobile'], 'customer_city' => $records['customer_city'], 'customer_state' => $records['customer_state'], 'customer_zipcode' => $records['customer_zipcode'], 'customer_emergency_number' => $records['customer_emergency_number'], 'customer_address' => $records['customer_address']); } mysql_free_result($result); // edit Customer Details if (isset($_POST['btnEditSubmit'])) { $txtDetails = array('customer_name' => isset($_POST['txtName']) ? $_POST['txtName'] : null, 'customer_family' => isset($_POST['txtFamily']) ? $_POST['txtFamily'] : null, 'customer_email' => isset($_POST['txtEmail']) ? $_POST['txtEmail'] : null, 'customer_mobile' => isset($_POST['txtMobile']) ? $_POST['txtMobile'] : null, 'customer_city' => isset($_POST['txtCity']) ? $_POST['txtCity'] : null, 'customer_state' => isset($_POST['txtState']) ? $_POST['txtState'] : null, 'customer_zipcode' => isset($_POST['txtZipCode']) ? $_POST['txtZipCode'] : null, 'customer_emergency_number' => isset($_POST['txtEmergencyNumber']) ? $_POST['txtEmergencyNumber'] : null, 'customer_address' => isset($_POST['txtAddress']) ? $_POST['txtAddress'] : null); $dataIsCorrect = true; foreach ($txtDetails as $pieceOfData) { if (is_null($pieceOfData)) { addMessage('اطلاعات محصول به درستی وارد نشده است', FAILURE); $dataIsCorrect = false; break; } } } } else { $url = BASE_URL . 'signup'; return array('redirect' => $url); } $resp['data'] = array('customerDetails' => $customerDetails); return $resp; }
function main() { if (hasPrivilege('customer')) { //@ToDo اگر سبد خالی بود به صفحه اصلی ارسال شود $resp = array('data' => array(1)); $resp['data']['shopingCart'] = array(); $cartItems = array(); if (isset($_SESSION['cart']) && count($_SESSION['cart']) > 0) { $productIds = array_keys($_SESSION['cart']); $temp = implode(', ', $productIds); $sql = "SELECT `id`, `product_name`,`product_picture_name`, `product_price` FROM `products` WHERE `id` IN ({$temp});"; $result = dbQuery($sql); while (($row = mysql_fetch_assoc($result)) !== false) { $resp['data']['cartItems'][] = array('id' => $row['id'], 'product_name' => $row['product_name'], 'product_price' => (int) $row['product_price'], 'product_picture_name' => $row['product_picture_name'], 'count' => $_SESSION['cart'][(int) $row['id']]); } mysql_free_result($result); } else { $url = BASE_URL; return array('redirect' => $url); } return $resp; } else { addMessage('برای تسویه حساب وارد حساب کاربری خود شوید، چنانچه هنوز عضو نیستید ثبت نام کنید', NOTICE); $url = BASE_URL . 'signup'; return array('redirect' => $url); } }
function main() { if (hasPrivilege('customer')) { } else { $url = BASE_URL . 'signup'; return array('redirect' => $url); } }
} return; } // Loading common functions and libraries using our autoLoadingManager function autoLoadingManager(array('dbf', 'url', 'message')); /* * Including functions and libraries which are required to handle this request. * These files are determined in $dependencies global variable */ if (isset($dependencies)) { autoLoadingManager($dependencies); unset($dependencies); } if (isset($acl)) { autoLoadingManager('authHelper'); if (!hasPrivilege($acl)) { die('Access Denied'); } } // Calling main function and processing the response $response = main(); $loadView = true; if (!is_null($response)) { $data = isset($response['data']) ? $response['data'] : array(); extract($data); // Check if we should redirect to another URL if (isset($response['redirect'])) { // View should not be loaded $loadView = false; //redirect logic header(sprintf('location: %s', $response['redirect']));