From 7ba861adeba09846f5be6d7638a1866497e243e3 Mon Sep 17 00:00:00 2001 From: Richard Perdaan Date: Mon, 17 Dec 2018 10:12:07 +0100 Subject: [PATCH] upload new version --- administrator/assets/js/myparcel_plugin.js | 180 +-- administrator/controllers/configs.php | 2 +- administrator/models/config.php | 2 +- administrator/myparcel.php | 2 +- administrator/myparcel_plugin.php | 1700 ++++++++++---------- administrator/tables/config.php | 367 +++-- myparcel.xml | 2 +- site/myparcel-passdata-virtuemart.html | 18 +- 8 files changed, 1162 insertions(+), 1111 deletions(-) diff --git a/administrator/assets/js/myparcel_plugin.js b/administrator/assets/js/myparcel_plugin.js index 040514a..15c8835 100755 --- a/administrator/assets/js/myparcel_plugin.js +++ b/administrator/assets/js/myparcel_plugin.js @@ -14,49 +14,50 @@ function onClickOnUnprocessedConsignment(event) { } MyParcel.virtuemart = { - setConsignmentId: function(orderId, timestamp, consignmentId, tracktrace_link, retour, addresas){ -//alert("order: " + orderId + " time:"+timestamp+" cons:"+consignmentId+" trac:"+tracktrace_link+" ret:"+retour); - var mypa_div = document.createElement('div'); - - // print checkbox - var mypa_check = document.createElement('input'); - mypa_check.className = 'mypaleft mypacheck'; - mypa_check.type = 'checkbox'; - mypa_check.value = consignmentId; - - // pdf image - var mypa_img = document.createElement('img'); - mypa_img.alt = 'print'; - mypa_img.src = addresas+'administrator/components/com_myparcel/assets/images/myparcel_pdf.png'; - if(retour == 1) mypa_img.src = addresas+'administrator/components/com_myparcel/assets/images/myparcel_retour.png'; - mypa_img.style.border = 0; - - // pdf image link - var mypa_link = document.createElement('a'); - mypa_link.className = 'myparcel-pdf'; - mypa_link.onclick = new Function('return printConsignments(' + consignmentId + ');'); - mypa_link.href = '#'; - mypa_link.appendChild(mypa_img); - - // tracktrace link - var mypa_track = document.createElement('a'); - mypa_track.target = '_blank'; - mypa_track.href = tracktrace_link; - mypa_track.innerHTML = 'Track&Trace'; - - // shove into DOM - mypa_div.appendChild(mypa_check); - mypa_div.appendChild(mypa_track); - mypa_div.appendChild(mypa_link); - var orderdiv = document.getElementById('mypa_exist_' + orderId); - orderdiv.insertBefore(mypa_div, orderdiv.firstChild); - - popup.close(); + setConsignmentId: function(orderId, timestamp, consignmentId, tracktrace_link, retour, addresas) { + //alert("order: " + orderId + " time:"+timestamp+" cons:"+consignmentId+" trac:"+tracktrace_link+" ret:"+retour); + var mypa_div = document.createElement('div'); + + // print checkbox + var mypa_check = document.createElement('input'); + mypa_check.className = 'mypaleft mypacheck'; + mypa_check.type = 'checkbox'; + mypa_check.value = consignmentId; + + // pdf image + var mypa_img = document.createElement('img'); + mypa_img.alt = 'print'; + mypa_img.src = addresas + 'administrator/components/com_myparcel/assets/images/myparcel_pdf.png'; + if (retour == 1) mypa_img.src = addresas + 'administrator/components/com_myparcel/assets/images/myparcel_retour.png'; + mypa_img.style.border = 0; + + // pdf image link + var mypa_link = document.createElement('a'); + mypa_link.className = 'myparcel-pdf'; + mypa_link.onclick = new Function('return printConsignments(' + consignmentId + ');'); + mypa_link.href = '#'; + mypa_link.appendChild(mypa_img); + + // tracktrace link + var mypa_track = document.createElement('a'); + mypa_track.target = '_blank'; + mypa_track.href = tracktrace_link; + mypa_track.innerHTML = 'Track&Trace'; + + // shove into DOM + mypa_div.appendChild(mypa_check); + mypa_div.appendChild(mypa_track); + mypa_div.appendChild(mypa_link); + var orderdiv = document.getElementById('mypa_exist_' + orderId); + orderdiv.insertBefore(mypa_div, orderdiv.firstChild); + + popup.close(); locked = false; } }; var lastTimestamp = 0; + function _getTimestamp() { var ret = Math.round(new Date().getTime() / 1000); if (ret <= lastTimestamp) { @@ -65,13 +66,12 @@ function _getTimestamp() { return lastTimestamp = ret; } -function createNewConsignment(orderId, retour) -{ +function createNewConsignment(orderId, retour) { if (locked) { if (!popup || popup.closed) { // User closed the popup } else { - popup.focus(); + popup.focus(); return; } } @@ -79,49 +79,45 @@ function createNewConsignment(orderId, retour) var timestamp = _getTimestamp(); var retourparam = ''; - if(retour == true) retourparam = '&retour=true'; - + if (retour == true) retourparam = '&retour=true'; + popup = window.open( 'components/com_myparcel/myparcel_plugin.php?action=post' + '&order_id=' + orderId + '×tamp=' + timestamp + retourparam, 'myparcel', 'width=730,height=830,dependent,resizable,scrollbars' - ); + ); if (window.focus) { popup.focus(); } return false; } -function printConsignments(consignmentList) -{ +function printConsignments(consignmentList) { if (locked) { if (!popup || popup.closed) { // User closed the popup } else { - popup.focus(); + popup.focus(); return; } } locked = true; var timestamp = _getTimestamp(); - + popup = window.open( 'components/com_myparcel/myparcel_plugin.php?action=print' + '&consignments=' + consignmentList + '×tamp=' + timestamp, 'myparcel', 'width=415,height=365,dependent,resizable,scrollbars' - ); + ); if (window.focus) { popup.focus(); } return false; } -function printConsignmentSelection() -{ - var consignmentList = Array(); +function printConsignmentSelection() { + var consignmentList = Array(); var checkboxes = document.getElementsByClassName('mypacheck'); - for(var i = checkboxes.length - 1; i >= 0; i--) - { - if(checkboxes[i].checked == true && checkboxes[i].value != '') - { - consignmentList.push(checkboxes[i].value); - } + for (var i = checkboxes.length - 1; i >= 0; i--) { + if (checkboxes[i].checked == true && checkboxes[i].value != '') { + consignmentList.push(checkboxes[i].value); + } } return (consignmentList.length == 0) ? false : printConsignments(consignmentList.join('|')); } @@ -147,35 +143,33 @@ function printConsignmentSelection() } */ -function processConsignmentSelection(a, b) -{ +function processConsignmentSelection(a, b) { var consignmentList2 = Array(); - - /** Start @Since version 1.0.9 **/ + + /** Start @Since version 1.0.9 **/ var checkboxes = document.getElementsByClassName('mypafunc'); a = checkboxes.length; /** End @Since version 1.0.9 **/ - + b || (b = "cb"); for (var e = document.adminForm, c = e.toggle.checked, f = a, g = 0, d = 0; d < f; d++) { var h = e[b + "" + d]; - if (h) - { - if (h.checked == true) - { - consignmentList2.push(h.value); - console.log(h.value); - } - - g++; - } + if (h) { + if (h.checked == true) { + consignmentList2.push(h.value); + console.log(h.value); + } + + g++; + } } return (consignmentList2.length > 0 && confirm("Hiermee creĆ«ert u " + consignmentList2.length + " MyParcel labels.\n\nKlik op OK om door te gaan.")) //return (consignmentList2.length > 0 && confirm("This will create " + consignmentList2.length + " labels.\n\nAre you sure?")) - ? processConsignments(consignmentList2.join('|')) - : false; - - - /* + ? + processConsignments(consignmentList2.join('|')) : + false; + + + /* var consignmentList = Array(); var checkboxes = document.getElementsByClassName('mypacheck'); for(var i = checkboxes.length - 1; i >= 0; i--) @@ -191,42 +185,36 @@ function processConsignmentSelection(a, b) */ } -function processConsignments(consignmentList) -{ +function processConsignments(consignmentList) { if (locked) { if (!popup || popup.closed) { // User closed the popup } else { - popup.focus(); + popup.focus(); return; } } locked = true; var timestamp = _getTimestamp(); - + popup = window.open( 'components/com_myparcel/myparcel_plugin.php?action=process' + '&order_ids=' + consignmentList + '×tamp=' + timestamp, 'myparcel', 'width=415,height=365,dependent,resizable,scrollbars' - ); + ); if (window.focus) { popup.focus(); } return false; } -function selectAllConsignmentsForPrint(checkboxas) -{ +function selectAllConsignmentsForPrint(checkboxas) { var checkboxes = document.getElementsByClassName('mypacheck'); if (checkboxas.checked == true) { - for(var i = checkboxes.length - 1; i >= 0; i--) - { - checkboxes[i].checked = true; - } - } - else - { - for(var i = checkboxes.length - 1; i >= 0; i--) - { - checkboxes[i].checked = false; - } + for (var i = checkboxes.length - 1; i >= 0; i--) { + checkboxes[i].checked = true; + } + } else { + for (var i = checkboxes.length - 1; i >= 0; i--) { + checkboxes[i].checked = false; + } } } \ No newline at end of file diff --git a/administrator/controllers/configs.php b/administrator/controllers/configs.php index 9c25f19..63757fd 100755 --- a/administrator/controllers/configs.php +++ b/administrator/controllers/configs.php @@ -21,7 +21,7 @@ class MyparcelControllerConfigs extends JControllerAdmin * Proxy for getModel. * @since 1.6 */ - public function getModel($name = 'config', $prefix = 'MyparcelModel') + public function getModel($name = 'config', $prefix = 'MyparcelModel', $config = array()) { $model = parent::getModel($name, $prefix, array('ignore_request' => true)); return $model; diff --git a/administrator/models/config.php b/administrator/models/config.php index 1a10e42..03d1f0c 100755 --- a/administrator/models/config.php +++ b/administrator/models/config.php @@ -103,7 +103,7 @@ public function getItem($pk = null) * * @since 1.6 */ - protected function prepareTable(&$table) + protected function prepareTable($table) { jimport('joomla.filter.output'); diff --git a/administrator/myparcel.php b/administrator/myparcel.php index 7f8e5b4..4494a73 100755 --- a/administrator/myparcel.php +++ b/administrator/myparcel.php @@ -22,4 +22,4 @@ $controller = JControllerLegacy::getInstance('Myparcel'); $controller->execute(JFactory::getApplication()->input->get('task')); -$controller->redirect(); +$controller->redirect(); \ No newline at end of file diff --git a/administrator/myparcel_plugin.php b/administrator/myparcel_plugin.php index 1baf343..d2d5a0b 100755 --- a/administrator/myparcel_plugin.php +++ b/administrator/myparcel_plugin.php @@ -1,830 +1,870 @@ -setQuery($q); - $order['details'] = $db->loadObjectList('address_type'); - - // Get the order history - $q = "SELECT * - FROM #__virtuemart_order_histories - WHERE virtuemart_order_id=".$virtuemart_order_id." - ORDER BY virtuemart_order_history_id ASC"; - $db->setQuery($q); - $order['history'] = $db->loadObjectList(); - - // Get the order items -$q = 'SELECT virtuemart_order_item_id, product_quantity, order_item_name, - order_item_sku, i.virtuemart_product_id, product_item_price, - product_final_price, product_basePriceWithTax, product_discountedPriceWithoutTax, product_priceWithoutTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status, - intnotes, virtuemart_category_id - FROM (#__virtuemart_order_items i - LEFT JOIN #__virtuemart_products p - ON p.virtuemart_product_id = i.virtuemart_product_id) - LEFT JOIN #__virtuemart_product_categories c - ON p.virtuemart_product_id = c.virtuemart_product_id - WHERE `virtuemart_order_id`="'.$virtuemart_order_id.'" group by `virtuemart_order_item_id`'; -//group by `virtuemart_order_id`'; Why ever we added this, it makes trouble, only one order item is shown then. -// without group by we get the product 3 times, when it is in 3 categories and similar, so we need a group by -//lets try group by `virtuemart_order_item_id` - $db->setQuery($q); - $order['items'] = $db->loadObjectList(); -// Get the order items - $q = "SELECT * - FROM #__virtuemart_order_calc_rules AS z - WHERE virtuemart_order_id=".$virtuemart_order_id; - $db->setQuery($q); - $order['calc_rules'] = $db->loadObjectList(); -// vmdebug('getOrder my order',$order); - return $order; -} - - -/* Since Pg_address drop number suffix */ -function isPgAddress($name, $street, $gkzip, $gkcity) -{ - $db =& JFactory::getDBO(); - $query_pg_address = $db->setQuery( - sprintf(' - SELECT * FROM `orders_myparcel_pg_address` WHERE `name`="%s" AND `street`="%s" AND `house_number`="%s" AND `postcode`="%s" AND `town`="%s" LIMIT 1' - , - $name, // Name - isset($street['street']) ? $street['street'] : '', // Street - isset($street['house_number']) ? $street['house_number'] : '', // House number - $gkzip, // Postcode - $gkcity // City - ) - ); - - $query_pg_address->execute(); - - if ($query_pg_address->getNumRows()) { - return true; - } - return false; -} -/*---------------------------------------*/ - -function getAddressComponents($address) -{ - $ret = array(); - $ret['house_number'] = ''; - $ret['number_addition'] = ''; - //$address = 'Markerkant 10 11E'; - $address = str_replace(array('?', '*', '[', ']', ',', '!'), ' ', $address); - $address = preg_replace('/\s\s+/', ' ', $address); - - $matches = _splitStreet($address); - - if (!empty($matches[2])) { - $ret['street'] = trim($matches[1]); - $ret['house_number'] = trim($matches[3]); - $ret['number_addition'] = trim($matches[4]); - } else { - $ret['street'] = $address; - } - - /** START @Since the fix for negative house number (64-69) **/ - if (strlen($ret['street']) && substr($ret['street'], -1) == '-') { - $ret['street'] = str_replace(' -', '', $ret['street']); - return getAddressComponents( $ret['street']); - } - /** END @Since the fix for negative house number (64-69) **/ - - return $ret; -} - -function _splitStreet($fullStreet) -{ - $split_street_regex = '~(?P.*?)\s?(?P(?P[\d]+)-?(?P[a-zA-Z/\s]{0,5}$|[0-9/]{0,5}$|\s[a-zA-Z]{1}[0-9]{0,3}$))$~'; - $fullStreet = preg_replace("/[\n\r]/", "", $fullStreet); - $result = preg_match($split_street_regex, $fullStreet, $matches); - - if (!$result || !is_array($matches) || $fullStreet != $matches[0]) { - if ($fullStreet != $matches[0]) { - // Characters are gone by preg_match - exit('Something went wrong with splitting up address ' . $fullStreet); - } else { - // Invalid full street supplied - exit('Invalid full street supplied: ' . $fullStreet); - } - } - - return $matches; -} - -/** START Since version 1.0.9 **/ -function getReturnUrlWithUri($uri){ - $return_url = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) == "on"?'s':'').'://'.$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'].'?'.$uri; - return $return_url; -} -/** END Since version 1.0.9 **/ - -/* - * JAVASCRIPT ACTIONS - */ -if(isset($_GET['action'])) -{ - /* - * MYPARCEL STATUS UPDATE - * - * Every time this script is called, it will check if an update of the order statuses is required - * Depending on the last update with a timeout, since TNT updates our status 2 times a day anyway - * - * NOTE - Increasing this timeout is POINTLESS, since TNT updates our statuses only 2 times a day - * Please save our bandwidth and use the Track&Trace link to get the actual status. Thanks - */ - - /** START Since version 1.0.9 **/ - if (version_compare(phpversion(), '5.4.0', '<')) { - if (session_id() == '') session_start(); - } else { - if (session_status() == PHP_SESSION_NONE) { - session_start(); - } - } - - if (empty($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'])) { - $_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'] = ''; - $db =& JFactory::getDBO(); - $query = "SELECT * FROM orders_myparcel WHERE tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"; - $db->setQuery( $query ); - $vendors = $db->loadObjectlist(); - $all_consignments = array(); - for ($i=0, $n=count( $vendors ); $i < $n; $i++) { - $row = &$vendors[$i]; - $all_consignments[] = $row->consignment_id; - } - } - - /** END Since version 1.0.9 **/ - - if( - (isset($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS']) && !empty($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'])) || - !empty($all_consignments) - ) - { - if (empty($all_consignments)) { - $visible_consignments = str_replace('|', ',', trim($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'], '|')); - - $db =& JFactory::getDBO(); - $query = "SELECT * FROM orders_myparcel WHERE consignment_id IN (" . $visible_consignments . ") AND tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"; - $db->setQuery($query); - $vendors = $db->loadObjectlist(); - $consignments = array(); - for ($i = 0, $n = count($vendors); $i < $n; $i++) { - $row = &$vendors[$i]; - $consignments[] = $row->consignment_id; - - //$status_q = tep_db_query("SELECT * ROM orders_myparcel WHERE consignment_id IN (" . $visible_consignments . ") AND tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"); - - /*while($consignment = tep_db_fetch_array($status_q)) - { - $consignments[] = $consignment['consignment_id']; - }*/ - } - } else { - $consignments = $all_consignments; - } - - if(!empty($consignments)) - { - error_reporting(0); - foreach ($consignments as $consignment) { - $status_file = file(MYPARCEL_LINK . 'status/tnt/' . $consignment); - - if ($status_file) { - $row = $status_file[0]; - $row = explode('|', $row); - if(count($row) != 3) exit; - - $qupdate = "UPDATE orders_myparcel SET tnt_status='".trim($row[2])."', tnt_updated_on='".date('Y-m-d H:i:s')."', tnt_final='".(int) $row[1]."' WHERE consignment_id = '" . $row[0] . "'"; - $db->setQuery( $qupdate ); - $db->query(); - - /* tep_db_perform('orders_myparcel', array( - 'tnt_status' => trim($row[2]), - 'tnt_updated_on' => date('Y-m-d H:i:s'), - 'tnt_final' => (int) $row[1], - ), 'update', "consignment_id = '" . $row[0] . "'"); - */ - } - } - } - } - - /* - * PLUGIN POPUP CREATE / RETOUR - */ - - if($_GET['action'] == 'post' && is_numeric($_GET['order_id'])) - { - //include(DIR_WS_CLASSES . 'order.php'); - // determine retour or normal consignment - if(isset($_GET['retour']) && $_GET['retour'] == 'true') - { - $myparcel_plugin_action = 'verzending-aanmaken-retour/'; - $myparcel_action = 'retour'; - } - else - { - $myparcel_plugin_action = 'verzending-aanmaken/'; - $myparcel_action = 'return'; - } - - $return_url = getReturnUrlWithUri('action=' . $myparcel_action . '&order_id=' . $_GET['order_id'] . '×tamp=' . $_GET['timestamp']); - $order = getOrderz($_GET['order_id']); - //echo "aaa"; - //print_r($order['details']['BT']->virtuemart_country_id); - //die; - //$address = $order->delivery; - - - if (strlen($order['details']['ST']->virtuemart_country_id) > 0) { - $gk_virtuemart_country_id = $order['details']['ST']->virtuemart_country_id; - } else { - $gk_virtuemart_country_id = $order['details']['BT']->virtuemart_country_id; - } - - $db =& JFactory::getDBO(); - $query = "SELECT country_2_code AS country_code FROM #__virtuemart_countries WHERE virtuemart_country_id='".$gk_virtuemart_country_id."' LIMIT 1"; - //echo ($query); - $db->setQuery( $query ); - //print_r($db->loadObjectlist());die; - $vendors = $db->loadObjectlist(); - $musu_country_code=''; - for ($i=0, $n=count( $vendors ); $i < $n; $i++) - { - $row = &$vendors[$i]; - //print_r($row);die; - $musu_country_code=$row->country_code; - } - - /*$country_sql = tep_db_query(" -SELECT countries_iso_code_2 AS country_code - FROM " . TABLE_COUNTRIES . " - WHERE countries_name = '" . $address['country'] . "' -"); - $country = tep_db_fetch_array($country_sql);*/ - -if (strlen($order['details']['ST']->company) > 0) { - $gkcompany = $order['details']['ST']->company; -} else { - $gkcompany = $order['details']['BT']->company; -} - -if (strlen($order['details']['ST']->zip) > 0) { - $gkzip = $order['details']['ST']->zip; -} else { - $gkzip = $order['details']['BT']->zip; -} - -if (strlen($order['details']['ST']->city) > 0) { - $gkcity = $order['details']['ST']->city; -} else { - $gkcity = $order['details']['BT']->city; -} - -if (strlen($order['details']['ST']->email) > 0) { - $gkemail = $order['details']['ST']->email; -} else { - $gkemail = $order['details']['BT']->email; -} - -if (strlen($order['details']['ST']->first_name) > 0) { - $gkfirstname = $order['details']['ST']->first_name; -} else { - $gkfirstname = $order['details']['BT']->first_name; -} -if (strlen($order['details']['ST']->last_name) > 0) { - $gklastname = $order['details']['ST']->last_name; -} else { - $gklastname = $order['details']['BT']->last_name; -} -if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr = $order['details']['ST']->address_1; -} else { - $gkaddr = $order['details']['BT']->address_1; -} -if (strlen($order['details']['ST']->phone_1) > 0) { - $gkphone = $order['details']['ST']->phone_1; -} else { - $gkphone = $order['details']['BT']->phone_1; -} - -//$gkadresas_num = preg_replace('/\D/', '', $gkaddr); - -//$gkadresas_street = preg_replace('/[^A-Z a-z]/', '', $gkaddr); - -// Changes for version 1.0.5 -if (strlen($order['details']['ST']->middle_name) > 0) { - $gkmiddlename = $order['details']['ST']->middle_name; -} else { - $gkmiddlename = $order['details']['BT']->middle_name; -} -// And the line below: 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, -// --------------------1.0.5 - - if($musu_country_code=='NL') - { - - // Added on 2016-04-07 - if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr2 = $order['details']['ST']->address_2; - } else { - $gkaddr2 = $order['details']['BT']->address_2; - } - $gkaddr .= (!empty($gkaddr2) ? ' ' . $gkaddr2 :''); - // End of 2016-04-07 - - /*-------------------Since pg_address----------------*/ - $street = getAddressComponents($gkaddr); - $pg_address = isPgAddress($gkcompany, $street, $gkzip, $gkcity); - - if ($pg_address) { - $street['number_addition'] = ''; - } - /*----------------------------------------pg_address*/ - - $consignment = array( - 'ToAddress[country_code]' => $musu_country_code, - 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, - 'ToAddress[business]' => $gkcompany, - 'ToAddress[postcode]' => $gkzip, - 'ToAddress[house_number]' => $street['house_number'], - 'ToAddress[number_addition]' => $street['number_addition'], - 'ToAddress[street]' => $street['street'], - 'ToAddress[town]' => $gkcity, - 'ToAddress[email]' => $gkemail, - 'ToAddress[phone_number]' => $gkphone, - 'custom_id' => $order['details']['BT']->order_number, - ); - } - else // buitenland - { - $weight = 0; - foreach($order['items'] as $val) { - //echo $val->product_quantity." ".$val->virtuemart_product_id."
"; - $queryz = 'SELECT product_weight FROM #__virtuemart_products where virtuemart_product_id='.$val->virtuemart_product_id; - //echo $query2."

"; - $db->setQuery( $queryz ); - $rezultatas = $db->loadResult(); - $weight += $rezultatas*$val->product_quantity; - } - - // Changes for version 1.0.6 - if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr2 = $order['details']['ST']->address_2; - } else { - $gkaddr2 = $order['details']['BT']->address_2; - } - // 'ToAddress[extraname]' => $gkaddr2 - // --------------------1.0.6 - - $consignment = array( - 'ToAddress[country_code]' => $musu_country_code, - 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, - 'ToAddress[business]' => $gkcompany, - 'ToAddress[street]' => $gkaddr, - 'ToAddress[eps_postcode]' => $gkzip, - 'ToAddress[town]' => $gkcity, - 'ToAddress[email]' => $gkemail, - 'ToAddress[phone_number]' => $gkphone, - 'ToAddress[extraname]' => $gkaddr2, - 'weight' => $weight, - 'custom_id' => $order['details']['BT']->order_number, - ); - //print_r($consignment); - //die; - } -?> - - -

Sending data to MyParcel ...

- - - - $order_id, - 'consignment_id' => $consignment_id, - 'retour' => $retour, - 'tracktrace' => $tracktrace, - 'postcode' => $postcode, - ));*/ - - - $qinsert = "INSERT INTO orders_myparcel SET orders_id='".$order_id."', consignment_id='".$consignment_id."', retour='".$retour."', postcode='".$postcode."', tracktrace = '" . $tracktrace . "'"; - //echo $qinsert; die; - $db->setQuery( $qinsert ); - $db->query(); - - - - $tracktrace_link = 'https://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?lang=nl&B=' . $tracktrace . '&P=' . $postcode; -?> - - -

Consignment aangemaakt [label bekijken]

-

- - - - - - -

Sending data to MyParcel ...

- - - -"; - /*$address = $order->delivery; - - $country_sql = tep_db_query(" -SELECT countries_iso_code_2 AS country_code - FROM " . TABLE_COUNTRIES . " - WHERE countries_name = '" . $address['country'] . "' -"); - $country = tep_db_fetch_array($country_sql);*/ - - if (strlen($order['details']['ST']->virtuemart_country_id) > 0) { - $gk_virtuemart_country_id = $order['details']['ST']->virtuemart_country_id; - } else { - $gk_virtuemart_country_id = $order['details']['BT']->virtuemart_country_id; - } - - $db =& JFactory::getDBO(); - $query = "SELECT country_2_code AS country_code FROM #__virtuemart_countries WHERE virtuemart_country_id='".$gk_virtuemart_country_id."' LIMIT 1"; - //echo ($query); - $db->setQuery( $query ); - //print_r($db->loadObjectlist());die; - $vendors = $db->loadObjectlist(); - $musu_country_code=''; - for ($i=0, $n=count( $vendors ); $i < $n; $i++) - { - $row = &$vendors[$i]; - //print_r($row);die; - $musu_country_code=$row->country_code; - } - - - - if (strlen($order['details']['ST']->company) > 0) { - $gkcompany = $order['details']['ST']->company; - } else { - $gkcompany = $order['details']['BT']->company; - } - - if (strlen($order['details']['ST']->zip) > 0) { - $gkzip = $order['details']['ST']->zip; - } else { - $gkzip = $order['details']['BT']->zip; - } - - if (strlen($order['details']['ST']->city) > 0) { - $gkcity = $order['details']['ST']->city; - } else { - $gkcity = $order['details']['BT']->city; - } - - if (strlen($order['details']['ST']->email) > 0) { - $gkemail = $order['details']['ST']->email; - } else { - $gkemail = $order['details']['BT']->email; - } - - if (strlen($order['details']['ST']->first_name) > 0) { - $gkfirstname = $order['details']['ST']->first_name; - } else { - $gkfirstname = $order['details']['BT']->first_name; - } - if (strlen($order['details']['ST']->last_name) > 0) { - $gklastname = $order['details']['ST']->last_name; - } else { - $gklastname = $order['details']['BT']->last_name; - } - // Changes for version 1.0.5 - if (strlen($order['details']['ST']->middle_name) > 0) { - $gkmiddlename = $order['details']['ST']->middle_name; - } else { - $gkmiddlename = $order['details']['BT']->middle_name; - } - // And the line below: 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, - // --------------------1.0.5 - if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr = $order['details']['ST']->address_1; - } else { - $gkaddr = $order['details']['BT']->address_1; - } - if (strlen($order['details']['ST']->phone_1) > 0) { - $gkphone = $order['details']['ST']->phone_1; - } else { - $gkphone = $order['details']['BT']->phone_1; - } - - if($musu_country_code=='NL') - { - // Added on 2016-04-07 - if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr2 = $order['details']['ST']->address_2; - } else { - $gkaddr2 = $order['details']['BT']->address_2; - } - $gkaddr .= (!empty($gkaddr2) ? ' ' . $gkaddr2 :''); - // End of 2016-04-07 - - /*-------------------Since pg_address----------------*/ - $street = getAddressComponents($gkaddr); - $pg_address = isPgAddress($gkcompany, $street, $gkzip, $gkcity); - if ($pg_address) { - $street['number_addition'] = ''; - } - /*----------------------------------------pg_address*/ - - $consignment = array( - 'ToAddress' => array( - 'country_code' => $musu_country_code, - 'name' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, - 'business' => $gkcompany, - 'postcode' => $gkzip, - 'house_number' => $street['house_number'], - 'number_addition' => $street['number_addition'], - 'street' => $street['street'], - 'town' => $gkcity, - 'email' => $gkemail, - ), - 'custom_id' => $order['details']['BT']->order_number, - ); - - } - else // buitenland - { - $weight = 0; - /*$product_sql = tep_db_query(" -SELECT op.products_quantity, p.products_weight - FROM " . TABLE_ORDERS_PRODUCTS . " op - LEFT JOIN " . TABLE_PRODUCTS . " p ON p.products_id = op.products_id - WHERE orders_id = '" . $order_id . "' -"); - while($product = tep_db_fetch_array($product_sql)) - { - $weight += $product['products_quantity'] * $product['products_weight']; - }*/ - foreach($order['items'] as $val) { - //echo $val->product_quantity." ".$val->virtuemart_product_id."
"; - $queryz = 'SELECT product_weight FROM #__virtuemart_products where virtuemart_product_id='.$val->virtuemart_product_id; - //echo $query2."

"; - $db->setQuery( $queryz ); - $rezultatas = $db->loadResult(); - $weight += $rezultatas*$val->product_quantity; - } - - // Changes for version 1.0.6 - if (strlen($order['details']['ST']->address_1) > 0) { - $gkaddr2 = $order['details']['ST']->address_2; - } else { - $gkaddr2 = $order['details']['BT']->address_2; - } - // --------------------1.0.6 - - $consignment = array( - 'ToAddress' => array( - 'country_code' => $musu_country_code, - 'name' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, - 'business' => $gkcompany, - 'street' => $gkaddr, - 'eps_postcode' => $gkzip, - 'town' => $gkcity, - 'email' => $gkemail, - 'phone_number' => $gkphone, - 'extraname' => $gkaddr2, - ), - 'weight' => $weight, - 'custom_id' => $order['details']['BT']->order_number, - ); - } - $formParams[$order_id] = serialize($consignment); - } -?> - - -

Sending data to MyParcel ...

- - - - $serialized_data) - { - //echo "--".$order_id."++
"; - if(!is_numeric($order_id)) continue; - - //$check_sql = tep_db_query("SELECT orders_id FROM " . TABLE_ORDERS . " WHERE orders_id = '" . tep_db_input($order_id) . "'"); - - $query2 = 'SELECT COUNT(virtuemart_order_id) FROM ' . TABLE_ORDERS . ' WHERE virtuemart_order_id = "' . $db->escape($order_id) . '"'; - //echo $query2."

"; - $db->setQuery( $query2 ); - $rezultatas = $db->loadResult(); - //echo "---"; print_r($rezultatas); echo "+++"; - //if ($rezultatas == 1) { - - if($rezultatas == 1) - { - $data = unserialize($serialized_data); - - // save - /*tep_db_perform('orders_myparcel', array( - 'orders_id' => $order_id, - 'consignment_id' => $data['consignment_id'], - 'retour' => null, - 'tracktrace' => $data['tracktrace'], - 'postcode' => $data['postcode'], - ));*/ - - $qinsert = "INSERT INTO orders_myparcel SET orders_id='".$order_id."', consignment_id='".$data['consignment_id']."', retour='', postcode='".$data['postcode']."', tracktrace = '" . $data['tracktrace'] . "'"; - //echo "

".$qinsert;//die; - $db->setQuery( $qinsert ); - $db->query(); - - } - } -?> - - -

Consignments aangemaakt

-

- - - - +setQuery($q); + $order['details'] = $db->loadObjectList('address_type'); + + // Get the order history + $q = "SELECT * + FROM #__virtuemart_order_histories + WHERE virtuemart_order_id=".$virtuemart_order_id." + ORDER BY virtuemart_order_history_id ASC"; + $db->setQuery($q); + $order['history'] = $db->loadObjectList(); + + // Get the order items +$q = 'SELECT virtuemart_order_item_id, product_quantity, order_item_name, + order_item_sku, i.virtuemart_product_id, product_item_price, + product_final_price, product_basePriceWithTax, product_discountedPriceWithoutTax, product_priceWithoutTax, product_subtotal_with_tax, product_subtotal_discount, product_tax, product_attribute, order_status, + intnotes, virtuemart_category_id + FROM (#__virtuemart_order_items i + LEFT JOIN #__virtuemart_products p + ON p.virtuemart_product_id = i.virtuemart_product_id) + LEFT JOIN #__virtuemart_product_categories c + ON p.virtuemart_product_id = c.virtuemart_product_id + WHERE `virtuemart_order_id`="'.$virtuemart_order_id.'" group by `virtuemart_order_item_id`'; +//group by `virtuemart_order_id`'; Why ever we added this, it makes trouble, only one order item is shown then. +// without group by we get the product 3 times, when it is in 3 categories and similar, so we need a group by +//lets try group by `virtuemart_order_item_id` + $db->setQuery($q); + $order['items'] = $db->loadObjectList(); +// Get the order items + $q = "SELECT * + FROM #__virtuemart_order_calc_rules AS z + WHERE virtuemart_order_id=".$virtuemart_order_id; + $db->setQuery($q); + $order['calc_rules'] = $db->loadObjectList(); +// vmdebug('getOrder my order',$order); + return $order; +} + +/* Since Pg_address drop number suffix */ +function isPgAddress($name, $street, $gkzip, $gkcity) +{ + $db = JFactory::getDBO(); + $query_pg_address = $db->setQuery( + sprintf(' + SELECT * FROM `orders_myparcel_pg_address` WHERE `name`="%s" AND `street`="%s" AND `house_number`="%s" AND `postcode`="%s" AND `town`="%s" LIMIT 1' + , + $name, // Name + isset($street['street']) ? $street['street'] : '', // Street + isset($street['house_number']) ? $street['house_number'] : '', // House number + $gkzip, // Postcode + $gkcity // City + ) + ); + + $query_pg_address->execute(); + + if ($query_pg_address->getNumRows()) { + return true; + } + return false; +} +/*---------------------------------------*/ + +function getAddressComponents($address) +{ + $ret = array(); + $ret['house_number'] = ''; + $ret['number_addition'] = ''; + //$address = 'Markerkant 10 11E'; + $address = str_replace(array('?', '*', '[', ']', ',', '!'), ' ', $address); + $address = preg_replace('/\s\s+/', ' ', $address); + + $matches = _splitStreet($address); + + if (!empty($matches[2])) { + $ret['street'] = trim($matches[1]); + $ret['house_number'] = trim($matches[3]); + $ret['number_addition'] = trim($matches[4]); + } else { + $ret['street'] = $address; + } + + /** START @Since the fix for negative house number (64-69) **/ + if (strlen($ret['street']) && substr($ret['street'], -1) == '-') { + $ret['street'] = str_replace(' -', '', $ret['street']); + return getAddressComponents( $ret['street']); + } + /** END @Since the fix for negative house number (64-69) **/ + + return $ret; +} + +function _splitStreet($fullStreet) +{ + $split_street_regex = '~(?P.*?)\s?(?P(?P[\d]+)-?(?P[a-zA-Z/\s]{0,5}$|[0-9/]{0,5}$|\s[a-zA-Z]{1}[0-9]{0,3}$))$~'; + $fullStreet = preg_replace("/[\n\r]/", "", $fullStreet); + $result = preg_match($split_street_regex, $fullStreet, $matches); + + if (!$result || !is_array($matches) || $fullStreet != $matches[0]) { + if ($fullStreet != $matches[0]) { + // Characters are gone by preg_match + exit('Something went wrong with splitting up address ' . $fullStreet); + } else { + // Invalid full street supplied + exit('Invalid full street supplied: ' . $fullStreet); + } + } + + return $matches; +} + +/** START Since version 1.0.9 **/ +function getReturnUrlWithUri($uri){ + $return_url = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) == "on"?'s':'').'://'.$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'].'?'.$uri; + return $return_url; +} +/** END Since version 1.0.9 **/ + +/* + * JAVASCRIPT ACTIONS + */ +if(isset($_GET['action'])) +{ + /* + * MYPARCEL STATUS UPDATE + * + * Every time this script is called, it will check if an update of the order statuses is required + * Depending on the last update with a timeout, since TNT updates our status 2 times a day anyway + * + * NOTE - Increasing this timeout is POINTLESS, since TNT updates our statuses only 2 times a day + * Please save our bandwidth and use the Track&Trace link to get the actual status. Thanks + */ + + /** START Since version 1.0.9 **/ + if (version_compare(phpversion(), '5.4.0', '<')) { + if (session_id() == '') session_start(); + } else { + if (session_status() == PHP_SESSION_NONE) { + session_start(); + } + } + + if (empty($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'])) { + $_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'] = ''; + $db = JFactory::getDBO(); + $query = "SELECT * FROM orders_myparcel WHERE tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"; + $db->setQuery( $query ); + $vendors = $db->loadObjectlist(); + $all_consignments = array(); + for ($i=0, $n=count( $vendors ); $i < $n; $i++) { + $row = &$vendors[$i]; + $all_consignments[] = $row->consignment_id; + } + } + + /** END Since version 1.0.9 **/ + + if( + (isset($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS']) && !empty($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'])) || + !empty($all_consignments) + ) + { + if (empty($all_consignments)) { + $visible_consignments = str_replace('|', ',', trim($_SESSION['MYPARCEL_VISIBLE_CONSIGNMENTS'], '|')); + + $db = JFactory::getDBO(); + $query = "SELECT * FROM orders_myparcel WHERE consignment_id IN (" . $visible_consignments . ") AND tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"; + $db->setQuery($query); + $vendors = $db->loadObjectlist(); + $consignments = array(); + for ($i = 0, $n = count($vendors); $i < $n; $i++) { + $row = &$vendors[$i]; + $consignments[] = $row->consignment_id; + + //$status_q = tep_db_query("SELECT * ROM orders_myparcel WHERE consignment_id IN (" . $visible_consignments . ") AND tnt_final = 0 AND tnt_updated_on < '" . date('Y-m-d H:i:s', time() - 43200) . "'"); + + /*while($consignment = tep_db_fetch_array($status_q)) + { + $consignments[] = $consignment['consignment_id']; + }*/ + } + } else { + $consignments = $all_consignments; + } + + if(!empty($consignments)) + { + error_reporting(0); + foreach ($consignments as $consignment) { + $status_file = file(MYPARCEL_LINK . 'status/tnt/' . $consignment); + + if ($status_file) { + $row = $status_file[0]; + $row = explode('|', $row); + if(count($row) != 3) exit; + + $qupdate = "UPDATE orders_myparcel SET tnt_status='".trim($row[2])."', tnt_updated_on='".date('Y-m-d H:i:s')."', tnt_final='".(int) $row[1]."' WHERE consignment_id = '" . $row[0] . "'"; + $db->setQuery( $qupdate ); + $db->query(); + + /* tep_db_perform('orders_myparcel', array( + 'tnt_status' => trim($row[2]), + 'tnt_updated_on' => date('Y-m-d H:i:s'), + 'tnt_final' => (int) $row[1], + ), 'update', "consignment_id = '" . $row[0] . "'"); + */ + } + } + } + } + + /* + * PLUGIN POPUP CREATE / RETOUR + */ + + if($_GET['action'] == 'post' && is_numeric($_GET['order_id'])) + { + //include(DIR_WS_CLASSES . 'order.php'); + // determine retour or normal consignment + if(isset($_GET['retour']) && $_GET['retour'] == 'true') + { + $myparcel_plugin_action = 'verzending-aanmaken-retour/'; + $myparcel_action = 'retour'; + } + else + { + $myparcel_plugin_action = 'verzending-aanmaken/'; + $myparcel_action = 'return'; + } + + $return_url = getReturnUrlWithUri('action=' . $myparcel_action . '&order_id=' . $_GET['order_id'] . '×tamp=' . $_GET['timestamp']); + $order = getOrderz($_GET['order_id']); + //echo "aaa"; + //print_r($order['details']['BT']->virtuemart_country_id); + //die; + //$address = $order->delivery; + + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->virtuemart_country_id) > 0) { + $gk_virtuemart_country_id = $order['details']['ST']->virtuemart_country_id; + } else { + $gk_virtuemart_country_id = $order['details']['BT']->virtuemart_country_id; + } + + $db = JFactory::getDBO(); + $query = "SELECT country_2_code AS country_code FROM #__virtuemart_countries WHERE virtuemart_country_id='".$gk_virtuemart_country_id."' LIMIT 1"; + //echo ($query); + $db->setQuery( $query ); + //print_r($db->loadObjectlist());die; + $vendors = $db->loadObjectlist(); + $musu_country_code=''; + for ($i=0, $n=count( $vendors ); $i < $n; $i++) + { + $row = &$vendors[$i]; + //print_r($row);die; + $musu_country_code=$row->country_code; + } + + /*$country_sql = tep_db_query(" +SELECT countries_iso_code_2 AS country_code + FROM " . TABLE_COUNTRIES . " + WHERE countries_name = '" . $address['country'] . "' +"); + $country = tep_db_fetch_array($country_sql);*/ + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->company) > 0) { + $gkcompany = $order['details']['ST']->company; +} else { + $gkcompany = $order['details']['BT']->company; +} + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->zip) > 0) { + $gkzip = $order['details']['ST']->zip; +} else { + $gkzip = $order['details']['BT']->zip; +} + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->city) > 0) { + $gkcity = $order['details']['ST']->city; +} else { + $gkcity = $order['details']['BT']->city; +} + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->email) > 0) { + $gkemail = $order['details']['ST']->email; +} else { + $gkemail = $order['details']['BT']->email; +} + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->first_name) > 0) { + $gkfirstname = $order['details']['ST']->first_name; +} else { + $gkfirstname = $order['details']['BT']->first_name; +} +if (isset($order['details']['ST']) && strlen($order['details']['ST']->last_name) > 0) { + $gklastname = $order['details']['ST']->last_name; +} else { + $gklastname = $order['details']['BT']->last_name; +} +if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_1) > 0) { + $gkaddr = $order['details']['ST']->address_1; +} else { + $gkaddr = $order['details']['BT']->address_1; +} +if (isset($order['details']['ST']) && strlen($order['details']['ST']->phone_1) > 0) { + $gkphone = $order['details']['ST']->phone_1; +} else { + $gkphone = $order['details']['BT']->phone_1; +} + +// Changes for version 1.0.5 + +if (isset($order['details']['ST']) && strlen($order['details']['ST']->middle_name) > 0) { + $gkmiddlename = $order['details']['ST']->middle_name; +} else { + $gkmiddlename = $order['details']['BT']->middle_name; +} +// And the line below: 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, +// --------------------1.0.5 + + +//$gkadresas_num = preg_replace('/\D/', '', $gkaddr); + +//$gkadresas_street = preg_replace('/[^A-Z a-z]/', '', $gkaddr); + if($musu_country_code=='NL') + { + // Added on 2016-04-07 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_2) > 0) { + $gkaddr2 = $order['details']['ST']->address_2; + } else { + $gkaddr2 = $order['details']['BT']->address_2; + } + $gkaddr .= (!empty($gkaddr2) ? ' ' . $gkaddr2 :''); + // End of 2016-04-07 + + /*-------------------Since pg_address----------------*/ + $raw_house_number = ''; + $raw_number_addition = ''; + $raw_street = ''; + + if (@$order['details']['ST']->Toevoegingen != '' || @$order['details']['ST']->Huisnummer != '') { + $raw_house_number = @$order['details']['ST']->Huisnummer; + $raw_number_addition = @$order['details']['ST']->Toevoegingen; + $raw_street = (@$order['details']['ST']->address_2 != '') ? @$order['details']['ST']->address_2 : @$order['details']['ST']->address_1; + } + + if (@$order['details']['BT']->Toevoegingen != '' || @$order['details']['BT']->Huisnummer != '') { + $raw_house_number = @$order['details']['BT']->Huisnummer; + $raw_number_addition = @$order['details']['BT']->Toevoegingen; + $raw_street = (@$order['details']['BT']->address_2 != '') ? @$order['details']['BT']->address_2 : @$order['details']['BT']->address_1; + } + + if($raw_house_number == '' && $raw_number_addition == '' && $raw_street == ''){ + $street = getAddressComponents($gkaddr); + $pg_address = isPgAddress($gkcompany, $street, $gkzip, $gkcity); + + if ($pg_address) { + $street['number_addition'] = ''; + } + + $raw_house_number = $street['house_number']; + $raw_number_addition = $street['number_addition']; + $raw_street = $street['street']; + } + /*----------------------------------------pg_address*/ + + $consignment = array( + 'ToAddress[country_code]' => $musu_country_code, + 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, + 'ToAddress[business]' => $gkcompany, + 'ToAddress[postcode]' => $gkzip, + 'ToAddress[house_number]' => $raw_house_number, + 'ToAddress[number_addition]' => $raw_number_addition, + 'ToAddress[street]' => $raw_street, + 'ToAddress[town]' => $gkcity, + 'ToAddress[email]' => $gkemail, + 'ToAddress[phone_number]' => $gkphone, + 'custom_id' => $order['details']['BT']->order_number, + ); + } + else // buitenland + { + $weight = 0; + foreach($order['items'] as $val) { + //echo $val->product_quantity." ".$val->virtuemart_product_id."
"; + $queryz = 'SELECT product_weight FROM #__virtuemart_products where virtuemart_product_id='.$val->virtuemart_product_id; + //echo $query2."

"; + $db->setQuery( $queryz ); + $rezultatas = $db->loadResult(); + $weight += $rezultatas*$val->product_quantity; + } + + // Changes for version 1.0.6 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_2) > 0) { + $gkaddr2 = $order['details']['ST']->address_2; + } else { + $gkaddr2 = $order['details']['BT']->address_2; + } + // --------------------1.0.6 + + $consignment = array( + 'ToAddress[country_code]' => $musu_country_code, + 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, + 'ToAddress[business]' => $gkcompany, + 'ToAddress[street]' => $gkaddr, + 'ToAddress[eps_postcode]' => $gkzip, + 'ToAddress[town]' => $gkcity, + 'ToAddress[email]' => $gkemail, + 'ToAddress[phone_number]' => $gkphone, + 'ToAddress[extraname]' => $gkaddr2, + 'weight' => $weight, + 'custom_id' => $order['details']['BT']->order_number, + ); + //print_r($consignment); + //die; + } +?> + + +

Sending data to MyParcel ...

+ + + + $order_id, + 'consignment_id' => $consignment_id, + 'retour' => $retour, + 'tracktrace' => $tracktrace, + 'postcode' => $postcode, + ));*/ + + + $qinsert = "INSERT INTO orders_myparcel SET orders_id='".$order_id."', consignment_id='".$consignment_id."', retour='".$retour."', postcode='".$postcode."', tracktrace = '" . $tracktrace . "'"; + //echo $qinsert; die; + $db->setQuery( $qinsert ); + $db->query(); + + + + $tracktrace_link = 'https://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?lang=nl&B=' . $tracktrace . '&P=' . $postcode; +?> + + +

Consignment aangemaakt [label bekijken]

+

+ + + + + + +

Sending data to MyParcel ...

+ + + +"; + /*$address = $order->delivery; + + $country_sql = tep_db_query(" +SELECT countries_iso_code_2 AS country_code + FROM " . TABLE_COUNTRIES . " + WHERE countries_name = '" . $address['country'] . "' +"); + $country = tep_db_fetch_array($country_sql);*/ + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->virtuemart_country_id) > 0) { + $gk_virtuemart_country_id = $order['details']['ST']->virtuemart_country_id; + } else { + $gk_virtuemart_country_id = $order['details']['BT']->virtuemart_country_id; + } + + $db = JFactory::getDBO(); + $query = "SELECT country_2_code AS country_code FROM #__virtuemart_countries WHERE virtuemart_country_id='".$gk_virtuemart_country_id."' LIMIT 1"; + //echo ($query); + $db->setQuery( $query ); + //print_r($db->loadObjectlist());die; + $vendors = $db->loadObjectlist(); + $musu_country_code=''; + for ($i=0, $n=count( $vendors ); $i < $n; $i++) + { + $row = &$vendors[$i]; + //print_r($row);die; + $musu_country_code=$row->country_code; + } + + + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->company) > 0) { + $gkcompany = $order['details']['ST']->company; + } else { + $gkcompany = $order['details']['BT']->company; + } + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->zip) > 0) { + $gkzip = $order['details']['ST']->zip; + } else { + $gkzip = $order['details']['BT']->zip; + } + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->city) > 0) { + $gkcity = $order['details']['ST']->city; + } else { + $gkcity = $order['details']['BT']->city; + } + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->email) > 0) { + $gkemail = $order['details']['ST']->email; + } else { + $gkemail = $order['details']['BT']->email; + } + + if (isset($order['details']['ST']) && strlen($order['details']['ST']->first_name) > 0) { + $gkfirstname = $order['details']['ST']->first_name; + } else { + $gkfirstname = $order['details']['BT']->first_name; + } + if (isset($order['details']['ST']) && strlen($order['details']['ST']->last_name) > 0) { + $gklastname = $order['details']['ST']->last_name; + } else { + $gklastname = $order['details']['BT']->last_name; + } + // Changes for version 1.0.5 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->middle_name) > 0) { + $gkmiddlename = $order['details']['ST']->middle_name; + } else { + $gkmiddlename = $order['details']['BT']->middle_name; + } + // And the line below: 'ToAddress[name]' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, + // --------------------1.0.5 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_1) > 0) { + $gkaddr = $order['details']['ST']->address_1; + } else { + $gkaddr = $order['details']['BT']->address_1; + } + if (isset($order['details']['ST']) && strlen($order['details']['ST']->phone_1) > 0) { + $gkphone = $order['details']['ST']->phone_1; + } else { + $gkphone = $order['details']['BT']->phone_1; + } + + if($musu_country_code=='NL') + { + // Added on 2016-04-07 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_2) > 0) { + $gkaddr2 = $order['details']['ST']->address_2; + } else { + $gkaddr2 = $order['details']['BT']->address_2; + } + $gkaddr .= (!empty($gkaddr2) ? ' ' . $gkaddr2 :''); + // End of 2016-04-07 + + /*-------------------Since pg_address----------------*/ + $raw_house_number = ''; + $raw_number_addition = ''; + $raw_street = ''; + + if (@$order['details']['ST']->Toevoegingen != '' || @$order['details']['ST']->Huisnummer != '') { + $raw_house_number = @$order['details']['ST']->Huisnummer; + $raw_number_addition = @$order['details']['ST']->Toevoegingen; + $raw_street = (@$order['details']['ST']->address_2 != '') ? @$order['details']['ST']->address_2 : @$order['details']['ST']->address_1; + } + + if (@$order['details']['BT']->Toevoegingen != '' || @$order['details']['BT']->Huisnummer != '') { + $raw_house_number = @$order['details']['BT']->Huisnummer; + $raw_number_addition = @$order['details']['BT']->Toevoegingen; + $raw_street = (@$order['details']['BT']->address_2 != '') ? @$order['details']['BT']->address_2 : @$order['details']['BT']->address_1; + } + + if($raw_house_number == '' && $raw_number_addition == '' && $raw_street == ''){ + $street = getAddressComponents($gkaddr); + $pg_address = isPgAddress($gkcompany, $street, $gkzip, $gkcity); + if ($pg_address) { + $street['number_addition'] = ''; + } + + $raw_house_number = $street['house_number']; + $raw_number_addition = $street['number_addition']; + $raw_street = $street['street']; + } + /*----------------------------------------pg_address*/ + + $consignment = array( + 'ToAddress' => array( + 'country_code' => $musu_country_code, + 'name' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, + 'business' => $gkcompany, + 'postcode' => $gkzip, + 'house_number' => $raw_house_number, + 'number_addition' => $raw_number_addition, + 'street' => $raw_street, + 'town' => $gkcity, + 'email' => $gkemail, + ), + 'custom_id' => $order['details']['BT']->order_number, + ); + } + else // buitenland + { + $weight = 0; + /*$product_sql = tep_db_query(" +SELECT op.products_quantity, p.products_weight + FROM " . TABLE_ORDERS_PRODUCTS . " op + LEFT JOIN " . TABLE_PRODUCTS . " p ON p.products_id = op.products_id + WHERE orders_id = '" . $order_id . "' +"); + while($product = tep_db_fetch_array($product_sql)) + { + $weight += $product['products_quantity'] * $product['products_weight']; + }*/ + foreach($order['items'] as $val) { + //echo $val->product_quantity." ".$val->virtuemart_product_id."
"; + $queryz = 'SELECT product_weight FROM #__virtuemart_products where virtuemart_product_id='.$val->virtuemart_product_id; + //echo $query2."

"; + $db->setQuery( $queryz ); + $rezultatas = $db->loadResult(); + $weight += $rezultatas*$val->product_quantity; + } + // Changes for version 1.0.6 + if (isset($order['details']['ST']) && strlen($order['details']['ST']->address_2) > 0) { + $gkaddr2 = $order['details']['ST']->address_2; + } else { + $gkaddr2 = $order['details']['BT']->address_2; + } + // --------------------1.0.6 + + $consignment = array( + 'ToAddress' => array( + 'country_code' => $musu_country_code, + 'name' => $gkfirstname. ($gkmiddlename ? " " . $gkmiddlename . " " : " ") .$gklastname, + 'business' => $gkcompany, + 'street' => $gkaddr, + 'eps_postcode' => $gkzip, + 'town' => $gkcity, + 'email' => $gkemail, + 'phone_number' => $gkphone, + 'extraname' => $gkaddr2, + ), + 'weight' => $weight, + 'custom_id' => $order['details']['BT']->order_number, + ); + } + $formParams[$order_id] = serialize($consignment); + } +?> + + +

Sending data to MyParcel ...

+ + + + $serialized_data) + { + //echo "--".$order_id."++
"; + if(!is_numeric($order_id)) continue; + + //$check_sql = tep_db_query("SELECT orders_id FROM " . TABLE_ORDERS . " WHERE orders_id = '" . tep_db_input($order_id) . "'"); + + $query2 = 'SELECT COUNT(virtuemart_order_id) FROM ' . TABLE_ORDERS . ' WHERE virtuemart_order_id = "' . $db->escape($order_id) . '"'; + //echo $query2."

"; + $db->setQuery( $query2 ); + $rezultatas = $db->loadResult(); + //echo "---"; print_r($rezultatas); echo "+++"; + //if ($rezultatas == 1) { + + if($rezultatas == 1) + { + $data = unserialize($serialized_data); + + // save + /*tep_db_perform('orders_myparcel', array( + 'orders_id' => $order_id, + 'consignment_id' => $data['consignment_id'], + 'retour' => null, + 'tracktrace' => $data['tracktrace'], + 'postcode' => $data['postcode'], + ));*/ + + $qinsert = "INSERT INTO orders_myparcel SET orders_id='".$order_id."', consignment_id='".$data['consignment_id']."', retour='', postcode='".$data['postcode']."', tracktrace = '" . $data['tracktrace'] . "'"; + //echo "

".$qinsert;//die; + $db->setQuery( $qinsert ); + $db->query(); + + } + } +?> + + +

Consignments aangemaakt

+

+ + + + diff --git a/administrator/tables/config.php b/administrator/tables/config.php index 63532e1..a149dc6 100755 --- a/administrator/tables/config.php +++ b/administrator/tables/config.php @@ -44,6 +44,13 @@ public function bind($array, $ignore = '') if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_myparcel') && $array['state'] == 1)) { $array['state'] = 0; } + + if($task == 'publish'){ + return $this->publish($array, 1); + }else + if($task == 'unpublish'){ + return $this->publish($array, 0); + } if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry(); @@ -148,17 +155,17 @@ public function publish($pks = null, $state = 1, $userId = 0) } // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . + $sql = 'UPDATE `' . $this->_tbl . '`' . ' SET `state` = ' . (int) $state . ' WHERE (' . $where . ')' . - $checkin - ); + $checkin; + + $this->_db->setQuery($sql); $this->_db->query(); // Check for a database error. if ($this->_db->getErrorNum()) { - $this->setError($this->_db->getErrorMsg()); + $this->setError($this->_db->getErrorMsg().' '.$sql); return false; } @@ -178,181 +185,187 @@ public function publish($pks = null, $state = 1, $userId = 0) $this->setError(''); ///***************************************************************//// - - $mano111_tpl_file_i = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'orders' . DS . 'tmpl' . DS . 'orders.php'; - $mano111_tpl_file_o = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'orders' . DS . 'tmpl' . DS . 'orders.php'; - $mano111_tpl_file_i_bcp = $mano111_tpl_file_i . "manoBCP"; - if (file_exists($mano111_tpl_file_i)) { - if (file_exists($mano111_tpl_file_i_bcp)) { - file_put_contents($mano111_tpl_file_i, file_get_contents($mano111_tpl_file_i_bcp)); - } else { - file_put_contents($mano111_tpl_file_i_bcp, file_get_contents($mano111_tpl_file_i)); - } - $mano111_tpl_file_i_current = file_get_contents($mano111_tpl_file_i); - $mano111_tpl_file_i_new = $mano111_tpl_file_i_current; - $musu_replace_array = array(); - - $musu_i = 0; - /* $musu_replace_array[$musu_i]['input']='AdminUIHelper::startAdminArea ();'; - $musu_replace_array[$musu_i++]['output']='AdminUIHelper::startAdminArea (); - JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\');'; */ - $musu_replace_array[$musu_i]['input'] = 'AdminUIHelper::startAdminArea'; - $musu_replace_array[$musu_i++]['output'] = ' - JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\'); - JHTML::script(JURI::base().\'components/com_myparcel/assets/js/myparcel_plugin.js\'); - AdminUIHelper::startAdminArea'; - - $musu_replace_array[$musu_i]['input'] = '
'; - $musu_replace_array[$musu_i++]['output'] = ' - '; - - - $musu_replace_array[$musu_i]['input'] = 'sort (\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?>'; - $musu_replace_array[$musu_i++]['output'] = 'sort (\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?> - - - - - - - - -
- MyParcel Labels
- -
- Actions -
- '; - - - $musu_replace_array[$musu_i]['input'] = ''; - $musu_replace_array[$musu_i++]['output'] = ''; - - - $musu_replace_array[$musu_i]['input'] = 'COM_VIRTUEMART_ORDER_EDIT_ORDER_ID\') . \' \' . $order->virtuemart_order_id)); ?>'; - $musu_replace_array[$musu_i++]['output'] = 'COM_VIRTUEMART_ORDER_EDIT_ORDER_ID\') . \' \' . $order->virtuemart_order_id)); ?> - - - -
- virtuemart_order_id . "\'"; - $db->setQuery( $query ); - $vendors = $db->loadObjectlist(); - for ($i2=0, $n=count( $vendors ); $i2 < $n; $i2++) - { - $row = &$vendors[$i2]; - - - $_SESSION[\'MYPARCEL_VISIBLE_CONSIGNMENTS\'] .= $row->consignment_id . \'|\'; - $mypa_tracktrace_link = \'https://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?lang=nl&B=\' . $row->tracktrace . \'&P=\' . $row->postcode; - $mypa_tnt_status = empty($row->tnt_status) ? \'Track&Trace\' : $row->tnt_status; - $mypa_pdf_image = ($row->retour == 1) ? \'myparcel_retour.png\' : \'myparcel_pdf.png\'; - echo \'\'; - } - ?> - - - - -
- '; - - $musu_replace_array[$musu_i]['input'] = ''; - $musu_replace_array[$musu_i++]['output'] = ''; - - - - - // vm 2.0.0 ----> - /* $musu_replace_array[$musu_i]['input']='AdminUIHelper::startAdminArea();'; - $musu_replace_array[$musu_i++]['output']='AdminUIHelper::startAdminArea(); - JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\');'; */ - - $musu_replace_array[$musu_i]['input'] = 'lists[\'filter_order_Dir\'], $this->lists[\'filter_order\']); ?>'; - $musu_replace_array[$musu_i++]['output'] = 'lists[\'filter_order_Dir\'], $this->lists[\'filter_order\']); ?> - - - - - - - - -
- MyParcel Labels
- -
- Actions -
- '; - - - $musu_replace_array[$musu_i]['input'] = ''; - $musu_replace_array[$musu_i++]['output'] = ''; - - $musu_replace_array[$musu_i]['input'] = ''; - $musu_replace_array[$musu_i++]['output'] = ''; - - - // vm 2.0.10 - $musu_replace_array[$musu_i]['input'] = 'sort(\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?>'; - $musu_replace_array[$musu_i++]['output'] = 'sort(\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?> - - - - - - - - -
- MyParcel Labels
- -
- Actions -
- '; - - - if ($state == 1) { - echo "ijungta"; - - //echo "+++"; print_r($mano111_tpl_file_i_current); echo "---
"; - foreach ($musu_replace_array AS $musu_replace_array_item) { - $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['output'], $musu_replace_array_item['input'], $mano111_tpl_file_i_new); - $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['input'], $musu_replace_array_item['output'], $mano111_tpl_file_i_new); - } - - //print_r($mano111_tpl_file_i_current);die; - } else { - echo "ishjungta"; - foreach ($musu_replace_array AS $musu_replace_array_item) { - $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['output'], $musu_replace_array_item['input'], $mano111_tpl_file_i_new); - } - rename($mano111_tpl_file_i_bcp, $mano111_tpl_file_i_bcp . (microtime())); - } - file_put_contents($mano111_tpl_file_o, $mano111_tpl_file_i_new); - } + $templates = array( + 'list.php', + 'orders.php', + ); + + foreach($templates as $template_item){ + $mano111_tpl_file_i = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'orders' . DS . 'tmpl' . DS . $template_item; + $mano111_tpl_file_o = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'orders' . DS . 'tmpl' . DS . $template_item; + $mano111_tpl_file_i_bcp = $mano111_tpl_file_i . "manoBCP"; + if (file_exists($mano111_tpl_file_i)) { + if (file_exists($mano111_tpl_file_i_bcp)) { + file_put_contents($mano111_tpl_file_i, file_get_contents($mano111_tpl_file_i_bcp)); + } else { + file_put_contents($mano111_tpl_file_i_bcp, file_get_contents($mano111_tpl_file_i)); + } + $mano111_tpl_file_i_current = file_get_contents($mano111_tpl_file_i); + $mano111_tpl_file_i_new = $mano111_tpl_file_i_current; + $musu_replace_array = array(); + + $musu_i = 0; + /* $musu_replace_array[$musu_i]['input']='AdminUIHelper::startAdminArea ();'; + $musu_replace_array[$musu_i++]['output']='AdminUIHelper::startAdminArea (); + JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\');'; */ + $musu_replace_array[$musu_i]['input'] = 'AdminUIHelper::startAdminArea'; + $musu_replace_array[$musu_i++]['output'] = ' + JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\'); + JHTML::script(JURI::base().\'components/com_myparcel/assets/js/myparcel_plugin.js\'); + AdminUIHelper::startAdminArea'; + + $musu_replace_array[$musu_i]['input'] = ''; + $musu_replace_array[$musu_i++]['output'] = ' + '; + + + $musu_replace_array[$musu_i]['input'] = 'sort (\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?>'; + $musu_replace_array[$musu_i++]['output'] = 'sort (\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?> + + + + + + + + +
+ MyParcel Labels
+ +
+ Actions +
+ '; + + + $musu_replace_array[$musu_i]['input'] = ''; + $musu_replace_array[$musu_i++]['output'] = ''; + + + $musu_replace_array[$musu_i]['input'] = 'COM_VIRTUEMART_ORDER_EDIT_ORDER_ID\') . \' \' . $order->virtuemart_order_id)); ?>'; + $musu_replace_array[$musu_i++]['output'] = 'COM_VIRTUEMART_ORDER_EDIT_ORDER_ID\') . \' \' . $order->virtuemart_order_id)); ?> + + + +
+ virtuemart_order_id . "\'"; + $db->setQuery( $query ); + $vendors = $db->loadObjectlist(); + for ($i2=0, $n=count( $vendors ); $i2 < $n; $i2++) + { + $row = &$vendors[$i2]; + + + $_SESSION[\'MYPARCEL_VISIBLE_CONSIGNMENTS\'] .= $row->consignment_id . \'|\'; + $mypa_tracktrace_link = \'https://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?lang=nl&B=\' . $row->tracktrace . \'&P=\' . $row->postcode; + $mypa_tnt_status = empty($row->tnt_status) ? \'Track&Trace\' : $row->tnt_status; + $mypa_pdf_image = ($row->retour == 1) ? \'myparcel_retour.png\' : \'myparcel_pdf.png\'; + echo \'\'; + } + ?> + + + + +
+ '; + + $musu_replace_array[$musu_i]['input'] = ''; + $musu_replace_array[$musu_i++]['output'] = ''; + + + + + // vm 2.0.0 ----> + /* $musu_replace_array[$musu_i]['input']='AdminUIHelper::startAdminArea();'; + $musu_replace_array[$musu_i++]['output']='AdminUIHelper::startAdminArea(); + JHTML::script(\'myparcel_plugin.js\', JURI::base().\'components/com_myparcel/assets/js/\');'; */ + + $musu_replace_array[$musu_i]['input'] = 'lists[\'filter_order_Dir\'], $this->lists[\'filter_order\']); ?>'; + $musu_replace_array[$musu_i++]['output'] = 'lists[\'filter_order_Dir\'], $this->lists[\'filter_order\']); ?> + + + + + + + + +
+ MyParcel Labels
+ +
+ Actions +
+ '; + + + $musu_replace_array[$musu_i]['input'] = ''; + $musu_replace_array[$musu_i++]['output'] = ''; + + $musu_replace_array[$musu_i]['input'] = ''; + $musu_replace_array[$musu_i++]['output'] = ''; + + + // vm 2.0.10 + $musu_replace_array[$musu_i]['input'] = 'sort(\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?>'; + $musu_replace_array[$musu_i++]['output'] = 'sort(\'virtuemart_order_id\', \'COM_VIRTUEMART_ORDER_LIST_ID\') ?> + + + + + + + + +
+ MyParcel Labels
+ +
+ Actions +
+ '; + + + if ($state == 1) { + echo "ijungta"; + + //echo "+++"; print_r($mano111_tpl_file_i_current); echo "---
"; + foreach ($musu_replace_array AS $musu_replace_array_item) { + $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['output'], $musu_replace_array_item['input'], $mano111_tpl_file_i_new); + $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['input'], $musu_replace_array_item['output'], $mano111_tpl_file_i_new); + } + + //print_r($mano111_tpl_file_i_current);die; + } else { + echo "ishjungta"; + foreach ($musu_replace_array AS $musu_replace_array_item) { + $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['output'], $musu_replace_array_item['input'], $mano111_tpl_file_i_new); + } + rename($mano111_tpl_file_i_bcp, $mano111_tpl_file_i_bcp . (microtime())); + } + file_put_contents($mano111_tpl_file_o, $mano111_tpl_file_i_new); + } + } //edit_address.php $db11 = JFactory::getDbo(); $db11->setQuery('SELECT * FROM #__myparcel_config'); $mano_db_result = $db11->loadAssoc(); - $mano_plugin_status = $mano_db_result['my_frontend_plugin']; + $mano_plugin_status = $mano_db_result['my_frontend_plugin']; $mano111_tpl_file_i = JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'user' . DS . 'tmpl' . DS . 'edit_address.php'; $mano111_tpl_file_o = JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'views' . DS . 'user' . DS . 'tmpl' . DS . 'edit_address.php'; @@ -418,7 +431,7 @@ function pakjegemak() } else { echo "ishjungta"; foreach ($musu_replace_array AS $musu_replace_array_item) { - $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['output'], $musu_replace_array_item['input'], $mano111_tpl_file_i_new); + $mano111_tpl_file_i_new = str_replace($musu_replace_array_item['input'], $musu_replace_array_item['output'], $mano111_tpl_file_i_new); } rename($mano111_tpl_file_i_bcp, $mano111_tpl_file_i_bcp . (microtime())); } @@ -454,7 +467,7 @@ protected function _getAssetName() * * @see JTable::_getAssetParentId */ - protected function _getAssetParentId($table = null, $id = null) + protected function _getAssetParentId(JTable $table = null, $id = null) { // We will retrieve the parent-asset from the Asset-table $assetParent = JTable::getInstance('Asset'); diff --git a/myparcel.xml b/myparcel.xml index 71b1237..25c73d3 100755 --- a/myparcel.xml +++ b/myparcel.xml @@ -7,7 +7,7 @@ Balticode giedrius@balticode.com www.balticode.com - 1.1.1 + 1.1.3 MyParcel diff --git a/site/myparcel-passdata-virtuemart.html b/site/myparcel-passdata-virtuemart.html index fece080..12acc1a 100755 --- a/site/myparcel-passdata-virtuemart.html +++ b/site/myparcel-passdata-virtuemart.html @@ -85,17 +85,27 @@ // NOTE: zorg dat pakjegemak zendingen naar Nederland gaan // in dit voorbeeld vullen we de 'country' drop-down automatisch goed in formulier['shipto_virtuemart_country_id'].value = 150; - parent.parent.window.opener.document.getElementById('shipto_virtuemart_country_id').style.display = 'block'; - if (parent.parent.window.opener.document.getElementById('shipto_virtuemart_country_id_chzn')) { parent.parent.window.opener.document.getElementById('shipto_virtuemart_country_id_chzn').style.display = 'none'; } + var opener_document = parent.parent.window.opener.document; + if (opener_document.getElementById('shipto_virtuemart_country_id_field')) { + opener_document.getElementById('shipto_virtuemart_country_id_field').style.display = 'block'; + } else { + opener_document.getElementById('shipto_virtuemart_country_id').style.display = 'block'; + } + if(opener_document.getElementById('shipto_virtuemart_country_id_field_chzn')) { + opener_document.getElementById('shipto_virtuemart_country_id_field_chzn').style.display = 'none'; + } else if (opener_document.getElementById('shipto_virtuemart_country_id_chzn')) { + opener_document.getElementById('shipto_virtuemart_country_id_chzn').style.display = 'none'; + } } } + /*------------ Since version 1.0.7 ----------*/ var pg_data = new Array('pg_extra_name=' + shopname, 'pg_extra_street=' + street, 'pg_extra_house_number=' + houseNr, 'pg_extra_number_addition=' + houseNrAdd, 'pg_extra_postcode=' + postalCodeNum + postalCodeAlpha, 'pg_extra_town=' + city); loadXMLDoc(pg_data); /*--------------------------------------1.0.7*/ } - - /*------------ Since version 1.0.7 ----------*/ + + /*------------ Since version 1.0.7 ----------*/ function loadXMLDoc(pg_data) { var xmlhttp;