diff --git a/source/includes/footer.html b/source/includes/footer.html index e26bb60..2f33b44 100644 --- a/source/includes/footer.html +++ b/source/includes/footer.html @@ -3,7 +3,7 @@ @@ -210,6 +210,13 @@ Use a USPS-provided red and white Flat Rate envelope for Priority Mail. You can pick one up at any post office. +
+ + +

diff --git a/source/pages/sample.md b/source/pages/sample.md index 25087fd..4bb4b0e 100644 --- a/source/pages/sample.md +++ b/source/pages/sample.md @@ -5,4 +5,10 @@ the options you choose. Click the image to get a PDF for a test print. Sample + + +Sample for printing on a #10 envelope: + + + #10 sample \ No newline at end of file diff --git a/source/static/assets/js/shipment.js b/source/static/assets/js/shipment.js index 31eded4..fd67fb3 100644 --- a/source/static/assets/js/shipment.js +++ b/source/static/assets/js/shipment.js @@ -113,7 +113,8 @@ function submitPayment() { "rateid": rateid, "stripeid": result.paymentMethod.id, "price": price, - "label_only": document.getElementById('label_only').checked ? "1" : "" + "label_only": document.getElementById('label_only').checked ? "1" : "", + "no10_envelope": document.getElementById('no10_envelope').checked ? "1" : "" }, dataType: "json", timeout: 1000 * 30, diff --git a/source/static/makeshipment.php b/source/static/makeshipment.php index fdd81f3..773a587 100644 --- a/source/static/makeshipment.php +++ b/source/static/makeshipment.php @@ -78,6 +78,9 @@ try { } if (!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") { + if (!empty($_REQUEST["no10_envelope"]) && $_REQUEST["no10_envelope"] == "no10_envelope") { + throw new Exception("You can't use your own envelope with Priority Mail Flat Rate. Use a USPS-provided Flat Rate envelope instead."); + } $shipmentinfo["parcel"] = \EasyPost\Parcel::create([ "predefined_package" => "FlatRateEnvelope", "weight" => $weight diff --git a/source/static/papertemplate_no10.png b/source/static/papertemplate_no10.png new file mode 100644 index 0000000..8b919b5 Binary files /dev/null and b/source/static/papertemplate_no10.png differ diff --git a/source/static/papertemplate_no10.svg b/source/static/papertemplate_no10.svg new file mode 100644 index 0000000..77eecb7 --- /dev/null +++ b/source/static/papertemplate_no10.svg @@ -0,0 +1,82 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/source/static/papertemplate_no10_4x6_certified.png b/source/static/papertemplate_no10_4x6_certified.png new file mode 100644 index 0000000..6ddc5f1 Binary files /dev/null and b/source/static/papertemplate_no10_4x6_certified.png differ diff --git a/source/static/papertemplate_no10_4x6_certified.svg b/source/static/papertemplate_no10_4x6_certified.svg new file mode 100644 index 0000000..74c49fe --- /dev/null +++ b/source/static/papertemplate_no10_4x6_certified.svg @@ -0,0 +1,91 @@ + +image/svg+xmlUSPS CERTIFIED MAILâ„¢ diff --git a/source/static/papertemplate_no10_certified.png b/source/static/papertemplate_no10_certified.png new file mode 100644 index 0000000..7603c5f Binary files /dev/null and b/source/static/papertemplate_no10_certified.png differ diff --git a/source/static/papertemplate_no10_certified.svg b/source/static/papertemplate_no10_certified.svg new file mode 100644 index 0000000..15682f5 --- /dev/null +++ b/source/static/papertemplate_no10_certified.svg @@ -0,0 +1,142 @@ + + + + + + + + image/svg+xml + + + + + + + + + + USPS CERTIFIED MAILâ„¢ + + + + + + + + + RESTRICTEDDELIVERY + + + diff --git a/source/static/payshipment.php b/source/static/payshipment.php index e65bd87..678ce78 100644 --- a/source/static/payshipment.php +++ b/source/static/payshipment.php @@ -57,7 +57,37 @@ try { // load postage image $labelimage = imagecreatefrompng($labelurl); - if ($shipment->postage_label->label_size == "4x6") { + $paperSize = "Letter"; + $paperOrientation = "P"; + if (!empty($_REQUEST["no10_envelope"]) && $_REQUEST["no10_envelope"] == "1") { + $paperSize = [9.5, 4.125]; + $paperOrientation = "L"; + if ($shipment->postage_label->label_size == "4x6") { + if (!empty($shipment->options->certified_mail)) { + // envelope with banner + $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10_4x6_certified.png"); + } else { + // plain envelope + $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10.png"); + } + $labelimage = imagerotate($labelimage, 270, 0); + imagecopyresampled($paperimage, $labelimage, 525, 19, 0, 0, 1200, 1800, 1200, 1800); + } else { + if (!empty($shipment->options->certified_mail)) { + // envelope with banner + $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10_certified.png"); + imagecopyresampled($paperimage, $labelimage, 375, 190, 0, 0, 2100, 900, 2100, 900); + if ($shipment->options->delivery_confirmation == "SIGNATURE_RESTRICTED") { + $restrictedstamp = imagecreatefrompng(__DIR__ . "/restricted_delivery.png"); + imagecopyresampled($paperimage, $restrictedstamp, 450, 825, 0, 0, 600, 225, 600, 225); + } + } else { + // plain envelope + $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10.png"); + imagecopyresampled($paperimage, $labelimage, 375, 90, 0, 0, 2100, 900, 2100, 900); + } + } + } else if ($shipment->postage_label->label_size == "4x6") { if ((!empty($_REQUEST["label_only"]) && $_REQUEST["label_only"] == "1") || $shipment->parcel->predefined_package == "FlatRateEnvelope") { if (!empty($shipment->options->certified_mail)) { // label and banner only @@ -109,7 +139,7 @@ try { imagepng($paperimage, $tmpfile); // Generate PDF from image - $pdf = new FPDF('P', 'in', 'Letter'); + $pdf = new FPDF($paperOrientation, 'in', $paperSize); $pdf->AddPage(); $pdf->Image($tmpfile, 0, 0, -300, -300, "PNG"); diff --git a/source/static/sample_no10.pdf b/source/static/sample_no10.pdf new file mode 100644 index 0000000..5d57b79 Binary files /dev/null and b/source/static/sample_no10.pdf differ diff --git a/source/static/sample_no10.png b/source/static/sample_no10.png new file mode 100644 index 0000000..1153418 Binary files /dev/null and b/source/static/sample_no10.png differ diff --git a/source/static/sample_no10.svg b/source/static/sample_no10.svg new file mode 100644 index 0000000..9e86ea6 --- /dev/null +++ b/source/static/sample_no10.svg @@ -0,0 +1,202 @@ + + + + + + + + image/svg+xml + + + + + + + + + + USPS CERTIFIED MAILâ„¢ + + + + + + + + + FROM NAME123 SAMPLE RDHELENA MT 59601 + + GYM, LANDLORD, COURT, ETC900 SHADY ST STE 42NEW YORK NY 10001 + + + RESTRICTEDDELIVERY + + + + diff --git a/source/static/sample_no10_300dpi.png b/source/static/sample_no10_300dpi.png new file mode 100644 index 0000000..d794205 Binary files /dev/null and b/source/static/sample_no10_300dpi.png differ