Beispiel #1
0
 /**
  * Build and return admin interface
  * 
  * Any module providing an admin interface is required to have this function, which
  * returns a string containing the (x)html of it's admin interface.
  * @return string
  */
 public function getAdminInterface()
 {
     switch (@$_REQUEST['section']) {
         case 'attributes':
             $this->addJS('/modules/Cart/js/optionvalueedit.js');
             switch (@$_REQUEST['action']) {
                 case 'values':
                     $option = new CartProductOption($_REQUEST['id']);
                     return json_encode($option->getValues());
                     die;
                 case 'addedit':
                     $option = new CartProductOption(@$_REQUEST['cartproductoption_id']);
                     $form = $option->getAddEditForm();
                     if (isset($_REQUEST['delete_value'])) {
                         $v = new CartProductOptionValue(trim($_REQUEST['delete_value'], 'delete_'));
                         $v->delete();
                         die;
                     }
                     if (isset($_REQUEST['value'])) {
                         foreach (@$_REQUEST['value'] as $key => $value) {
                             $v = new CartProductOptionValue($key);
                             $v->setName($value);
                             $v->save();
                         }
                     }
                     if (isset($_REQUEST['newvalue'])) {
                         foreach (@$_REQUEST['newvalue'] as $key => $value) {
                             $v = new CartProductOptionValue();
                             $v->setName($value);
                             $v->setLanguage_id(1);
                             $v->optionid = $option->getId();
                             $v->save();
                         }
                     }
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['cartproductoption_submit']) && !isset($_REQUEST['valuesubmit'])) {
                         $this->smarty->assign('form', $form);
                         $this->smarty->assign('option', $option);
                         if ($option->getId()) {
                             $this->smarty->assign('values', $option->getOptionsValues());
                         }
                         return $this->smarty->fetch('admin/optionsedit.tpl');
                     }
                     break;
                 case 'delete':
                     $option = new CartProductOption(@$_REQUEST['cartproductoption_id']);
                     $option->delete();
             }
             $options = CartProductOption::getAllCartProductOptions();
             $this->smarty->assign('options', $options);
             return $this->smarty->fetch('admin/options.tpl');
         case 'products':
             require_once 'include/CartProduct.php';
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     if (isset($_REQUEST['delete_att'])) {
                         $a = new CartProductAttribute($_REQUEST['delete_att']);
                         $a->delete();
                         die;
                     }
                     if (isset($_REQUEST['delete_altimage'])) {
                         $sql = 'delete from cart_products_images where id=' . e($_REQUEST['delete_altimage']);
                         Database::singleton()->query($sql);
                         die;
                     }
                     $this->addJS('/modules/Cart/js/productedit.js');
                     $product = new CartProduct(@$_REQUEST['cartproduct_products_id']);
                     $form = $product->getAddEditForm();
                     if (!isset($_REQUEST['cartproduct_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $product = new CartProduct(@$_REQUEST['cartproduct_products_id']);
                     $product->delete();
                     break;
                 case 'auto':
                     $array = CartProduct::toArray($_REQUEST['value']);
                     $rs = array_slice($array, 1, count($array), true);
                     $str = '<ul>';
                     foreach ($rs as $key => $r) {
                         $str .= '<li id="' . $key . '">' . $r . '</li>';
                     }
                     $str .= '</ul>';
                     return $str;
             }
             require_once 'Pager.php';
             $pagerOptions = array('mode' => 'Sliding', 'delta' => 5, 'perPage' => 20, 'append' => false, 'path' => '/', 'fileName' => "Cart&section=products&pageID=%d", 'totalItems' => CartProduct::getCountCartProducts());
             $pager =& Pager::factory($pagerOptions);
             list($from, $to) = $pager->getOffsetByPageId();
             $items = CartProduct::getAllCartProducts($from, 20);
             $this->smarty->assign('pager_links', $pager->links);
             $this->smarty->assign('page_numbers', array('current' => $pager->getCurrentPageID(), 'total' => $pager->numPages()));
             $this->smarty->assign('products', $items);
             return $this->smarty->fetch('admin/products.tpl');
             break;
         case 'categories':
             require_once 'include/CartCategory.php';
             error_reporting(E_ALL);
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $category = new CartCategory(@$_REQUEST['cartcategory_categories_id']);
                     $form = $category->getAddEditForm();
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['cartcategory_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $category = new CartCategory(@$_REQUEST['cartcategory_categories_id']);
                     $category->delete();
                     break;
             }
             $this->smarty->assign('categories', CartCategory::getCartCategorys(array('parent_id' => 0)));
             return $this->smarty->fetch('admin/categories.tpl');
             break;
         case 'product_types':
             require_once 'include/CartProductType.php';
             error_reporting(E_ALL);
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $productType = new CartProductType(@$_REQUEST['cartproducttype_type_id']);
                     $form = $productType->getAddEditForm();
                     if (!$form->validate() || !$form->isSubmitted() || !isset($_REQUEST['cartproducttype_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $productType = new CartProductType(@$_REQUEST['cartproducttype_type_id']);
                     $productType->delete();
                     break;
             }
             $this->smarty->assign('productTypes', CartProductType::getAllCartProductTypes());
             return $this->smarty->fetch('admin/product_types.tpl');
             break;
         case 'shipping':
             require_once 'include/CartShippingRate.php';
             $this->addJS('/modules/Cart/js/cartEvent.js');
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $rate = new CartShippingRate(@$_REQUEST['cartshippingrate_id']);
                     $form = $rate->getAddEditForm();
                     if (!$form->validate() || !isset($_REQUEST['cartshippingrate_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $rate = new CartShippingRate(@$_REQUEST['cartshippingrate_id']);
                     $rate->delete();
                     break;
             }
             $rates = CartShippingRate::getAllCartShippingRates();
             $this->smarty->assign('rates', $rates);
             return $this->smarty->fetch('admin/shippingrates.tpl');
             break;
         case 'tax_classes':
             require_once 'include/CartTaxClass.php';
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $class = new CartTaxClass(@$_REQUEST['carttaxclass_tax_class_id']);
                     $form = $class->getAddEditForm();
                     if (!$form->validate() || !isset($_REQUEST['carttaxclass_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $class = new CartTaxClass(@$_REQUEST['carttaxclass_tax_class_id']);
                     $class->delete();
                     break;
             }
             $classes = CartTaxClass::getAllCartTaxClasses();
             $this->smarty->assign('taxclasses', $classes);
             return $this->smarty->fetch('admin/taxclasses.tpl');
             break;
         case 'tax_rates':
             require_once 'include/CartTaxRate.php';
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $rate = new CartTaxRate(@$_REQUEST['carttaxrate_tax_rates_id']);
                     $form = $rate->getAddEditForm();
                     if (!$form->validate() || !isset($_REQUEST['carttaxrate_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $rate = new CartTaxRate(@$_REQUEST['carttaxrate_tax_rates_id']);
                     $rate->delete();
                     break;
             }
             $rates = CartTaxRate::getAllCartTaxRates();
             $this->smarty->assign('taxrates', $rates);
             return $this->smarty->fetch('admin/taxrates.tpl');
             break;
         case 'manufacturers':
             require_once 'include/CartManufacturer.php';
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $man = new CartManufacturer(@$_REQUEST['cartmanufacturer_manufacturers_id']);
                     $form = $man->getAddEditForm();
                     if (!isset($_REQUEST['cartmanufacturer_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $man = new CartManufacturer(@$_REQUEST['cartmanufacturer_manufacturers_id']);
                     $man->delete();
                     break;
             }
             $manufacturers = CartManufacturer::getAllCartManufacturers();
             $this->smarty->assign('manufacturers', $manufacturers);
             return $this->smarty->fetch('admin/manufacturers.tpl');
             break;
         case 'orders':
             require_once 'include/CartOrder.php';
             $this->addCSS('/modules/Cart/css/cart.css');
             $this->addJS('/modules/Cart/js/cart.js');
             switch (@$_REQUEST['action']) {
                 case 'addedit':
                     $order = new CartOrder(@$_REQUEST['cartorder_orders_id']);
                     $form = $order->getAddEditForm();
                     if (!$form->validate() || !isset($_REQUEST['cartorder_submit'])) {
                         return $form->display();
                     }
                     break;
                 case 'delete':
                     $order = new CartOrder(@$_REQUEST['cartorder_orders_id']);
                     $order->delete();
                     break;
                 case 'details':
                     $order = new CartOrder(@$_REQUEST['cartorder_orders_id']);
                     $this->smarty->assign('order', $order);
                     return $this->smarty->fetch('admin/order_details.tpl');
                     break;
             }
             $orders = CartOrder::getAllCartOrders();
             $this->smarty->assign('orders', $orders);
             return $this->smarty->fetch('admin/orders.tpl');
             break;
         default:
             require_once 'include/CartCategory.php';
             require_once 'include/CartProduct.php';
             $cats = CartCategory::getCartCategorys();
             $prods = CartProduct::getCountCartProducts();
             $this->smarty->assign('categories', $cats);
             $this->smarty->assign('products', $prods);
             return $this->smarty->fetch('admin/dashboard.tpl');
             break;
     }
 }
Beispiel #2
0
 public function process($values = null)
 {
     //It seems that the parameter $values is not used at all
     //I gave it a default value of null.
     //Anas, 29, October, 2008
     $order = new CartOrder();
     $customer = $_SESSION['authenticated_user'];
     $billing_adr = $_SESSION['cart_checkout']['address']['billing_address'];
     $shipping_adr = $_SESSION['cart_checkout']['address']['shipping_address'];
     $payment = $_SESSION['cart_checkout']['payment'];
     $shipping = $_SESSION['cart_checkout']['shipping'];
     $order->setCustomer($customer->getId());
     $order->setCustomerName($customer->getName());
     $order->setCustomerAddress($billing_adr->getId());
     $order->setCustomerTelephone($customer->getPhone());
     $order->setCustomerEmail($customer->getEmail());
     $order->setBillingName($customer->getName());
     $order->setBillingAddress($billing_adr->getId());
     $order->setDeliveryName($customer->getName());
     $order->setDeliveryAddress($shipping_adr->getId());
     $order->setPaymentMethod($payment->getName());
     $order->setPaymentModuleCode($payment->getClass());
     $order->setShippingMethod($shipping->getName());
     $order->setShippingModuleCode($shipping->getClass());
     $order->setShippingCost($shipping->getCost());
     $order->setCurrency('CAD');
     $order->setCurrencyValue('1.000000');
     $order->setDeliveryDirections($_SESSION['cart_checkout']['delivery_direction']);
     $cartitems = CartBasket::getUserCartBaskets($_SESSION['authenticated_user']->getId());
     $subtotal = 0;
     $tax = 0;
     foreach ($cartitems as $item) {
         $subtotal += $item->getPrice() * $item->getQuantity();
         $taxclass = $item->getProduct()->getTaxClass();
         $taxrate = CartTaxRate::getTaxRate($taxclass, $shipping_adr)->getRate();
         $tax += $taxrate / 100 * ($item->getPrice() * $item->getQuantity());
     }
     $order->setSubTotal($subtotal);
     $order->setTax($tax);
     $order->setTotal($subtotal + $tax + $shipping->getCost());
     $order->setStatus(1);
     $order->setIp_address($_SERVER['REMOTE_ADDR']);
     $order->setDate_purchased(date('Y-m-d H:i:s'));
     $order->setPaypal_ipn_id(@$_REQUEST["txn_id"]);
     $order->save();
     foreach ($cartitems as $item) {
         $product = new CartOrderProduct();
         $product->setOrderId($order->getId());
         $product->setProduct($item->getProduct()->getId());
         $product->setModel($item->getProduct()->getModel());
         $product->setName($item->getProduct()->getName());
         $product->setPrice($item->getPrice());
         $product->setFinalPrice($item->getQuantity() * $item->getPrice());
         $product->setQuantity($item->getQuantity());
         $taxclass = $item->getProduct()->getTaxClass();
         $taxrate = CartTaxRate::getTaxRate($taxclass, $billing_adr)->getRate();
         $product->setTax($taxrate);
         $product->save();
         if ($item->getProduct()->getAttId()) {
             $product_atts = CartBasketAttribute::getCartBasketProductAttributes($item->getProduct()->getId() . ':' . $item->getProduct()->getAttId());
             foreach ($product_atts as $product_att) {
                 $att = new CartOrderProductAttribute();
                 $att->setOrderid($order->getId());
                 $att->setProductid($product->getId());
                 $option = new CartProductOption($product_att['products_options_id']);
                 // works
                 $att->setProducts_options($option->getName());
                 // works
                 $option_value = new CartProductOptionValue($product_att['products_options_value_id']);
                 $att->setProducts_options_values($option_value->getName());
                 $sql = 'select * from cart_products_attributes where options_id=' . $product_att['products_options_id'] . ' and ';
                 $sql .= 'options_values_id=' . $product_att['products_options_value_id'] . ' and ';
                 $sql .= 'products_id=' . $item->getProduct()->getId();
                 $r = Database::singleton()->query_fetch($sql);
                 $att->setOptions_values_price($r['options_values_price']);
                 $att->save();
             }
         }
     }
     $_SESSION['cart_checkout']['order'] = $order;
 }
Beispiel #3
0
    /**
     * Get an Add/Edit form for the object.
     *
     * @param string $target Post target for form submission
     */
    public function getAddEditForm($target = '/admin/Cart')
    {
        $form = new Form('CartProduct_addedit', 'post', $target, '', array('class' => 'admin'));
        $form->setConstants(array('section' => 'products'));
        $form->addElement('hidden', 'section');
        $form->setConstants(array('action' => 'addedit'));
        $form->addElement('hidden', 'action');
        if (!is_null($this->getId())) {
            $form->setConstants(array('cartproduct_products_id' => $this->getId()));
            $form->addElement('hidden', 'cartproduct_products_id');
            $defaultValues['cartproduct_type'] = $this->getType()->getId();
            $defaultValues['cartproduct_quantity'] = $this->getQuantity();
            $defaultValues['cartproduct_pallet_count'] = $this->getPalletCount();
            //$defaultValues ['cartproduct_model'] = $this->getModel();
            $defaultValues['cartproduct_image'] = $this->getImage()->getId();
            $defaultValues['cartproduct_price'] = $this->getPrice();
            //$defaultValues ['cartproduct_virtual'] = $this->getVirtual();
            $defaultValues['cartproduct_date_added'] = $this->getDate_added();
            $defaultValues['cartproduct_lastModified'] = $this->getLastModified();
            $defaultValues['cartproduct_dateAvailable'] = $this->getDateAvailable();
            $defaultValues['cartproduct_weight'] = $this->getWeight();
            $defaultValues['cartproduct_weight_unit'] = $this->getWeightUnit();
            $defaultValues['cartproduct_status'] = $this->getStatus();
            $defaultValues['cartproduct_taxClass'] = $this->getTaxClass()->getId();
            $defaultValues['cartproduct_manufacturer'] = $this->getManufacturer()->getId();
            $defaultValues['cartproduct_ordered'] = $this->getOrdered();
            $defaultValues['cartproduct_orderMin'] = $this->getOrderMin();
            $defaultValues['cartproduct_orderUnits'] = $this->getOrderUnits();
            $defaultValues['cartproduct_pricedByAttribute'] = $this->getPricedByAttribute();
            $defaultValues['cartproduct_isFree'] = $this->getIsFree();
            $defaultValues['cartproduct_isCall'] = $this->getIsCall();
            $defaultValues['cartproduct_quantityMixed'] = $this->getQuantityMixed();
            $defaultValues['cartproduct_isAlwaysFreeShipping'] = $this->getIsAlwaysFreeShipping();
            $defaultValues['cartproduct_qtyBoxStatus'] = $this->getQtyBoxStatus();
            $defaultValues['cartproduct_qtyOrderMax'] = $this->getQtyOrderMax();
            $defaultValues['cartproduct_sortOrder'] = $this->getSortOrder();
            $defaultValues['cartproduct_discountType'] = $this->getDiscountType();
            $defaultValues['cartproduct_discountTypeFrom'] = $this->getDiscountTypeFrom();
            $defaultValues['cartproduct_priceSorter'] = $this->getPriceSorter();
            $defaultValues['cartproduct_category'] = $this->getCategory()->getId();
            $defaultValues['cartproduct_mixedDiscountQty'] = $this->getMixedDiscountQty();
            $defaultValues['cartproduct_titleStatus'] = $this->getTitleStatus();
            $defaultValues['cartproduct_nameStatus'] = $this->getNameStatus();
            $defaultValues['cartproduct_modelStatus'] = $this->getModelStatus();
            $defaultValues['cartproduct_priceStatus'] = $this->getPriceStatus();
            $defaultValues['cartproduct_taglineStatus'] = $this->getTaglineStatus();
            $defaultValues['cartproduct_name'] = $this->getName();
            $defaultValues['cartproduct_description'] = $this->getDescription();
            //$defaultValues ['cartproduct_url'] = $this->getUrl();
            //$defaultValues ['cartproduct_accessoryof'] = $this->getAccessoryOf()->getId();
        } else {
            /*******************************************************/
            //The following few lines assign the default values to the elements.
            //It is very important especially for adjusting the layout
            $defaultValues['cartproduct_date_added'] = "&nbsp;";
            $defaultValues['cartproduct_lastModified'] = "&nbsp;";
            //$defaultValues ['cartproduct_virtual'] = 0;
            /*******************************************************/
        }
        $form->setDefaults($defaultValues);
        $form->addElement('header', 'product_details', 'Product Details');
        $form->addElement('text', 'cartproduct_name', 'Name');
        $desc = $form->addElement('tinymce', 'cartproduct_description', 'Description');
        //$form->addElement('text', 'cartproduct_url', 'Link URL');
        /*
        $products = CartProduct::toArray();
        $products[0] = "Not an Accessory";
        $acc = $form->addElement('select', 'cartproduct_accessoryof', 'Accessory Of', $products);
        $acc->setMultiple(true);
        
        $accs = array();
        
        foreach ($this->getAccessoryOf() as $p) {
        	$accs[] = $p->getId();
        }
        
        $acc->setSelected($accs);
        */
        $form->addElement('select', 'cartproduct_manufacturer', 'Supplier', CartManufacturer::toArray());
        $form->addElement('select', 'cartproduct_category', 'Category', CartCategory::toArray());
        require_once 'CartProductType.php';
        $form->addElement('select', 'cartproduct_type', 'Product Type', @CartProductType::toArray());
        $form->addElement('text', 'cartproduct_quantity', 'Stock Qty');
        $form->addElement('text', 'cartproduct_pallet_count', 'Pallet Count');
        //$form->addElement('text', 'cartproduct_model', 'Model #');
        $newImage = $form->addElement('file', 'cartproduct_image_upload', 'Product Image');
        if ($this->getImage()) {
            $curImage = $form->addElement('dbimage', 'cartproduct_image', $this->getImage()->getId());
        }
        $form->addElement('text', 'cartproduct_price', 'Price ($)');
        //$form->addElement('select', 'cartproduct_virtual', 'Virtual Product', Form::booleanArray());
        $form->addElement('static', 'cartproduct_date_added', 'Date Added');
        $form->addElement('static', 'cartproduct_lastModified', 'Last Modified');
        $form->addElement('text', 'cartproduct_dateAvailable', 'Date Availible');
        $form->addElement('text', 'cartproduct_weight', 'Weight per bag');
        $form->addElement('select', 'cartproduct_weight_unit', 'Weight Unit', CartProduct::getAvailableWeightUnits());
        $form->addElement('select', 'cartproduct_taxClass', 'Tax Class', CartTaxClass::toArray());
        //$form->addElement('text', 'cartproduct_ordered', 'ordered');
        $form->addElement('text', 'cartproduct_orderMin', 'Minimum Order Quantity');
        $form->addElement('select', 'cartproduct_status', 'Status', Form::statusArray());
        $form->addElement('header', 'alt_images', 'Alternate Product Images');
        foreach ($this->getAltImages() as $image) {
            $form->addElement('html', '
				<div style="float: right;" id="delete_altimage_div_' . $image['id'] . '">
					<input type="image" src="/images/admin/cross.gif" name="delete_altimage" onclick="return !deleteAltImage(' . $image['id'] . ');" />
				</div>
			');
            $form->addElement('dbimage', 'cartproduct_altimage_' . $image['id'], $image['image_id']);
        }
        $newAltImage = $form->addElement('file', 'cartproduct_altimage_upload', 'New Alternate Product Image');
        $options = $this->getOptions();
        foreach ($options as $option) {
            $form->addElement('header', 'product_options_' . $option->getId(), 'Product Options: ' . $option->getOptionsId()->getName());
            $form->addElement('static', 'value_' . $option->getId(), $option->getOptionsId()->getName(), $option->getValue()->getName());
            $form->addElement('text', 'attprice[' . $option->getId() . ']', 'Additional Price');
            $form->addElement('text', 'inventory[' . $option->getId() . ']', 'Inventory');
            $form->addElement('html', '
				<div style="float: right;">
					<input type="image" src="/images/admin/cross.gif" name="delete_att" onclick="return !deleteAtt(' . $option->getId() . ');" />
				</div>
			');
            $defaultValues['attprice[' . $option->getId() . ']'] = $option->getValuesPrice();
            $defaultValues['inventory[' . $option->getId() . ']'] = $option->getInventory();
        }
        $form->addElement('header', 'new_product_options', 'New Product Option');
        $form->addElement('select', 'newoption', 'Option', CartProductOption::toArray(), array('onclick' => 'getValues(this);'));
        $form->addElement('select', 'newvalue', 'Value', array());
        $form->addElement('text', 'newattprice', 'Additional Price');
        $form->addElement('text', 'newinventory', 'Inventory');
        $form->setDefaults($defaultValues);
        if (isset($_REQUEST['cartproduct_submit']) && $form->validate() && $form->isSubmitted()) {
            $this->setName($form->exportValue('cartproduct_name'));
            $this->setDescription($form->exportValue('cartproduct_description'));
            //$this->setUrl($form->exportValue('cartproduct_url'));
            $this->setType($form->exportValue('cartproduct_type'));
            $this->setQuantity($form->exportValue('cartproduct_quantity'));
            $this->setPalletCount($form->exportValue('cartproduct_pallet_count'));
            //$this->setModel($form->exportValue('cartproduct_model'));
            $this->setImage($form->exportValue('cartproduct_image_upload'));
            $this->setPrice($form->exportValue('cartproduct_price'));
            //$this->setVirtual($form->exportValue('cartproduct_virtual'));
            $this->setDate_added($form->exportValue('cartproduct_date_added'));
            $this->setLastModified(date('Y-m-d H:i:s'));
            $this->setDateAvailable($form->exportValue('cartproduct_dateAvailable'));
            $this->setWeight($form->exportValue('cartproduct_weight'));
            $this->setWeightUnit($form->exportValue('cartproduct_weight_unit'));
            $this->setStatus($form->exportValue('cartproduct_status'));
            $this->setTaxClass($form->exportValue('cartproduct_taxClass'));
            $this->setManufacturer($form->exportValue('cartproduct_manufacturer'));
            //$this->setAccessoryOf($form->exportValue('cartproduct_accessoryof'));
            //$this->setOrdered($form->exportValue('cartproduct_ordered'));
            if ($form->exportValue('cartproduct_orderMin') <= 0) {
                $this->setOrderMin(1);
            } else {
                $this->setOrderMin($form->exportValue('cartproduct_orderMin'));
            }
            $this->setCategory($form->exportValue('cartproduct_category'));
            /*
            $this->setOrderUnits($form->exportValue('cartproduct_orderUnits'));
            $this->setPricedByAttribute($form->exportValue('cartproduct_pricedByAttribute'));
            $this->setIsFree($form->exportValue('cartproduct_isFree'));
            $this->setIsCall($form->exportValue('cartproduct_isCall'));
            $this->setQuantityMixed($form->exportValue('cartproduct_quantityMixed'));
            $this->setIsAlwaysFreeShipping($form->exportValue('cartproduct_isAlwaysFreeShipping'));
            $this->setQtyBoxStatus($form->exportValue('cartproduct_qtyBoxStatus'));
            $this->setQtyOrderMax($form->exportValue('cartproduct_qtyOrderMax'));
            $this->setSortOrder($form->exportValue('cartproduct_sortOrder'));
            $this->setDiscountType($form->exportValue('cartproduct_discountType'));
            $this->setDiscountTypeFrom($form->exportValue('cartproduct_discountTypeFrom'));
            $this->setPriceSorter($form->exportValue('cartproduct_priceSorter'));
            $this->setMixedDiscountQty($form->exportValue('cartproduct_mixedDiscountQty'));
            $this->setTitleStatus($form->exportValue('cartproduct_titleStatus'));
            $this->setNameStatus($form->exportValue('cartproduct_nameStatus'));
            $this->setModelStatus($form->exportValue('cartproduct_modelStatus'));
            $this->setPriceStatus($form->exportValue('cartproduct_priceStatus'));
            $this->setTaglineStatus($form->exportValue('cartproduct_taglineStatus'));
            */
            if ($newImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newImage->getValue());
                $this->setImage($id);
                //$curImage->setSource($this->getImage()->getId());
            }
            $this->save();
            if ($newAltImage->isUploadedFile()) {
                $im = new Image();
                $id = $im->insert($newAltImage->getValue());
                $sql = 'insert into cart_products_images set product_id=' . $this->getId() . ', image_id=' . $id;
                Database::singleton()->query($sql);
            }
            if (is_array(@$_REQUEST['attprice'])) {
                foreach (@$_REQUEST['attprice'] as $key => $value) {
                    $att = new CartProductAttribute($key);
                    $att->setValuesPrice($value);
                    $att->setInventory($_REQUEST['inventory'][$key]);
                    $att->save();
                }
            }
            if (isset($_REQUEST['newvalue']) && isset($_REQUEST['newoption']) && isset($_REQUEST['newattprice'])) {
                $a = new CartProductAttribute();
                $a->setProductid($this->getId());
                $a->setOptionsId($_REQUEST['newoption']);
                $a->setValue($_REQUEST['newvalue']);
                $a->setValuesPrice($_REQUEST['newattprice']);
                $a->setInventory($_REQUEST['newinventory']);
                $a->save();
            }
        }
        $form->addElement('header', 'product_submit', 'Save Product');
        $form->addElement('submit', 'cartproduct_submit', 'Submit');
        return $form;
    }