Beispiel #1
0
 function getCurrency()
 {
     $this->onExecuteBefore('getCurrency');
     $id = JRequest::getInt('id');
     $currency = KSSystem::loadDbItem($id, 'currencies');
     $this->onExecuteAfter('getCurrency', array(&$currency));
     return $currency;
 }
Beispiel #2
0
 function getDiscount()
 {
     $this->onExecuteBefore('getDiscount');
     $id = JRequest::getInt('id');
     $discount = KSSystem::loadDbItem($id, 'discounts');
     $discount = KSMedia::setItemMedia($discount, 'discount');
     if (empty($discount->from_date)) {
         $discount->from_date = date('d.m.Y');
     }
     if (empty($discount->to_date)) {
         $discount->to_date = date('d.m.Y');
     }
     if (empty($discount->categories)) {
         $discount->categories = '{}';
     }
     if (empty($discount->manufacturers)) {
         $discount->manufacturers = '{}';
     }
     if (empty($discount->regions)) {
         $discount->regions = '{}';
     }
     if (empty($discount->params)) {
         $discount->params = '{}';
     }
     if (empty($discount->user_actions)) {
         $discount->user_actions = '{}';
     }
     if (empty($discount->user_groups)) {
         $discount->user_groups = '{}';
     }
     if (empty($discount->info_methods)) {
         $discount->info_methods = '{}';
     }
     if (empty($discount->type)) {
         $discount->type = $this->getState('discount_type');
     }
     $discount->categories = json_decode($discount->categories, true);
     $discount->manufacturers = json_decode($discount->manufacturers, true);
     $discount->regions = json_decode($discount->regions, true);
     $discount->params = json_decode($discount->params, true);
     $discount->user_actions = json_decode($discount->user_actions, true);
     $discount->user_groups = json_decode($discount->user_groups, true);
     $discount->info_methods = json_decode($discount->info_methods, true);
     $discount->from_date = date('d.m.Y', strtotime($discount->from_date));
     $discount->to_date = date('d.m.Y', strtotime($discount->to_date));
     $this->setState('discount_type', $discount->type);
     $this->setState('discount_params', $discount->params);
     $this->setState('discount_id', $discount->id);
     $this->onExecuteAfter('getDiscount', array(&$discount));
     return $discount;
 }
Beispiel #3
0
 function getManufacturer()
 {
     $this->onExecuteBefore('getManufacturer');
     $id = JRequest::getInt('id');
     $manufacturer = KSSystem::loadDbItem($id, 'manufacturers');
     $manufacturer = KSMedia::setItemMedia($manufacturer, 'manufacturer');
     $this->onExecuteAfter('getManufacturer', array(&$manufacturer));
     return $manufacturer;
 }
Beispiel #4
0
 function getRate()
 {
     $this->onExecuteBefore('getRate');
     $id = JRequest::getInt('id');
     $rate = KSSystem::loadDbItem($id, 'commentrates');
     $this->onExecuteAfter('getRate', array(&$rate));
     return $rate;
 }
Beispiel #5
0
 public static function getPriceWithProperties($product_id, $properties = array(), $price = null)
 {
     $db = JFactory::getDBO();
     if (empty($price)) {
         $product = KSSystem::loadDbItem($product_id, 'products');
         $price = KSMPrice::getPriceInCurrentCurrency($product->price, $product->price_type);
     }
     foreach ($properties as $property_id => $values) {
         $query = $db->getQuery(true);
         $query->select('edit_price')->from('#__ksenmart_properties');
         $query->where('id=' . $property_id);
         $db->setQuery($query);
         $edit_price = $db->loadResult();
         if ($edit_price == 1) {
             foreach ($values as $value_id) {
                 $query = $db->getQuery(true);
                 $query->select('price')->from('#__ksenmart_product_properties_values');
                 $query->where('property_id=' . $property_id)->where('value_id=' . $value_id)->where('product_id=' . $product_id);
                 $db->setQuery($query);
                 $under_price = $db->loadResult();
                 if ($under_price && !empty($under_price)) {
                     $under_price_act = substr($under_price, 0, 1);
                     switch ($under_price_act) {
                         case '+':
                             $price += substr($under_price, 1, strlen($under_price) - 1);
                             break;
                         case '-':
                             $price -= substr($under_price, 1, strlen($under_price) - 1);
                             break;
                         case '/':
                             $price = $price / substr($under_price, 1, strlen($under_price) - 1);
                             break;
                         case '*':
                             $price = $price * substr($under_price, 1, strlen($under_price) - 1);
                             break;
                         default:
                             $price += $under_price;
                     }
                 }
             }
         }
     }
     return $price;
 }
Beispiel #6
0
 function getRegion()
 {
     $this->onExecuteBefore('getRegion');
     $id = JRequest::getInt('id');
     $region = KSSystem::loadDbItem($id, 'regions');
     $region = KSMedia::setItemMedia($region, 'region');
     $this->onExecuteAfter('getRegion', array(&$region));
     return $region;
 }
Beispiel #7
0
 function getPayment($vars = array())
 {
     $this->onExecuteBefore('getPayment', array(&$vars));
     $id = JRequest::getInt('id');
     $payment = KSSystem::loadDbItem($id, 'payments');
     $payment = KSMedia::setItemMedia($payment, 'payment');
     if (empty($payment->params)) {
         $payment->params = '{}';
     }
     if (empty($payment->regions)) {
         $payment->regions = '{}';
     }
     if (empty($payment->type)) {
         $payment->type = $this->getState('payment_type');
     }
     $payment->params = json_decode($payment->params, true);
     $payment->regions = json_decode($payment->regions, true);
     $this->setState('payment_type', $payment->type);
     $this->setState('payment_params', $payment->params);
     $this->setState('payment_id', $payment->id);
     $this->onExecuteAfter('getPayment', array(&$payment));
     return $payment;
 }
Beispiel #8
0
 function getProperty()
 {
     $this->onExecuteBefore('getProperty');
     $id = JRequest::getInt('id');
     $property = KSSystem::loadDbItem($id, 'properties');
     $property->type = $id > 0 ? $property->type : 'text';
     $query = $this->_db->getQuery(true);
     $query->select('category_id')->from('#__ksenmart_product_categories_properties')->where('property_id=' . $id);
     $this->_db->setQuery($query);
     $property->categories = $this->_db->loadColumn();
     $query = $this->_db->getQuery(true);
     $query->select('*')->from('#__ksenmart_property_values')->where('property_id=' . $id)->order('ordering');
     $this->_db->setQuery($query);
     $property->values = $this->_db->loadObjectList();
     $this->onExecuteAfter('getProperty', array(&$property));
     return $property;
 }
Beispiel #9
0
 function getOrderStatus()
 {
     $this->onExecuteBefore('getOrderStatus');
     $id = JRequest::getInt('id');
     $orderstatus = KSSystem::loadDbItem($id, 'orderstatuses');
     $this->onExecuteAfter('getOrderStatus', array(&$orderstatus));
     return $orderstatus;
 }
Beispiel #10
0
 function getUserField()
 {
     $this->onExecuteBefore('getUserField');
     $id = JRequest::getInt('id');
     $userfield = KSSystem::loadDbItem($id, 'userfields');
     $this->onExecuteAfter('getUserField', array(&$userfield));
     return $userfield;
 }
Beispiel #11
0
 function getShipping()
 {
     $this->onExecuteBefore('getShipping');
     $id = JRequest::getInt('id');
     $shipping = KSSystem::loadDbItem($id, 'shippings');
     $shipping = KSMedia::setItemMedia($shipping, 'shipping');
     $shipping->user_fields = array();
     $shipping->address_fields = array();
     if (empty($shipping->params)) {
         $shipping->params = '{}';
     }
     if (empty($shipping->regions)) {
         $shipping->regions = '{}';
     }
     if (empty($shipping->type)) {
         $shipping->type = $this->getState('shipping_type');
     }
     $shipping->params = json_decode($shipping->params, true);
     $shipping->regions = json_decode($shipping->regions, true);
     if ($id > 0) {
         $query = $this->_db->getQuery(true);
         $query->select('*')->from('#__ksenmart_shipping_fields')->where('shipping_id=' . (int) $shipping->id)->where('position=' . $this->_db->quote('customer'))->order('ordering');
         $this->_db->setQuery($query);
         $shipping->user_fields = $this->_db->loadAssocList('id');
         foreach ($shipping->user_fields as &$user_field) {
             if ($user_field['type'] == 'select') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_shipping_fields_values')->where('field_id=' . $user_field['id']);
                 $this->_db->setQuery($query);
                 $user_field['values'] = $this->_db->loadObjectList('id');
             }
         }
         $query = $this->_db->getQuery(true);
         $query->select('*')->from('#__ksenmart_shipping_fields')->where('shipping_id=' . (int) $shipping->id)->where('position=' . $this->_db->quote('address'))->order('ordering');
         $this->_db->setQuery($query);
         $shipping->address_fields = $this->_db->loadAssocList('id');
         foreach ($shipping->address_fields as &$address_field) {
             if ($address_field['type'] == 'select') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_shipping_fields_values')->where('field_id=' . $address_field['id']);
                 $this->_db->setQuery($query);
                 $address_field['values'] = $this->_db->loadObjectList('id');
             }
         }
     }
     $this->setState('shipping_type', $shipping->type);
     $this->setState('shipping_params', $shipping->params);
     $this->setState('shipping_id', $shipping->id);
     $this->onExecuteAfter('getShipping', array(&$shipping));
     return $shipping;
 }