be9eddd7 by Jeff Balicki

edit pdf done

1 parent 362be453
......@@ -139,10 +139,10 @@ class ApiController extends Controller
$pdf = new PdfController();
$pdf = $pdf->pdf($pdfId);
//$response = $pdf;
$response = $pdfId;
$statusCode = 200;
return Response::json('good', $statusCode);
return Response::json( $response, $statusCode);
......@@ -177,13 +177,14 @@ class ApiController extends Controller
public function getpdfgoogle($json)
{
$id = new pdfModel();
$id = $id->getpdfid($json)->get();
$rows = new pdfModel();
$id = $rows->getpdfid($json)->get();
$rows = new pdfModel();
// $rows = new pdfModel();
$rows = $rows->getpdf($id[0]->pdfid)->get();
$response = $rows;
$statusCode = 200;
//var_dump($rows);
return Response::json($response, $statusCode);
}
......
......@@ -33,7 +33,7 @@ class PdfController extends Controller
$searchpath = "$folder";
$pdffile = $searchpath.'/'.$rows[0]->file;
//$outfile="";
$title = "Test Pages";
$pageHeight = $rows[0]->pheight;
$pageWidth = $rows[0]->pwidth;
......@@ -61,8 +61,8 @@ try {
if ($p->begin_document($outfile, "") == 0)
die("Error: " . $p->get_errmsg());
$p->set_info("Creator", "Rock Star Jeff");
$p->set_info("Title", $title );
$p->set_info("Creator", "Tenzing Communications");
$p->set_info("Title", $rows[0]->name );
/* Open the input PDF */
$response = $storagePath.$pdffile;
......
......@@ -32,12 +32,12 @@ class pdfModel extends Model
$rows = DB::table('PDF')
->join('changesPDF', 'PDF_idPDF', '=', 'idPDF')
->join('stylesPDF', 'stylesPDF_idstylesPDF', '=', 'idstylesPDF')
->join('change_typePDF', 'idchange_typePDF', '=', 'change_typePDF_idchange_typePDF')
->where('PDF.idPDF','=', $id)
->orderBy('changesPDF.order', 'asc');
->orderBy('changesPDF.order', 'ASC');
return $rows;
}
......@@ -137,7 +137,7 @@ class pdfModel extends Model
);
$idchangesPDF = DB::table('changesPDF')->insertGetId(
array('PDF_idPDF' => $pdfId, 'change_typePDF_idchange_typePDF' => $change->idchange_typePDF, 'stylesPDF_idstylesPDF' => $idstylesPDF, 'locationUp' => $change->locationUp, 'locationRight' => $change->locationRight, 'width' => $change->width, 'height' => $change->height, 'pages' => $change->pages, 'content' => $content, 'z-index' => '')
array('PDF_idPDF' => $pdfId, 'change_typePDF_idchange_typePDF' => $change->idchange_typePDF, 'stylesPDF_idstylesPDF' => $idstylesPDF, 'locationUp' => $change->locationUp, 'locationRight' => $change->locationRight, 'width' => $change->width, 'height' => $change->height, 'names'=> $change->names, 'example'=> $change->example, 'tips'=> $change->tips, 'order'=> $change->order, 'pages' => $change->pages, 'content' => $content, 'z-index' => '')
);
}
......
//var pluginUrl = "http://localhost:8888/Forms";
//var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
var pluginUrl = "http://localhost:8888/Forms";
var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
//var pluginUrl = "http://contact.gotenzing.com";
//var pdf_customizer = "http://pdf-customizer.synapsus.co";
var imageHeight="";
var imageWidth="";
var edit = false;
var pluginUrl = "http://contact.gotenzing.com";
var pdf_customizer = "http://pdf-customizer.synapsus.co";
function getAuth() {
jQuery(document).ready(function($) {
......@@ -138,8 +145,21 @@ function getOneJson(id) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
edit = false;
changePdfOptions(json,edit);
});
});
}
function getBackOneJson(id) {
jQuery(document).ready(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
//$('#google_drive').show();
edit = true;
changePdfOptions(json);
changePdfOptions(json,edit);
});
});
}
......@@ -159,16 +179,25 @@ function pickPdfFromList(json) {
}
strVar += ' <div class="callout primary"><div class="row column"> <h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
strVar += ' ';
strVar += '</div></div></div><div id="contentAreaOver"></div> ';
document.getElementById('contentArea').innerHTML = strVar;
});
}
function changePdfOptions(json) {
function changePdfOptions(json, edit) {
jQuery(function($) {
if(edit == false){
$('#contentAreaOver').hide();
}
console.log( json );
json = JSON.parse(json);
$(document).ready(function() {
$("#changescontentdate").datepicker({
plugins: "tabfocus",
changeMonth: true,
......@@ -191,6 +220,7 @@ function changePdfOptions(json) {
error.insertAfter(element);
}
}
});
});
......@@ -199,14 +229,31 @@ function changePdfOptions(json) {
var pdfChange = "";
var f = 0;
var scaleImage = 350 / json[0].pwidth;
var windowWidth = 0.68 * $(window).width();
var windowHeight = 0.86 * $(window).height();
var windowHBG = 0.923 * $(window).height();
if(json[0].pwidth > json[0].pheight){
var scaleImage = windowWidth / json[0].pwidth;
var imageHeight = json[0].pheight * scaleImage;
var imageWidth = 350;
console.log(json[0].pheight, scaleImage, imageHeight);
var imageWidth = windowWidth;
var imgLeft = 0;
var imgTop = 25;
}else{
var scaleImage = windowHeight / json[0].pheight;
var imageHeight = windowHeight;
var imageWidth = json[0].pwidth * scaleImage;
var imgLeft = 30;
var imgTop = 2;
}
console.log(windowWidth ,windowHeight, imageWidth, imageHeight);
pdflist += '<div id="pdfPreview" class="column">';
pdflist += '<div id="pdfPreview" style="" class="column">';
// pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">';
pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" margin-top:30px; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px"></div>';
pdflist += '<canvas id="Canvas" width="' + imageWidth + '" height="' + imageHeight + '" style=" margin-top:'+imgTop+'%; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:' + imageWidth + 'px ' + imageHeight + 'px"></div>';
pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"></br><h4>' + json[0].name + '</h4>';
pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
for (i = 0; i < json.length; ++i) {
......@@ -222,9 +269,16 @@ function changePdfOptions(json) {
pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>';
}
if (json[i].change_type == "img") {
pdfChange += json[i].names + ':<label onfocusout="HideBox()" onfocus=" ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input tabindex="-1" class="fileupload upload required" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button"></span><strong>Browse</strong></span></label>';
if(edit == true){
pdfChange += '<input value="'+json[i].content+'" tabindex="-1" class="required" id="hiddenchangescontent[' + i + ']" type="hidden" name="content[' + i + ']" >';
pdfChange += json[i].names + ':<label onfocusout="HideBox()" onfocus=" ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input tabindex="-1" class="fileupload upload" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">'+json[i].content+'</span><strong>Browse</strong></span></label>';
}else{
pdfChange += json[i].names + ':<label onfocusout="HideBox()" onfocus=" ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="focusButton' + i + '" class="custom-file-input" tabindex="0"><input value="'+json[i].content+'" tabindex="-1" class="fileupload upload required" id="changescontent[' + i + ']" type="file" name="content[' + i + ']" ><span class="file-button"><span class="file-name file-button">'+json[i].content+'</span><strong>Browse</strong></span></label>';
}
pdfChange += '<span id="span' + i + '">' + json[i].tips + '</span><br/>';
}
}
if (json[i].change_type == "date") {
pdfChange += json[i].names + ': <input onfocusout="HideBoxwithdate()" onfocus="ShowBox(' + json[0].pheight + ',' + json[0].pwidth + ',' + json[i].locationUp + ',' + json[i].locationRight + ',' + json[i].height + ',' + json[i].width + ',' + i + ',\'' + example + '\')" id="changescontentdate" type="text" class="required date" name="content[' + i + ']" value="' + json[i].content + '"">';
pdfChange += '<span id="span' + i + '"> </span><br/>';
......@@ -232,19 +286,23 @@ function changePdfOptions(json) {
}
}
pdfChange += '<input type="submit" value="Save and download">';
pdfChange += '<input type="submit" value="Save and Continue">';
pdfChange += '</form>';
strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
strVar2 += '';
strVar2 += ' </div></div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3">';
strVar2 += pdflist + '<div id="changesColumn" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>';
strVar2 += '';
strVar2 += '</div><div id="wrapper" class="black small-up-2 medium-up-3 large-up-3" style="height:'+windowHBG+'px;"> <a class="closeEditer"><i class="fa fa-times fa-1x"></i></a>';
strVar2 += pdflist + '<div id="changesColumn" style="height:'+windowHBG+'px;" class="column" >' + pdfChange + '<div id="tezingLogo"></div></div><div id="pdfFooter"></div></div>';
document.getElementById('contentArea').innerHTML = strVar2;
document.getElementById('google_drive').innerHTML = " ";
document.getElementById('contentAreaOver').innerHTML = strVar2;
if(edit == false){
$("#contentAreaOver").slideToggle();
$('#google_drive').slideToggle();
//document.getElementById('google_drive').innerHTML = " ";
}
var tinymces = tinymce.init({
selector: '.textarea',
entity_encoding: "raw",
......@@ -281,6 +339,14 @@ function changePdfOptions(json) {
});
}
});
$('.closeEditer').click(function() {
$("#contentAreaOver").slideToggle(function(){
edit = false;
tinyMCE.remove();
});
$('#google_drive').slideToggle();
});
var files;
var imagefiles = [];
......@@ -319,9 +385,10 @@ function changePdfOptions(json) {
});
$("#changes").submit(function(e) {
e.preventDefault();
if ($("#changes").valid()) {
$(tinymce.get()).each(function(i, el) {
......@@ -330,8 +397,24 @@ function changePdfOptions(json) {
$('#changes').hide();
tinymce.get(el.id).remove();
});
if ($("#changes").valid()) {
var ids =[];
if(edit == true){
$("#changes input[type=file]").each(function() {
if($(this).get(0).files.length == 0 ){
document.getElementById(this.id).remove();
}else{
console.log("hidden"+this.id);
document.getElementById("hidden"+this.id).remove();
}
});}
var form = $("#changes");
console.log(form);
returnfileOptions(imagefiles, form);
return false;
......@@ -380,6 +463,8 @@ function returnfileOptions(files, form) {
});
}
function returnOptions(form) {
......@@ -387,21 +472,22 @@ function returnOptions(form) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
// Get the element with id summary and set the inner text to the result.
var json = dataReturnd;
//console.log(json);
var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pageWidth + '","pageHeight":"' + json[0].pageHeight + '"}],"changes":['
var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pwidth + '","pageHeight":"' + json[0].pheight + '"}],"changes":['
var e = 1;
for (i = 0; i < json.length; ++i) {
var style = JSON.stringify(json[i].style);
var content = JSON.stringify(form[0][e].value);
console.log(form[0][e].value);
//console.log(form[0][e].value);
//console.log(json[i].label+' '+json[i].order);
jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}';
jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style +', "names":"' + json[i].names +'", "example":"' + json[i].example +'", "tips":"' + json[i].tips + '", "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/pdf/"}';
if (i < json.length - 1) {
......@@ -410,7 +496,33 @@ function returnOptions(form) {
++e
}
jsonReturn += ' ]}';
var windowWidth = 0.68 * $(window).width();
var windowHeight = 0.86 * $(window).height();
var windowHBG = 0.923 * $(window).height();
if(json[0].pwidth > json[0].pheight){
var scaleImage = windowWidth / json[0].pwidth;
var imageHeight = json[0].pheight * scaleImage;
var imageWidth = windowWidth;
var imgLeft = 0;
var imgTop = 25;
}else{
var scaleImage = windowHeight / json[0].pheight;
var imageHeight = windowHeight;
var imageWidth = json[0].pwidth * scaleImage;
var imgLeft = 30;
var imgTop = 2;
}
// console.log(jsonReturn);
$("#Canvas").fadeOut(60000000);
$.ajax({
......@@ -418,25 +530,48 @@ function returnOptions(form) {
type: "POST",
dataType: 'json',
data: jsonReturn,
processData: false,
contentType: "application/json",
CrossDomain: true,
async: true,
success: function(data) {
var strVar2 = ""
strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">';
strVar2 += '<br/><br/>' + '<a class="downloadpdf" href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a></div>';
// strVar2 += ' <div class="callout primary"><div class="row column"><h1 class="pdfeditortitle">CUBOS COLLATERAL MATERIAL</h1>';
//strVar2 += '</div></div><div class="row small-up-2 medium-up-3 large-up-3">';
strVar2 += '<div id="seepdf" style=" display:hidden; width:'+imageWidth+'px;" ><a class="media" style="display: block; margin-left:auto; margin-right:auto; " href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ></a></div>';
//<i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>
document.getElementById('pdfPreview').innerHTML = strVar2;
$('#changes').replaceWith('<div id="changes"></div>')
var strVar3 ='<div id="button"><input id="editMe" type="submit" value="Edit"><a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><input id="downloadMe" type="submit" value="Download"></a> </div>';
document.getElementById('changes').innerHTML = strVar3;
//console.log(data);
// $('#changes').show();
$("#seepdf").fadeIn(60000000);
$('a.media').media({width:imageWidth, height:imageHeight});
$('#editMe').click(function() {
$("#google_drive").hide();
getBackOneJson(data);
});
document.getElementById('contentArea').innerHTML = strVar2
},
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
alert(xhr.status);
document.getElementById('contentArea').innerHTML = xhr.responseText;
document.getElementById('pdfPreview').innerHTML = xhr.responseText;
}
});
});
});
}
\ No newline at end of file
......