Created
August 15, 2022 14:52
-
-
Save apalwe/8c9913b0bfb67d3e30e73ac57b613f06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require("../../config.php"); | |
// Fetch user groups allowed to access this file | |
//require '/usr/local/bin/vendor/autoload.php'; | |
require("../../header.php"); | |
require_once __DIR__.'/initialize.php'; | |
$userId = App::Auth()->uid; | |
$id = $_POST['id']; | |
$nominal = trim($_POST['nominal']); | |
//Get the site Inspection details using id | |
$result = mysqli_query($con,"SELECT * FROM design.siteInspection WHERE id = {$id} "); | |
$row = mysqli_fetch_assoc($result); | |
$nominalSelected = $row["nominal"]; | |
$inspectionId = $row["id"]; | |
if ($row["photosUploaded"]== 'No'){ | |
//$pdfPhotos = "No Photos Attached."; | |
$imageFiles = "No Photos Attached."; | |
echo "<script type=\"text/javascript\"> | |
alert(\"No Photos Attached.\"); | |
window.location = \"siteInspection.php\" | |
</script>"; | |
return $imageFiles; | |
} | |
else { | |
//set the prefix for finding bucket key names | |
$prefix_keyName='siteInspectionReport/'. $inspectionId .'_'. $nominalSelected .'_'. $nominalSelected .'_'; | |
$keynames = $s3->getIterator('ListObjects', [ | |
'Bucket' => 'fieldapp', | |
'Prefix' => $prefix_keyName, | |
'Delimiter' => '' | |
]); | |
foreach ($keynames as $keyname) { | |
$folderName='siteInspectionReport'; | |
// get the images and store in array | |
$file = $s3->getObject([ | |
'Bucket' => 'fieldapp', | |
'Prefix' => $folderName.'/', | |
'Key' => $keyname['Key'], | |
]); | |
$imageFiles[]= clone $file; | |
} | |
//echo "<script>print_row(id);</script>"; | |
header("Content-Type: {$file['ContentType']}"); | |
echo $file['Body']; | |
/* echo "<script type=\"text/javascript\"> | |
alert('<?php echo $file ;?>') | |
window.location = \"siteInspection.php\" | |
</script>";*/ | |
/*catch (Exception $exception) { | |
echo "Failed to list objects in $bucket_name with error: " . $exception->getMessage(); | |
exit("Please fix error with listing objects before continuing."); | |
}*/ | |
echo "<script> print_row(389); </script>"; | |
} | |
?> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.debug.js"></script> | |
<script type="text/javascript"> | |
function print_row(id) | |
{ | |
if (!id) | |
var rowid = jQuery("#list0").jqGrid("getGridParam","selrow"); | |
else | |
var rowid = id; | |
let imageFiles = null; | |
//var row = $("#list0").getRowData(rowid); | |
/*$.ajax({ | |
url: "s3/siteInspectionImages.php", | |
type: "GET", | |
context: document.body | |
}).done(function getImg(imageFiles){ | |
//alert(imageFiles); | |
// your code goes here | |
});*/ | |
var doc = new jsPDF(); | |
// {orientation: "portrait", unit: "mm", format: [120, 80]} | |
// set font size | |
doc.setFont("Times"); | |
doc.setFontType("bold"); | |
doc.setFontSize(18); | |
var y = 10; | |
var space = 6; | |
doc.text("Site Inspection Report",75,y); | |
doc.setFont("Helvetica"); | |
doc.setFontType("normal"); | |
doc.setFontSize(11); | |
doc.text("SIR ID: " + id,4,y+=space+4); | |
doc.text("Nominal: " + nominal, 4, y+=space); | |
//doc.text("Site Name: " + row["siteName"], 4, y+=space); | |
//doc.imageData("Photos: " + $imageFiles,4,y+=space+4); | |
//doc.text("Photos: " + imageFiles,4,y+=space+4); | |
window.open(doc.output("bloburl"), "_blank","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes,top=200,left=350,width=600,height=400"); | |
}; | |
</script> | |
<div class="wojo segment"> | |
<div style="margin:10px"> | |
<div class="materialized"> | |
<h3>FE-Site Health Check <i style="font-size: 80%;" class="material-icons">work_outline</i></h3> | |
</div> | |
<div id="tabs-1" style="width:98%"> | |
<?php echo $out;?> | |
</div> | |
<br> | |
</div> | |
</div> | |
<?php include(FRONTBASE . "/footer.tpl.php");?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment