Esempio n. 1
0
    {
        $cols = array('id?', DBColumn::make('integer', 'order_nb', 'Order'), DBColumn::make('integer', 'product', 'Product'), DBColumn::make('text', 'product_name', 'Product Name'), DBColumn::make('integer', 'quantity', 'Quantity'));
        return new DBTable("ecomm_order_detail", __CLASS__, $cols);
    }
    public static function getAll($orderId = 0)
    {
        $sql = 'select `id` from ecomm_order_detail';
        if ($orderId) {
            $sql .= " where order_nb = '" . e($orderId) . "'";
        }
        $sql .= " order by id";
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new OrderDetail($result['id']);
        }
        return $results;
    }
    public function getProductPluginInfo()
    {
        require_once SITE_ROOT . '/modules/EComm/plugins/products/ECommProduct.php';
        $hookResults = ECommProduct::adminPluginHooks("BeforeDisplayOrder", $this);
        //var_dump($hookResults);exit;
        return $hookResults;
    }
    static function getQuickFormPrefix()
    {
        return 'orderdetail_';
    }
}
DBRow::init('OrderDetail');
Esempio n. 2
0
        $province = $address->getState();
        $sql = 'select `tax_rate` from ecomm_tax_rate where country = "' . e($country) . '" AND 
															province = "' . e($province) . '" AND
															tax_class = "' . e($taxClass) . '"';
        $result = Database::singleton()->query_fetch($sql);
        $taxRate = $result['tax_rate'];
        if (!$taxRate) {
            $taxRate = 0;
        }
        $taxRate = $taxRate / 100;
        return (double) $taxRate * (double) $productPrice;
    }
    public static function getAll($filter = true)
    {
        $sql = 'select `id` from ecomm_tax_rate';
        if ($filter) {
            $sql .= ' where status = 1';
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new TaxRate($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'taxrate_';
    }
}
DBRow::init('TaxRate');
Esempio n. 3
0
    public function reGenerateSession()
    {
        $newSession = new Session();
        $newSession->setIpAddress($this->getIpAddress());
        $newSession->setStatus($this->getStatus());
        $newSession->setUser($this->getUser());
        $newSession->setShippingClass($this->getShippingClass());
        $newSession->setPaymentClass($this->getPaymentClass());
        $newSession->save();
        $_SESSION["ECommSessionId"] = $newSession->getId();
        return $newSession->getId();
    }
    public static function getAll($filter = true)
    {
        $sql = 'select `id` from ecomm_session';
        if ($filter) {
            $sql .= " where status = 1";
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Session($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'session_';
    }
}
DBRow::init('Session');
Esempio n. 4
0
{
    function createTable()
    {
        $cols = array('id?', DBColumn::make('//integer', 'order_nb', 'Order'), DBColumn::make('select', 'status', 'Order Status', array("Pending" => "Pending", "Shipped" => "Shipped", "Complete" => "Complete")), DBColumn::make('textarea', 'comment', 'Comment'));
        return new DBTable("ecomm_order_comment", __CLASS__, $cols);
    }
    public function getAddEditFormHook($form)
    {
        $form->setConstants(array('order_id' => $this->getOrderNb()));
        $form->addElement('hidden', 'order_id');
    }
    public static function getAll($orderId = 0)
    {
        $sql = 'select `id` from ecomm_order_comment';
        if ($orderId) {
            $sql .= " where order_nb = '" . e($orderId) . "'";
        }
        $sql .= " order by id";
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new OrderComment($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'ordercomment_';
    }
}
DBRow::init('OrderComment');
Esempio n. 5
0
        foreach ($results as &$result) {
            $result = new Product($result['id']);
        }
        return $results;
    }
    public static function searchProductsSimple($searchPhrase)
    {
        $sql = 'select ecomm_product.id from ecomm_product
					left join ecomm_category on ecomm_product.category = ecomm_category.id
					left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id
					left join ecomm_product_type on ecomm_product.producttype = ecomm_product_type.id
					where ecomm_product.status=1 and (';
        $sql .= ' ecomm_product.name like "%' . e($searchPhrase) . '%" OR ecomm_product.details like "%' . e($searchPhrase) . '%"';
        $sql .= ' OR ecomm_category.name like "%' . e($searchPhrase) . '%"';
        $sql .= ' OR ecomm_supplier.name like "%' . e($searchPhrase) . '%"';
        $sql .= ' OR ecomm_product_type.name like "%' . e($searchPhrase) . '%"';
        $sql .= ')';
        $sql .= ' order by ecomm_product.name';
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Product($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'product_';
    }
}
DBRow::init('Product');
Esempio n. 6
0
<?php

include_once SITE_ROOT . '/core/DBColumn.php';
include_once SITE_ROOT . '/core/DBColumns.php';
class PaypalIPN extends DBRow
{
    function createTable()
    {
        $cols = array('id?', DBColumn::make('integer', 'is_verified', 'Is Verified'), DBColumn::make('text', 'transaction', 'Transaction'), DBColumn::make('text', 'txnid', 'Paypal Transaction ID'), DBColumn::make('text', 'payment_status', 'Payment Status'), DBColumn::make('text', 'post_string', 'Post fields'), DBColumn::make('text', 'memo', 'Memo'));
        return new DBTable("ecomm_paypal_ipn", __CLASS__, $cols);
    }
    public static function getAll($sessionId = 0)
    {
        $sql = 'select `id` from ecomm_paypal_ipn';
        if ($sessionId) {
            $sql .= " where session = '" . e($sessionId) . "'";
        }
        $sql .= " order by id";
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new PaypalIPN($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'paypalipn_';
    }
}
DBRow::init('PaypalIPN');
Esempio n. 7
0
include_once SITE_ROOT . '/core/DBColumns.php';
class Order extends DBRow
{
    function createTable()
    {
        $cols = array('id?', DBColumn::make('text', 'tid', 'Transaction ID'), DBColumn::make('integer', 'user', 'User'), DBColumn::make('text', 'customer_name', 'Customer Name'), DBColumn::make('text', 'user_email', 'Customer Email'), DBColumn::make('text', 'phone', 'Phone number'), DBColumn::make('text', 'shipping_street', 'Shipping street'), DBColumn::make('text', 'shipping_city', 'Shipping City'), DBColumn::make('text', 'shipping_postal', 'Shipping Postal'), DBColumn::make('text', 'shipping_province', 'Shipping Province'), DBColumn::make('text', 'shipping_country', 'Shipping Country'), DBColumn::make('text', 'billing_street', 'Billing Street'), DBColumn::make('text', 'billing_city', 'Billing City'), DBColumn::make('text', 'billing_postal', 'Billing Postal'), DBColumn::make('text', 'billing_province', 'Billing Province'), DBColumn::make('text', 'billing_country', 'Billing Country'), DBColumn::make('text', 'cost_subtotal', 'Sub Total'), DBColumn::make('text', 'cost_tax', 'Tax'), DBColumn::make('text', 'cost_shipping', 'Shipping Cost'), DBColumn::make('text', 'cost_total', 'Total'), DBColumn::make('text', 'ip', 'IP Address'), DBColumn::make('text', 'shipping_class', 'Shipping Class'), DBColumn::make('text', 'payment_class', 'Payment Class'), DBColumn::make('text', 'created', 'Timestamp'), DBColumn::make('textarea', 'delivery_instructions', 'Delivery Instructions'), DBColumn::make('text', 'status', 'Status'));
        return new DBTable("ecomm_order", __CLASS__, $cols);
    }
    public static function getAll($allOrders = false, $userId = null)
    {
        $sql = 'select `id` from ecomm_order where 1=1';
        if (!$allOrders) {
            $sql .= ' and status like "Pending"';
        }
        if ($userId) {
            $sql .= ' and user = "******"';
        }
        $sql .= ' order by id desc';
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Order($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'order_';
    }
}
DBRow::init('Order');
Esempio n. 8
0
        $form->addElement('checkbox', $this->quickformPrefix() . 'no_image', 'No image');
        if ($this->getImage()) {
            $curImage = $form->addElement('dbimage', $this->quickformPrefix() . 'image', $this->getImage());
        }
        if ($this->getDateAdded()) {
            $form->addElement('static', $this->quickformPrefix() . 'date_added_label', 'Date Added', $this->getDateAdded()->getDate());
        }
        if ($this->getLastModified()) {
            $form->addElement('static', $this->quickformPrefix() . 'last_modified_label', 'Last Modified', $this->getLastModified());
        }
        $form->addElement('button', 'btn_cancel', 'Cancel', array("onclick" => "document.location='/admin/EComm&section=" . $_REQUEST["section"] . "';"));
    }
    public static function getAll($filter = true)
    {
        $sql = 'select `id` from ecomm_supplier';
        if ($filter) {
            $sql .= ' where status = 1';
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Supplier($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'supplier_';
    }
}
DBRow::init('Supplier');
Esempio n. 9
0
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new CartItem($result['id']);
        }
        return $results;
    }
    public function getCartItemProduct()
    {
        //Return the object of the product
        $productId = $this->getProduct();
        if ($this->cartItemProduct && $this->cartItemProduct->getId() == $productId) {
            return $this->cartItemProduct;
        }
        $this->cartItemProduct = new Product($productId);
        return $this->cartItemProduct;
    }
    public function calculatePrice()
    {
        //This method calls the getPrice method (which returns the base price) and then adds all the plugin prices
        //This method calcultes the price of the product plus the added price of the plugins
        require_once SITE_ROOT . '/modules/EComm/plugins/products/ECommProduct.php';
        $plugInPrices = ECommProduct::getPluginsPrice($this);
        return $plugInPrices + $this->getCartItemProduct()->getPrice();
    }
    static function getQuickFormPrefix()
    {
        return 'cartitem_';
    }
}
DBRow::init('CartItem');
Esempio n. 10
0
    {
    }
    public function clientHookBeforeDisplayCartItem(&$cartItem, &$ecommModule)
    {
    }
}
include_once SITE_ROOT . '/core/DBColumn.php';
include_once SITE_ROOT . '/core/DBColumns.php';
class ProductPropertiesTbl extends DBRow
{
    function createTable()
    {
        $cols = array('id?', DBColumn::make('!integer', 'product', 'Product'), DBColumn::make('!integer', 'pallet_count', 'Pallet Count'), DBColumn::make('!float', 'weight', 'Weight'), DBColumn::make('!select', 'weight_unit', 'Weight Unit', array('KG' => 'KG', 'Cubic Feet' => 'Cubic Feet', 'Cubic Yards' => 'Cubic Yards', 'LB' => 'LB')));
        return new DBTable("ecomm_product_properties", __CLASS__, $cols);
    }
    public static function getPropertiesBasedOnProductId($productId)
    {
        if (!$productId) {
            return new ProductPropertiesTbl();
        }
        $sql = 'select `id` from ecomm_product_properties where product = "' . e($productId) . '"';
        $result = Database::singleton()->query_fetch($sql);
        return new ProductPropertiesTbl($result['id']);
    }
    static function getQuickFormPrefix()
    {
        return 'product_';
    }
}
DBRow::init('ProductPropertiesTbl');
Esempio n. 11
0
        $form->addElement('checkbox', $this->quickformPrefix() . 'no_image', 'No image');
        if ($this->getImage()) {
            $curImage = $form->addElement('dbimage', $this->quickformPrefix() . 'image', $this->getImage());
        }
        if ($this->getDateAdded()) {
            $form->addElement('static', $this->quickformPrefix() . 'date_added_label', 'Date Added', $this->getDateAdded()->getDate());
        }
        if ($this->getLastModified()) {
            $form->addElement('static', $this->quickformPrefix() . 'last_modified_label', 'Last Modified', $this->getLastModified());
        }
        $form->addElement('button', 'btn_cancel', 'Cancel', array("onclick" => "document.location='/admin/EComm&section=" . $_REQUEST["section"] . "';"));
    }
    public static function getAll($filter = true)
    {
        $sql = 'select `id` from ecomm_product_type';
        if ($filter) {
            $sql .= ' where status = 1';
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new ProductType($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'producttype_';
    }
}
DBRow::init('ProductType');
Esempio n. 12
0
        } else {
            $obj = new UserDetails($result['id']);
        }
        return $obj;
    }
    public function getAddress($type)
    {
        if ($type == "billing_address") {
            $add = new Address($this->getBillingAddress());
        } else {
            //$type is shipping_address
            $add = new Address($this->getShippingAddress());
        }
        return $add;
    }
    public function setAddress($type, $address)
    {
        if ($type == "shipping_address") {
            $this->setShippingAddress($address->getId());
        } else {
            //$type is billing_address
            $this->setBillingAddress($address->getId());
        }
    }
    static function getQuickFormPrefix()
    {
        return 'userdetails_';
    }
}
DBRow::init('UserDetails');
Esempio n. 13
0
    {
        $sql = 'select `id` from ecomm_transaction  where tid like "' . e($tid) . '"';
        $result = Database::singleton()->query_fetch($sql);
        $obj = new Transaction($result['id']);
        return $obj;
    }
    public static function generateNewTID()
    {
        srand((double) microtime() * 1000000);
        $tid = "";
        for ($i = 0; $i < 30; $i++) {
            $tid .= rand(1, 9);
        }
        return $tid;
    }
    public static function getAll()
    {
        $sql = 'select `id` from ecomm_transaction';
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Transaction($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'transaction_';
    }
}
DBRow::init('Transaction');
Esempio n. 14
0
    public static function getAll($filter = true, $parentCategory = null)
    {
        $sql = 'select `id` from ecomm_category where 1=1';
        if ($filter) {
            $sql .= ' and status = 1';
        }
        if (is_numeric($parentCategory)) {
            $sql .= " and parent_category = '" . e($parentCategory) . "'";
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new Category($result['id']);
        }
        return $results;
    }
    public function displayBreadCrumb()
    {
        $result = '';
        if (!$this->getId()) {
            return '<a href="/Store/Category">Back to categories</a>';
        }
        $parent = new Category($this->getParentCategory());
        return $parent->displayBreadCrumb() . ' | <a href="/Store/Category/' . $this->getId() . '">' . $this->getName() . '</a>';
    }
    static function getQuickFormPrefix()
    {
        return 'category_';
    }
}
DBRow::init('Category');
Esempio n. 15
0
        $form->addElement('button', 'btn_cancel', 'Cancel', array("onclick" => "document.location='/admin/EComm&section=" . $_REQUEST["section"] . "';"));
    }
    public static function getAll($filter = true)
    {
        $sql = 'select `id` from ecomm_tax_class';
        if ($filter) {
            $sql .= ' where status = 1';
        }
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new TaxClass($result['id']);
        }
        return $results;
    }
    public static function getAllTaxClassesIdAndName()
    {
        $results = array();
        $sql = 'select `id`,`name` from ecomm_category';
        $allTaxClasses = TaxClass::getAll(false);
        foreach ($allTaxClasses as $taxClass) {
            $results[$taxClass->getId()] = $taxClass->getName();
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'taxclass_';
    }
}
DBRow::init('TaxClass');
Esempio n. 16
0
        return 2.5;
    }
}
include_once SITE_ROOT . '/core/DBColumn.php';
include_once SITE_ROOT . '/core/DBColumns.php';
class AlternativeImage extends DBRow
{
    function createTable()
    {
        $cols = array('id?', DBColumn::make('!integer', 'product', 'Product'), DBColumn::make('!integer', 'image', 'Image'));
        return new DBTable("ecomm_product_alternative_image", __CLASS__, $cols);
    }
    public static function getAll($productId)
    {
        if (!$productId) {
            return array();
        }
        $sql = 'select `id` from ecomm_product_alternative_image where product = "' . e($productId) . '"';
        $results = Database::singleton()->query_fetch_all($sql);
        foreach ($results as &$result) {
            $result = new AlternativeImage($result['id']);
        }
        return $results;
    }
    static function getQuickFormPrefix()
    {
        return 'alternativeimage_';
    }
}
DBRow::init('AlternativeImage');