Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #114 from jorisvos/bug/emailfix
Browse files Browse the repository at this point in the history
Fixed email
  • Loading branch information
sems authored Dec 9, 2018
2 parents 653ea66 + 8ae98c2 commit 2a2ebb7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
FROM customers C
LEFT JOIN orders O
ON O.CustomerID = C.CustomerID
LEFT JOIN user u
ON c.PrimaryContactPresonID = u.userID
WHERE O.OrderID = :order_id");
$stmt2->execute(['order_id' => $orderID]);
$customer_info = $stmt2->fetch();
Expand Down Expand Up @@ -55,7 +53,8 @@

if ($row['InternalComments'] == "paid") {
$message = $message."
De betaling is gelukt!";
De betaling is gelukt!
<br /><br />";
} else if ($row['InternalComments'] == "open") {
$message = $message."
Er is iets mis gegaan met de betaling.<br />
Expand Down
28 changes: 22 additions & 6 deletions src/forms/f_placeorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
if (isset($_SESSION['PersonID'])) {
# for users with an account

// check if user already excits with the adrress
$stmt = $db->prepare("SELECT CustomerID, PrimaryContactPersonID FROM customers WHERE PrimaryContactPersonID=:person_id");
// check if user already exists with the adrress
$stmt = $db->prepare("SELECT CustomerID, PrimaryContactPersonID, LogonName
FROM customers C
LEFT JOIN user P
ON P.UserID = C.PrimaryContactPersonID
WHERE PrimaryContactPersonID=:person_id");
$stmt->execute(['person_id' => $personID]);
$row = $stmt->fetch();

if (!empty($row)) {
# if customer has address
$basket = json_decode($_COOKIE['basket'], true);
Expand Down Expand Up @@ -41,7 +45,7 @@
$IsUndersupplyBackordered = 0;

try {
$result = '';
/*
{ // Get Customer info ALSO needed when sending email
$stmt2 = $db->prepare("SELECT *
FROM customers C
Expand All @@ -53,6 +57,7 @@
$stmt2->execute(['order_id' => $orderID]);
$result = $stmt2->fetch();
}
*/

$query = "INSERT INTO orders (OrderID, CustomerID, SalespersonPersonID, PickedByPersonID, ContactPersonID, BackorderOrderID, OrderDate, ExpectedDeliveryDate, CustomerPurchaseOrderNumber, IsUndersupplyBackordered, PickingCompletedWhen, LastEditedBy, LastEditedWhen, InternalComments)
VALUES (:order_id, :customer_id, :salesperson_id, :picked_by_person_id, :contactperson_id, :backorder_id, :order_date, :expected_delivery_date, :purchase_order_number, :under_supply, :picking_completed_at, :last_edited_by, :last_edit_when, :internal_comments) ";
Expand All @@ -73,7 +78,7 @@
$dbinsert->bindParam(':picking_completed_at', $currentDate, PDO::PARAM_STR);
$dbinsert->bindParam(':last_edited_by', $personID, PDO::PARAM_STR);
$dbinsert->bindParam(':last_edit_when', $currentDate, PDO::PARAM_STR);
$dbinsert->bindParam(':internal_comments', $result['LogonName'], PDO::PARAM_STR);
$dbinsert->bindParam(':internal_comments', $row['LogonName'], PDO::PARAM_STR);

// Execute call
$dbinsert-> execute();
Expand Down Expand Up @@ -173,6 +178,7 @@
$arrayOrders = array();
$totaal = 0;
$message = '';
$result = '';

{ // Get orderlines
$stmt1 = $db->prepare('SELECT *
Expand Down Expand Up @@ -200,6 +206,17 @@
}
}
}
{ // Get Customer info ALSO needed when sending email
$stmt2 = $db->prepare("SELECT *
FROM customers C
LEFT JOIN orders O
ON O.CustomerID = C.CustomerID
LEFT JOIN user P
ON P.UserID = C.PrimaryContactPersonID
WHERE O.OrderID = :order_id");
$stmt2->execute(['order_id' => $orderID]);
$result = $stmt2->fetch();
}
{ // Change QuantityOnHand
foreach ($arrayOrders as $data) {
$item_id = $data['StockItemID'];
Expand Down Expand Up @@ -270,7 +287,6 @@

// Sending email
sendEmail($result['LogonName'], $result['CustomerName'], "Order: ".$result['OrderID'], $message, true);

// Redirect to payment.php after email is send
header('Location: payment.php');
} catch (Exception $e) {
Expand Down
1 change: 0 additions & 1 deletion src/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ function sendEmail($to, $name, $subject, $body, $makePDFFromEmail = false) {
// Send the message
$result = $mailer->send($message);
} catch (Exception $e) {
$e->getMessage();
setAlert("Er is wat mis gegaan tijdens het verzenden van de email.", "warning");
}
}
Expand Down

0 comments on commit 2a2ebb7

Please sign in to comment.