/** * Display date regarding to language preferences * * @param $date * @param null $full * @return string Date * @throws JException */ public static function dateFormat($date, $full = NULL) { return JeproshopTools::displayDate($date, $full); }
public function renderView($tpl = null) { if ($this->getLayout() !== 'modal') { } if ($this->context == null) { $this->context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $this->setLayout('view'); $this->loadObject(); if (!JeproshopTools::isLoadedObject($this->customer, 'customer_id')) { return; } $this->context->customer = $this->customer; $customer_stats = $this->customer->getStats(); $query = "SELECT SUM(total_paid_real) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE customer_id = " . (int) $this->customer->customer_id . " AND valid = 1"; $db->setQuery($query); $total_customer = $db->loadResult(); if ($total_customer) { $query = "SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE valid = 1 AND customer_id != " . (int) $this->customer->customer_id . " GROUP BY "; $query .= "customer_id HAVING SUM(total_paid_real) > " . (int) $total_customer; $db->setQuery($query); $db->loadResult(); $count_better_customers = (int) $db->loadResult('SELECT FOUND_ROWS()') + 1; } else { $count_better_customers = '-'; } $orders = JeproshopOrderModelOrder::getCustomerOrders($this->customer->customer_id, true); $total_orders = count($orders); for ($i = 0; $i < $total_orders; $i++) { $orders[$i]->total_paid_real_not_formated = $orders[$i]->total_paid_real; $orders[$i]->total_paid_real = JeproshopTools::displayPrice($orders[$i]->total_paid_real, new JeproshopCurrencyModelCurrency((int) $orders[$i]->currency_id)); } $messages = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages((int) $this->customer->customer_id); $total_messages = count($messages); for ($i = 0; $i < $total_messages; $i++) { $messages[$i]->message = substr(strip_tags(html_entity_decode($messages[$i]->message, ENT_NOQUOTES, 'UTF-8')), 0, 75); $messages[$i]->date_add = Tools::displayDate($messages[$i]->date_add, null, true); } $groups = $this->customer->getGroups(); $total_groups = count($groups); for ($i = 0; $i < $total_groups; $i++) { $group = new JeproshopGroupModelGroup($groups[$i]); $groups[$i] = array(); $groups[$i]['group_id'] = $group->group_id; $groups[$i]['name'] = $group->name[$this->context->controller->default_form_language]; } $total_ok = 0; $orders_ok = array(); $orders_ko = array(); foreach ($orders as $order) { if (!isset($order->order_state)) { $order->order_state = JText::_('COM_JEPROSHOP_THERE_IS_NO_STATUS_DEFINED_FOR_THIS_ORDER_MESSAGE'); } if ($order->valid) { $orders_ok[] = $order; $total_ok += $order->total_paid_real_not_formated; } else { $orders_ko[] = $order; } } $products = $this->customer->getBoughtProducts(); $carts = JeproshopCartModelCart::getCustomerCarts($this->customer->customer_id); $total_carts = count($carts); for ($i = 0; $i < $total_carts; $i++) { $cart = new JeproshopCartModelCart((int) $carts[$i]->cart_id); $this->context->cart = $cart; $summary = $cart->getSummaryDetails(); $currency = new JeproshopCurrencyModelCurrency((int) $carts[$i]->currency_id); $carrier = new JeproshopCarrierModelCarrier((int) $carts[$i]->carrier_id); $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']); $carts[$i]['date_add'] = JeproshopValidator::displayDate($carts[$i]->date_add, null, true); $carts[$i]['total_price'] = Tools::displayPrice($summary->total_price, $currency); $carts[$i]->name = $carrier->name; } $query = "SELECT DISTINCT cart_product.product_id, cart.cart_id, cart.shop_id, cart_product.shop_id "; $query .= " AS cart_product_shop_id FROM " . $db->quoteName('#__jeproshop_cart_product') . " AS cart_product"; $query .= " JOIN " . $db->quoteName('#__jeproshop_cart') . " AS cart ON (cart.cart_id = cart_product.cart_id) "; $query .= "JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (cart_product.product_id = product."; $query .= "product_id) WHERE cart.customer_id = " . (int) $this->customer->customer_id . " AND cart_product.product_id"; $query .= " NOT IN ( SELECT product_id FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord JOIN "; $query .= $db->quoteName('#__jeproshop_order_detail') . " AS ord_detail ON (ord.order_id = ord_detail.order_id ) WHERE "; $query .= "ord.valid = 1 AND ord.customer_id = " . (int) $this->customer->customer_id . ")"; $db->setQuery($query); $interested = $db->loadObjectList(); $total_interested = count($interested); for ($i = 0; $i < $total_interested; $i++) { $product = new JeproshopProductModelProduct($interested[$i]->product_id, false, $this->context->controller->default_form_language, $interested[$i]->shop_id); if (!Validate::isLoadedObject($product, 'product_id')) { continue; } $interested[$i]->url = $this->context->controller->getProductLink($product->product_id, $product->link_rewrite, JeproshopCategoryModelCategory::getLinkRewrite($product->default_category_id, $this->context->controller->default_form_language), null, null, $interested[$i]->cp_shop_id); $interested[$i]->product_id = (int) $product->product_id; $interested[$i]->name = htmlentities($product->name); } $connections = $this->customer->getLastConnections(); if (!is_array($connections)) { $connections = array(); } $total_connections = count($connections); for ($i = 0; $i < $total_connections; $i++) { $connections[$i]->http_referer = $connections[$i]->http_referer ? preg_replace('/^www./', '', parse_url($connections[$i]->http_referer, PHP_URL_HOST)) : JText::_('COM_JEPROSHOP_DIRECT_LINK_LABEL'); } $referrers = JeproshopReferrerModelReferrer::getReferrers($this->customer->customer_id); $total_referrers = count($referrers); for ($i = 0; $i < $total_referrers; $i++) { $referrers[$i]->date_add = JeproshopTools::displayDate($referrers[$i]->date_add, null, true); } $customerLanguage = new JeproshopLanguageModelLanguage($this->customer->lang_id); $shop = new JeproshopShopModelShop($this->customer->shop_id); //$this->assignRef('customer', $customer); /*'gender' => $gender, /* 'gender_image' => $gender_image, // General information of the customer */ $registration = JeproshopTools::displayDate($this->customer->date_add, null, true); $this->assignRef('registration_date', $registration); $this->assignRef('customer_stats', $customer_stats); $last_visit = JeproshopTools::displayDate($customer_stats->last_visit, null, true); $this->assignRef('last_visit', $last_visit); $this->assignRef('count_better_customers', $count_better_customers); $shop_feature_active = JeproshopShopModelShop::isFeaturePublished(); $this->assignRef('shop_is_feature_active', $shop_feature_active); $this->assignRef('shop_name', $shop->shop_name); $customerBirthday = JeproshopTools::displayDate($this->customer->birthday); $this->assignRef('customer_birthday', $customerBirthday); $last_update = JeproshopTools::displayDate($this->customer->date_upd, null, true); $this->assignRef('last_update', $last_update); $customerExists = JeproshopCustomerModelCustomer::customerExists($this->customer->email); $this->assignRef('customer_exists', $customerExists); $this->assignRef('lang_id', $this->customer->lang_id); $this->assignRef('customerLanguage', $customerLanguage); // Add a Private note $customerNote = JeproshopTools::htmlentitiesUTF8($this->customer->note); $this->assignRef('customer_note', $customerNote); // Messages $this->assignRef('messages', $messages); // Groups $this->assignRef('groups', $groups); // Orders $this->assignRef('orders', $orders); $this->assignRef('orders_ok', $orders_ok); $this->assignRef('orders_ko', $orders_ko); $total_ok = JeproshopTools::displayPrice($total_ok, $this->context->currency->currency_id); $this->assignRef('total_ok', $total_ok); // Products $this->assignRef('products', $products); // Addresses $addresses = $this->customer->getAddresses($this->context->controller->default_form_language); $this->assignRef('addresses', $addresses); // Discounts $discounts = JeproshopCartRuleModelCartRule::getCustomerCartRules($this->context->controller->default_form_language, $this->customer->customer_id, false, false); $this->assignRef('discounts', $discounts); // Carts $this->assignRef('carts', $carts); // Interested $this->assignRef('interested_products', $interested); // Connections $this->assignRef('connections', $connections); // Referrers $this->assignRef('referrers', $referrers); if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } parent::display($tpl); }
/** * Assign template vars related to attribute groups and colors */ protected function assignAttributesGroups() { $colors = array(); $groups = array(); if ($this->context == null) { $this->context = JeproshopContext::getContext(); } // @todo (RM) should only get groups and not all declination ? $attributes_groups = $this->product->getAttributesGroups($this->context->language->lang_id); if (is_array($attributes_groups) && $attributes_groups) { $combination_images = $this->product->getCombinationImages($this->context->language->lang_id); $combination_prices_set = array(); $combinations = array(); foreach ($attributes_groups as $k => $row) { // Color management if (isset($row->is_color_group) && $row->is_color_group && (isset($row->attribute_color) && $row->attribute_color) || file_exists(JURI::base() . COM_JEPROSHOP_COLOR_IMAGE_DIRECTORY . $row->attribute_id . '.jpg')) { $colors[$row->attribute_id]['value'] = $row->attribute_color; $colors[$row->attribute_id]['name'] = $row->attribute_name; if (!isset($colors[$row->attribute_id]['attributes_quantity'])) { $colors[$row->attribute_id]['attributes_quantity'] = 0; } $colors[$row->attribute_id]['attributes_quantity'] += (int) $row->quantity; } if (!isset($groups[$row->attribute_group_id])) { $attribute_row = new JObject(); $attribute_row->set('group_name', $row->group_name); $attribute_row->set('name', $row->public_group_name); $attribute_row->set('group_type', $row->group_type); $attribute_row->set('default', -1); $groups[$row->attribute_group_id] = $attribute_row; } $groups[$row->attribute_group_id]->attributes[$row->attribute_id] = $row->attribute_name; if ($row->default_on && $groups[$row->attribute_group_id]->default == -1) { $groups[$row->attribute_group_id]->default = (int) $row->attribute_id; } if (!isset($groups[$row->attribute_group_id]->attributes_quantity[$row->attribute_id])) { $groups[$row->attribute_group_id]->attributes_quantity[$row->attribute_id] = 0; } $groups[$row->attribute_group_id]->attributes_quantity[$row->attribute_id] += (int) $row->quantity; $data = new JObject(); $combinations[$row->product_attribute_id]->attributes_values[$row->attribute_group_id] = $row->attribute_name; $combinations[$row->product_attribute_id]->attributes[] = (int) $row->attribute_id; $combinations[$row->product_attribute_id]->price = (double) $row->price; // Call getPriceStatic in order to set $combination_specific_price if (!isset($combination_prices_set[(int) $row->product_attribute_id])) { $combination_specific_price = null; JeproshopProductModelProduct::getStaticPrice((int) $this->product->product_id, false, $row->product_attribute_id, 6, null, false, true, 1, false, null, null, null, $combination_specific_price); $combination_prices_set[(int) $row->product_attribute_id] = true; $combinations[$row->product_attribute_id]->specific_price = $combination_specific_price; } $combinations[$row->product_attribute_id]->ecotax = (double) $row->ecotax; $combinations[$row->product_attribute_id]->weight = (double) $row->weight; $combinations[$row->product_attribute_id]->quantity = (int) $row->quantity; $combinations[$row->product_attribute_id]->reference = $row->reference; $combinations[$row->product_attribute_id]->unit_impact = $row->unit_price_impact; $combinations[$row->product_attribute_id]->minimal_quantity = $row->minimal_quantity; if ($row->available_date != '0000-00-00') { $combinations[$row->product_attribute_id]->available_date = $row->available_date; $combinations[$row->product_attribute_id]->date_formatted = JeproshopTools::displayDate($row->available_date); } else { $combinations[$row->product_attribute_id]->available_date = ''; } if (!isset($combination_images[$row->product_attribute_id][0]->image_id)) { $combinations[$row->product_attribute_id]->image_id = -1; } else { $combinations[$row->product_attribute_id]->image_id = $image_id = (int) $combination_images[$row->product_attribute_id][0]->image_id; if ($row->default_on) { if (isset($this->cover->value)) { $current_cover = $this->cover->value; } if (is_array($combination_images[$row->product_attribute_id])) { foreach ($combination_images[$row->product_attribute_id] as $tmp) { if ($tmp->image_id == $current_cover->image_id) { $combinations[$row->product_attribute_id]->image_id = $image_id = (int) $tmp->image_id; break; } } } if ($image_id > 0) { if (isset($this->images->value)) { $product_images = $this->images->value; } if (isset($product_images) && is_array($product_images) && isset($product_images[$image_id])) { $product_images[$image_id]->cover = 1; $this->assignRef('mainImage', $product_images[$image_id]); if (count($product_images)) { $this->assignRef('images', $product_images); } } if (isset($this->cover->value)) { $cover = $this->cover->value; } if (isset($cover) && is_array($cover) && isset($product_images) && is_array($product_images)) { $product_images[$cover->image_id]->cover = 0; if (isset($product_images[$image_id])) { $cover = $product_images[$image_id]; } $cover->image_id = JeproshopSettingModelSetting::getValue('legacy_images') ? $this->product->product_id . '_' . $image_id : (int) $image_id; $cover->image_only_id = (int) $image_id; $this->assignRef('cover', $cover); } } } } } // wash attributes list (if some attributes are unavailable and if allowed to wash it) if (!JeproshopProductModelProduct::isAvailableWhenOutOfStock($this->product->out_of_stock) && JeproshopSettingModelSetting::getValue('display_unavailable_attributes') == 0) { foreach ($groups as &$group) { foreach ($group->attributes_quantity as $key => &$quantity) { if ($quantity <= 0) { unset($group->attributes[$key]); } } } foreach ($colors as $key => $color) { if ($color->attributes_quantity <= 0) { unset($colors[$key]); } } } foreach ($combinations as $product_attribute_id => $comb) { $attribute_list = ''; foreach ($comb->attributes as $attribute_id) { $attribute_list .= '\'' . (int) $attribute_id . '\','; } $attribute_list = rtrim($attribute_list, ','); $combinations[$product_attribute_id]->list = $attribute_list; } $this->assignRef('groups', $groups); $isColors = count($colors) ? $colors : false; $this->assignRef('colors', $isColors); $this->assignRef('combinations', $combinations); $this->assignRef('combinationImages', $combination_images); } }
?> </a></td> <td width="2%" class="nowrap center hidden-phone"><?php echo JeproshopTools::displayPrice($order->total_paid_tax_incl); ?> </td> <td width="5%" class="nowrap center hidden-phone"><?php echo $order->payment; ?> </td> <td width="1%" class="nowrap hidden-phone"><?php echo $order->order_status_name; ?> </td> <td width="1%" class="nowrap center hidden-phone"><?php echo JeproshopTools::displayDate($order->date_add); ?> </td> <td width="1%" class="nowrap center hidden-phone" > <div class="btn-group-action" > <div class="btn-group" > <a href="<?php echo $order_link; ?> " class="btn btn-micro" ><i class="icon-edit" ></i> <?php echo JText::_('COM_JEPROSHOP_EDIT_LABEL'); ?> </a> </div> </div> </td>