Compare commits

...

2 Commits

@ -128,10 +128,38 @@
</div>
<br />
<h3>Options:</h3>
<h3>Speed:</h3>
<div class="row gtr-uniform">
<div class="col-4 col-12-small">
<input id="postagetype_certified" type="radio" name="postagetype" value="certified" checked="" />
<input id="postagetype_first" type="radio" name="postagetype" value="first" checked="" />
<label for="postagetype_first"><b>First-Class Mail</b>
<br />
2 to 5 day delivery. Tracking only included with Certified Mail service.
</label>
</div>
<div class="col-4 col-12-small">
<input id="postagetype_priority" type="radio" name="postagetype" value="priority" />
<label for="postagetype_priority"><b>Priority Mail</b>
<br />
1-3 day Priority Mail service with tracking.
</label>
</div>
<!-- <div class="col-4 col-12-small">
<input id="postagetype_express" type="radio" name="postagetype" value="express" />
<label for="postagetype_express"><b>Priority Mail Express</b>
<br />
1 to 2 day guaranteed delivery and tracking. Clock starts when
accepted by a USPS mail carrier or employee. Can't be combined with
Certified Mail, but adding normal signature on delivery is free.
</label>
</div> -->
</div>
<br />
<h3>Services:</h3>
<div class="row gtr-uniform">
<div class="col-4 col-12-small">
<input id="postagetype_certified" type="radio" name="postageservice" value="certified" checked="" />
<label for="postagetype_certified"><b>Certified Mail</b>
<br />
Trackable via USPS.com to follow its progress and see the
@ -140,7 +168,7 @@
</label>
</div>
<div class="col-4 col-12-small">
<input id="postagetype_certified_receipt" type="radio" name="postagetype" value="certified_receipt" />
<input id="postagetype_certified_receipt" type="radio" name="postageservice" value="certified_receipt" />
<label for="postagetype_certified_receipt"><b>Certified Mail + Electronic Return Receipt</b>
<br />
With this extra service, after the letter is delivered,
@ -150,13 +178,17 @@
</label>
</div>
<div class="col-4 col-12-small">
<input id="postagetype_first" type="radio" name="postagetype" value="first" />
<label for="postagetype_first"><b>First Class letter</b>
<input id="postagetype_plain" type="radio" name="postageservice" value="plain" />
<label for="postagetype_plain"><b>No Extras</b>
<br />
Make a regular First Class envelope with no tracking, signatures,
or special features. Papers only please, nothing bumpy or hard.
Make an envelope with no special features or signature.
</label>
</div>
</div>
<br />
<h3>Extra Options:</h3>
<div class="row gtr-uniform">
<div class="col-4 col-12-small">
<input id="restricted_delivery" type="checkbox" name="restricted_delivery" value="restricted_delivery" />
<label for="restricted_delivery"><b>Restricted Delivery</b>
@ -164,11 +196,29 @@
Only the named recipient or their legal agent will be allowed to sign for and receive the letter.
</label>
</div>
<div class="col-4 col-12-small">
<input id="label_only" type="checkbox" name="label_only" value="label_only" />
<label for="label_only"><b>Print Postage Only</b>
<br />
Use your own envelope for Priority Mail by selecting this option. You'll get a shipping label to cut out and tape on.
</label>
</div>
<div class="col-4 col-12-small">
<input id="flat_rate" type="checkbox" name="flat_rate" value="flat_rate" />
<label for="flat_rate"><b>Print Flat Rate Postage</b>
<br />
Use a USPS-provided red and white Flat Rate envelope for Priority Mail. You can pick one up at any post office.
</label>
</div>
</div>
<br />
<div id="addresserror"></div>
<br />
<div>
By continuing, you acknowledge that you aren't sending anything except paper documents.
</div>
<br />
<ul class="actions">
<li><a id="getRateAndValidateAddressButton" class="button large primary"><i class="far fa-chevron-right"></i> Next</a></li>
</ul>

@ -10,6 +10,7 @@ var printed = false;
function getRateAndValidateAddress() {
$("#getRateAndValidateAddressButton").html('<i class="far fa-spinner fa-spin"></i> Working...</a>');
disableGetRateButton = true;
$("#addresserror").text("");
$.post("makeshipment.php",
$("#addressform").serialize(),
function (resp) {
@ -28,6 +29,7 @@ function getRateAndValidateAddress() {
$("input[name=from_city]").val(resp.fromaddress.city);
$("input[name=from_state]").val(resp.fromaddress.state);
$("input[name=from_zip]").val(resp.fromaddress.zip);
$("input[name=from_email]").val(resp.fromaddress.email);
$("#toaddr").html(
resp.address.name
@ -69,6 +71,7 @@ function getRateAndValidateAddress() {
$("#getRateAndValidateAddressButton").html('<i class="far fa-chevron-right"></i> Next</a>');
$("#header-small-text").text("Confirm and Pay");
document.getElementById("label").scrollIntoView();
$("#addresserror").text("");
disablePayButton = false;
} else {
$("#addresserror").text(resp.message);
@ -99,7 +102,8 @@ function submitPayment() {
"shipmentid": shipmentid,
"rateid": rateid,
"stripeid": result.paymentMethod.id,
"price": price
"price": price,
"label_only": document.getElementById('label_only').checked ? "1" : ""
},
function (resp) {
if (resp.status == "OK") {

@ -61,27 +61,35 @@ try {
$weight = ($_REQUEST["page_count"] * 1 + 1) / 5;
}
if ($weight > 3.5) {
throw new Exception("Too many pages to send as a letter.");
if ($weight > 3.5 && $_REQUEST["postagetype"] == "first") {
throw new Exception("Too many pages to send as a First-Class letter. Use Priority Mail instead.");
}
if (!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") {
$shipmentinfo["parcel"] = \EasyPost\Parcel::create([
"predefined_package" => "FlatRateEnvelope",
"weight" => $weight
]);
} else {
$shipmentinfo["parcel"] = \EasyPost\Parcel::create([
"predefined_package" => "Letter",
"weight" => $weight
]);
}
$shipmentinfo["parcel"] = \EasyPost\Parcel::create([
"predefined_package" => "Letter",
"weight" => $weight
]);
if (empty($_SETTINGS["test"]) || $_SETTINGS["test"] != true) {
$shipmentinfo["carrier_accounts"] = [$_SETTINGS["easypost_usps_account"]]; // USPS
}
if ($_REQUEST["postagetype"] == "certified") {
if ($_REQUEST["postageservice"] == "certified") {
$shipmentinfo["options"]["certified_mail"] = true;
} else if ($_REQUEST["postagetype"] == "certified_receipt") {
} else if ($_REQUEST["postageservice"] == "certified_receipt") {
$shipmentinfo["options"]["certified_mail"] = true;
$shipmentinfo["options"]["return_receipt"] = true;
}
if ($_REQUEST["restricted_delivery"] == "restricted_delivery") {
if (!empty($_REQUEST["restricted_delivery"]) && $_REQUEST["restricted_delivery"] == "restricted_delivery") {
if (!empty($shipmentinfo["options"]["certified_mail"]) && $shipmentinfo["options"]["certified_mail"] == true) {
$shipmentinfo["options"]["delivery_confirmation"] = "SIGNATURE_RESTRICTED";
} else {
@ -89,8 +97,19 @@ try {
}
}
$shipmentinfo["options"]["label_format"] = "PNG";
$shipmentinfo["options"]["label_size"] = "7x3";
if ($_REQUEST["postagetype"] == "priority") {
$shipmentinfo["options"]["label_format"] = "PNG";
$shipmentinfo["options"]["label_size"] = "4x6";
} else {
$shipmentinfo["options"]["label_format"] = "PNG";
$shipmentinfo["options"]["label_size"] = "7x3";
}
if ($_REQUEST["postagetype"] == "first" && ((!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") || (!empty($_REQUEST["label_only"]) && $_REQUEST["label_only"] == "label_only"))) {
throw new Exception("First-Class Mail can't be combined with the \"Print Postage Only\" or the \"Print Flat Rate Postage\" options.");
}
$mailing_date = date("c", strtotime("tomorrow"));
if (!empty($_REQUEST["mailing_date"])) {
@ -115,13 +134,16 @@ try {
$rate = $shipment->rates[$i];
$retail_rate = $rate->retail_rate ?? ($rate->list_rate ?? $rate->rate);
if ($rate->service != "First") {
if ($_REQUEST["postagetype"] == "priority" && $rate->service != "Priority") {
continue;
}
if ($_REQUEST["postagetype"] == "first" && $rate->service != "First") {
continue;
}
$selectedrate = [
"id" => $rate->id,
"cost" => $retail_rate,
"cost" => $rate->rate,
"price" => $retail_rate + 1.00
];
}
@ -154,7 +176,8 @@ try {
"street2" => $fromaddress->street2 ?? "",
"city" => $fromaddress->city ?? "",
"state" => $fromaddress->state ?? "",
"zip" => $fromaddress->zip ?? ""
"zip" => $fromaddress->zip ?? "",
"email" => $fromaddress->email ?? ""
]]
));
} catch (Exception $ex) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="8.5in"
height="11in"
viewBox="0 0 215.9 279.4"
version="1.1"
id="svg8"
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
sodipodi:docname="papertemplate_labelonly.svg"
inkscape:export-filename="papertemplate-labelonly.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="177.78685"
inkscape:cy="390.92903"
inkscape:document-units="in"
inkscape:current-layer="layer1"
showgrid="false"
units="in"
inkscape:measure-start="24,480"
inkscape:measure-end="24,336"
inkscape:window-width="1920"
inkscape:window-height="1015"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="false"
inkscape:document-rotation="0"
inkscape:showpageshadow="2"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:export-bgcolor="#ffffffff" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-17.6)"
style="display:inline">
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333px;line-height:101.391%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0.264583px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="107.8865"
y="257.28128"
id="text971"><tspan
sodipodi:role="line"
x="107.8865"
y="257.28128"
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-family:Ubuntu;-inkscape-font-specification:'Ubuntu Medium';text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan1023">Instructions:</tspan><tspan
sodipodi:role="line"
x="107.8865"
y="261.57349"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan991">Cut on the dashed lines.</tspan><tspan
sodipodi:role="line"
x="107.8865"
y="265.86572"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan2">Tape your label to your envelope along all four sides.</tspan><tspan
sodipodi:role="line"
x="108.01878"
y="270.15793"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan3">Place envelope in mailbox with signal flag up or in outgoing slot of mailbox cluster.</tspan></text>
<text
id="text1051"
y="283.74017"
x="107.97822"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:100%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0.264583px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
id="tspan1184"
style="font-size:3.52778px;text-align:center;text-anchor:middle;stroke-width:0.264583px"
y="283.74017"
x="108.11051"
sodipodi:role="line">CertifiedFromHome.com</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:0.275002;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1.65001, 1.65001;stroke-dashoffset:0"
id="rect1"
width="157.205"
height="106.405"
x="-235.9025"
y="54.747501"
transform="rotate(-90)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="8.5in"
height="11in"
viewBox="0 0 215.9 279.4"
version="1.1"
id="svg8"
inkscape:version="1.3.2 (1:1.3.2+202311252150+091e20ef0f)"
sodipodi:docname="papertemplate_labelonly_certified.svg"
inkscape:export-filename="papertemplate-labelonly-certified.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"><defs
id="defs2" /><sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="319.20821"
inkscape:cy="483.35799"
inkscape:document-units="in"
inkscape:current-layer="layer1"
showgrid="false"
units="in"
inkscape:measure-start="24,480"
inkscape:measure-end="24,336"
inkscape:window-width="1920"
inkscape:window-height="1015"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="false"
inkscape:document-rotation="0"
inkscape:showpageshadow="2"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:export-bgcolor="#ffffffff" /><metadata
id="metadata5"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-17.6)"
style="display:inline"><text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.23333px;line-height:101.391%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0.264583px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="107.8865"
y="257.28128"
id="text971"><tspan
sodipodi:role="line"
x="107.8865"
y="257.28128"
style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-family:Ubuntu;-inkscape-font-specification:'Ubuntu Medium';text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan1023">Instructions:</tspan><tspan
sodipodi:role="line"
x="107.8865"
y="261.57349"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan991">Cut on the dashed lines.</tspan><tspan
sodipodi:role="line"
x="107.8865"
y="265.86572"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan2">Tape your label to your envelope along all four sides.</tspan><tspan
sodipodi:role="line"
x="108.01878"
y="270.15793"
style="text-align:center;text-anchor:middle;stroke-width:0.264583px"
id="tspan3">Place envelope in mailbox with signal flag up or in outgoing slot of mailbox cluster.</tspan></text><g
id="g1011"
transform="translate(5.9856228,-49.634806)"><g
transform="translate(0,33.937901)"
id="g930"><rect
y="77.158173"
x="51.164379"
height="17.63979"
width="101.6"
id="rect845"
style="opacity:1;fill:#2e7d32;fill-opacity:1;stroke:none;stroke-width:0.258613;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:1.55168, 1.55168;stroke-dashoffset:0;stroke-opacity:1"
rx="2.54"
ry="2.54" /><text
id="text843"
y="88.245018"
x="63.122543"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:6.35px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0.264583px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#ffffff;fill-opacity:1;stroke-width:0.264583px"
y="88.245018"
x="63.122543"
id="tspan841"
sodipodi:role="line">USPS CERTIFIED MAIL™</tspan></text></g></g><text
id="text1051"
y="283.74017"
x="107.97822"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52778px;line-height:100%;font-family:Ubuntu;-inkscape-font-specification:Ubuntu;text-align:center;letter-spacing:0.264583px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
id="tspan1184"
style="font-size:3.52778px;text-align:center;text-anchor:middle;stroke-width:0.264583px"
y="283.74017"
x="108.11051"
sodipodi:role="line">CertifiedFromHome.com</tspan></text><rect
style="fill:none;stroke:#000000;stroke-width:0.292197;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1.75318, 1.75318;stroke-dashoffset:0"
id="rect1"
width="177.5078"
height="106.38781"
x="-236.10561"
y="54.756096"
transform="rotate(-90)" /></g></svg>

After

Width:  |  Height:  |  Size: 5.9 KiB

@ -31,7 +31,7 @@ try {
'payment_method' => $_REQUEST["stripeid"],
'description' => "CertifiedFromHome.com",
'statement_descriptor' => "CrtfdFrmHome",
'payment_method_types' => ['card'],
'payment_method_types' => ['card', 'link'],
'capture_method' => 'manual',
'confirm' => true
]);
@ -57,7 +57,34 @@ try {
// load postage image
$labelimage = imagecreatefrompng($labelurl);
if (!empty($shipment->options->certified_mail)) {
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
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate-labelonly-certified.png");
} else {
// label only
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate-labelonly.png");
}
imagecopyresampled($paperimage, $labelimage, 675, 753, 0, 0, 1200, 1800, 1200, 1800);
} else {
if (!empty($shipment->options->certified_mail)) {
// envelope with banner
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate.png");
} else {
// plain envelope
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_notracking.png");
}
$labelimage = imagerotate($labelimage, 270, 0);
imagecopyresampled($paperimage, $labelimage, 375, 750, 0, 0, 1800, 1200, 1800, 1200);
if ($shipment->options->delivery_confirmation == "SIGNATURE_RESTRICTED") {
$restrictedstamp = imagecreatefrompng(__DIR__ . "/restricted_delivery.png");
$restrictedstamp = imagerotate($restrictedstamp, 270, 0);
imagecopyresampled($paperimage, $restrictedstamp, 2200, 1050, 0, 0, 225, 600, 225, 600);
imagecopyresampled($paperimage, $restrictedstamp, 130, 1050, 0, 0, 225, 600, 225, 600);
}
}
} else if (!empty($shipment->options->certified_mail)) {
// load page template
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate.png");

Loading…
Cancel
Save