Example #1
0
 public function testGetRelatedProducts()
 {
     $otherProducts = array();
     foreach (range(1, 5) as $i) {
         $otherProducts[$i] = Product::getNewInstance($this->productCategory);
         $otherProducts[$i]->setValueByLang("name", "en", "Test");
         $otherProducts[$i]->save();
         $this->product->addRelatedProduct($otherProducts[$i]);
     }
     $i = 1;
     $this->assertEqual(5, $this->product->getRelatedProducts()->getTotalRecordCount());
     foreach ($this->product->getRelatedProducts() as $relatedProduct) {
         $this->assertIsA($relatedProduct, 'Product');
         $this->assertTrue($relatedProduct === $otherProducts[$i]);
         $i++;
     }
     // Save and reload
     $this->product->save();
     ActiveRecord::removeClassFromPool('Product');
     $this->product->load();
     $i = 1;
     $this->assertEqual(5, $this->product->getRelatedProducts()->getTotalRecordCount());
     foreach ($this->product->getRelatedProducts() as $relatedProduct) {
         $this->assertIsA($relatedProduct, 'Product');
         $this->assertTrue($relatedProduct === $otherProducts[$i]);
         $relatedProductName = $relatedProduct->name->get();
         $this->assertEqual($relatedProductName['en'], 'Test');
         $i++;
     }
 }
 public static function getAllProducts()
 {
     $aAllProducts = array();
     $connection = new Connection();
     $sSQL = "SELECT ProductID\n                     FROM tbproduct\n                     ORDER BY CreatedAt DESC\n                     ";
     $resultSet = $connection->query($sSQL);
     while ($row = $connection->fetch_array($resultSet)) {
         $iProductID = $row['ProductID'];
         $oProduct = new Product();
         $oProduct->load($iProductID);
         $aAllProducts[] = $oProduct;
     }
     $connection->close_connection();
     return $aAllProducts;
 }
Example #3
0
 public static function renderCheckoutBasket($oBasket)
 {
     $aContents = $oBasket->contents;
     $sOutput = '<h1 class="textAlignCenter marginBottom30">Checkout</h1>' . "\n";
     $sOutput .= '<div class="mainForms checkOutBasket clearBoth sixteenColumns marginBottom50 selfClear">' . "\n";
     $sOutput .= '<h2 class="paddingTop10 paddingBottom20 textAlignCenter">Checkout Basket Items</h2>' . "\n";
     $sOutput .= '<ul class="shoppingCartList">' . "\n";
     $sOutput .= '<li class="eight columns marginBottom20 colour3A floatLeft">Item Description</li>' . "\n";
     $sOutput .= '<li class="one columns offset-by-two marginBottom20 colour3A floatLeft">Quantity</li>' . "\n";
     $sOutput .= '<li class="two columns offset-by-one marginBottom20 colour3A floatLeft">Price</li>' . "\n";
     $sOutput .= '</ul>' . "\n";
     $fTotal = 0;
     $fSubTotal = 0;
     $fDelivery = 0;
     foreach ($aContents as $iProductID => $iQuantity) {
         $oProduct = new Product();
         $oProduct->load($iProductID);
         $fSubTotal = $oProduct->price * $iQuantity;
         $sOutput .= '<ul class="clearBoth checkOutBasketItem">' . "\n";
         $sOutput .= '<li class="eight columns floatLeft"><span class="stockTitleSmall">Item Description: </span>' . $oProduct->description . ' <br /><span class="removeCTA2 removeCTA"><a href="removeFromBasket.php?ProductID=' . $oProduct->productID . '">REMOVE</a></span></li>' . "\n";
         $sOutput .= '<li class="quantityTotal one columns offset-by-two floatLeft textAlignRight"><span class="stockTitleSmall">Quantity: </span>' . $iQuantity . '</li>' . "\n";
         $sOutput .= '<li class="two columns offset-by-one floatLeft"><span class="stockTitleSmall">Item Price: </span>' . $fSubTotal . '</li>' . "\n";
         $sOutput .= '</ul>' . "\n";
         $fTotal += $oProduct->price * $iQuantity;
         // calculates total of items
         if ($fTotal > 50) {
             $fDelivery = 0;
         } else {
             $fDelivery = 20;
         }
     }
     $fTotal2 = $fTotal + $fDelivery;
     $sOutput .= '<ul class="clearBoth">' . "\n";
     $sOutput .= '<li class="eight columns floatLeft"></li>' . "\n";
     $sOutput .= '<li class="one columns offset-by-two marginBottom20 colour3A floatLeft">Delivery</li>' . "\n";
     // $sOutput .= ''."\n";
     $sOutput .= '<li class="two columns offset-by-one floatLeft">' . $fDelivery . '</li>' . "\n";
     $sOutput .= '</ul>' . "\n";
     $sOutput .= '<ul class="marginBottom20 selfClear">' . "\n";
     $sOutput .= '<li class="totalNumber one columns offset-by-ten colour3A floatLeft textAlignRight"><h3>Total</h3></li>' . "\n";
     $sOutput .= '<li class="totalNumber two columns offset-by-one floatLeft"><h3>$' . $fTotal2 . '</h3></li>' . "\n";
     $sOutput .= '</ul>' . "\n";
     $sOutput .= '</div>' . "\n";
     return $sOutput;
 }
 function admin()
 {
     global $Shopp;
     $db =& DB::get();
     if (!defined('WP_ADMIN') || !isset($_GET['page'])) {
         return;
     }
     $Admin = $Shopp->Flow->Admin;
     $adminurl = $Shopp->wpadminurl . "admin.php";
     $defaults = array('page' => false, 'deleting' => false, 'delete' => false, 'id' => false, 'save' => false, 'duplicate' => false, 'next' => false);
     $args = array_merge($defaults, $_REQUEST);
     extract($args, EXTR_SKIP);
     if (strstr($page, $Admin->categories)) {
         if ($page == "shopp-categories" && !empty($deleting) && !empty($delete) && is_array($delete)) {
             foreach ($delete as $deletion) {
                 $Category = new Category($deletion);
                 $db->query("UPDATE {$Category->_table} SET parent=0 WHERE parent={$Category->id}");
                 $Category->delete();
             }
             $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete[]' => null, 'deleting' => null)), $adminurl));
             shopp_redirect($redirect);
         }
         if ($id && $id != "new") {
             $Shopp->Category = new Category($id);
         } else {
             $Shopp->Category = new Category();
         }
         if ($save) {
             $this->save_category($Shopp->Category);
             $this->Notice = '<strong>' . stripslashes($Shopp->Category->name) . '</strong> ' . __('has been saved.', 'Shopp');
             if ($next) {
                 if ($next != "new") {
                     $Shopp->Category = new Category($next);
                 } else {
                     $Shopp->Category = new Category();
                 }
             } else {
                 if (empty($id)) {
                     $id = $Shopp->Category->id;
                 }
                 $Shopp->Category = new Category($id);
             }
         }
     }
     // end $Admin->categories
     if (strstr($page, $Admin->products)) {
         if ($page == "shopp-products" && !empty($deleting) && !empty($delete) && is_array($delete)) {
             foreach ($delete as $deletion) {
                 $Product = new Product($deletion);
                 $Product->delete();
             }
             $redirect = esc_url(add_query_arg(array_merge($_GET, array('delete' => null, 'deleting' => null)), $adminurl));
             shopp_redirect($redirect);
             exit;
         }
         if ($duplicate) {
             $Product = new Product();
             $Product->load($duplicate);
             $Product->duplicate();
             shopp_redirect(add_query_arg('page', $Admin->products, $adminurl));
         }
         if ($id && $id != "new") {
             $Shopp->Product = new Product($id);
             $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
         } else {
             $Shopp->Product = new Product();
             $Shopp->Product->published = "on";
         }
         if ($save) {
             $this->save_product($Shopp->Product);
             $this->Notice = '<strong>' . stripslashes($Shopp->Product->name) . '</strong> ' . __('has been saved.', 'Shopp');
             if ($next) {
                 if ($next == "new") {
                     $Shopp->Product = new Product();
                     $Shopp->Product->published = "on";
                 } else {
                     $Shopp->Product = new Product($next);
                     $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
                 }
             } else {
                 if (empty($id)) {
                     $id = $Shopp->Product->id;
                 }
                 $Shopp->Product = new Product($id);
                 $Shopp->Product->load_data(array('prices', 'specs', 'categories', 'tags'));
             }
         }
     }
     // end $Admin->products
 }
Example #5
0
 * Copyright (c) 2006 bitweaver.org
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
 *
 * @package warehouse
 * @subpackage functions
 */
/**
 * required setup
 */
require_once '../kernel/setup_inc.php';
include_once WAREHOUSE_PKG_PATH . 'Product.php';
$gBitSystem->verifyPackage('warehouse');
$gBitSystem->verifyPermission('p_warehouse_view');
if (!empty($_REQUEST['product_id'])) {
    $gProduct = new Product($_REQUEST['product_id'], $_REQUEST['content_id']);
    $gProduct->load();
} else {
    $gProduct = new Product();
}
$gProduct->getStockList($gProduct->mProductId);
$gProduct->getPalletMoveList($gProduct->mProductId);
$gProduct->getBatchList($gProduct->mProductId);
$gBitSmarty->assign_by_ref('productInfo', $gProduct->mInfo);
//if ( $gClient->isValid() ) {
$gBitSystem->setBrowserTitle("Product Details Record");
$gBitSystem->display('bitpackage:warehouse/show_product.tpl');
//} else {
//	header ("location: ".WAREHOUSE_PKG_URL."index.php");
//	die;
//}
Example #6
0
 private function productForm(Product $product)
 {
     $productFormData = $product->toArray();
     if ($product->isLoaded()) {
         $product->loadSpecification();
         $productFormData = array_merge($productFormData, $product->getSpecification()->getFormData());
         if (isset($productFormData['Manufacturer']['name'])) {
             $productFormData['manufacturer'] = $productFormData['Manufacturer']['name'];
         }
     } else {
         $product->load(ActiveRecord::LOAD_REFERENCES);
     }
     $product->loadPricing();
     $form = $this->buildForm($product);
     $pricing = $product->getPricingHandler();
     $pricesData = $product->toArray();
     $listPrices = $pricing->toArray(ProductPricing::DEFINED, ProductPricing::LIST_PRICE);
     $pricesData['shippingHiUnit'] = (int) $pricesData['shippingWeight'];
     $pricesData['shippingLoUnit'] = ($pricesData['shippingWeight'] - $pricesData['shippingHiUnit']) * 1000;
     if (array_key_exists('defined', $pricesData)) {
         foreach ($pricesData['calculated'] as $currency => $price) {
             $pricesData['price_' . $currency] = isset($pricesData['defined'][$currency]) ? $pricesData['defined'][$currency] : '';
             $productFormData['price_' . $currency] = $pricesData['price_' . $currency];
         }
     }
     foreach ($listPrices as $currency => $price) {
         $pricesData['listPrice_' . $currency] = $price;
     }
     $form->setData($productFormData);
     // status values
     $status = array(0 => $this->translate('_disabled'), 1 => $this->translate('_enabled'));
     // product types
     $types = array(Product::TYPE_TANGIBLE => $this->translate('_tangible'), Product::TYPE_DOWNLOADABLE => $this->translate('_intangible'), Product::TYPE_BUNDLE => $this->translate('_bundle'));
     // default product type
     if (!$product->isLoaded()) {
         $product->type->set(substr($this->config->get('DEFAULT_PRODUCT_TYPE'), -1));
         $form->set('type', $product->type->get());
     }
     $response = new ActionResponse();
     $product->getSpecification()->setFormResponse($response, $form);
     $response->set("cat", $product->getCategory()->getID());
     $response->set("hideFeedbackMessage", $this->request->get("afterAdding") == 'on');
     $response->set("productForm", $form);
     $response->set("path", $product->getCategory()->getPathNodeArray(true));
     $response->set("productTypes", $types);
     $response->set("productStatuses", $status);
     $response->set("baseCurrency", $this->application->getDefaultCurrency()->getID());
     $response->set("otherCurrencies", $this->application->getCurrencyArray(LiveCart::EXCLUDE_DEFAULT_CURRENCY));
     $response->set("shippingClasses", $this->getSelectOptionsFromSet(ShippingClass::getAllClasses()));
     $response->set("taxClasses", $this->getSelectOptionsFromSet(TaxClass::getAllClasses()));
     $productData = $product->toArray();
     if (empty($productData['ID'])) {
         $productData['ID'] = 0;
     }
     $response->set("product", $productData);
     return $response;
 }
Example #7
0
 public static function template_new_gameserver_mail($param, $is_resend = false)
 {
     $param = json_decode(json_encode($param), FALSE);
     $user_name = str_replace('@gameloft.com', '', $_SERVER['REMOTE_USER']);
     $user_name = str_replace('.', ' ', ucfirst($user_name));
     //$cc[] = MAIL_MEX;
     foreach ($param as $key => $value) {
         unset($to);
         unset($cc);
         unset($bcc);
         $to[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_OGI;
         $cc[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_MEX;
         $dolly_users = explode(',', $param->{$key}->dolly_users);
         foreach ($dolly_users as $key2 => $value2) {
             if (array_search($value2, $dolly_users)) {
                 if ($value2 == $param->{$key}->requested_by) {
                     unset($dolly_users[$key2]);
                 } else {
                     $cc[] = $value2;
                 }
             }
         }
         $product = Product::load($param->{$key}->product_id)->to_array();
         $product_name = $product['name'];
         $tpl = $param->{$key};
         $tpl->server_type = $key;
         $tpl->comments = $param->{$key}->comments_ogi;
         $tpl->dolly_users = $param->{$key}->dolly_users;
         //Get email template
         ob_start();
         $subject = '[TUNA][chklst] ' . $param->{$key}->environment . ' ' . $key . ' checklist for ' . $product_name;
         include 'mail_templates/new_gameserver_checklist.php';
         $body = ob_get_contents();
         ob_end_clean();
         $m = new Mail('text/plain');
         $m->from($_SERVER['REMOTE_USER']);
         $m->to(@implode(',', $to));
         $m->cc(@implode(',', $cc));
         $m->bcc(@implode(',', $bcc));
         $m->subject($subject);
         $m->body($body);
         $m->send();
     }
     TunaLog::info_log(__CLASS__, __FUNCTION__, $_SERVER['REMOTE_USER'], '');
 }
Example #8
0
 public static function getProducts($id = null)
 {
     $obj = new Thing();
     $obj->db->select();
     $obj->db->from('thing');
     $obj->db->where('name = "product"');
     if (!is_null($id)) {
         $obj->db->where('altid', $id);
     }
     $query = $obj->db->get();
     //get things for products
     $thingProducts = array();
     foreach ($query->result() as $row) {
         $thingProducts[] = Thing::loadFromRow($row);
     }
     //get products
     $products = array();
     foreach ($thingProducts as $thingProduct) {
         $products[] = Product::load($thingProduct);
     }
     return $products;
     /*
     
         //$json = json_encode($json, JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_QUOT);
     
         echo "<pre>";
         print_r($json);
         echo "</pre>";
     */
 }
Example #9
0
<?php

#1.
Auth::kickout_non_admin('/pokecart/');
$product = new Product();
$product->load(Route::param('id'));
$product->delete();
#2. REDIRECT
URL::redirect('/pokecart/admin');
<?php

require_once "includes/header.php";
require_once "includes/form.php";
if (isset($_SESSION["UserID"]) == false) {
    // if user hasn't logged on
    // redirect back to login if user has not logged on.
    header("Location:loginSignUp.php");
    exit;
    // terminates request
}
$oBasket = $_SESSION["basket"];
$iProductID = 1;
if (isset($_GET["ProductID"])) {
    $iProductID = $_GET["ProductID"];
}
$oProduct = new Product();
$oProduct->load($iProductID);
echo View::renderShoppingBasket($oBasket);
require_once "includes/footerAdmin.php";
<?php

require_once "includes/header.php";
require_once "includes/product.php";
require_once "includes/productManager.php";
require_once "includes/form.php";
if (isset($_POST["save"])) {
    $oProduct = new Product();
    $oProduct->load($_POST["productID"]);
    $oProduct->stockLevel = $_POST["stockLevel"];
    $oProduct->save();
    // redirect after adding new page successfully to that new location
    header("Location:editProductStock.php?message=stockUpdated");
    exit;
    // terminates request
}
$aForms = array();
$aAllProducts = ProductManager::getAllProducts();
for ($iCount = 0; $iCount < count($aAllProducts); $iCount++) {
    $oProduct = $aAllProducts[$iCount];
    $oStockLevelForm = new Form();
    $aStickyData = array();
    $aStickyData["stockLevel"] = $oProduct->stockLevel;
    $oStockLevelForm->data = $aStickyData;
    // form markup:
    $oStockLevelForm->stockInput("stockLevel", "", "floatLeft");
    $oStockLevelForm->makeHiddenField("productID", $oProduct->productID);
    $oStockLevelForm->makeSubmit("save", "Save", "blueButton bgBlue selfClear");
    $aForms[] = $oStockLevelForm;
}
// stock level form
Example #12
0
DB::execute("TRUNCATE material");
DB::execute("TRUNCATE product");
DB::execute("TRUNCATE company");
/** 1.1. Create a new company */
$company = new Company();
$company->name = 'Testowa S.A.';
$company->save();
/** 1.2. Check if successfully created */
debug($company->load());
/** 1.3. Add a new product */
$product = new Product();
$product->belongs_to($company);
$product->name = 'Kanapa trzydrzwiowa';
$product->save();
/** 1.4. Check if successfully created */
debug($product->load());
/** 1.5. Create two new materials */
$mat_1 = new Material();
$mat_1->belongs_to($company);
$mat_1->name = 'Skóra';
$mat_1->save();
$mat_2 = new Material();
$mat_2->belongs_to($company);
$mat_2->name = 'Drewno brzozowe';
$mat_2->save();
/** 1.6. Check if materials successfully created */
debug($mat_1->load());
debug($mat_2->load());
/** 1.7. Create a new material combination */
$comb = new Combination();
$comb->belongs_to($product);