/* xhrPool = [];
function addToCart(){
console.log(1);
$.each(xhrPool, function(idx, jqXHR) {
jqXHR.abort();
});
xhrPool = [];
$.ajax({
type: 'POST',
url: 'http://paksmet.ru/index.php?option=com_jshopping&controller=cart&task=clear&ajax=1',
data: 'ajax=1',
async: false,
beforeSend: function (jqXHR, settings) {
xhrPool.push(jqXHR);
},
success: function(msg){
$('#requests>div').each(function(indx, elem){
//setTimeout(function(){
$.ajax({
type: 'POST',
url: 'http://paksmet.ru/index.php?option=com_jshopping&controller=cart&task=add&ajax=1',
data: ''+$(elem).text()+'',
async: false,
beforeSend: function (jqXHR, settings) {
xhrPool.push(jqXHR);
},
success: function(msg){
}
});
//}, indx*200);
})
}
});
} */
function checkIsFrame(){
var isFramed = false;
try {
isFramed = window != window.top || document != top.document || self.location != top.location;
} catch (e) {
isFramed = true;
}
if (isFramed && window.location.href.search("paksmet.ru")>-1) {
// console.log('iframe');
// console.log(window.location.href.search("paksmet.ru"));
return 1;
} else {
// console.log('Not Iframe');
return 0;
}
};
function savePDF(){
// console.log('savePDF');
var PDFtable = [];
var trHtml;
var PDFtextText = $('#print-text-text').html();
var PDFtextSumm = $('#print-text-summ').html();
var PDFtext = PDFtextText+' - '+PDFtextSumm;
$('#print tr').each(function(index, elem){
trHtml = [$(this).children('td:nth-child(1)').html(), $(this).children('td:nth-child(2)').html(), $(this).children('td:nth-child(3)').html(), $(this).children('td:nth-child(4)').html(), $(this).children('td:nth-child(5)').html()];
PDFtable.push(trHtml);
});
//console.log(PDFtable);
var savedImg = $('#print-image>img').attr('src');
//console.log(savedImg.src);
var logoImg = $('#print-logo>img').attr('src');
//console.log(savedImg.src);
var docDefinition = {
content: [
{
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: logoImg
},
{
text: PDFtext, fontSize: 12, margin: [ 0, 20, 0, 20 ]
},
{
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: savedImg,
width: 520,
margin: [ 0, 30, 0, 0 ]
},
{
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 0,
widths: [ 'auto', 'auto', 'auto', 'auto', 'auto' ],
body: PDFtable
}
}
]
};
pdfMake.createPdf(docDefinition).download('project.pdf');
};
function saveOrder(){
// console.log("save order 111");
var PDFtable = [];
var PDFtableOrder = [];
var trHtml;
var PDFtextText = $('#print-text-text').html();
var PDFtextSumm = $('#print-text-summ').html();
var PDFtext = PDFtextText+' - '+PDFtextSumm;
// console.log(PDFtextText);
$('#order tr').each(function(index, elem){
trHtml = [$(this).children('td:nth-child(1)').html(), $(this).children('td:nth-child(2)').html()];
PDFtableOrder.push(trHtml);
});
$('#print tr').each(function(index, elem){
trHtml = [$(this).children('td:nth-child(1)').html(), $(this).children('td:nth-child(2)').html(), $(this).children('td:nth-child(3)').html(), $(this).children('td:nth-child(4)').html(), $(this).children('td:nth-child(5)').html()];
PDFtable.push(trHtml);
});
// console.log(PDFtable);
// console.log(PDFtableOrder);
var email = PDFtableOrder[4][1];
var emailOwner = $("#email").attr("src");
var savedImg = $('#print-image>img').attr('src');
// console.log(savedImg.src);
var docDefinition = {
content: [
{
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIMAAAAgCAYAAAAxFcsmAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA0NJREFUeNrsW1FymzAQxZ38h9/OpGP/tj9JTmB8gnADOAK9gX2CcgR8A/sEtm9AfvJNpjPtLzmBo808EpUiIWHAxOyb2bEtr9AiPe2ukJgcj0eHMV78/fbD/fr7Kafvkz8331VsWAilfamiJz52VcpCd2LQcFvM+8+2PtrQ3b/KJo09K6G/rNDXtWEF3ZiIdqjtUIgrZCMkuuK5MUpvQCS4E0IeIQMh4i/cNZ12+t1ATfNp8EGCGTyDz2Tolgj7gZqXgwQ5fhMpcg4T3RLheqAmkldIYGMqhPKHhD3DeYjwAtd8FojEMpWSRwoZESWz5BkWijqpomzRgX1rMLWMXYtt/Ky4Jxq4Xy1dfyeIYKJHRPAwINYrnA4I8Y4r1RJNcYG8oziYKZZlbbaRViwV+56UpxDBsRmrJuAw0S8aE6EPjCmBjIUnyEtlbs82RGXXzGQ4D24HYENAoUl4h0ESgsPEeQiRDNIzCMNUSUlUjm9YNsWK5MYb+SDTiijDCuXBgBCU0MaWy1arBNJ2TChMzBX/uYqyOU/uSiRFto+ZH9ToN8lXOu17DhMdADnB+rPZPaYEsnDjMmYGM7gxIfAcI2AyDNiNSzHY63KwQIhPQwYOE4x/PMNK8V+mKFud0J6q7t5SP2vQhu39tKHf5J5P7ePGmPAZSAaHCQaTgcFkYDAZGLariYuBWNPTs37aG3jfV8Gj4ZljuddSpa+pQ/sMUY1tb8fLhIRCNzO4l+J9ho3JHoZk17LpIZhL8wzUIfT8PkQHEQkClOn2WjIs9WTJFW3Ip73mzseh0jpEsm0G8KEfGepHlvqjCRO+1EEmSMtkUM1eKsebUHv8ppmY1MzaGQbq2YIMEfSn8Cp1XsSH/gPaYzIIPEodSLI1qEOHYnclaRNLfMawLTRw+beo9yyRW0f+a0nPZzJ8uPEtOnLqmB1Jp5PTi5K0lce40uAUJ7FDA6/wAo9DEuA6Ov1H5DjbpqHiUsPEBjPr4OgfXTvS4CxlafHVuGLW3uNFWCLeXOXKJfIUJE50BJK8SCzd+xSbcKMmQwrZgAgxPMVBkRDq/qtDhromSe1aWpkkqOdp9NNicJG7rLEiUukfCvLAmxxQboVXAQYAhvVO2JtEOOcAAAAASUVORK5CYII='
},
{
text: PDFtext, fontSize: 12, margin: [ 0, 20, 0, 20 ]
},
{
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: savedImg,
width: 520,
margin: [ 0, 30, 0, 30 ]
},
{
text: '', fontSize: 12, margin: [ 0, 20, 0, 20 ]
},
{
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 0,
widths: [ 'auto', 'auto'],
body: PDFtableOrder,
margin: [ 0, 30, 0, 30 ]
}
},
{
table: {
// headers are automatically repeated if the table spans over multiple pages
// you can declare how many rows should be treated as headers
headerRows: 0,
widths: [ 'auto', 'auto', 'auto', 'auto', 'auto' ],
body: PDFtable,
margin: [ 0, 30, 0, 30 ]
}
}
]
};
// var pdfDoc = pdfMake.createPdfKitDocument(docDefinition);
// pdfDoc is a stream so you can pipe it to the file system
// pdfDoc.pipe(fs.createWriteStream('orders/order-'& Math.random().toString(36).substr(2, 16) &'.pdf'));
// pdfDoc.end();
// var pdf = pdfMake.createPdf(docDefinition);
// pdf.write('orders/order-'& Math.random().toString(36).substr(2, 16) &'.pdf');
// pdfMake.createPdf(docDefinition).getBuffer(function(buffer) {
// fs.writeFileSync('orders/order-'& Math.random().toString(36).substr(2, 16) &'.pdf', new Buffer(new Uint8Array(buffer)));
// });
//pdfMake.createPdf(docDefinition).download('orders/order-'& Math.random().toString(36).substr(2, 16) &'.pdf');
pdfMake.createPdf(docDefinition).getBuffer(function(buffer) {
var blob = new Blob([buffer]);
var reader = new FileReader();
// this function is triggered once a call to readAsDataURL returns
reader.onload = function(event) {
var fd = new FormData();
fd.append('fname', 'order-' + Math.random().toString(36).substr(2, 16) + '.pdf');
fd.append('data', event.target.result);
fd.append('text', PDFtextText);
fd.append('email', email);
fd.append('email2', emailOwner);
$.ajax({
type: 'POST',
url: 'upload.php', // Change to PHP filename
data: fd,
processData: false,
contentType: false
}).done(function(data) {
// print the output from the upload.php script
console.log(data);
});
};
// trigger the read from the reader...
reader.readAsDataURL(blob);
});
}