Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*LOAD MAIL CLASS*/
- require_once('/var/www/restock/include/class.phpmailer.php');
- $order_mail = new PHPMailer();
- $order_mail->IsSMTP(); //telling class to use SMTP
- $order_mail->SMTPDebug = 1;
- $order_mail->Host = "relay-hosting.secureserver.net";
- //$order_mail->AddReplyTo("[email protected]","Name");
- //$order_mail->AddAddress("[email protected]","Name");
- //$order_mail->AddAddress("[email protected]","Name");
- $order_mail->Subject = "New Order from " . $_SESSION['company_name'];
- /*query to get the next order number*/
- $query = "SELECT Auto_increment
- FROM information_schema.tables
- WHERE table_name='orderHead'";
- $result = mysqli_query($mysqli_db, $query);
- $new_order_num = mysqli_fetch_array($result);
- $order_mail->IsHTML(TRUE);
- $body = "<style type='text/css'>h3, p, table td {font-family:arial;}</style>";
- $body .= "<h3>Order " . $new_order_num[0]++ . " from " . $_SESSION['company_name'] . " Epicor ID: " . $_SESSION['epicor_id'] ."</h3>";
- //$body .= "<h3>PO 4510153722</h3>";
- $body .= "<table>";
- $body .= "<tr><td><u>SD Part Number</u></td><td><u>Quantity</u></td><td><u>UOM</u></td></tr>";
- foreach($_POST as $key => $value) {
- /*from $_POST only process the input boxes, ignoring the other $_POST variables*/
- if (strpos($key, "input-final-qty-") !== FALSE) {
- $quantity_to_order = mysqli_real_escape_string($mysqli_db, (trim($value)));
- $part_id = str_replace('input-final-qty-','', $key);
- //see if the matching rush checkbox was set (highlight rush parts)
- $matching_rush_input_id = 'input-rush-' . $part_id;
- $rush_part_style = (array_key_exists($matching_rush_input_id, $_POST)) ? "background-color:#fba7a7;" : "";
- //create query to get part number based on partID
- $query = "SELECT partNumber, conversionFactor, UOMOrder
- FROM part
- WHERE partID = '" . $part_id . "'
- ORDER BY savedRush DESC, partID
- LIMIT 1";
- //run query
- $result = mysqli_query($mysqli_db, $query);
- //get result
- $row = mysqli_fetch_array($result);
- $quantity_to_order = $quantity_to_order * $row[1];
- $body .= "<tr><td style='". $rush_part_style . "'>" . $row[0] . "</td> <td align='center' style='" . $rush_part_style . "'>" . $quantity_to_order . "</td> <td>" . $row[2] . "</td></tr>";
- mysqli_free_result($result);
- }
- }
- /*check for user typed note*/
- $order_message = "";
- if (isset($_POST['order-message-confirm'])) { //user typed something
- //sanitize input
- $order_message = mysqli_real_escape_string($mysqli_db, trim($_POST['order-message-confirm']));
- //attach note to email if there was one
- if ($order_message != "") {
- $body .= "</table><p style='font-size:10pt;'><br /><br /><u>Special Note / Comments / Request / Instructions</u><br />";
- $body .= "<span style='font-weight:normal; font-size:12pt;'>" . $order_message . "</span></p>";
- }
- else { $body .="</table>"; }
- }
- else { $body .= "</table>"; }
- $order_mail->Body = $body;
- /*SEND MAIL*/
- if (!$order_mail->Send()) {
- $order_sent = FALSE;
- } else {
- $order_sent = TRUE;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment