예제 #1
0
 public function display($tpl = null)
 {
     if (!isset($this->context) || $this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if (!$this->context->controller->isInitialized()) {
         $this->context->controller->initialize();
     }
     $app = JFactory::getApplication();
     $useSSL = isset($this->context->controller->ssl_enabled) && $this->context->conteoller->ssl_enabled && $app->input->get('enable_ssl') || JeproshopTools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     /*$contextParams = $this->context->controller->getContextParams();
       foreach ($contextParams as $assign_key => $assign_value){
           if (!is_array($assign_value) && mb_substr($assign_value, 0, 1, 'utf-8') == '/' || $protocol_content == 'https://'){
               $this->assignRef($assign_key, $protocol_content.JeproshopTools::getMediaServer($assign_value).$assign_value);
           }else{
               $this->assignRef($assign_key, $assign_value);
           }
       }*/
     if (!isset(self::$cache_products)) {
         $category = new JeproshopCategoryModelCategory(JeproshopContext::getContext()->shop->getCategoryId(), (int) JeproshopContext::getContext()->language->lang_id);
         $nb = (int) JeproshopSettingModelSetting::getValue('number_of_products_on_page');
         self::$cache_products = JeproshopDefaultModelDefault::getProducts((int) JeproshopContext::getContext()->language->lang_id, 0, $nb ? $nb : 8, 'position');
     }
     if (self::$cache_products === false || empty(self::$cache_products)) {
         self::$cache_products = false;
     }
     $this->assignRef('products', self::$cache_products);
     $display_add_product = JeproshopSettingModelSetting::getValue('display_category_attribute');
     $this->assignRef('display_add_product', $display_add_product);
     $homeSize = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('home'));
     $this->assignRef('homeSize', $homeSize);
     $this->assignRef('pagination', JeproshopDefaultModelDefault::$_pagination);
     parent::display($tpl);
 }
예제 #2
0
 /**
  * Load class supplier using identifier in $_GET (if possible)
  * otherwise return an empty supplier, or die
  *
  * @param boolean $opt Return an empty supplier if load fail
  * @return supplier|boolean
  */
 public function loadObject($opt = false)
 {
     $app = JFactory::getApplication();
     $currency_id = (int) $app->input->get('currency_id');
     if ($currency_id && JeproshopTools::isUnsignedInt($currency_id)) {
         if (!$this->currency) {
             $this->currency = new JeproshopCurrencyModelCurrency($currency_id);
         }
         if (JeproshopTools::isLoadedObject($this->currency, 'currency_id')) {
             return $this->currency;
         }
         // throw exception
         JError::raiseError(500, 'The currency cannot be loaded (or not found)');
         return false;
     } elseif ($opt) {
         if (!$this->currency) {
             $this->currency = new JeproshopCurrencyModelCurrency();
         }
         return $this->currency;
     } else {
         $this->context->controller->has_errors = true;
         Tools::displayError('The currency cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
예제 #3
0
 public function save()
 {
     if ($this->viewAccess() && JeproshopTools::checkAttachmentToken()) {
         $attachmentModel = new JeproshopAttachmentModelAttachment();
         $attachmentModel->saveAttachment();
     }
 }
예제 #4
0
 public function threads()
 {
     JeproshopTools::checkCustomerToken() or die('COM_JEPROSHOP_FORBIDDEN_AREA_MESSAGE');
     $view = $this->input->get('view', 'customer');
     $layout = $this->input->get('layout', 'threads');
     $viewClass = $this->getView($view, JFactory::getDocument()->getType());
     $viewClass->setLayout($layout);
     $viewClass->viewThreads();
 }
예제 #5
0
 public function edit_group()
 {
     if ($this->viewAccess() && JeproshopTools::checkAttributeGroupToken()) {
         $app = JFactory::getApplication();
         $view = $app->input->get('view');
         $viewClass = $this->getView($view, JFactory::getDocument()->getType());
         $viewClass->setLayout('edit_group');
         $viewClass->editGroup();
     }
 }
예제 #6
0
 public function update()
 {
     if ($this->viewAccess() && JeproshopTools::checkCategoryToken()) {
         $app = JFactory::getApplication();
         $category_id = $app->input->get('category_id');
         if (isset($category_id) && $category_id > 0) {
             $categoryModel = new JeproshopCategoryModelCategory($category_id);
             $categoryModel->updateCategory();
         }
     }
 }
예제 #7
0
 public function initialize()
 {
     parent::initialize();
     $app = JFactory::getApplication();
     $context = JeproshopContext::getContext();
     // Get address ID
     $address_id = 0;
     $type = $app->input->get('type');
     if ($this->use_ajax && isset($type)) {
         if ($type == 'delivery' && isset($context->cart->address_delivery_id)) {
             $address_id = (int) $context->cart->address_delivery_id;
         } else {
             if ($type == 'invoice' && isset($context->cart->address_invoice_id) && $context->cart->id_address_invoice != $context->cart->address_delivery_id) {
                 $address_id = (int) $context->cart->address_invoice_id;
             }
         }
     } else {
         $address_id = (int) $app->input->get('address_id', 0);
     }
     // Initialize address
     if ($address_id) {
         $address = new JeproshopAddressModelAddress($address_id);
         $view = $app->input->get('view');
         $viewClass = $this->getView($view, JFactory::getDocument()->getType());
         if (JeproshopTools::isLoadedObject($address, 'address_id') && JeproshopCustomerModelCustomer::customerHasAddress($context->customer->customer_id, $address_id)) {
             $task = $app->input->get('task');
             if (isset($task) && $task == 'delete') {
                 if ($address->delete()) {
                     if ($context->cart->address_invoice_id == $address->address_id) {
                         unset($context->cart->address_invoice_id);
                     }
                     if ($context->cart->id_address_delivery == $address->address_id) {
                         unset($context->cart->id_address_delivery);
                         $context->cart->updateAddressId($address->address_id, (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($context->customer->customer_id));
                     }
                     $app->redirect('index.php?option=com_jeproshop&view=address');
                 }
                 $this->has_errors = true;
                 JError::raiseError(500, 'This address cannot be deleted.');
             }
         } elseif ($this->use_ajax) {
             $app->close;
         } else {
             $app->redirect('index.php?option=com_jeproshop&view=address');
         }
     }
 }
예제 #8
0
 /**
  * Assign template vars related to countries display
  */
 protected function assignCountries()
 {
     $context = JeproshopContext::getContext();
     $app = JFactory::getApplication();
     $country_id = $app->input->get('country_id');
     // Get selected country
     if (isset($country_id) && !is_null($country_id) && is_numeric($country_id)) {
         $selected_country = (int) $country_id;
     } else {
         if (isset($this->address) && isset($this->address->country_id) && !empty($this->address->country_id) && is_numeric($this->address->country_id)) {
             $selected_country = (int) $this->address->country_id;
         } else {
             if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                 // get all countries as language (xy) or language-country (wz-XY)
                 $array = array();
                 preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
                 if (!JeproshopTools::isLanguageIsoCode($array[0]) || !($selected_country = JeproshopCountryModelCountry::getByIso($array[0]))) {
                     $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
                 }
             } else {
                 $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
             }
         }
     }
     // Generate countries list
     if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
         $countries = JeproshopCarrierModelCarrier::getDeliveredCountries($context->language->lang_id, true, true);
     } else {
         $countries = JeproshopCountryModelCountry::getCountries($context->language->lang_id, true);
     }
     // @todo use helper
     $list = '';
     foreach ($countries as $country) {
         $selected = $country->country_id == $selected_country ? 'selected="selected"' : '';
         $list .= '<option value="' . (int) $country->country_id . '" ' . $selected . '>' . htmlentities(ucfirst($country->name)) . '</option>';
     }
     // Assign vars
     $this->assignRef('countries_list', $list);
     $this->assignRef('countries', $countries);
 }
예제 #9
0
 public function loadObject($option = false)
 {
     $app = JFactory::getApplication();
     $tag_id = $app->input->get('tag_id');
     if ($tag_id && JeproshopTools::isUnsignedInt($tag_id)) {
         if (!$this->tag) {
             $this->tag = new JeproshopTagModelTag($tag_id);
         }
         if (JeproshopTools::isLoadedObject($this->tag, 'tag_id')) {
             return $this->tag;
         }
         JError::raiseError(500, JText::_('COM_JEPROSHOP_TAG_CANNOT_BE_LOADED_OR_FOUND_LABEL'));
     } elseif ($option) {
         if ($this->tag) {
             $this->tag = new JeproshopTagModelTag();
         }
         return $this->tag;
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_TAG_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE'));
         return false;
     }
 }
예제 #10
0
 /**
  * Return messages from Order ID
  *
  * @param integer $order_id Order ID
  * @param boolean $private return WITH private messages
  * @param JeproshopContext $context
  * @return array Messages
  */
 public static function getMessagesByOrderId($order_id, $private = false, JeproshopContext $context = null)
 {
     if (!JeproshopTools::isBool($private)) {
         die(JError::raiseError());
     }
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     $db = JFactory::getDBO();
     $query = "SELECT message.*, customer." . $db->quoteName('firstname') . " AS customer_firstname, customer.";
     $query .= $db->quoteName('lastname') . " AS customer_lastname, employee." . $db->quoteName('name') . " AS employee_name, ";
     $query .= "employee." . $db->quoteName('username') . " AS employee_user_name, (COUNT(message_readed.message_id) = 0 AND ";
     $query .= "message.customer_id != 0) AS is_new_for_me FROM " . $db->quoteName('#__jeproshop_message') . " AS message LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_customer') . " AS customer ON message." . $db->quoteName('customer_id') . " = ";
     $query .= "customer." . $db->quoteName('customer_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_message_readed');
     $query .= " AS message_readed ON message_readed." . $db->quoteName('message_id') . " = message." . $db->quoteName('message_id');
     $query .= " AND message_readed." . $db->quoteName('employee_id') . " = " . (isset($context->employee) ? (int) $context->employee->employee_id : "");
     $query .= " LEFT OUTER JOIN " . $db->quoteName('#__users') . " AS employee ON employee." . $db->quoteName('id');
     $query .= " = message." . $db->quoteName('employee_id') . "\tWHERE order_id = " . (int) $order_id;
     $query .= (!$private ? " AND message." . $db->quoteName('private') . " = 0" : "") . " GROUP BY message.message_id";
     $query .= " ORDER BY message.date_add DESC";
     $db->setQuery($query);
     return $db->loadObjectList();
 }
예제 #11
0
 public function loadObject($option = false)
 {
     echo 'correct';
     exit;
     $app = JFactory::getApplication();
     $attribute_id = $app->input->get('attribute_id');
     if ($attribute_id && JeproshopTools::isUnsignedInt($attribute_id)) {
         if (!$this->attribute) {
             $this->attribute = new JeproshopAttributeModelAttribute($attribute_id);
         }
         if (JeproshopTools::isLoadedObject($this->attribute, 'attribute_id')) {
             return $this->attribute;
         }
         JError::raiseError(500, JText::_('COM_JEPROSHOP_ATTRIBUTE_CANNOT_BE_LOADED_OR_FOUND_LABEL'));
     } elseif ($option) {
         if ($this->attribute) {
             $this->attribute = new JeproshopAttributeModelAttribute();
         }
         return $this->attribute;
     } else {
         JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ATTRIBUTE_CANNOT_BE_LOADED_THE_IDENTIFIER_IS_MISSING_OR_INVALID_MESSAGE'));
         return false;
     }
 }
예제 #12
0
 /**
  * Load class supplier using identifier in $_GET (if possible)
  * otherwise return an empty supplier, or die
  *
  * @param boolean $opt Return an empty supplier if load fail
  * @return supplier|boolean
  */
 public function loadObject($opt = false)
 {
     $app = JFactory::getApplication();
     $manufacturer_id = (int) $app->input->get('manufacturer_id');
     if ($manufacturer_id && JeproshopTools::isUnsignedInt($manufacturer_id)) {
         if (!$this->manufacturer) {
             $this->manufacturer = new JeproshopManufacturerModelManufacturer($manufacturer_id);
         }
         if (JeproshopTools::isLoadedObject($this->manufacturer, 'manufacturer_id')) {
             return $this->manufacturer;
         }
         // throw exception
         JError::raiseError(500, 'The manufacturer cannot be loaded (or found)');
         return false;
     } elseif ($opt) {
         if (!$this->manufacturer) {
             $this->manufacturer = new JeproshopManufacturerModelManufacturer();
         }
         return $this->manufacturer;
     } else {
         $this->errors[] = Tools::displayError('The manufacturer cannot be loaded (the identifier is missing or invalid)');
         return false;
     }
 }
예제 #13
0
 /**
  * Check if order contains (only) virtual products
  *
  * @param boolean $strict If false return true if there are at least one product virtual
  * @return boolean true if is a virtual order or false
  *
  */
 public function isVirtual($strict = true)
 {
     $products = $this->getProducts();
     if (count($products) < 1) {
         return false;
     }
     $virtual = true;
     foreach ($products as $product) {
         $pd = JeproshopProductDownloadModelProductDownload::getIdFromProductId((int) $product->product_id);
         if ($pd && JeproshopTools::isUnsignedInt($pd) && $product->download_hash && $product->display_filename != '') {
             if ($strict === false) {
                 return true;
             }
         } else {
             $virtual &= false;
         }
     }
     return $virtual;
 }
예제 #14
0
                    <th class="nowrap" width="8%" ><?php 
echo JText::_('COM_JEPROSHOP_POSITION_LABEL');
?>
</th>
                    <th class="nowrap" width="8%" ><?php 
echo JText::_('COM_JEPROSHOP_ACTIONS_LABEL');
?>
</th>
                </tr>
            </thead>
            <tbody>
            	<?php 
if (isset($this->features) && count($this->features)) {
    foreach ($this->features as $index => $feature) {
        $editLink = JRoute::_('index.php?option=com_jeproshop&view=feature&task=edit&feature_id=' . $feature->feature_id . '&' . JeproshopTools::getFeatureToken() . '=1');
        $deleteLink = JRoute::_('index.php?option=com_jeproshop&view=feature&task=delete&feature_id=' . $feature->feature_id . '&' . JeproshopTools::getFeatureToken() . '=1');
        ?>
            	<tr class="row_<?php 
        echo $index % 2;
        ?>
" >
            		<td class="nowrap center"><?php 
        echo $index + 1;
        ?>
</td>
            		<td class="nowrap center"><?php 
        echo JHtml::_('grid.id', $index, $feature->feature_id);
        ?>
</td>
            		<td class="nowrap "><a href="<?php 
        echo $editLink;
예제 #15
0
 /**
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     if (JeproshopTools::isUnsignedInt($this->customer_id)) {
         JeproshopCustomerModelCustomer::resetAddressCache($this->customer_id);
     }
     if (!$this->isUsed()) {
         return parent::delete();
     } else {
         $this->deleted = true;
         return $this->update();
     }
 }
예제 #16
0
 public function save_zone()
 {
     if ($this->viewAccess() && JeproshopTools::checkCountryToken()) {
         if ($this->has_errors) {
             return false;
         }
         $zoneModel = new JeproshopZoneModelZone();
         $zoneModel->saveZone();
     }
 }
예제 #17
0
파일: view.php 프로젝트: jeprodev/jeproshop
                    ?>
                                            <br /><?php 
                    echo JText::_('COM_JEPROSHOP_NOT_IMPACTED_BY_DISCOUNT_LABEL');
                    ?>
                                        <?php 
                }
                ?>
                                    </div>
                                </div>
                                <?php 
            }
            if (!empty($this->product->unity) && $this->product->unit_price_ratio > 0.0) {
                $unit_price = $product_price / $this->unit_price_ratio;
                ?>
                                    <p class="unit_price"><span id="jform_unit_price_display"><?php 
                JeproshopTools::convertPrice($unit_price);
                ?>
</span> <?php 
                echo JText::_('COM_JEPROSHOP_PER_LABEL') . ' ' . $this->product->unity;
                ?>
</p>
                                        <!-- {hook h="displayProductPriceBlock" product=$product type="unit_price"} -->
                                <?php 
            }
            ?>
                            </div>
                            <div class="product_attributes clearfix horizontal-form well">
                                <!-- quantity wanted -->
                                <?php 
            if (!$this->catalog_mode) {
                ?>
예제 #18
0
 private function assignDate()
 {
     //Generate years, month and days
     $app = JFactory::getApplication();
     $years = $app->input->get('years');
     $selectedYear = 0;
     if (isset($years) && is_numeric($years)) {
         $selectedYear = $years;
     }
     $years = JeproshopTools::dateYears();
     $months = $app->input->get('months');
     $selectedMonths = 0;
     if (isset($months) && is_numeric($months)) {
         $selectedMonths = $months;
     }
     $days = $app->input->get('days');
     $selectedDay = 0;
     if (isset($days) && is_numeric($days)) {
         $selectedDay = $days;
     }
     $onePhoneAtLeast = (int) JeproshopSettingModelSetting::getValue('one_phone_at_least');
     $this->assignRef('years', $years);
     $this->assignRef('selected_year', $selectedYear);
     $this->assignRef('selected_month', $selectedMonths);
     //$this->assignRef('days', $days);
     $this->assignRef('selected_day', $selectedDay);
     $this->assignRef('one_phone_at_least', $onePhoneAtLeast);
 }
예제 #19
0
$context->language = $language;
$currency_id = $context->cookie->currency_id ? $context->cookie->currency_id : JeproshopSettingModelSetting::getValue('default_currency');
$context->currency = new JeproshopCurrencyModelCurrency($currency_id);
if (isset($context->cookie->customer_id) && (int) $context->customer_id) {
    $customer = new JeproshopCustomerModelCustomer($context->cookie->customer_id);
    if (!JeproshopTools::isLoadedObject($customer)) {
        $context->cookie->logout();
    } else {
        $customer->logged = TRUE;
        if ($customer->lang_id != $context->language->lang_id) {
            $customer->lang_id = $context->language->lang_id;
            $customer->update();
        }
    }
}
if (!isset($customer) || !JeproshopTools::isLoadedObject($customer)) {
    $customer = new JeproshopCustomerModelCustomer();
    if (JeproshopGroupModelGroup::isFeaturePublished()) {
        $customer->default_group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group');
    }
}
$customer->guest_id = $context->cookie->guest_id;
$context->customer = $customer;
/** controller and redirection */
$controller = JFactory::getApplication()->input->get('view');
if ($controller) {
    if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php')) {
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controller.php';
        require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $controller . '.php';
    } else {
        $controller = '';
예제 #20
0
        echo ucfirst($customer->lastname);
        ?>
</a></td>
                    		<td class="nowrap " width="15%" ><a href="<?php 
        echo $customer_view_link;
        ?>
" ><?php 
        echo ucfirst($customer->firstname);
        ?>
</a></td>
                    		<td class="nowrap  hidden-phone" width="25%" ><?php 
        echo $customer->email;
        ?>
</td>
                    		<td class="nowrap " width="6%" ><?php 
        echo JeproshopTools::displayPrice($customer->total_spent);
        ?>
</td>
                            <?php 
        if (JeproshopSettingModelSetting::getValue('enable_b2b_mode')) {
            ?>
                                <td class="nowrap" width="5" ><?php 
            if (isset($customer->website)) {
                ?>
<a href="<?php 
                echo $customer->website;
                ?>
" ><?php 
            }
            echo ucfirst($customer->company);
            if (isset($customer->website)) {
예제 #21
0
 public function update_message()
 {
     $app = JFactory::getApplication();
     $order_id = $app->input->get('order_id');
     $customer_id = $app->input->get('customer_id');
     $order = new JeproshopOrderModelOrder($order_id);
     if (isset($order)) {
         if ($this->viewAccess()) {
             $customer = new JeproshopCustomerModelCustomer($customer_id);
             if (!JeproshopTools::isLoadedObject($customer, 'customer_id')) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_CUSTOMER_IS_INVALID_MESSAGE'));
             } elseif (!$inputMessage) {
                 JError::raiseError(JText::_('COM_JEPROSHOP_THE_MESSAGE_CANNOT_BE_BLANK_MESSAGE'));
             } else {
                 /** Get Message rules anf check fields validity */
                 $rules = JeproshopMessageModelMessage::getValidationRules();
                 foreach ($rules->required as $field) {
                     $value = $app->input->get($field) == false;
                     if ($value && (string) $value != '0') {
                         if ($order_id || $field != 'passwd') {
                             JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_IS_REQUIRED_FIELD_MESSAGE'));
                         }
                     }
                 }
                 foreach ($rules->size as $field => $maxLength) {
                     if ($app->input->get($field) && strlen($field) > $maxLength) {
                         JError::raiseError($field . ' ' . JText::_('COM_JEPROSHOP_FIELD_IS_TOO_LONG_LABEL') . ' ' . $maxLength . ' ' . JText::_('COM_JEPROSHOP_MAX_CHARS_LABEL'));
                     }
                 }
                 foreach ($rules->validate as $field => $function) {
                     if ($app->input->get($field)) {
                         if (!JeproshopTools::$function()) {
                             JError::raiseError(JText::_('COm_JEPROSHOP_FIELD_IS_INVALID_LABEL'));
                         }
                     }
                 }
                 if (12) {
                     $customer_thread_id = JeproshopCustomerThreadModelCustomerThread::getCustomerThreadIdByEmailAndOrderId($customer->email, $order->order_id);
                     if (!$customer_thread_id) {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread();
                         $customerThread->contact_id = 0;
                         $customerThread->customer_id = (int) $order->customer_id;
                         $customerThread->shop_id = (int) $context->shop->shop_id;
                         $customerThread->order_id = (int) $order->order_id;
                         $customerThread->lang_id = (int) $context->language->lang_id;
                         $customerThread->email = $customer->email;
                         $customerThread->status = 'open';
                         $customerThread->token = JeproshopTools::passwdGen(12);
                         $customerThread->add();
                     } else {
                         $customerThread = new JeproshopCustomerThreadModelCustomerThread((int) $customer_thread_id);
                     }
                     $customerMessage = new JeproshopCustomerMessageModelCustomerMessage();
                     $customerMessage->customer_thread_id = $customerThread->customer_thread_id;
                     $customerMessage->employee_id = (int) $context->employee->employee_id;
                     $customerMessage->message = $app->input->get('message');
                     $customerMessage->private = $app->input->get('visibility');
                     if (!$customerMessage->add()) {
                         JError::raiseError(JText::_('COM_JEPROSHOP_AN_ERROR_WHILE_'));
                     } elseif ($customerMessage->private) {
                         $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id);
                     } else {
                     }
                 }
             }
         }
     }
 }
예제 #22
0
파일: shop.php 프로젝트: jeprodev/jeproshop
 /**
  * Load list of groups and shops, and cache it
  *
  * @param bool $refresh
  */
 public static function cacheShops($refresh = false)
 {
     if (!is_null(self::$shops) && !$refresh) {
         return;
     }
     self::$shops = array();
     $db = JFactory::getDBO();
     $from = "";
     $where = "";
     $employee = JeproshopContext::getContext()->employee;
     // If the profile isn't a superAdmin
     if (JeproshopTools::isLoadedObject($employee, 'employee_id') && $employee->profile_id != _PS_ADMIN_PROFILE_) {
         $from .= " LEFT JOIN " . $db->quoteName('#__jeproshop_employee_shop') . " AS employee_shop ON employee_shop.shop_id = shop.shop_id";
         $where .= " AND employee_shop.employee_id = " . (int) $employee->employee_id;
     }
     $query = "SELECT shop_group.*, shop.*, shop_group.name AS group_name, shop.shop_name AS shop_name, ";
     $query .= " shop.published, shop_url.domain, shop_url.ssl_domain, shop_url.physical_uri, shop_url.";
     $query .= "virtual_uri FROM " . $db->quoteName('#__jeproshop_shop_group') . " AS shop_group LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_shop') . " AS shop ON shop.shop_group_id = shop_group.shop_group_id ";
     $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_shop_url') . " AS shop_url ON shop.shop_id =";
     $query .= " shop_url.shop_id AND shop_url.main = 1 " . $from . " WHERE shop.deleted = 0 AND shop_group.";
     $query .= "deleted = 0 " . $where . " ORDER BY shop_group.name, shop.shop_name";
     $db->setQuery($query);
     $results = $db->loadObjectList();
     if ($results) {
         foreach ($results as $row) {
             if (!isset(self::$shops[$row->shop_group_id])) {
                 self::$shops[$row->shop_group_id] = array('shop_group_id' => $row->shop_group_id, 'name' => $row->group_name, 'share_customer' => $row->share_customer, 'share_order' => $row->share_order, 'share_stock' => $row->share_stock, 'shops' => array());
                 self::$shops[$row->shop_group_id]['shops'][$row->shop_id] = $row;
                 /*array(
                 				'shop_id' => $row->shop_id,
                 				'shop_group_id' => $row->shop_group_id,
                 				'name' => $row->shop_name,
                 				'theme_id' => $row->theme_id,
                 				'category_id' => $row->category_id,
                 				'domain' => $row->domain,
                 				'ssl_domain' =>	$row->ssl_domain,
                 				'uri' =>  $row->physical_uri . $row->virtual_uri,
                 				'published' => $row->published
                 		);*/
             }
         }
     }
 }
예제 #23
0
 /**
  * For a given product, tells if it depends on the physical (usable) stock
  *
  * @param int $product_id
  * @param int $shop_id Optional : gets context if null @see Context::getContext()
  * @return bool : depends on stock @see $depends_on_stock
  */
 public static function dependsOnStock($product_id, $shop_id = null)
 {
     if (!JeproshopTools::isUnsignedInt($product_id)) {
         return false;
     }
     $db = JFactory::getDBO();
     $query = "SELECT depends_on_stock FROM " . $db->quoteName('#__jeproshop_stock_available') . " WHERE product_id = " . (int) $product_id;
     $query .= " AND product_attribute_id = 0 " . JeproshopStockAvailableModelStockAvailable::addShopRestriction($shop_id);
     $db->setQuery($query);
     return $db->loadResult();
 }
예제 #24
0
 public static function getProducts($lang_id, $limit_start, $limit, $order_by = null, $order_way = null, $get_total = false, $published = true, $random = false, $random_number_products = 1, $check_access = true, JeproshopContext $context = null)
 {
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     $db = JFactory::getDBO();
     $app = JFactory::getApplication();
     jimport('joomla.html.pagination');
     //if ($check_access && !$context->controller->checkAccess($context->customer->customer_id, $category_id)){ return false; }
     if ($limit_start < 1) {
         $limit_start = 0;
     }
     if (empty($order_by)) {
         $order_by = 'position';
     } else {
         /* Fix for all modules which are now using lowercase values for 'orderBy' parameter */
         $order_by = strtolower($order_by);
     }
     if (empty($order_way)) {
         $order_way = "DESC";
     }
     $order_by_prefix = false;
     if ($order_by == 'product_id' || $order_by == 'date_add' || $order_by == 'date_upd') {
         $order_by_prefix = "product";
     } elseif ($order_by == 'name') {
         $order_by_prefix = "product_lang";
     } elseif ($order_by == 'manufacturer') {
         $order_by_prefix = "manufacturer";
         $order_by = "name";
     } elseif ($order_by == 'position') {
         $order_by_prefix = "product";
     }
     if ($order_by == 'price') {
         $order_by = 'order_price';
     }
     if (!JeproshopTools::isOrderBy($order_by) || !JeproshopTools::isOrderWay($order_way)) {
         die(JError::raiseError());
     }
     $supplier_id = (int) $app->input->get('supplier_id');
     /* Return only the number of products */
     $query = "SELECT COUNT(product." . $db->quoteName('product_id') . ") AS total FROM " . $db->quoteName('#__jeproshop_product') . " AS product ";
     $query .= JeproshopShopModelShop::addSqlAssociation('product') . " WHERE product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog')";
     $query .= " AND product_shop." . $db->quoteName('published') . " = 1 " . ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : "");
     $db->setQuery($query);
     $total = (int) $db->loadResult();
     $number_days_new_product = JeproshopSettingModelSetting::getValue('number_days_new_product');
     $query = "SELECT product.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.product_attribute_id) AS  ";
     $query .= "product_attribute_id, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity,  product_lang." . $db->quoteName('description');
     $query .= ", product_lang." . $db->quoteName('short_description') . ", product_lang." . $db->quoteName('available_now') . ", product_lang." . $db->quoteName('available_later');
     $query .= ", product_lang." . $db->quoteName('link_rewrite') . ", product_lang." . $db->quoteName('meta_description') . ", product_lang." . $db->quoteName('meta_keywords');
     $query .= ", product_lang." . $db->quoteName('meta_title') . ", product_lang." . $db->quoteName('name') . ", MAX(image_shop." . $db->quoteName('image_id') . " ) AS ";
     $query .= "image_id, image_lang." . $db->quoteName('legend') . ", manufacturer." . $db->quoteName('name') . " AS manufacturer_name, DATEDIFF(product_shop." . $db->quoteName('date_add');
     $query .= ", DATE_SUB(NOW(), INTERVAL " . (JeproshopTools::isUnsignedInt($number_days_new_product) ? $number_days_new_product : 20) . "\tDAY)) > 0 AS new, product_shop.price AS";
     $query .= " order_price FROM " . $db->quoteName('#__jeproshop_product') . " AS product " . JeproshopShopModelShop::addSqlAssociation('product') . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_product_attribute') . " AS product_attribute ON (product." . $db->quoteName('product_id') . " = product_attribute." . $db->quoteName('product_id');
     $query .= ") " . JeproshopShopModelShop::addSqlAssociation('product_attribute', false, 'product_attribute_shop.`default_on` = 1');
     $query .= JeproshopProductModelProduct::sqlStock('product', 'product_attribute_shop', false, $context->shop) . " LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang');
     $query .= " AS product_lang ON (product." . $db->quoteName('product_id') . " = product_lang." . $db->quoteName('product_id') . " AND product_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . JeproshopShopModelShop::addSqlRestrictionOnLang('product_lang');
     $query .= ") LEFT JOIN " . $db->quoteName('#__jeproshop_image') . " AS image ON (image." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") " . JeproshopShopModelShop::addSqlAssociation('image', false, 'image_shop.cover=1') . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_image_lang') . " AS image_lang ON (image_shop." . $db->quoteName('image_id') . " = image_lang." . $db->quoteName('image_id') . " AND image_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_manufacturer') . " AS manufacturer ON manufacturer." . $db->quoteName('manufacturer_id') . " = product." . $db->quoteName('manufacturer_id') . "\tWHERE product_shop." . $db->quoteName('shop_id') . " = " . (int) $context->shop->shop_id;
     $query .= " AND product_shop." . $db->quoteName('published') . " = 1 AND product_shop." . $db->quoteName('visibility') . " IN ('both', 'catalog') ";
     $query .= ($supplier_id ? " AND product.supplier_id = " . (int) $supplier_id : "") . " GROUP BY product_shop.product_id";
     if ($random === true) {
         $query .= " ORDER BY RAND() LIMIT " . (int) $random_number_products;
     } else {
         //$query .= " ORDER BY " . (!empty($order_by_prefix) ? $order_by_prefix. "." : "") . $db->quoteName($order_by);
         $query .= " " . $order_way . " LIMIT " . (int) $limit_start . ", " . (int) $limit;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     if ($order_by == 'order_price') {
         JeproshopTools::orderbyPrice($result, $order_way);
     }
     if (!$result) {
         return array();
     }
     self::$_pagination = new JPagination($total, $limit_start, $limit);
     /* Modify SQL result */
     return JeproshopProductModelProduct::getProductsProperties($lang_id, $result);
 }
예제 #25
0
파일: add.php 프로젝트: jeprodev/jeproshop
                                    <select id="jform_address_invoice_id" name="jform[address_invoice_id]"></select>
                                </span>
                            </h4>

                            <div class="well">
                                <a href="" id="edit_invoice_address" class="btn btn-default pull-right fancybox"><i class="icon-pencil"></i> <?php 
echo JText::_('COM_JEPROSHOP_Edit_LABEL');
?>
</a>
                                <div id="address_invoice_detail"></div>
                            </div>
                        </div>
                        <div style="clear: both" ></div>
                        <div class="row">
                            <a class="fancybox btn btn-default pull-right" id="new_address" href="<?php 
echo JRoute::_('index.php?option=com_jeproshop&viewp=address&task=add&customer_id=' . $this->customer->customer_id . '&use_ajax=1&' . JeproshopTools::getAddressToken() . '=1', true, 1);
?>
$link->getAdminLink('AdminAddresses')|escape:'html':'UTF-8'}&amp;addaddress&amp;id_customer=42&amp;liteDisplaying=1&amp;submitFormAjax=1#" >
                                <i class="icon-plus-sign-alt"></i> <?php 
echo JText::_('COM_JEPROSHOP_ADD_A_NEW_ADDRESS_LABEL');
?>
                            </a>
                        </div>
                    </div>

                </div>
                <div class="panel" id="carriers_part" style="display:none;">
                    <div class="panel-title"><i class="icon-truck"></i>  <?php 
echo JText::_('COM_JEPROSHOP_SHIPPING_LABEL');
?>
</div>
예제 #26
0
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
if (empty($this->zones)) {
    ?>
                        <tr>
                            <td colspan="5" ><div class="alert alert-no-items" ><?php 
    echo JText::_('JGLOBAL_NO_MACTHING_RESULTS');
    ?>
</div></td>
                        </tr>
                        <?php 
} else {
    foreach ($this->zones as $index => $zone) {
        $zoneLink = JRoute::_('index.php?option=com_jeproshop&view=country&task=edit_zone&zone_id=' . $zone->zone_id . '&' . JeproshopTools::getCountryToken() . '=1');
        $allow_delivery = $zone->allow_delivery ? 'icon-publish' : 'icon-unpublish';
        ?>
                        <tr class="row_<?php 
        echo $index % 2;
        ?>
" sortable-group-id="<?php 
        ?>
">
                            <td class="order nowrap center hidden-phone"><?php 
        echo $index + 1;
        ?>
</td>
                            <td class="order nowrap center hidden-phone"><?php 
        echo JHtml::_('grid.id', $index, $zone->zone_id);
        ?>
예제 #27
0
                    <th class="nowrap center" width="8%" ><?php 
echo JText::_('COM_JEPROSHOP_STATUS_LABEL');
?>
</th>
                    <th class="nowrap" width="8%" ><?php 
echo JText::_('COM_JEPROSHOP_ACTIONS_LABEL');
?>
</th>
                </tr>
            </thead>
            <tbody>
            	<?php 
if (isset($this->suppliers) && count($this->suppliers)) {
    foreach ($this->suppliers as $index => $supplier) {
        $supplier_link = JRoute::_('index.php?option=com_jeproshop&view=supplier&task=edit&supplier_id=' . $supplier->supplier_id . '&' . JeproshopTools::getSupplierToken() . '=1');
        $delete_supplier_link = JRoute::_('index.php?option=com_jeproshop&view=supplier&task=delete&supplier_id=' . $supplier->supplier_id . '&' . JeproshopTools::getSupplierToken() . '=1');
        ?>
            	<tr class="row_<?php 
        echo $index % 2;
        ?>
" >
                    <td class="nowrap" ><?php 
        echo $index + 1;
        ?>
</td>
                    <td class="nowrap center" ><?php 
        echo JHtml::_('grid.id', $index, $supplier->supplier_id);
        ?>
</td>
                    <td class="nowrap" ><?php 
        echo ucfirst($supplier->name);
예제 #28
0
 public function __construct($manufacturer_id = null, $lang_id = null)
 {
     $db = JFactory::getDBO();
     if ($lang_id !== null) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($manufacturer_id) {
         // Load object from database if object id is present
         $cache_id = 'jeproshop_manufacturer_model_' . (int) $manufacturer_id . '_' . (int) $lang_id;
         $db = JFactory::getDBO();
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS manufacturer ";
             // Get lang informations
             if ($lang_id) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang ON (manufacturer." . $db->quoteName('manufacturer_id');
                 $query .= " = manufacturer_lang." . $db->quoteName('manufacturer_id') . " AND manufacturer_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")";
             }
             $query .= " WHERE manufacturer." . $db->quoteName('manufacturer_id') . " = " . (int) $manufacturer_id;
             // Get shop informations
             /*if (Shop::isTableAssociated($this->def['table']))
               $sql->leftJoin($this->def['table'].'_shop', 'c', 'a.'.$this->def['primary'].' = c.'.$this->def['primary'].' AND c.id_shop = '.(int)$this->id_shop); */
             $db->setQuery($query);
             $manufacturer_data = $db->loadObject();
             if ($manufacturer_data) {
                 if (!$lang_id) {
                     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer_lang') . " WHERE " . $db->quoteName('manufacturer_id') . " = " . (int) $manufacturer_id;
                     $db->setQuery($query);
                     $manufacturer_data_lang = $db->loadObjectList();
                     if ($manufacturer_data_lang) {
                         foreach ($manufacturer_data_lang as $row) {
                             foreach ($row as $key => $value) {
                                 if (array_key_exists($key, $this) && $key != 'manufacturer_id') {
                                     if (!isset($manufacturer_data->{$key}) || !is_array($manufacturer_data->{$key})) {
                                         $manufacturer_data->{$key} = array();
                                     }
                                     $manufacturer_data->{$key}[$row->lang_id] = $value;
                                 }
                             }
                         }
                     }
                 }
                 JeproshopCache::store($cache_id, $manufacturer_data);
             }
         } else {
             $manufacturer_data = JeproshopCache::retrieve($cache_id);
         }
         if ($manufacturer_data) {
             //$this->id = (int)$id;
             foreach ($manufacturer_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     $this->link_rewrite = JeproshopTools::str2url($this->name);
 }
예제 #29
0
파일: view.php 프로젝트: jeprodev/jeproshop
    ?>
}</td>
			 										<td class="partial_refund_fields current-edit" style="display:none;"></td>
			 									</tr>
			 									<?php 
}
$order_total_price = $this->order->total_paid_tax_incl;
?>
												<tr id="total_order">
													<td class="text-right"><strong><?php 
echo ucfirst(JText::_('COM_JEPROSHOP_TOTAL_LABEL'));
?>
</strong></td>
													<td class="amount text-right">
														<strong><?php 
echo JeproshopTools::displayPrice($order_total_price, $this->currency->currency_id);
?>
</strong>
													</td>
													<td class="partial_refund_fields current-edit" style="display:none;"></td>
												</tr>
											</table>
										</div>
									</div>
								</div>
							</div>
							<div style="clear: both; " ></div>
							<div style="display: none;" class="standard_refund_fields form-horizontal panel">
								<div class="form-group">
									<?php 
if ($this->order->hasBeenDelivered() && JeproshopSettingModelSetting::getValue('return_order')) {
예제 #30
0
 /**
  * Return current group object
  * Use context
  * @static
  * @return Group Group object
  */
 public static function getCurrent()
 {
     static $groups = array();
     $customer = JeproshopContext::getContext()->customer;
     if (JeproshopTools::isLoadedObject($customer, 'customer_id')) {
         $group_id = (int) $customer->default_group_id;
     } else {
         $group_id = (int) JeproshopSettingModelSetting::getValue('unidentified_group');
     }
     if (!isset($groups[$group_id])) {
         $groups[$group_id] = new JeproshopGroupModelGroup($group_id);
     }
     if (!$groups[$group_id]->isAssociatedToShop(JeproshopContext::getContext()->shop->shop_id)) {
         $group_id = (int) JeproshopSettingModelSetting::getValue('customer_group');
         if (!isset($groups[$group_id])) {
             $groups[$group_id] = new JeproshopGroupModelGroup($group_id);
         }
     }
     return $groups[$group_id];
 }