public function look($id) { $look = YouniqueAPI::call("/look/view/" . urlencode($id), array("market_id" => $this->marketId)); if ($look->status == 3) { $this->redirect("browse"); } $this->set("look", $look); }
public function startup(Controller $controller) { $cacheName = 'promotions'; if (($details = Cache::read($cacheName, 'short')) === false) { $data = YouniqueAPI::call("promotionalProduct/promotionComponentData"); $details = array(); if (!empty($data)) { foreach ($data as $index => $promotion) { if ($promotion->m->can_order == 0) { //nobody can order in the market $details[$promotion->i->sku][$promotion->tc->reference_id] = 'unavailable'; } else { if (in_array($promotion->iat->item_availability_id, [1, 4, 5])) { // 1 = Upcoming // 4 = Disabled // 5 = Retired // these mean that the promotion is not available $details[$promotion->i->sku][$promotion->tc->reference_id] = 'unavailable'; } elseif (in_array($promotion->iat->item_availability_id, [2, 3])) { // 2 = Sell remaining // 3 = Sell endless // these mean that the promotion is still selling so we need the selling ui $details[$promotion->i->sku][$promotion->tc->reference_id] = 'selling'; } elseif (in_array($promotion->iat->item_availability_id, [6, 8])) { // 6 = Backorder Individual // 8 = Backorder All // these mean that the promotion is still on backorder so we need the backorder ui $details[$promotion->i->sku][$promotion->tc->reference_id] = 'backordered'; } elseif (in_array($promotion->iat->item_availability_id, [9, 10, 11])) { //This section should only happen if the sku in the promotional_products table has not ended but //a warehouse is one of the following item_availability_ids // 9 = Unorderable Individual // 10 = Unorderable Individual - Collection Backorder // 11 = Unorderable All // these mean that the promotion is still sold out so we need the sold out ui $details[$promotion->i->sku][$promotion->tc->reference_id] = 'soldout'; } } } } //hard code fix for April /*$details = array( 'US-53031-02' => array ( 1 => 'selling', 2 => 'selling', 3 => 'selling', 4 => 'selling', 5 => 'selling', 6 => 'selling', 7 => 'selling', 8 => 'selling', 9 => 'unavailable', ), );*/ Cache::write($cacheName, $details, 'short'); } $controller->viewVars['promotions'] = $details; }
/** * Change user using Admin cookie */ public function younique($userId = null) { $facebookId = $this->Session->read("user.facebook_id"); $this->Cookie->name = 'Adm'; $this->Cookie->type('aes'); $this->Cookie->key = "Q'3gM@DZ9Cc%wWSuX1uNB6c9`>xe6cLe4s9s3eC'78:vc581s.12TT*I#u)0"; if (YOUNIQUE_TESTSERVER === true && !empty($userId)) { $user_id = $userId; } else { $user_id = $this->Cookie->read('aid'); } if (!empty($user_id)) { $user = $this->User->find('first', array("fields" => array('User.*', 'UserOauth2.*'), "joins" => array(array('table' => 'user_oauth2', 'alias' => 'UserOauth2', 'type' => 'LEFT', 'conditions' => array('UserOauth2.user_id = User.id', "UserOauth2.provider" => 'Facebook'))), "conditions" => array("User.id" => $user_id), "order" => array('UserOauth2.user_id desc', "User.id desc"))); $this->Session->write("user_id", $user_id); $this->Session->write("user", array("id" => $this->userId, "facebook_id" => $facebookId, "first_name" => "{$user_id}", "last_name" => "Logged in as", "primary_email" => "*****@*****.**", "img" => "https://graph.facebook.com/{$facebookId}/picture?type=large", "userOauth" => !empty($user['UserOauth2']['uid']) ? "true" : "")); $presenter_id = YouniqueAPI::call("presenter/getSequenceIdFromUserId/" . urlencode($user_id)); /** * Admins can view inactive presenters with admin_override */ if (!empty($presenter_id) && $presenter_id != -1) { $presenter = YouniqueAPI::call("presenter/getPresenterFromSequenceId/" . urlencode($presenter_id)); $this->presenterId = $presenter_id; $this->Session->write("presenter_id", $this->presenterId); $this->Session->write("admin_override", $this->presenterId); $this->Session->write('presenter_market_id', $presenter->Presenter->market_id); } else { $this->presenterId = 0; $this->Session->delete("presenter_id"); } //clear session stuff that gets messed up with this $this->Session->delete('logged_in_presenter_site'); $recognized_status = YouniqueAPI::call("presenter/getRecognizedStatus/" . $this->presenterId); $this->Session->write('presenter.recognized_status', $recognized_status); $this->redirect(array("controller" => "account", "action" => "tools")); } else { throw new ForbiddenException(); } }
public function partyCheck() { $this->partyId = (int) $this->Cookie->read("id"); if (!empty($this->partyId)) { try { $this->party = YouniqueAPI::call("/party/" . $this->partyId); if (!empty($this->party)) { $this->set("party", $this->party); $this->set("partyid", $this->party->Party->id); } if (!empty($this->party) && $this->party->Party->party_status_id == 1 && (!empty($this->webSiteInfo) || $this->webSiteInfo->id == $this->party->Presenter->id)) { $this->Cookie->name = 'party'; $this->Cookie->time = 0; $this->Cookie->write("id", $this->party->Party->id, false); return $this->party->Presenter->PresenterSite->site_url; } else { $this->Cookie->delete("party"); } } catch (YouniqueAPIException $e) { //not found...so just ignore it } } }
protected function setCurrencyFormat($marketId = null) { if (empty($marketId)) { $marketId = $this->marketId; } //$return = YouniqueAPI::call("market/getMarketData/" . $marketId); if (($currency = Cache::read($marketId . '_currency', 'short')) === false) { $currency = YouniqueAPI::call("market/getMarketData/" . $marketId); Cache::write($marketId . '_currency', $currency, 'short'); } $this->set("currencyCode", $currency->currencyCode); $this->set("currencySymbol", $currency->currencySymbol); //TODO: lame hack where currency is the "format" anc currencyCode is the actual code. $this->set("currency", $currency->currency); }
/** * Deprecated * * @throws PHPExcel_Exception */ public function warehouse_unused() { $auth = new Auth(); if ($auth->getPermission("warehouse")) { ini_set("max_execution_time", 900); ini_set("max_input_time", 60); ini_set("memory_limit", "256M"); $this->goCake = true; ob_implicit_flush(true); @ob_end_flush(); $i = 0; App::import('Vendor', 'PHPExcel/PHPExcel'); if (!empty($this->request->data)) { $file_name = $this->request->data['shipping_upload_file']['tmp_name']; $excelFileObj = PHPExcel_IOFactory::load($file_name); $worksheet = $excelFileObj->getSheet(0); $highestRow = $worksheet->getHighestRow(); $highestColumn = $worksheet->getHighestColumn(); $validated = array(); $returnErrors = array(); $i = 0; $pure_endicia = false; for ($row = 1; $row <= $highestRow; $row++) { $errors = array(); if ($row != 1) { $rowData = $worksheet->rangeToArray("A{$row}" . ':' . "{$highestColumn}{$row}", NULL, true, false); //make array easier to use if ($row == 2 && $rowData[0][0] == 'Account Number') { $pure_endicia = true; continue; } if ($pure_endicia === true) { $data = array('order_id' => preg_replace('/[^0-9]/', '', $rowData[0][14]), 'order_shipment_id' => 'LOOKUP', 'tracking_number' => $rowData[0][8], 'carrier' => 'USPS', 'date_created' => null, 'date_shipped' => $rowData[0][3], 'items_not_included' => null); try { $order_shipment_id = YouniqueAPI::call("/orders/getOrderShipmentId/" . $rowData[0][14]); if ($order_shipment_id) { $data['order_shipment_id'] = $order_shipment_id; } } catch (Exception $e) { error_log('API: failed to get order_shipment_id'); } } else { $data = array('order_id' => $rowData[0][0], 'order_shipment_id' => $rowData[0][1], 'tracking_number' => $rowData[0][2], 'carrier' => $rowData[0][3], 'date_created' => $rowData[0][4], 'date_shipped' => $rowData[0][5], 'items_not_included' => $rowData[0][6]); } $split = array(); //validation rules //need all fields if (empty($data['order_id']) || empty($data['order_shipment_id']) || empty($data['tracking_number']) || empty($data['carrier']) || empty($data['date_shipped'])) { $data['error'] = "Row {$row} is missing data"; $errors[] = $data; } //order id must be int or - separated ints or int-REP if (!is_numeric($data['order_id'])) { //it may be a list $order_ids = explode('-', $data['order_id']); foreach ($order_ids as $value) { if (!is_numeric($value)) { if (strtoupper($value) != "REP" || strtoupper($value) != "BO") { $data['error'] = "Row {$row} has invalid order id(s)"; $errors[] = $data; } } else { //split it $split[] = $value; } } } //order shipment id must be int if (!is_numeric($data['order_shipment_id'])) { $data['error'] = "Row {$row} has invalid order shipment id"; $errors[] = $data; } //tracking number must be int or 'int' if (!ctype_alnum($data['tracking_number'])) { if (!ctype_alnum(str_replace("'", '', $data['tracking_number']))) { $data['error'] = "Row {$row} has invalid tracking number"; $errors[] = $data; } else { $data['tracking_number'] = str_replace("'", '', $data['tracking_number']); } } //carrier must be "USPS" or "Landmark Global" if ($data['carrier'] != "USPS" && $data['carrier'] != "Landmark Global") { $data['error'] = "Row {$row} has invalid carrier"; $errors[] = $data; } //date created is optional but must be a valid date //in the excel format or in valid php date format if (is_numeric($data['date_created'])) { //excel format $date = PHPExcel_Style_NumberFormat::toFormattedString($data['date_created'], "YYYY-MM-DD h:mm:ss"); if (!DateTime::createFromFormat('G-m-d H:i:s', $date)) { $date_created = DateTime::createFromFormat('Y-m-d H:i:s', $date); $data['date_created'] = $date_created->format("Y-m-d H:i:s"); } else { $data['date_created'] = ''; } } else { $validate_date = date_parse($data['date_created']); if (empty($validate_date['errors'])) { $date = new DateTime($data['date_created']); if ($date) { $date_created = date_format($date, "Y-m-d H:i:s"); $data['date_created'] = $date_created; } else { $data['date_created'] = ''; } } } //date shipped must be a valid date in the excel format or in valid php date format if (is_numeric($data['date_shipped'])) { //excel format $date = PHPExcel_Style_NumberFormat::toFormattedString($data['date_shipped'], "YYYY-MM-DD h:mm:ss"); if (!DateTime::createFromFormat('G-m-d H:i:s', $date)) { $date_shipped = DateTime::createFromFormat('Y-m-d H:i:s', $date); $data['date_shipped'] = $date_shipped->format("Y-m-d H:i:s"); } else { $data['error'] = "Row {$row} has invalid date"; $errors[] = $data; } } else { $validate_date = date_parse($data['date_shipped']); if (empty($validate_date['errors'])) { $date = new DateTime($data['date_shipped']); if ($date) { $date_shipped = date_format($date, "Y-m-d H:i:s"); $data['date_shipped'] = $date_shipped; } else { $data['error'] = "Row {$row} has invalid date"; $errors[] = $data; } } else { $data['error'] = "Row {$row} has invalid date"; $errors[] = $data; } } if (!array_key_exists("error", $data)) { $data['row'] = $row; if (!empty($split)) { foreach ($split as $value) { $data['order_id'] = $value; //need to get the right order shipment id try { $result = YouniqueAPI::call("/orders/getOrderShipmentId/" . $value); if ($result) { $data['order_shipment_id'] = $result; $validated[] = $data; } } catch (Exception $e) { error_log("API failed"); } } } else { $validated[] = $data; } } else { //consolidate errors foreach ($errors as $error) { $returnErrors[$row][] = $error['error']; } } } if ($row % 100 == 0) { echo "<pre>{$row} Records Validated.</pre>"; } } echo "<pre>{$row} Total Records Validated. </pre>"; // chunk the array - this is necessary as there are php limits on // how many variables can be sent to the api controlled by max_input_vars ini setting // if the number of elements sent change, you may have to adjust // the chunk size. // the default limit is 1000 variables. the array currently has 7 elements, so chunk // size of 100 should be safe $chunks = array_chunk($validated, 100); //process validated rows //send to api foreach ($chunks as $value) { try { $result = YouniqueAPI::call("/admin/orders/shipmentpackages/", $value); if ($result) { $i += $result->count; } echo "<pre>{$i} Records Processed. </pre>"; } catch (Exception $e) { $returnErrors[] = (array) $result->errors; } } //process errors if (!empty($returnErrors)) { echo "Errors:<br />"; foreach ($returnErrors as $errorValue) { echo '<pre>'; foreach ($errorValue as $error) { echo "{$error}" . "<br />"; } echo '</pre>'; } } echo "<pre>Total Orders processed: " . $i . "</pre>"; } ob_implicit_flush(false); } else { echo "Login Required"; } }
/** * Grabs product availability information information for PSPs * @param $action Controller action being called. * @param $sku SKU the PSP is for. */ private function getProductStoryPageAvailabilityInfo($action, $sku) { $product_info = YouniqueAPI::call("products/" . $sku . "?market_id=" . $action->Session->read('market_id')); $product_availabilities = []; if (!empty($product_info->ChildItems)) { foreach ($product_info->ChildItems as $variant) { $product_availabilities[$variant->sku] = $variant->item_availability->item_availability_id; } } $action->set('product_availabilities', $product_availabilities); }
public function _getReplacementData($order_id) { try { return YouniqueAPI::call("/admin/orders/getReplacementData/" . urlencode($order_id)); } catch (Exception $e) { return 0; } }
public function aboutme() { $result = YouniqueAPI::call("/presenter/getSiteBio/" . urlencode($this->siteUrl), $this->data); $this->set("bio", $result); $this->set("area", "about"); }
/** * Get the full data set for a selected (single) user * * Gets the user, presenter, email, phone, address, and product credit records for this user. * Also returns the meta data - that is the available types for certain data types * for instance, the phones table has a type_id. * The meta data would contain the names of these types keyed to their id for referencing int he code. * Example: user.meta.phone[<insert the user's phone type id here>].name would dynamically give you the phone type name * * Returns stdClass * user * id * first_name * middle_name * last_name * entity * date_of_birth * consent_to_agreements * presenter * id * presenter_sequence_id * user_id * sponosr_id * market_id * market_sequence_id * government_id * consent_to_agreements * default_locale * terminated_date * presenter_status_id * _autiddate * status_level_name * status_level_id * presenter_site * id * presenter_id * site_url * is_primary * head_shot * bio * analytics_code * presenter_info * fast_start_end_date * email * {id} * id * email_type_id * user_id * email * phone * {id} * id * phone_type_id * user_id * nickname * phone * address * {id} * id * address_type_id * user_id * nickname * address1 * address2 * address3 * city * county * state_id * postal_code * country_id * product_credits * transactions * [] * product_credit_id * presenter_id * entry_user * amount * credit_type * entry_type * status * reference_id * timestamp * currency * balances * younique_cash * parties * [] * id * party_name * start_time * end_time * party_total * finalized_sate * display_result * presenter_sequence_id * presenter_facebook * hostess_facebook * presenter_name * hostess_name * display - initial display setting - closed parties are false, open are true * orders * [] * id * date_completed * presenter * customer * grand_total * status_name * status_id * display - initial display setting - closed parties are false, open are true * coupons * records * [] * id * coupon_presenter_id * user_id * date_added * user_visible * reference_id * date_redeemed * redemption_reference_id * redemption_amount * expiration_date * available * meta - see _getMeta for structure * * @param int $user_id * @param bool $include_meta_data * @return \stdClass */ public function getAllUserData($user_id, $include_meta_data = TRUE) { require_once APPLICATION_PATH . MODEL_DIR . '/User.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Presenter.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Email.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Phone.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Address.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Address_geocode.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Market.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Product_credits.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Order.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Party.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Coupon_presenter_user.php'; require_once APPLICATION_PATH . MODEL_DIR . '/User_oauth2.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Accomplishments.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_documents.php'; require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_us_tax_data.php'; $results = new stdClass(); //user table $user = new User(); $results->user = $user->getDataById($user_id); //presenter $presenter = new Presenter(); $results->presenter = $presenter->getDataByUserId($user_id, TRUE); if (!empty($results->presenter)) { //compliance info $results->presenter->compliance = $presenter->getComplianceDataByUserId($user_id, $results->presenter->market_id); //presenter_site require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_site.php'; $presenter_site = new Presenter_site(); $results->presenter_site = $presenter_site->getDataByPresenterId($results->presenter->id); //presenter_us_tax_data require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_us_tax_data.php'; $results->presenter_us_tax_data = $presenter->getBusinessDataByPresenterId($results->presenter->id); //get presenter status require_once APPLICATION_PATH . MODEL_DIR . '/Presenter_type.php'; $presenter_type = new Presenter_type(); $results->presenter->status_level_id = $presenter_type->getMaxType($results->presenter->id); $results->presenter->status_level_name = $presenter_type->getPresenterStatusName($results->presenter->status_level_id); //get sponsor data $sponsor = new Presenter(); $results->presenter->sponsor = $sponsor->getSponsorData($results->presenter->sponsor_id); //presenter info $results->presenter_info = new stdClass(); $sign_up_date = new DateTime($results->presenter->consent_to_agreements); //to get the right end date for fast start, we ned to check if they are in a new market that had a 1 month //delay between sign up and sales $fast_start_end_date = YouniqueAPI::call("presenter/getFastStartDeadline/" . $results->presenter->presenter_sequence_id); $results->presenter_info->fast_start_end_date = date("M d, Y", strtotime($fast_start_end_date)); $presenter_documents = new Presenter_documents(); $results->presenter_documents = $presenter_documents->getPresenterDocuments($results->presenter->presenter_sequence_id); } //these have multiple records potentially, so we load them on their own //emails $email = new Email(); $results->email = $email->getDataByUserId($user_id); //phones $phone = new Phone(); $results->phone = $phone->getDataByUserId($user_id); //oauth $oauth = new User_oauth2(); $results->oauth = $oauth->getDataByUserId($user_id); //addresses $address = new Address(); $geo = new Address_geocode(); $results->address = $address->getDataByUserId($user_id); //accomplishments $accomplishments = new Accomplishments(); $results->accomplishments = $this->_sortAccomplishments($accomplishments->getDataByUserId($user_id)); foreach ($results->address as $a_key => &$a_value) { $a_geo = $geo->getByAddressId($a_value['id']); if (!$a_geo) { continue; } $a_value['geo_id'] = $a_geo->id; $a_value['lat'] = $a_geo->lat; $a_value['lng'] = $a_geo->lng; } //todo: apply geocodes //get product credit info $product_credits = new Product_credits(); $results->product_credits = new stdClass(); $results->product_credits->transactions = $product_credits->getTransactionsByUserId($user_id); $results->product_credits->balances = $product_credits->getBalancesByUserId($user_id); //markets $market = new Market(); $results->country_codes = new stdClass(); $results->country_codes->transactions = $market->getCountryCodesByMarkets(); $result = new stdClass(); foreach ($results as $key => $value) { if ($key == 'accomplishments') { $result->{$key} = $value; continue; } $result->{$key} = $this->_rekeyArray($value); } //orders $order = new Order(); $result->orders = $order->getOrdersByUserId($user_id); //check replacement percentage $order_ids = []; foreach ($result->orders as $value) { $order_ids[] = $value['id']; } if (!empty($results->presenter)) { $result->presenter->replacement_percentage = $order->getUserReplacementOrderPercentage($order_ids); //parties $party = new Party(); $result->parties = $party->getPresenterParties($results->presenter->id); } //coupons $coupon = new Coupon_presenter_user(); $result->coupons = new stdClass(); $result->coupons->records = $coupon->getDataByUserId($user_id); $result->coupons->promocoupons = $coupon->getPromoCoupons(); $result->coupons->promorecords = $coupon->getPromoDataByUserId($user_id); $result->coupons->available = 0; $result->coupons->promoavailable = 0; if (!empty($result->coupons->promorecords)) { foreach ($result->coupons->promorecords as $key => $value) { if ($value['date_redeemed'] == NULL) { $result->coupons->promoavailable++; } } } foreach ($result->coupons->records as $key => $value) { if ($value['date_redeemed'] == NULL) { $result->coupons->available++; } } //meta if ($include_meta_data) { $result->meta = $this->_getMetaData(); } return $this->_filterResults($result); }
if (isset($_POST['rm_data']) && $_POST['rm_data'] == 'rm_siret_vitale_file') { $save_result = YouniqueAPI::call('presenter/setVitaleDoc/' . $_POST['presenter_id']); } } if ($save_result) { $result->success = TRUE; $result->message = "File Removed successfully."; } else { $result->success = FALSE; $result->message = "Error: File was not removed"; } } } /** * Handler for the remove coupon functionality */ if (isset($_POST['form']) && $_POST['form'] == "add_business_data") { if (isset($_POST['data'])) { $business_data = $_POST['data']; $save_result = YouniqueAPI::call('presenter/setBusinessDetails/', $business_data); if ($save_result) { $result->success = TRUE; $result->message = "Business details saved successfully."; } else { $result->success = FALSE; $result->message = "Failed to save details."; } } } header('Content-Type: application/json'); echo json_encode($result);
public function claimparty() { $this->requireLoggedInUser(); YouniqueAPI::call("/party/claim/" . $this->party->Party->id . "/" . $this->userId); //redir to view page $page_data = DruniqueAPI::call('page_blocks.json', array("tag" => "flash-page"), $this->Session->read('Config.language')); $this->Session->setFlash($page_data['you have successfully claimed the party']['content'], "default", array(), "claim_copy"); $this->redirect(Router::url('/', true) . $this->party->Presenter->PresenterSite->site_url . "/party/" . $this->party->Party->id . "/view/"); }
public function collectionvariants($sku, $market_id) { $parent_item = YouniqueAPI::call("/products/{$sku}?market_id={$market_id}"); $products = []; foreach ($parent_item->ChildItems as $child_item) { if (in_array($child_item->item_type_id, [2, 3])) { $products[$child_item->sku] = ['qty' => $child_item->qty_required, 'options' => YouniqueAPI::call("/products/{$child_item->sku}?market_id={$market_id}")]; } } $this->set("mainsku", $sku); $this->set("products", $products); $selectedOptions = array("qty" => 1); foreach ($products as $sku => $product) { if (!empty($product['options'])) { $selectedOptions[$sku] = array(); if (isset($product['options']->sku) && $product['options']->sku != $sku) { $selectedOptions[$sku][$product['options']->sku] = array('skus' => new stdClass()); } else { $selectedOptions[$sku]['skus'] = new stdClass(); } } else { $selectedOptions["skus"][] = $sku; } } $this->set("selectedOptions", $selectedOptions); }
private function limitedItem($product, $cart_items) { //find out if the item has a limited per order quantity $limited_qty = YouniqueAPI::call("/products/limitedItem/" . $product->sku); if (!$limited_qty->result) { //no active limit found $this->set("limit_qty", FALSE); } else { //active limit found //find out the current quantity of the item or its children in the cart $limited_item_qty = 0; $limited_item_different_count = 0; if ($product->type == 2) { //variant master //get the child skus $child_items = array(); foreach ($product->ChildItems as $childitem) { $child_items[] = $childitem->sku; } //find the qty of child skus in the cart and the number of different child skus foreach ($cart_items as $index => $item_data) { if (in_array($item_data['sku'], $child_items)) { $limited_item_qty += (int) $item_data['qty']; $limited_item_different_count++; } } } else { //find the qty of sku in the cart foreach ($cart_items as $index => $item_data) { if ($item_data['sku'] == $product->sku) { $limited_item_qty += (int) $item_data['qty']; $limited_item_different_count++; } } } $limited_quantities[$product->sku]['qty'] = $limited_item_qty; $limited_quantities[$product->sku]['count'] = $limited_item_different_count; $limited_max = (int) $limited_qty->result - $limited_item_qty; $limited_value = 1; $limited_min = 1; if ($limited_max < 1) { $limited_value = 0; $limited_min = 0; } $this->set("limit_qty", TRUE); $this->set("limited_qty", (int) $limited_qty->result); $this->set("limited_max", $limited_max); $this->set("limited_min", $limited_min); $this->set("limited_value", $limited_value); $this->set("limited_item_qty", $limited_item_qty); $this->set("limited_item_different_count", $limited_item_different_count); //$this->set("limited_quantities", $limited_quantities); } }
public function taxledger() { $data = YouniqueAPI::call("user/getproductcreditledger", array('userId' => $this->userId, 'marketId' => $this->marketId)); $this->set("ledger", $data); }
public function success() { //provides the date format expected for different markets. this should be somewhere more reusable switch ($this->market_id) { case 7: //GER //GER case 3: //AUS //AUS case 4: //NZ $date_format = "d-m-Y"; break; case 2: //CAN //CAN case 1: //USA //USA default: $date_format = "m-d-Y"; break; } $latest_order = YouniqueAPI::call('/orders/getLatest/' . $this->Session->read('user')['id']); $order_information = YouniqueAPI::call('/orders/view/' . $this->Session->read('user')['id'] . '/' . $latest_order->Order->id); //Build the address to display on the page $addressBuild = $order_information->OrderCustomer->Address->address1; if ($order_information->OrderCustomer->Address->address2 != '') { $addressBuild .= "\n" . $order_information->OrderCustomer->Address->address2; } if ($order_information->OrderCustomer->Address->address3 != '') { $addressBuild .= "\n" . $order_information->OrderCustomer->Address->address3; } $addressBuild .= " \n" . $order_information->OrderCustomer->Address->city . ", " . (!empty($order_information->OrderCustomer->Address->State->abbrev) ? $order_information->OrderCustomer->Address->State->abbrev . " " : null) . $order_information->OrderCustomer->Address->postal_code; $order_data = array('orderId' => $order_information->Order->id, 'presenterNumber' => $order_information->Presenter->presenterNumber, 'name' => $order_information->User->first_name . " " . $order_information->User->last_name, 'picture' => null, 'facebookurl' => null, 'market_id' => $order_information->Order->market_id, 'market_name' => $order_information->OrderCustomer->Address->Country->name, 'market_sequence_id' => null, 'market_ordinal' => null, 'siteurl' => $order_information->Presenter->siteurl, 'email' => $order_information->User->email, 'phone' => $order_information->OrderCustomer->Phone->phone, 'birthdate' => strtotime($order_information->User->date_of_birth), 'government_id' => null, 'address' => $addressBuild, 'card' => null, 'charge' => $order_information->Order->grand_total, 'subtotal' => $order_information->Order->subtotal, 'shipping_tax' => $order_information->Order->shipping_tax, 'taxtotal' => $order_information->Order->taxtotal, 'vattotal' => $order_information->Order->vattotal, 'shippingtotal' => $order_information->Order->shippingtotal, 'sponsor' => $order_information->Presenter->sponsor, 'sponsor_site_url' => null, 'sponsor_image_url' => null, 'cardName' => null, 'cardZip' => null, 'default_locale' => $order_information->User->user_default_locale); $TaxRate = null; if ($order_data['vattotal'] > 0) { $TaxRate = YouniqueAPI::call("market/getTaxes/" . $order_data['market_id']); } $this->set("TaxRate", $TaxRate); $market_currency = YouniqueAPI::call("market/getMarketData/" . $order_data['market_id']); $this->set('market_currency', $market_currency->currency); $market_ordinal = $this->getOrdinalSuffix($order_data['market_sequence_id']); $this->set('date_format', $date_format); $this->set('market_ordinal', $market_ordinal); $this->set($order_data); $this->Session->delete("order_details"); }
$result = ""; $order_item = new Order_item(); $result = $order_item->getOrderIdById($order_item_id); } } if (isset($_POST['form']) && $_POST['form'] == "get_search_history") { require_once APPLICATION_PATH . MODEL_DIR . '/Ajax.php'; $ajax = new Ajax(); $result = $ajax->getSearchHistory($_POST['search_type']); } /** * Wrapper for API Call to RoyaltiesEarnedController.edit */ if (isset($_POST['form']) && $_POST['form'] == 'update_royalty') { if (isset($_POST['RoyaltiesEarned']) && !empty($_POST['RoyaltiesEarned'])) { /** Require Admin role to update */ $admin_user = CakeSession::read('admin_user'); if ($admin_user->role == 1) { $url = '/royalties_earned/' . $_POST['RoyaltiesEarned']['id']; $data = $_POST['RoyaltiesEarned']; $admin = $admin_user->id; $result = YouniqueAPI::put($url, $data, $admin); } else { $result = array('result' => false); } } else { $result = array('result' => false); } } header('Content-Type: application/json'); echo json_encode(array("result" => $result));
public function collectionvariants($sku) { // Windows to the Soul Collection if ($sku == "US-41011-01") { $products = array("US-21000-00" => array("qty" => 4, "options" => YouniqueAPI::call("/mproducts/US-21000-00")), "US-22100-00" => array("qty" => 3, "options" => YouniqueAPI::call("/mproducts/US-22100-00"))); } elseif ($sku == "US-41021-02") { $products = array("US-21900-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21900-00"))); } elseif ($sku == "US-41041-01") { $products = array("US-21801-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-21801-00")), "US-22100-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-22100-00")), "US-21000-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-21000-00")), "US-1092-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-1092-00"))); } elseif ($sku == "US-91201-01") { $products = array("US-21900-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21900-00")), "US-21000-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21000-00"))); } elseif ($sku == "US-41051-01") { $products = array("US-21000-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21000-00")), "US-22102-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-22102-00")), "US-22101-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-22101-00")), "US-1092-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-1092-00")), "US-21801-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21801-00"))); } elseif ($sku == "US-41061-02") { $products = array("US-21000-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-21000-00")), "US-21801-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21801-00")), "US-21900-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-21900-00")), "US-1092-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-1092-00")), "US-1062-00" => array("qty" => 1, "options" => YouniqueAPI::call("/mproducts/US-1062-00")), "US-22100-00" => array("qty" => 3, "options" => YouniqueAPI::call("/mproducts/US-22100-00"))); } else { if ($sku == "US-31001-01") { $products = array("US-21000-00" => array("qty" => 4, "options" => YouniqueAPI::call("/mproducts/US-21000-00"))); } else { if ($sku == "US-2005-00") { $products = array("US-1092-00" => array("qty" => 2, "options" => YouniqueAPI::call("/mproducts/US-1092-00"))); } elseif ($sku == "US-31801-01") { $products = array("US-21801-00" => array("qty" => 3, "options" => YouniqueAPI::call("/mproducts/US-21801-00"))); } elseif ($sku == "US-32101-01") { $products = array("US-22100-00" => array("qty" => 3, "options" => YouniqueAPI::call("/mproducts/US-22100-00"))); } elseif ($sku == "US-32101-02") { $products = array("US-22100-00" => array("qty" => 10, "options" => YouniqueAPI::call("/mproducts/US-22100-00"))); } } } //$this->set("mainsku", $sku); //$this->set("products", $products); $selectedOptions = array("qty" => 1); foreach ($products as $sku => $product) { if (!empty($product['options'])) { $selectedOptions[$sku] = array(); if ($product['options']->sku != $sku) { $selectedOptions[$sku][$product['options']->sku] = array('skus' => new stdClass()); } else { $selectedOptions[$sku]['skus'] = new stdClass(); } } else { $selectedOptions["skus"][] = $sku; } } //$this->set("selectedOptions", $selectedOptions); $tempResult = array("mainsku" => $sku, "products" => $products, "selectedOptions" => $selectedOptions); $this->sendSuccess($tempResult); //exit; // echo "<pre>"; //print_r($sku); //print_r($products); //print_r($selectedOptions); //exit; //$this->autoRender = false; }
public function newPartyCreate($userId, $marketId = 1) { /* $days = array( "3"=>date("M d, Y", strtotime("+3 days")), "5"=>date("M d, Y", strtotime("+5 days")), "10"=>date("M d, Y", strtotime("+10 days")), ); */ $presenter_data = YouniqueAPI::call("presenter/isPresenter/" . $userId); //$presenter_data = $this->mobile_isPresenter($userId); //print_r($presenter_data); //echo $presenter_data->isPresenter; //exit; $is_presenter = $presenter_data->isPresenter; //$marketId = $this->marketId; //echo "rrr".$is_presenter; $showpartynav = true; //print_r($this->params['pass']); //exit; //$this->data['presenterId'] if (in_array('theme', $this->params['pass'])) { $templateName = $this->params['pass'][1]; //pgande $templateObject = YouniqueAPI::call("/party/theme/". $templateName); $templateObject = $this->partyTheme($templateName); $templateSettings = $templateObject; } //pgande $partyTheme = YouniqueAPI::call("party/theme"); $partyTheme = $this->partyTheme(); $total_array = array("is_presenter" => $is_presenter, "marketId" => $marketId, "showpartynav" => $showpartynav, "templateSettings" => $templateSettings, "partyTheme" => $partyTheme); $this->sendSuccess($total_array); //echo json_encode($total_array); }