diff --git a/install.xml b/install.xml old mode 100755 new mode 100644 index 707c1e6..34701cf --- a/install.xml +++ b/install.xml @@ -5,7 +5,7 @@ --> MyParcel NL - 1.0.5 + 1.1.2 MyParcelNL MyParcel NL https://www.myparcel.nl/ @@ -20,13 +20,13 @@ Ship To - + - + ]]> - + /]]> @@ -41,14 +41,14 @@ - {{ order.column_myparcel }} + {{ order.column_myparcel }} ]]> /]]> + ]]> @@ -145,16 +145,18 @@ - + - + load->model('extension/myparcelnl/helper'); - $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); - $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); + $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); + $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'sweetalert.min.css'); + $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); + $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'sweetalert.min.js'); ]]> @@ -164,8 +166,8 @@ ]]> load->model('extension/myparcelnl/helper'); - $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); - $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); + $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); + $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); ]]> @@ -175,9 +177,9 @@ ]]> load->model('extension/myparcelnl/helper'); - $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); - $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); - $data['use_addition_address'] = Myparcel($this->registry)->settings->general->use_addition_address_as_number_suffix; + $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'order.css'); + $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); + $data['use_addition_address'] = Myparcel($this->registry)->settings->general->use_addition_address_as_number_suffix; ]]> @@ -185,18 +187,18 @@ \$result\['customer'],/]]> $result['customer'], - 'column_myparcel' => $this->model_extension_myparcelnl_helper->getContent('column_myparcel', array('order_id' => $result['order_id'])), - 'ship_to_myparcel' => $this->model_extension_myparcelnl_helper->getContent('ship_to_myparcel', array('order_id' => $result['order_id'])), + 'column_myparcel' => $this->model_extension_myparcelnl_helper->getContent('column_myparcel', array('order_id' => $result['order_id'])), + 'ship_to_myparcel' => $this->model_extension_myparcelnl_helper->getContent('ship_to_myparcel', array('order_id' => $result['order_id'])), 'mp_packet_type' => $this->model_extension_myparcelnl_helper->getContent('myparcel_packet_type', array('order_id' => $result['order_id'])), ]]> - + model_extension_myparcelnl_helper->getContent('column_header_myparcel'); - $data['myparcel_popup_modal'] = $this->model_extension_myparcelnl_helper->getContent('myparcel_popup_modal'); + $data['column_header_myparcel'] = $this->model_extension_myparcelnl_helper->getContent('column_header_myparcel'); + $data['myparcel_popup_modal'] = $this->model_extension_myparcelnl_helper->getContent('myparcel_popup_modal'); ]]> @@ -238,17 +240,17 @@ - - + - load->model('extension/myparcelnl/helper'); $data['myparcel_order_header'] = $this->model_extension_myparcelnl_helper->getContent('myparcel_order_header'); /* MyParcel Ocmod End */ ]]> - + @@ -280,6 +282,43 @@ $data['tracktrace'] = $this->model_extension_myparcelnl_helper->getContent('myparcel_email_tracktrace', array('order_id' => $order_info['order_id'])); ]]> + + + session->data['myparcel']['data'])){ + $myparcel = str_replace('"','"',$this->session->data['myparcel']['data']); + $myparcel = json_decode($myparcel,true); + if(isset($myparcel['location'])){ + $language->load('extension/module/myparcel'); + $data['text_pickup_location'] = 'Pickup Location'; + $data['pickup_location'] = implode("
", array($myparcel['location'],$myparcel['street'] . ' ' . $myparcel['number'], $myparcel['city'] . ' (' . $myparcel['distance'] . 'm)')); + } + } + else if(isset($this->session->data['myparcel_order_id'])){ + $this->load->model('extension/myparcelnl/shipment'); + $myparcel_delivery_options = $this->model_extension_myparcelnl_shipment->getMyParcelDeliveryOptions($this->session->data['myparcel_order_id']); + if(isset($myparcel_delivery_options['location'])){ + $data['text_pickup_location'] = 'Pickup Location'; + $data['pickup_location'] = implode("
", array($myparcel_delivery_options['location'],$myparcel_delivery_options['street'] . ' ' . $myparcel_delivery_options['number'], $myparcel_delivery_options['city'] . ' (' . $myparcel_delivery_options['distance'] . 'm)')); + } + } + if(!isset($data['pickup_location'])){ + if(isset($this->session->data['myparcel_shipping_choosed'])){ + $myparcel_delivery_options = $this->session->data['myparcel_shipping_choosed']; + if(isset($myparcel_delivery_options['location'])){ + $data['text_pickup_location'] = 'Pickup Location'; + $data['pickup_location'] = implode("
", array($myparcel_delivery_options['location'],$myparcel_delivery_options['street'] . ' ' . $myparcel_delivery_options['number'], $myparcel_delivery_options['city'] . ' (' . $myparcel_delivery_options['distance'] . 'm)')); + } + } + } + ]]>
+
+ + $order_total['title'],]]> + strip_tags($order_total['title']), + ]]> + @@ -290,6 +329,22 @@ {% if tracktrace %}

{{ tracktrace.text }} {{ tracktrace.code|join(', ') }}

{% endif %} ]]> + + {{ text_shipping_address }}]]> + {{ text_pickup_location }} + {% endif %} + ]]> + + + {{ shipping_address }}]]> + {{ pickup_location }} + {% endif %} + ]]> +
@@ -304,8 +359,21 @@ - ]]> - {{ order.tracktrace_myaccount }}]]> + {{ column_date_added }}]]> + {{ entry_track_trace }} + {% endif %} + ]]> + + + {{ order.date_added }}]]> + {{ order.tracktrace_myaccount }} + {% endif %} + + ]]> @@ -336,7 +404,16 @@ $order_total = $this->model_account_order->getTotalOrders(); ]]> registry); + } $this->load->model('extension/myparcelnl/helper'); + $this->load->language('extension/module/myparcelnl'); + if(MyParcel()->settings->general->trackandtrace_myaccount){ + $data['is_show_track_trace'] = MyParcel()->settings->general->trackandtrace_myaccount; + $data['entry_track_trace'] = $this->language->get('entry_track_trace'); + } ]]> @@ -344,7 +421,7 @@ load->model('extension/myparcelnl/helper'); $data['myparcel_order_header'] = $this->model_extension_myparcelnl_helper->getContent('myparcel_order_header'); - $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); + $this->document->addScript($this->model_extension_myparcelnl_helper->getJsUrl() . 'order.js'); ]]> @@ -401,6 +478,12 @@ {% endif %} ]]> + + + + @@ -420,6 +503,33 @@ + + + + + + + + + + + + + + @@ -462,6 +572,734 @@ + + + request->get['showpayment'])) {]]> + cart->hasShipping() && isset($this->session->data['shipping_method']['code']) && ($this->session->data['shipping_method']['code'] == 'myparcel_delivery.myparcel_delivery' || $this->session->data['shipping_method']['code'] == 'myparcel_pickup.myparcel_pickup')){ + if (!class_exists('MyParcel')) { + require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php'; + MyParcel($this->registry); + } + $myparcel_error = $this->load->controller(MyParcel()->getMyparcelXtensionControllerPath().'/externalValidate'); + if($myparcel_error){ + $json['error'] = $myparcel_error; + } + } + //Myparcel plugin - end + ]]> + + + template = $this->config->get('xtensions_view_path').'xpayment_address';]]> + session->data['myparcel_api_errors'])){ + $this->data['myparcel_api_errors'] = $this->session->data['myparcel_api_errors']; + } + ]]> + + + + + + request->get['direct'])){]]> + cart->hasShipping() && isset($this->session->data['shipping_method']['code']) && ($this->session->data['shipping_method']['code'] == 'myparcel_delivery.myparcel_delivery' || $this->session->data['shipping_method']['code'] == 'myparcel_pickup.myparcel_pickup')){ + if (!class_exists('MyParcel')) { + require_once DIR_SYSTEM . 'library/myparcelnl/class_myparcel.php'; + MyParcel($this->registry); + } + $myparcel_error = $this->load->controller(MyParcel()->getMyparcelXtensionControllerPath().'/externalValidate'); + if($myparcel_error){ + $json['error'] = $myparcel_error; + } + } + //Myparcel plugin - end + ]]> + + + + + + session->data['shipping_address'])){ + $json['address_exit'] = 1; + } + ]]> + + + + + + + session->data['myparcel_price_pickup']) + && isset($this->session->data['shipping_method']['code']) && strpos($this->session->data['shipping_method']['code'],$this->session->data['myparcel_price_pickup']['shipping_method_code']) !== false){ + $myparcel_delivery_options = $this->session->data['myparcel_price_pickup']['myparcel_shipping_choosed']; + if(isset($myparcel_delivery_options['location'])){ + $this->language->load('extension/module/myparcelnl'); + $this->data['myparcel_pickup_price_summary']['title'] = $this->language->get('entry_title_location'); + $this->data['myparcel_pickup_price_summary']['location'] = $myparcel_delivery_options['location']. ', ' .$myparcel_delivery_options['street'] . ' ' . $myparcel_delivery_options['number'] .', ' . $myparcel_delivery_options['city']; + $this->data['myparcel_pickup_price_summary']['shipping_title'] = $value['title']; + } + } + //Myparcel plugin - end + ]]> + + + + + + + + + load->model('extension/myparcelnl/helper'); + $this->document->addStyle($this->model_extension_myparcelnl_helper->getCssUrl() . 'checkout.css'); + ]]> + + + + registry); + } + if(isset($this->session->data['shipping_method'])){ + if(isset($this->session->data['myparcel_shipping_choosed'])){ + $shipping_method = $this->session->data['shipping_method']; + $myparcel_shipping_choosed = $this->session->data['myparcel_shipping_choosed']; + if(explode('.',$shipping_method['code'])[0] != $myparcel_shipping_choosed['code']){ + unset($this->session->data['myparcel_shipping_choosed']); + } + } + } + else{ + if(isset($this->session->data['myparcel_shipping_choosed'])){ + unset($this->session->data['myparcel_shipping_choosed']); + } + } + if (!empty($shipping_address) && ($shipping_address['iso_code_2'] == 'NL' || $shipping_address['iso_code_2'] == 'BE')) { + $api = MyParcel()->api; + $registry = MyParcel::$registry; + /** @var \Cart\Currency $currency **/ + $currency = $registry->get('currency'); + $current_currency_code = $this->session->data['currency']; + $shipment_class = MyParcel()->shipment; + /** @var MyParcel_Shipment_Checkout $checkout_helper **/ + $checkout_helper = $shipment_class->checkout; + $config = $registry->get('config'); + $myparcelnl_checkout_settings = $config->get('module_myparcelnl_fields_checkout'); + $default_price_0_text = isset($myparcelnl_checkout_settings['default_price_0_text']) ? $myparcelnl_checkout_settings['default_price_0_text'] : ''; + if(isset($myparcelnl_checkout_settings['enable_delivery']) && $myparcelnl_checkout_settings['enable_delivery'] == 1){ + $delivery_params = MyParcel()->helper->getDeliveryParams($shipping_address); + $myparcel_delivery = $api->getDeliveryOptions($delivery_params); + + if(isset($myparcel_delivery['code']) && $myparcel_delivery['code'] == 200 && !isset($myparcel_delivery['body']['errors'])){ + $myparcel_delivery = MyParcel()->helper->formatDeliveryPrice($myparcel_delivery, $shipping_address ,$this->cart->getSubTotal(),$this->language,$current_currency_code); + + + $shipping_method_code = null; + $myparcel_option_title = []; + if (isset($this->session->data['shipping_method']['code'])){ + $shipping_method_code = $this->session->data['shipping_method']['code']; + $shipping_method_code = explode('.',$shipping_method_code)[0]; + } + $this->data['myparcel_option_title'] = array(); + $arrMyparcelShippingKey = []; + foreach ($myparcel_delivery['body']['data'] as $key => $value){ + if(count($value)) { + $sort_order = count($quote_data); + $key_delivery = 'myparcel_' . $key; + $cost = 0; + $cost_with_tax = 0; + $price_key = 'myparcel_price_' . $key; + if (!isset($this->session->data[$price_key])) { + MyParcel()->helper->saveDefaultMyparcelMethodXtension($value,$key); + } + if (isset($this->session->data[$price_key])) { + $myparcel_price = $this->session->data[$price_key]; + $text_price_detail = explode(' - ',$myparcel_price['text_myparcel_price_'.$key]); + //recalculate price choose + switch ($myparcel_price['shipping_method_code']){ + case 'delivery': + foreach ($value as $k => $v){ + if(date('Y-m-d',strtotime($v['date'])) == date('Y-m-d',strtotime($text_price_detail[0]))){ + foreach ($v['time'] as $time){ + if(date('H:i',strtotime($time['start'])) == date('H:i',strtotime($text_price_detail[1])) && date('H:i',strtotime($time['end'])) == date('H:i',strtotime($text_price_detail[2]))){ + $myparcel_price['amount'] = $time['price']['amount']; + $myparcel_price['amount_with_tax'] = $time['price']['amount_with_tax']; + break; + } + } + } + } + break; + case 'pickup': + foreach ($value as $k => $v){ + if($v['location'] == trim($text_price_detail[0])){ + foreach ($v['time'] as $time){ + if(date('H:i',strtotime($time['start'])) == date('H:i',strtotime($text_price_detail[2])) ){ + $myparcel_price['amount'] = $time['price']['amount']; + $myparcel_price['amount_with_tax'] = $time['price']['amount_with_tax']; + break; + } + } + } + } + break; + } // end recalculate price choose + + if ($myparcel_price['shipping_method_code'] == $key) { + $cost = $currency->convert($myparcel_price['amount'], $myparcel_price['currency'], $current_currency_code); + $cost_with_tax = $currency->convert($myparcel_price['amount_with_tax'], $myparcel_price['currency'], $current_currency_code); + }; + if ($shipping_address['iso_code_2'] == 'NL' && isset($this->session->data['additional_service_checked'][$key])) { + if (isset($this->session->data['additional_service'])) { + $additional_service = $this->session->data['additional_service']; + + $delivery_prices = $checkout_helper->getDeliveryPrices(false, true, '', false, 0,$this->cart->getSubTotal()); + $delivery_prices_format = $checkout_helper->getDeliveryPrices(false, true, '', true, 0,$this->cart->getSubTotal()); + foreach ($additional_service as $service_name => $service_value) { + if(isset($delivery_prices[$shipping_address['iso_code_2']][$service_name]) && $delivery_prices[$shipping_address['iso_code_2']][$service_name] !== 'disable'){ + $additional_service[$service_name]['amount'] = round($currency->convert($delivery_prices[$shipping_address['iso_code_2']][$service_name],'EUR',$current_currency_code),2); + $additional_service[$service_name]['amount_with_tax'] = round($currency->convert($delivery_prices_format[$shipping_address['iso_code_2']][$service_name],'EUR',$current_currency_code),2); + $additional_service[$service_name]['text_amount'] = $currency->format($delivery_prices_format[$shipping_address['iso_code_2']][$service_name],$current_currency_code); + } + } + $additional_service_checked = $this->session->data['additional_service_checked'][$key]; + foreach ($additional_service_checked as $service_name => $service_value) { + if ($service_value) { + $cost += $additional_service[$service_name]['amount']; + $cost_with_tax += $additional_service[$service_name]['amount_with_tax']; + } + } + } + } + } + else{ + //delivery default select standard for delivery or first location for pickup if not selected + switch ($key){ + case 'delivery': + foreach ($value as $k => $v){ + foreach ($v['time'] as $k => $time){ + if($time['price_comment'] == 'standard'){ + $cost = $time['price']['amount']; + $cost_with_tax = $time['price']['amount_with_tax']; + break; + } + } + } + break; + case 'pickup': + $pickup = $value[0]; + $time = $pickup['time'][0]; + $cost = $time['price']['amount']; + $cost_with_tax = $time['price']['amount_with_tax']; + break; + } + + } + + $arrQuote = array( + 'code' => $key_delivery . '.' . $key_delivery, + 'title' => $this->language->get('entry_myparcel_' . $key), + 'cost' => $cost, + 'tax_class_id' => $checkout_helper->getTaxFromCart(), + 'text' => ($cost_with_tax == 0 && $default_price_0_text != '') ? $default_price_0_text :$currency->format($cost_with_tax, $current_currency_code), + ); + $arrShipping = array( + 'title' => $this->language->get('entry_myparcel_' . $key), + 'sort_order' => $sort_order, + 'error' => '' + ); + if ($shipping_method_code == $key_delivery) { + $arrQuote['headingtitle'] = $this->language->get('entry_select_myparcel_' . $key); + } + $myparcel_option_title['title_heading_myparcel_' . $key] = $this->language->get('entry_select_myparcel_' . $key); + $myparcel_option_title['text_edit_myparcel_' . $key] = (isset($myparcel_price['text_myparcel_price_'.$key])) ? $myparcel_price['text_myparcel_price_'.$key] : $this->language->get('entry_edit_myparcel_' . $key); + $arrShipping['quote'][$key_delivery] = $arrQuote; + $quote_data[$key_delivery] = $arrShipping; + $arrMyparcelShippingKey[] = $key_delivery; + } + } + $this->session->data['myparcel_option_title'] = $myparcel_option_title; + $this->session->data['myparcel_delivery'] = $myparcel_delivery['body']['data']; + if(isset($this->session->data['myparcel_api_errors'])){ + unset($this->session->data['myparcel_api_errors']); + } + + //make myparcel shipping method to first. + if(count($arrMyparcelShippingKey)){ + $arrMyparcelShippingKey = array_reverse($arrMyparcelShippingKey); + foreach ($arrMyparcelShippingKey as $key){ + if(isset($quote_data[$key])) { + $value = $quote_data[$key]; + unset($quote_data[$key]); + $quote_data = array($key => $value) + $quote_data; + } + } + } + } + else{ + if(isset($myparcel_delivery['body']['errors'])){ + $myparcel_errors = $myparcel_delivery['body']['errors']; + $error_message = []; + if(is_array($myparcel_errors) && count($myparcel_errors)){ + foreach($myparcel_errors as $error){ + $error_language_key = 'entry_myparcel_api_error_code_' . $error['code']; + $error_message[] = ($this->language->get($error_language_key) != $error_language_key) ? $this->language->get($error_language_key) : $error['message']; + } + $this->session->data['myparcel_api_errors'] = htmlspecialchars(implode('.',$error_message), ENT_QUOTES); + } + } + }} + else{ + if(isset($this->session->data['myparcel_api_errors'])){ + unset($this->session->data['myparcel_api_errors']); + } + } + } + else{ + if(isset($this->session->data['myparcel_api_errors'])){ + unset($this->session->data['myparcel_api_errors']); + } + } + ]]> + + + template = $this->config->get('xtensions_view_path').'xshipping_method';]]> + registry); + } + if(isset($this->session->data['myparcel_api_errors'])){ + $this->data['myparcel_api_errors'] = $this->session->data['myparcel_api_errors']; + } + if(isset($this->session->data['myparcel_option_title'])){ + $this->data['myparcel_option_title'] = $this->session->data['myparcel_option_title']; + } + ($_SERVER['HTTPS'] && defined(HTTPS_SERVER)) ? $url_server = HTTPS_SERVER : $url_server = HTTP_SERVER; + $this->data['myparcel_action'] = $url_server . 'index.php?route=' . MyParcel()->getMyparcelXtensionControllerPath(); + ]]> + + + + + + + '+json['error']['date']+''); + } + if(json['error']['timeslot']){ + loadSlots(); + $('#xdeltimeslots').before('
'+json['error']['timeslot']+'
'); + } + }else if(json['success']){ + $('.myparcel-pickup-table').html(json['html']); + loadShippingMethods(true); + } + hideLoader(); + } + }); + }); + function changeAdditionalService(obj,name) { + var element = obj; + var id = obj.id.toString(); + console.log(id); + $.ajax({ + url: 'index.php?route='+$(obj).attr('action')+'/save', + type: 'post', + data: { + 'addition_name' : name, + 'addition_value': obj.checked + }, + dataType: 'json', + beforeSend: function() { + $('.xdeldateandtimeslots .alert').remove(); + $('.xdelslotselected').removeClass('xdelslotselected'); + $(element).closest('tr').addClass('xdelslotselected'); + }, + success: function(json) { + if(json['error']){ + if(json['error']['date']){ + $('#xdeltimeslots').before('
'+json['error']['date']+'
'); + } + if(json['error']['timeslot']){ + loadSlots(); + $('#xdeltimeslots').before('
'+json['error']['timeslot']+'
'); + } + }else if(json['success']){ + loadShippingMethods(); + } + + } + }); + }; + function loadMyparcelDelivery(action,headingtitle){ + $('#modal-shipping-dependancy').remove(); + $('.bootstrap-datetimepicker-widget').remove(); + $.ajax({ + url: action, + type: 'post', + data: $('#shipping_method input[type=\'radio\']:checked'), + dataType: 'html', + beforeSend: function() { + + }, + success: function(data) { + html = '