Skip to content

Commit

Permalink
Some change to prior PR#7429 (openemr#7447)
Browse files Browse the repository at this point in the history
* Some change to prior PR
- revert jspdf to prior version 2.5.1
- use jspdf UMD version in fax viewers. I misconfigure in my first tries at UMD for this library.

* - php warnings
- file extension invalid for forward email. Missing period
  • Loading branch information
sjpadgett committed May 21, 2024
1 parent 1daecba commit c49a6ac
Show file tree
Hide file tree
Showing 6 changed files with 1,561 additions and 3,388 deletions.
5 changes: 1 addition & 4 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ assets:
script: jszip.min.js
jspdf:
basePath: '%assets_static_relative%/jspdf/dist/'
script: jspdf.min.js
jspdfdebug:
basePath: '%assets_static_relative%/jspdf/dist/'
script: jspdf.debug.js
script: jspdf.umd.min.js
jstiff:
basePath: '%assets_static_relative%/tiff/'
script: tiff.min.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ function getLayoutRes()
$form_city = '';
$form_postcode = '';
$form_countrycode = '';
$form_regdate = DateToYYYYMMDD(trim($_POST['regdate']));
$form_regdate = DateToYYYYMMDD(trim($_POST['regdate'] ?? ''));
newPatientData(
$_POST["db_id"],
$_POST["db_id"] ?? '',
$_POST["title"] ?? '',
$form_fname,
$form_lname,
Expand Down Expand Up @@ -160,16 +160,16 @@ function getLayoutUOR($form_id, $field_id)
$_POST = $data;
unset($data);
}
$form_pubpid = $_POST['pubpid'] ? trim($_POST['pubpid']) : '';
$form_title = $_POST['title'] ? trim($_POST['title']) : '';
$form_fname = $_POST['fname'] ? trim($_POST['fname']) : '';
$form_mname = $_POST['mname'] ? trim($_POST['mname']) : '';
$form_lname = $_POST['lname'] ? trim($_POST['lname']) : '';
$form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
$form_sex = $_POST['sex'] ? trim($_POST['sex']) : '';
$form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
$form_dob = $_POST['DOB'] ? trim($_POST['DOB']) : '';
$form_regdate = $_POST['regdate'] ? trim($_POST['regdate']) : date('Y-m-d');
$form_pubpid = $_POST['pubpid'] ?? '' ? trim($_POST['pubpid']) : '';
$form_title = $_POST['title'] ?? '' ? trim($_POST['title']) : '';
$form_fname = $_POST['fname'] ?? '' ? trim($_POST['fname']) : '';
$form_mname = $_POST['mname'] ?? '' ? trim($_POST['mname']) : '';
$form_lname = $_POST['lname'] ?? '' ? trim($_POST['lname']) : '';
$form_refsource = $_POST['refsource'] ?? '' ? trim($_POST['refsource']) : '';
$form_sex = $_POST['sex'] ?? '' ? trim($_POST['sex']) : '';
$form_refsource = $_POST['refsource'] ?? '' ? trim($_POST['refsource']) : '';
$form_dob = $_POST['DOB'] ?? '' ? trim($_POST['DOB']) : '';
$form_regdate = $_POST['regdate'] ?? '' ? trim($_POST['regdate']) : date('Y-m-d');

?>
<!DOCTYPE html>
Expand Down
10 changes: 7 additions & 3 deletions interface/modules/custom_modules/oe-module-faxsms/messageUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,21 @@ function showPrint(base64, _contentType = 'image/tiff') {

// Function to convert images to PDF and return a base64
async function convertImagesToPdf(images, filename = 'fax-tiff-to-pdf.pdf') {
const {jsPDF} = window.jspdf;
const doc = new jsPDF();
const pageHeight = doc.internal.pageSize.getHeight();
doc.internal.write.isEvalSupported = false;
const pageHeight = doc.internal.pageSize.height;
const pageWidth = doc.internal.pageSize.width;

for (let i = 0; i < images.length; i++) {
if (i !== 0) {
doc.addPage();
}
doc.addImage(images[i], 'JPEG', 10, 10, 190, pageHeight - 20);
doc.addImage(images[i], 'JPEG', 0, 0, pageWidth, pageHeight);
}

return doc.output('datauristring').split(',')[1]; // Return only the Base64 part
// Return the PDF as base64 string
return doc.output('datauristring').split(',')[1];
}

function showDocument(_base64, _contentType = 'image/tiff') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function forwardFax(): string

$content = $fax->FaxImage;
$c_header = $fax->DocumentParams->Type;
$ext = $c_header == 'application/pdf' ? 'pdf' : ($c_header == 'image/tiff' || $c_header == 'image/tif' ? 'tiff' : 'txt');
$ext = $c_header == 'application/pdf' ? '.pdf' : ($c_header == 'image/tiff' || $c_header == 'image/tif' ? '.tiff' : '.txt');
$filepath = $this->baseDir . "/send/" . ($jobId . $ext);

if (!file_exists($this->baseDir . '/send')) {
Expand Down Expand Up @@ -430,7 +430,7 @@ public function viewFax(): string
throw new Exception(sprintf('Directory "%s" was not created', $faxStoreDir));
}

$file_name = "{$faxStoreDir}/Fax_{$docId}." . ($c_header == 'application/pdf' ? 'pdf' : ($c_header == 'image/tiff' ? 'tiff' : 'txt'));
$file_name = "{$faxStoreDir}/Fax_{$docId}" . ($c_header == 'application/pdf' ? '.pdf' : ($c_header == 'image/tiff' ? '.tiff' : '.txt'));
file_put_contents($file_name, base64_decode($faxImage));
$this->setSession('where', $file_name);
$this->setFaxDeleted($apiResponse->JobId);
Expand Down
Loading

0 comments on commit c49a6ac

Please sign in to comment.