Exemple #1
0
 private function validateSpecificPrice($shop_id, $currency_id, $country_id, $group_id, $customer_id, $price, $from_quantity, $reduction, $reduction_type, $from, $to, $product_attribute_id = 0)
 {
     $app = JFactory::getApplication();
     $product_id = $app->input->get('product_id');
     if (!JeproshopTools::isUnsignedInt($shop_id) || !JeproshopTools::isUnsignedInt($currency_id) || !JeproshopTools::isUnsignedInt($country_id) || !JeproshopTools::isUnsignedInt($group_id) || !JeproshopTools::isUnsignedInt($customer_id)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('Wrong IDs'));
     } elseif (!isset($price) && !isset($reduction) || isset($price) && !JeproshopTools::isNegativePrice($price) || isset($reduction) && !JeproshopTools::isPrice($reduction)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('Invalid price/discount amount'));
     } elseif (!JeproshopTools::isUnsignedInt($from_quantity)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('Invalid quantity'));
     } elseif ($reduction && !JeproshopTools::isReductionType($reduction_type)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('Please select a discount type (amount or percentage).'));
     } elseif ($from && $to && (!JeproshopTools::isDateFormat($from) || !Validate::isDateFormat($to))) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('The from/to date is invalid.'));
     } elseif (JeproshopSpecificPriceMpdelSpecificPrice::exists((int) $product_id, $product_attribute_id, $shop_id, $group_id, $country_id, $currency_id, $customer_id, $from_quantity, $from, $to, false)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, JText::_('A specific price already exists for these parameters.'));
     } else {
         return true;
     }
     return false;
 }