|
|
@@ -293,6 +293,7 @@ $controller = new class($document_type, $document_number) {
|
|
|
$item->dts_created = Database::dts();
|
|
|
}
|
|
|
|
|
|
+ $item->product_id = $this->request->int("product_id");
|
|
|
$item->description = $this->request->string("description");
|
|
|
$item->serial_number = $this->request->string("serial_number");
|
|
|
$item->quantity = $this->request->int("quantity");
|
|
|
@@ -370,6 +371,7 @@ $controller = new class($document_type, $document_number) {
|
|
|
foreach($items as $item) {
|
|
|
$document_item = new DocumentItem();
|
|
|
$document_item->document_id = $document->id;
|
|
|
+ $document_item->product_id = $item->product_id;
|
|
|
$document_item->description = $item->description;
|
|
|
$document_item->serial_number = $item->serial_number;
|
|
|
$document_item->quantity = $item->quantity;
|
|
|
@@ -432,6 +434,8 @@ $controller = new class($document_type, $document_number) {
|
|
|
|
|
|
public function emailPdf(): void {
|
|
|
|
|
|
+ $include_brochures = $this->request->int("include_brochures");
|
|
|
+
|
|
|
$document = $this->requireDocument();
|
|
|
$core = Core::getInstance();
|
|
|
|
|
|
@@ -494,6 +498,15 @@ $controller = new class($document_type, $document_number) {
|
|
|
$mailer->AltBody = strip_tags($body);
|
|
|
$mailer->addAttachment($pdf_path, $title . ".pdf");
|
|
|
|
|
|
+ if($include_brochures) {
|
|
|
+ foreach($document->getProducts() as $product) {
|
|
|
+ if($product->hasBrochure()) {
|
|
|
+ $attachment_name = $product->name . ".pdf";
|
|
|
+ $mailer->addAttachment($product->getBrochurePath(), $attachment_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$mailer->send();
|
|
|
|
|
|
Json::success();
|
|
|
@@ -501,9 +514,7 @@ $controller = new class($document_type, $document_number) {
|
|
|
catch(Exception $e) {
|
|
|
Json::fail($e->getMessage());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
};
|
|
|
|
|
|
switch($action) {
|