Skip to content

Commit

Permalink
upload new version
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardPerdaan committed Dec 17, 2018
1 parent 6f63b9b commit 7ba861a
Show file tree
Hide file tree
Showing 8 changed files with 1,162 additions and 1,111 deletions.
180 changes: 84 additions & 96 deletions administrator/assets/js/myparcel_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -65,63 +66,58 @@ 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;
}
}
locked = true;
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 + '&timestamp=' + 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 + '&timestamp=' + 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('|'));
}
Expand All @@ -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--)
Expand All @@ -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 + '&timestamp=' + 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;
}
}
}
2 changes: 1 addition & 1 deletion administrator/controllers/configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion administrator/models/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getItem($pk = null)
*
* @since 1.6
*/
protected function prepareTable(&$table)
protected function prepareTable($table)
{
jimport('joomla.filter.output');

Expand Down
2 changes: 1 addition & 1 deletion administrator/myparcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

$controller = JControllerLegacy::getInstance('Myparcel');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
$controller->redirect();
Loading

0 comments on commit 7ba861a

Please sign in to comment.