public function displayContent($params)
 {
     $alias_shop = (int) Tools::getValue('ash');
     if (!empty($alias_shop)) {
         $_s = AphStore::getByAlias($alias_shop, Context::getContext()->language->id);
         $id_shop = $_s['id_shop'];
     } else {
         $id_shop = (int) Tools::getValue('ids');
     }
     $shop = new AphStore($id_shop, Context::getContext()->language->id);
     $this->nbOffers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay, true);
     $this->pagination((int) $this->nbOffers);
     // Pagination must be call after "getStoresByProduct"
     $this->offerSort();
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $offers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay);
     foreach ($offers as &$offer) {
         $offer = new AphOffer($offer['id_offer'], (int) Context::getContext()->language->id, (int) $id_shop);
         $offer['price_from'] = Tools::displayPrice($offer->price_wt, $id_currency);
         error_log($o->reduction . ' ' . $o->id);
         $offer['new_price'] = $o->price_wt < 0 ? $o->reduction_type == 'percentage' ? '-' . intval(round($o->reduction)) . '%' : '-' . Tools::displayPrice($o['reduction'], (int) Context::getContext()->currency->id) : Tools::displayPrice($o->price_wt, (int) Context::getContext()->currency->id) . ' ';
         $offer['url'] = Context::getContext()->link->getModuleLink('blockoffers', 'offer', array('aof' => $offer['link_rewrite'], 'ido' => $offer['id_offer']));
         $offer['img_link_rewrite'] = Tools::link_rewrite($offer['legend']);
     }
     $this->context->smarty->assign(array('offers' => $offers, 'nb_offers' => $this->nbOffers));
     $this->context->controller->addJS($this->_path . 'blockoffer.js');
     return $this->display(__FILE__, 'blockoffers.tpl', $this->getCacheId());
 }
Exemple #2
0
 public function initContent()
 {
     parent::initContent();
     $shop = NULL;
     $alias_offer = (int) Tools::getValue('aof');
     if (!empty($alias_offer)) {
         $_o = AphOffer::getByAlias($alias_offer, Context::getContext()->language->id);
         $id_offer = $_o['id_offer'];
     } else {
         $id_offer = (int) Tools::getValue('ido');
     }
     $offer = new AphOffer($id_offer, Context::getContext()->language->id);
     $offer->new_price = $offer->price_wt < 0 ? $offer->reduction_type == 'percentage' ? '-' . intval($offer->reduction * 100) . '%' : '-' . Tools::displayPrice($offer['reduction'], (int) Context::getContext()->currency->id) : Tools::displayPrice($offer->price_wt, (int) Context::getContext()->currency->id) . ' ';
     $cover = NULL;
     $images = AphOfferImage::getImages(Context::getContext()->language->id, $id_offer);
     foreach ($images as &$image) {
         if (!empty($image['cover'])) {
             $cover = $image;
         }
     }
     if (empty($cover) && !empty($images)) {
         $cover = $images[0];
     }
     $this->context->smarty->tpl_vars['meta_title']->value = $offer->name;
     $this->context->smarty->tpl_vars['meta_description']->value = $offer->meta_description;
     $shops = AphOffer::getShopsLight(Context::getContext()->language->id, $offer->id);
     foreach ($shops as &$shop) {
         $shop['link'] = Context::getContext()->link->getModuleLink('blockshops', 'shop', array('ash' => $shop['uri'], 'ids' => $shop['id_shop']));
     }
     /*$products = AphOffer::getProductsLight(Context::getContext()->language->id, $offer->id);
     		foreach ($products as &$product) {
     			$product['link'] = Context::getContext()->link->getProductLink((int)$product['id_product'], $product['link_rewrite']);
     		}*/
     $products_by_category = array();
     $ps = AphOffer::getProductsLight(Context::getContext()->language->id, $offer->id);
     foreach ($ps as &$p) {
         $product = new Product($p['id_product'], false, Context::getContext()->language->id);
         $category = new Category($product->id_category_default, Context::getContext()->language->id);
         if (empty($products_by_category[$category->id])) {
             $products_by_category[$category->id] = array('id_category' => $category->id, 'name' => $category->name, 'class' => Tools::link_rewrite($category->name), 'products' => array());
         }
         $products_by_category[$category->id]['products'][$product->id] = array('id_product' => $product->id, 'name' => $product->name, 'link' => Context::getContext()->link->getProductLink((int) $product->id, $product->link_rewrite, $category->id, $product->ean13));
     }
     $this->context->smarty->assign(array('offer' => $offer, 'cover' => $cover, 'images' => $images, 'shops' => $shops, 'products_by_category' => $products_by_category));
     $this->setTemplate('offer.tpl');
 }
Exemple #3
0
 public function initContent()
 {
     parent::initContent();
     $this->module->nbOffers = AphOffer::getOffers(NULL, NULL, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->module->orderBy, $this->module->orderWay, true);
     $this->module->pagination((int) $this->module->nbOffers);
     // Pagination must be call after "getStoresByProduct"
     $this->module->offerSort();
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $offers = AphOffer::getOffers(NULL, NULL, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->module->orderBy, $this->module->orderWay);
     foreach ($offers as &$offer) {
         $o = new AphOffer($offer['id_offer'], (int) Context::getContext()->language->id, (int) $id_shop);
         $offer['description_short'] = $o->description_short;
         $offer['available_from_date'] = $o->available_from_date;
         $offer['available_to_date'] = $o->available_to_date;
         $offer['price_from'] = Tools::displayPrice($o->price_wt, $id_currency);
         $offer['new_price'] = $o->price_wt < 0 ? $o->reduction_type == 'percentage' ? '-' . intval(round($o->reduction)) . '%' : '-' . Tools::displayPrice($o->reduction, (int) Context::getContext()->currency->id) : Tools::displayPrice($o->price_wt, (int) Context::getContext()->currency->id) . ' ';
         $offer['url'] = Context::getContext()->link->getModuleLink('blockoffers', 'offer', array('aof' => $offer['link_rewrite'], 'ido' => $offer['id_offer']));
         $offer['img_link_rewrite'] = Tools::link_rewrite($offer['legend']);
     }
     $this->context->smarty->assign(array('offers' => $offers, 'nb_offers' => $this->module->nbOffers));
     $this->context->controller->addJS('blockoffers.js');
     $this->setTemplate('blockoffers.tpl');
 }
 /**
  * @param Offer $obj
  * @throws Exception
  * @throws PrestaShopException
  * @throws SmartyException
  */
 public function initFormProducts($obj)
 {
     $offer = $obj;
     $data = $this->createTemplate($this->tpl_form);
     // Selected shops
     $selected_products = array();
     $products = AphOffer::getProductsLight($this->context->language->id, $offer->id);
     if (!empty($products)) {
         foreach ($products as $product) {
             $selected_products[] = $product['id_product'];
         }
     }
     // Generate category selection tree
     $tree = new HelperTreeProducts('products-tree', $this->l('Seleziona servizio'));
     $tree->setAttribute('selected_products', $selected_products);
     $tree->setInputName('checkBoxProductAsso_offer');
     $tree->setSelectedProducts($selected_products);
     $tree->setUseShopRestriction(true);
     $data->assign('product_tree', $tree->render());
     // if ($post_products = Tools::getValue('inputProducts')) {
     //     $post_products_tab = explode('-', $post_products);
     //     foreach ($post_products_tab as $product_id) {
     //         if (!$this->haveThisProduct($product_id, $products) && $product = AphOffer::getProductById($product_id)) {
     //             $products[] = $product;
     //         }
     //     }
     // }
     // $data->assign('products', $products);
     $data->assign(array('offer' => $offer, 'link' => $this->context->link, 'is_shop_context' => Shop::getContext() == Shop::CONTEXT_SHOP));
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }
 public function ajaxshowCalendar()
 {
     $id_lang = Context::getContext()->language->id;
     $id_shop = Tools::getValue('ids');
     $shop = new AphStore($id_shop, Context::getContext()->language->id);
     $shop->hours = json_decode($shop->hours, true);
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $context = Context::getContext();
     $context->shop->id = $id_shop;
     $dates = array();
     $dday = Tools::getValue('date');
     for ($i = 2; $i > 0; $i--) {
         if (date('Y-m-d', strtotime('-' . $i . ' day', strtotime($dday))) >= date('Y-m-d')) {
             $dates[] = date('Y-m-d', strtotime('-' . $i . ' day', strtotime($dday)));
         }
     }
     $dates[] = $dday;
     for ($d = sizeof($dates), $i = 1; $d < 5; $d++, $i++) {
         $dates[] = date('Y-m-d', strtotime('+' . $i . ' day', strtotime($dday)));
     }
     $id_product = Tools::getValue('id_product');
     $product = new Product($id_product, true, $id_lang, $id_shop);
     $product_need_tools = false;
     $product_need_employees = true;
     $service_duration = 0;
     $_features = Product::getFrontFeaturesStatic($id_lang, $id_product);
     foreach ($_features as &$feature) {
         if ($product->id_service_duration > 0 && $feature['id_feature'] == $product->id_service_duration) {
             $service_duration = (int) substr($feature['value'], 0, -1);
         }
         if ($product->id_service_duration < 1 && $feature['id_feature'] == Configuration::get('APH_FEATURE_DURATION')) {
             $service_duration = (int) substr($feature['value'], 0, -1);
         }
         if ($feature['id_feature'] == Configuration::get('APH_FEATURE_SERVICE_BY')) {
             if ((int) $feature['value'] == (int) Configuration::get('APH_FEATURE_SERVICE_BY_NO_EMPLOYEE')) {
                 $product_need_employees = false;
             }
         }
         $service_duration = (int) substr($feature['value'], 0, -1);
     }
     $id_tool = 0;
     $necessary_quantity_of_tool = 0;
     $products_use_this_tool = array();
     $tool = AphTool::getByShopAndProduct($id_shop, $id_product);
     if (!empty($tool)) {
         $id_tool = $tool[0]['id_tool'];
         $necessary_quantity_of_tool = $tool[0]['quantity'];
         $product_need_tools = true;
         $_products = AphTool::getProducts($id_tool);
         if (!empty($_products)) {
             foreach ($_products as &$_product) {
                 $products_use_this_tool[] = $_product['id_product'];
             }
         }
     }
     $employees = array();
     if ($product_need_employees) {
         $_employees = AphEmployeeProduct::getEmployeesByShopAndProduct($id_shop, $id_product);
         foreach ($_employees as &$employee) {
             $employees[] = $employee['id_employee'];
         }
     }
     $time_slice = (int) Configuration::get('APH_CALENDAR_TIME_SLICE_ONLINE');
     if ($service_duration > $time_slice) {
         for ($t = 1; $t <= 4; $t++) {
             if ($time_slice * $t >= $service_duration) {
                 $time_slice = $time_slice * $t;
                 break;
             }
         }
     }
     /*$attributues_by_value = array();
       $attributues = $product->getAttributesResume($id_lang, ': ', ', ');
       foreach ($attributues as &$attribute) {
           list($giorno, $orario) = explode(', ', $attribute['attribute_designation']);
           list(, $giorno) = explode(': ', $giorno);
           list(, $giorno) = explode(' ', $giorno);
           list(, $orario) = explode(': ', $orario);
           list(, $orario) = explode(' ', $orario);
           if (!array_key_exists($giorno, $attributues_by_value))
               $attributues_by_value[$giorno] = array();
           $attributues_by_value[$giorno][strval($orario)] = $attribute['id_product_attribute'];
       }*/
     $first_day = $last_day = NULL;
     $days = array();
     foreach ($dates as $day) {
         if (empty($first_day)) {
             $first_day = $day;
         }
         $last_day = $day;
         $days[$day] = array('date' => $day, 'date_ts' => strtotime($day), 'class' => 'store_opened', 'status' => 'opened', 'available' => true, 'price_from' => $product->price, 'times_tot' => 0, 'times_not_available' => 0, 'times_full' => 0, 'times' => array());
         $days[$day]['date_lang'] = date('d/m/Y', $days[$day]['date_ts']);
         $days[$day]['week_day'] = date('w', $days[$day]['date_ts']);
         $days[$day]['week_day_lang'] = $this->week_days[(int) date('w', $days[$day]['date_ts'])];
         $days[$day]['month_lang'] = $this->months[(int) date('w', $days[$day]['date_ts'])];
         if (!empty($shop->hours[date('w', $days[$day]['date_ts'])])) {
             $hour_1 = $shop->hours[date('w', $days[$day]['date_ts'])][1];
             $hour_2 = $shop->hours[date('w', $days[$day]['date_ts'])][2];
             if ($hour_1['o'] == 'X' && $hour_1['c'] == 'X' && $hour_2['o'] == 'X' && $hour_2['c'] == 'X') {
                 $days[$day]['status'] = 'closed';
                 $days[$day]['available'] = false;
             } else {
                 $time_start = $hour_1['o'] == 'X' ? $hour_2['o'] : $hour_1['o'];
                 $time_end = $hour_2['c'] == 'X' ? $hour_1['c'] : $hour_2['c'];
                 $pause_start = $hour_1['c'] == 'X' ? false : $hour_1['c'];
                 $pause_end = $hour_2['o'] == 'X' ? false : $hour_2['o'];
             }
         } else {
             $days[$day]['status'] = 'closed';
             $days[$day]['available'] = false;
         }
         if (!empty($shop->rights_hasCalendar)) {
             if ($days[$day]['status'] == 'closed') {
                 // apertura straordinaria
                 $shop_availability = AphAvailability::getByDate($id_shop, 0, $day, 1);
                 if (!empty($shop_availability)) {
                     $days[$day]['status'] = 'opened';
                     $days[$day]['available'] = true;
                 }
             } else {
                 // chiusura straordinaria
                 $shop_availability = AphAvailability::getByDate($id_shop, 0, $day, -1);
                 if (!empty($shop_availability)) {
                     $days[$day]['status'] = 'closed';
                     $days[$day]['available'] = false;
                 }
             }
             if ($days[$day]['status'] == 'closed') {
                 $days[$day]['class'] = 'store_closed';
                 $days[$day]['available'] = false;
                 continue;
             }
         }
         // almeno un'offerta disponibile nel giorno
         $shop_offers = AphOffer::getByDate($id_shop, $id_product, $day, 1);
         if (!empty($shop_offers)) {
             $days[$day]['status'] = 'promoted';
             $days[$day]['class'] = 'store_promoted';
         }
         print_r($days[$day]['available']);
         if (!empty($days[$day]['available'])) {
             $times = array();
             for ($hours = substr($time_start, 0, 2); $hours < substr($time_end, 0, 2); $hours++) {
                 // the interval for hours is '1'
                 for ($mins = 0; $mins < 60; $mins += $time_slice) {
                     // the interval for mins is 'APH_CALENDAR_TIME_SLICE'
                     $t = str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT);
                     // se sto valutanto l'orario nella pausa allora lo ignoro
                     if (!empty($pause_start) && !empty($pause_end) && $t >= $pause_start && $t < $pause_end) {
                         continue;
                     }
                     $times[$t] = array('time' => $t, 'available' => false, 'status' => 'available', 'class' => $days[$day]['class']);
                     $times[$t]['from'] = $t;
                     $time = new DateTime($day . ' ' . $times[$t]['from']);
                     $time->add(new DateInterval('PT' . $service_duration . 'M'));
                     $times[$t]['to'] = $time->format('H:i');
                     if ($times[$t]['to'] > $time_end) {
                         $times[$t]['available'] = false;
                         $times[$t]['status'] = 'available';
                         $times[$t]['class'] .= ' time_notavailable';
                         $days[$day]['times_not_available']++;
                     }
                     $days[$day]['times_tot']++;
                     if (!empty($shop->rights_hasCalendar)) {
                         $completed_orders = AphOrderDetail::getBetweenTimes($id_shop, 0, 0, $days[$day]['date_ts'], $times[$t]['from'], $times[$t]['to']);
                         if ($product_need_tools && !empty($products_use_this_tool)) {
                             $completed_orders_about_tool = AphOrderDetail::getBetweenTimes($id_shop, 0, $products_use_this_tool, $days[$day]['date_ts'], $times[$t]['from'], $times[$t]['to']);
                             $t = AphTool::getByDate($id_tool, $available_date);
                             $tool_is_availability = !empty($t) ? true : false;
                         } else {
                             $completed_orders_about_tool = array();
                         }
                         $availabilies_of_shop = AphAvailability::getBetweenTimes($id_shop, 0, strtotime($day . ' ' . $times[$t]['from']), strtotime($day . ' ' . $times[$t]['to']), 1);
                         $not_availabilies_of_shop = AphAvailability::getBetweenTimes($id_shop, 0, strtotime($day . ' ' . $times[$t]['from']), strtotime($day . ' ' . $times[$t]['to']), 0);
                         if ($product_need_employees && empty($not_availabilies_of_shop)) {
                             $working_employees = AphWorkingDay::getByEmployeeAndDateBetweenTimes($id_shop, $employees, $day, $times[$t]['from'], $times[$t]['to'], 1);
                             $availabilies_of_employees = AphAvailability::getBetweenTimes($id_shop, $employees, strtotime($day . ' ' . $times[$t]['from']), strtotime($day . ' ' . $times[$t]['to']), 1);
                             $not_availabilies_of_employees = AphAvailability::getBetweenTimes($id_shop, $employees, strtotime($day . ' ' . $times[$t]['from']), strtotime($day . ' ' . $times[$t]['to']), 0);
                         } else {
                             $working_employees = $availabilies_of_employees = $not_availabilies_of_employees = array();
                         }
                     }
                     // chiusura straordinaria
                     if (!empty($not_availabilies_of_shop)) {
                         $times[$t]['available'] = false;
                         $times[$t]['status'] = 'closed';
                         $times[$t]['class'] .= ' time_closed';
                         $days[$day]['times_not_available']++;
                         continue;
                     }
                     // slot di tempo esaurito per mancanza di dipendenti
                     if ($product_need_employees && !empty($completed_orders) && !empty($working_employees) && sizeof($completed_orders) >= sizeof($working_employees) - sizeof($not_availabilies_of_employees)) {
                         $times[$t]['available'] = false;
                         $times[$t]['status'] = 'full';
                         $times[$t]['class'] .= ' time_full';
                         $days[$day]['times_full']++;
                         continue;
                     }
                     // slot di tempo esaurito per mancanza di macchinari
                     if ($product_need_tools && !$tool_is_availability || !empty($necessary_quantity_of_tool) && !empty($completed_orders_about_tool) && sizeof($completed_orders_about_tool) >= $necessary_quantity_of_tool) {
                         $times[$t]['available'] = false;
                         $times[$t]['status'] = 'full';
                         $times[$t]['class'] .= ' time_full';
                         $days[$day]['times_full']++;
                         continue;
                     }
                     // apertura straordinaria (i macchinari sono sempre disponibili)
                     if ($product_need_employees && !empty($availabilies_of_employees) && !empty($completed_orders) && !empty($availabilies_of_employees) && sizeof($completed_orders) >= sizeof($availabilies_of_employees) - sizeof($not_availabilies_of_employees)) {
                         $times[$t]['available'] = false;
                         $times[$t]['status'] = 'full';
                         $times[$t]['class'] .= ' time_full';
                         $days[$day]['times_full']++;
                         continue;
                     }
                     $times[$t]['available'] = true;
                     $times[$t]['status'] = 'available';
                     $times[$t]['class'] .= ' time_available';
                     if (!empty($times[$t]['available'])) {
                         //error_log(var_export(__LINE__,true));
                         //$price = Product::getPriceStatic($id_product, true, 0, 2, null, false, true, 1, false, null, null, null, $specific_price, true, true, $context, true, $day, $times[$t]['from'], $times[$t]['to']);
                         //$times[$t]['price'] = $price;
                         $times[$t]['price'] = 0;
                         $times[$t]['price_label'] = Tools::displayPrice($times[$t]['price'], $id_currency);
                         if ($times[$t]['price'] < $days[$day]['price_from']) {
                             $days[$day]['price_from'] = $times[$t]['price'];
                         }
                     }
                 }
             }
             $days[$day]['times'] = $times;
             $days[$day]['price_from_label'] = Tools::displayPrice($days[$day]['price_from'], $id_currency);
             if ($days[$day]['times_full'] == $days[$day]['times']) {
                 $days[$day]['available'] = false;
                 $days[$day]['status'] = 'full';
                 $days[$day]['class'] = 'store_full';
             } elseif ($days[$day]['times_not_available'] == $days[$day]['times']) {
                 $days[$day]['available'] = false;
                 $days[$day]['status'] = 'closed';
                 $days[$day]['class'] = 'store_closed';
             }
         }
     }
     $jsVars = array();
     $jsVars['calendar_params'] = array('ajax' => 1, 'ajaxCall' => 'ajaxshowCalendar', 'id_product' => $id_product, 'ids' => $id_shop, 'date' => $dday, 'id_city' => empty($id_city) ? $shop->id_city : $id_city);
     $this->context->smarty->assign(array('days' => $days, 'dday' => $dday, 'first_day' => $days[$first_day], 'last_day' => $days[$last_day], 'jsVars' => $jsVars));
     // $jsVars = array(
     //     'language' => $this->context->language->iso_code,
     //     'slotDuration' => '00:'.Configuration::get('APH_CALENDAR_TIME_SLICE').':00'
     // );
     // $this->content .= '<script>var admin_aphcalendar = '.json_encode($jsVars).';</script>';
     return $this->display(__FILE__, 'availability_calendar.tpl', $this->getCacheId('blockmobilecart-column'));
 }
Exemple #6
0
 public function displayAjaxshowCalendar()
 {
     if ($this->errors) {
         $this->ajaxDie(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors)));
     }
     if ($this->ajax_refresh) {
         $this->ajaxDie(Tools::jsonEncode(array('refresh' => true)));
     }
     $this->setTemplate('available_calendar.tpl');
     $id_shop = Tools::getValue('ids');
     $shop = new AphStore($id_shop, Context::getContext()->language->id);
     $shop->hours = json_decode($shop->hours, true);
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $dates = array();
     $date = $dday = Tools::getValue('date');
     for ($i = 2; $i > 0; $i--) {
         if (date('Y-m-d', strtotime('-' . $i . ' day')) >= date('Y-m-d')) {
             $dates[] = date('Y-m-d', strtotime('-' . $i . ' day'));
         }
     }
     $dates = array($date);
     for ($d = sizeof($dates), $i = 1; $d < 5; $d++, $i++) {
         $dates[] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     $id_product = Tools::getValue('id_product');
     $product = new Product($id_product, true, Context::getContext()->language->id, $id_shop);
     $days = array();
     foreach ($dates as $day) {
         $days[$day] = array('date' => $day, 'date_ts' => strtotime($day), 'date_lang' => date('d/m/Y', strtotime($day)), 'class' => 'store_opened', 'status' => 'closed');
         $hour = $shop->hours[strtolower(date('D', $days[$day]['date_ts']))];
         $time_start = $hour['op'];
         $time_end = $hour['cl'];
         if ($hour['op'] == 'CLOSE' || $hour['cl'] == 'CLOSE') {
             $days[$day]['status'] = 'closed';
         }
         if ($days[$day]['status'] == 'closed') {
             $shop_availability = AphAvailability::getByDate($id_shop, 0, $day, 1);
             if (!empty($shop_availability)) {
                 $days[$day]['status'] = 'opened';
             }
         } else {
             $shop_availability = AphAvailability::getByDate($id_shop, 0, $day, -1);
             if (!empty($shop_availability)) {
                 $days[$day]['status'] = 'closed';
             }
         }
         if ($days[$day]['status'] == 'closed') {
             $days[$day]['class'] = 'store_closed';
             break;
         }
         $shop_offers = AphOffer::getByDate($id_shop, $id_product, $day, 1);
         if (!empty($shop_offers)) {
             $days[$day]['status'] = 'promoted';
             $days[$day]['class'] = 'store_promoted';
         }
         $specific_prices = AphSpecificPrice::getByDate($id_shop, $id_currency, $shop->id_country, 0, $day, 0, $id_product, date('w', $day));
         if (!empty($specific_prices)) {
             $specific_price = new AphSpecificPrice($specific_prices[0]['id_specific_price']);
         }
         $price = $product->getPrice(true, null, $decimals = 6, null, false, true, 1, true, null, null, null, $specific_price, false, false, null, true);
         $days[$day]['price'] = $price;
         $days[$day]['price_from'] = $price;
     }
     $this->context->smarty->assign(array('days' => $days, 'dday' => $dday));
     //$this->ajaxDie($this->context->smarty->fetch());
     $this->ajaxDie($this->createTemplate('availability_calendar.tpl')->fetch());
 }