MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b744/yushibrentwood.com/
File Upload :
Current < : /hermes/sb_web/b744/yushibrentwood.com/show_order.050317.php

<?php
/*
  MailBeez Automatic Trigger Email Campaigns
  http://www.mailbeez.com

  Copyright (c) 2010 MailBeez
	
	inspired and in parts based on
  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
	
	v1.7
*/


// disable Gzip compression
  define('GZIP_COMPRESSION', 'false');
  define('GZIP_LEVEL', '0');
define('SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT', 'Order--');
define('EMAIL_TEXT_DELIVERY_DATE', 'Delivery or Pickup Date:');
define('EMAIL_SEPARATOR', '------------------------------------------------------');
define('EMAIL_TEXT_SUBJECT', 'Order Update');
define('EMAIL_TEXT_ORDER_NUMBER', 'Order Number:');
define('EMAIL_TEXT_INVOICE_URL', 'Detailed Invoice:');
define('EMAIL_TEXT_STATUS_COMMENTS', 'Status Changed:');
define('EMAIL_TEXT_DATE_ORDERED', 'Date Ordered:');
define('EMAIL_TEXT_COMMENTS_UPDATE', '<em>The comments for your order are: </em>');
define('EMAIL_TEXT_STATUS_UPDATED', 'Your order has been updated to the following status:' . "\n");
define('EMAIL_TEXT_STATUS_LABEL', '<strong>New status:</strong> %s' . "\n\n");
define('EMAIL_TEXT_STATUS_PLEASE_REPLY', 'Please reply to this email if you have any questions.' . "\n");
define('EMAIL_TEXT_NEW_STATUS', 'New Order Status:');
//EMAIL_TEXT_NEW_STATUS EMAIL_TEXT_STATUS_COMMENTS EMAIL_CUSTOMERS_NAME SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT
define('EMAIL_TEXT_STATUS_UPDATE', 'Your order has been updated to the following status.' . "\n\n" . 'New status: %s' . "\n\n" . 'Please reply to this email if you have any questions.' . "\n");


 // define('STRICT_ERROR_REPORTING', true);

  require('includes/application_top.php');

	// zencart, xtcommerce
	if (!defined('DIR_WS_HTTP_CATALOG')) define('DIR_WS_HTTP_CATALOG', DIR_WS_CATALOG);	
	
	define('TEXT_EMAIL_ALREADY_SEND', 'was already sent: ');
	define('TEXT_EMAIL_SEND', 'successfully sent: ');

  require_once(DIR_FS_CATALOG. 'mailhive/common/functions/compatibility.php');
  require_once(DIR_FS_CATALOG. 'mailhive/common/classes/mailbeez.php');		
  require(DIR_FS_CATALOG . 'mailhive/common/classes/mailhive.php');
  include(DIR_WS_CLASSES . 'order.php');

  function zen_remove_order($order_id, $restock = false) {
    global $db;
    if ($restock == 'on') {
      $order = $db->Execute("select products_id, products_quantity
                             from " . TABLE_ORDERS_PRODUCTS . "
                             where orders_id = '" . (int)$order_id . "'");

      while (!$order->EOF) {
        $db->Execute("update " . TABLE_PRODUCTS . "
                      set products_quantity = products_quantity + " . $order->fields['products_quantity'] . ", products_ordered = products_ordered - " . $order->fields['products_quantity'] . " where products_id = '" . (int)$order->fields['products_id'] . "'");
        $order->MoveNext();
      }
    }

    $db->Execute("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
    $db->Execute("delete from " . TABLE_ORDERS_PRODUCTS . "
                  where orders_id = '" . (int)$order_id . "'");

    $db->Execute("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
                  where orders_id = '" . (int)$order_id . "'");

    $db->Execute("delete from " . TABLE_ORDERS_STATUS_HISTORY . "
                  where orders_id = '" . (int)$order_id . "'");

    $db->Execute("delete from " . TABLE_ORDERS_TOTAL . "
                  where orders_id = '" . (int)$order_id . "'");

  }
function format_phone($num) 
	{ 
    $num = ereg_replace('[^0-9]', '', $num); 

    $len = strlen($num); 
    if($len == 7) 
        $num = preg_replace('/([0-9]{3})([0-9]{4})/', '$1-$2', $num); 
    elseif($len == 10) 
        $num = preg_replace('/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $num); 

    return $num; 
	} 
 function format_creditcard($cc)
  {
	// Clean out extra data that might be in the cc
	$cc = str_replace(array('-',' '),'',$cc);

	// Get the CC Length
	$cc_length = strlen($cc);

	// Initialize the new credit card to contian the last four digits
	$newCreditCard = substr($cc,-4);

	// Walk backwards through the credit card number and add a dash after every fourth digit
	for($i=$cc_length-5;$i>=0;$i--){
		// If on the fourth character add a dash
		if((($i+1)-$cc_length)%4 == 0){
			$newCreditCard = '-'.$newCreditCard;
		}
		// Add the current character to the new credit card
		$newCreditCard = $cc[$i].$newCreditCard;
	}

	// Return the formatted credit card number
	return $newCreditCard;
   }
  
  // prepare order-status pulldown list
  $orders_statuses = array();
  $orders_status_array = array();
  $orders_status = $db->Execute("select orders_status_id, orders_status_name
                                 from " . TABLE_ORDERS_STATUS . "
                                 where language_id = '" . (int)$_SESSION['languages_id'] . "'");
  while (!$orders_status->EOF) {
    $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
                               'text' => $orders_status->fields['orders_status_name'] . ' [' . $orders_status->fields['orders_status_id'] . ']');
    $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
    $orders_status->MoveNext();
  }


  $order_exists = false;
  if (isset($_GET['oID']) && trim($_GET['oID']) == '') unset($_GET['oID']);

  if (isset($_GET['oID'])) {
  
   $my_option = explode("-",  zen_db_prepare_input(trim($_GET['oID'])));
   $oID = $my_option[0];
  // $oID = zen_db_prepare_input($_GET['oID']);
   $zf_insert_id = $oID;

    $orders_check = $db->Execute("select * from " . TABLE_ORDERS . "
                            where orders_id = '" . (int)$oID . "'");
    $order_exists = true;
	$cvv = '000';
    if ($orders_check->RecordCount() <= 0) {
      $order_exists = false;
    }else {
	  $order = new order($zf_insert_id);
	  $cvv = $orders_check->fields['cc_cvv'];
	}
  }

  $mailHive= new mailHive;
	
	$mailhive_token = MAILBEEZ_MAILHIVE_TOKEN;
	
	// call external module action e.g. block
	if ( isset($_GET['ma']) ) {
		$module_action = $_GET['ma'];
		$module = (isset($_GET['m'])) ? $_GET['m'] : false;
		$module_params = (isset($_GET['mp'])) ? $_GET['mp'] : false;
		$result = $mailHive->moduleAction($module, 'external_' .$module_action, $module_params);
	}
	//	
	
	if (isset($_GET[$mailhive_token]) ) {
		$mpaction = $_GET[$mailhive_token];
	} elseif (isset($_POST[$mailhive_token]) ) {
		$mpaction = $_POST[$mailhive_token];
	}
	
	$output_plain = false;
	
	if ($mpaction == 'view') {
		$output_plain = true;
	}
	
	if ($output_plain == false) {
	//use timezon setting //$current_time= time() - 60 * 60; // adjust tomezone server time is Easten time $orders_check->fields['cc_cvv']
	$current_time = strtotime($order->info['date_purchased']);
	$current_time_string = date('m/d D g:iA', $current_time);
	//$pickup_asap = $current_time + 60 * 15;
	$delivery_asap = $current_time +  60 * (int)(MODULE_SHIPPING_STOREHOURS_DELIVERY_DELAY);
    $my_delivery = explode("::", zen_db_output($order->info['order_delivery_date']));
	$delivery_text = "DELIVERY(外送):";
	$delivery_time = "<font color=red>Future(预订) </font>";
	$pay_mathod = $order->info['payment_method'];
	
	if ($order->info['shipping_module_code'] == 'storepickup') {
	   $delivery_text = "PICKUP(来拿):";
	   if (zen_db_output($order->info['order_delivery_date']) == 'NONE') { $delivery_time = "ASAP (尽快)"; }
	}else {
		if (zen_db_output($order->info['order_delivery_date']) == 'NONE') { $delivery_time = "ASAP (尽快) Before: ". date('g:i A',$delivery_asap); }
		//if (zen_db_output($order->info['order_delivery_date']) == 'NONE') { $delivery_time = "ASAP (尽快)"; }
	}
	$delivery_text .= ' ' . $pay_mathod;
	$delivery_time .= ' ' . $my_delivery[2];
//	
header('Content-Type: text/html; charset=UTF-8')	
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_HTTPS_CATALOG; ?>">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<script type="text/javascript">
  <!-- Begin Hidden JavaScript
  function scrolldown() {
   var a=document.anchors.length;
   var b=document.anchors[a-1];
   var y=b.offsetTop;
   window.scrollTo(0,y+120);
  }
  // End hidden JavaScript -->
  </script>   
<style>
body { font-family: Verdana, Arial, sans-serif; font-size: 10px; }
.s { font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #99ff00; }
.w { font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #ffb3b5; }
.rn { width: 30px; float: left; font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #e6e6e6; }
.r { margin-left: 30px; position: relative; margin-bottom: 3px; font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #e9e9e9; }
.pageHeading { font-family: Arial, Verdana, sans-serif; font-size: 24px; font-weight: bold; padding-top: 10px; padding-bottom: 7px; }
.smallText{font-size:9px;}
</style>

<!-- body //-->


<?php 
	}
 
if (($mpaction == 'order') && ($order_exists)) {
	// 

	$products_ordered_htm ='';
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
      $products_ordered_htm .= '      <tr class="dataTableRow">' . "\n" .
           '        <td class="dataTableContent" valign="top" align="left" width="10%">' . $order->products[$i]['qty'] . '&nbsp;x</td>' . "\n" .
           '        <td  valign="top" width="80%"><b><font FACE="Lucida Sans, sans-serif" size=4>' . $order->products[$i]['name'];

      if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
        for ($j = 0; $j < $k; $j++) {
          $products_ordered_htm .= '<br><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br(zen_output_string_protected($order->products[$i]['attributes'][$j]['value']));
          if ($order->products[$i]['attributes'][$j]['price'] != '0') $products_ordered_htm .= ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
          if ($order->products[$i]['attributes'][$j]['product_attribute_is_free'] == '1' and $order->products[$i]['product_is_free'] == '1') $products_ordered_htm .= TEXT_INFO_ATTRIBUTE_FREE;
          $products_ordered_htm .= '</i></small>';
        }
      }

     $products_ordered_htm .= '        </font> </b></td>' ;
//           '        <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
      $products_ordered_htm .= 
	  /**
	       '        <td class="dataTableContent" align="right" valign="top">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
           '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</b></td>' . "\n" .
           '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</b></td>' . "\n" .
           '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</b></td>' . "\n" .
        **/
           '        <td class="dataTableContent" align="right" valign="top"><b>' .
                      $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
                      ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
                    '</b></td>' ;
      $products_ordered_htm .= '      </tr>';

    }
	$refax_info = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
	  <header>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	  </header>
	  <BODY STYLE="font-family: Lucida Sans, sans-serif">';

	  
   $fax_info = ' <u><h3> RED PASSION: ' .  preg_replace('/\(.*?\)/', '', STORE_NAME) . 
     " #  <a href=\"" . HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . 'show_order.php?red=order&oID=' . $zf_insert_id . "\">" . $zf_insert_id . "</a></h3></u>" .
	'<b><font size=4>' . $delivery_text . '</font><br> <font size=4>' . $delivery_time  . 
	'</b><br> Order Placed:  <b>' . $current_time_string  . 
	'</font></b><br><br><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><td valign="top" width="50%">';	

	//Delivery address
	if ($order->info['shipping_module_code'] != 'storepickup') { 
	  $my_address = $order->delivery['street_address'] . ", " . $order->delivery['city'].", ". $order->delivery['state']." ". $order->delivery['postcode'] ;
	  $fax_info .= "<strong> Delivery (外送)</strong><br>" .
      '--------------------'. '<br><strong><font FACE="Lucida Sans, sans-serif" size=4>' .
      '<a href="https://maps.google.com?saddr=Current+Location&daddr='. urlencode($my_address).'&sensor=false&avoid=highways">' . $my_address . "</a></font></strong>";
    }
	$fax_info .= '</td><td valign="top" width="50%">';
	//Billing address

	$fax_info .= "Billing (帐单) <br>" .
		'--------------------' . '<br><font FACE="Lucida Sans, sans-serif" size=3>' .
		preg_replace ('/United States/', "", zen_address_format($order->customer['format_id'], $order->billing, 1, '', '<br>')) . "</font>";

	$fax_info .= '</td></tr><tr><td valign="top" colspan="2">';

	//Payment method
/**
	  if ( $pay_mathod == 'Credit Card') {	   
	   $pay_mathod =  "Charge " . $pay_mathod . " below.";
	   }
	 
	 $fax_info .= "<strong>Customer Info</strong><br>" .
      '--------------------' . "<br><b>" .
	  $pay_mathod . "<br>" .
	  $order->customer['telephone'] . "</b><br>" . 
	  '<a href="mailto:' . $order->customer['email_address']  . '">' . $order->customer['email_address'] . "</a><br>";
**/
    $fax_info .= 
	  $order->customer['telephone'] . ' ' .  
	  '<a href="mailto:' . $order->customer['email_address']  . '">' . $order->customer['email_address'] . "</a>";
	 $fax_info .= '</td></tr></table>';
	$fax_info .= '<hr><table border="0" width="100%" cellspacing="0" cellpadding="2">' . 
		  '<tr>'. "\n" .
	  '<td  align="left" valign="top" width="10%">QTY</td>' . "\n" .
	  '<td  valign="top" align="left" width="80%">ITEMS</td>'. "\n" .
	  '<td  valign="top" align="right" width="10%">PRICE</td></tr></table><hr>'. "\n" .
	  '<table border="0" width="100%" cellspacing="0" cellpadding="4">' .
	$products_ordered_htm .  '</table>';
	 $fax_info .= '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . 
    '<tr>'. "\n" .
	'<td align="right" >' . '&nbsp;' . '</td> ' . "\n" . '<td></td><td align="right" nowrap="nowrap" colspan="2">' . '---------' .'</td> </tr>' . "\n" . '<tr>';
   $tip=0;
   $total=0;
   $shipping=0;
	for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {
	   if ($order->totals[$i]['class'] == 'ot_tip'){$tip = preg_replace('/[\$,]/', '', $order->totals[$i]['text']);}
	   if ($order->totals[$i]['class'] == 'ot_shipping'){$shipping = $order->totals[$i]['value'];}
	   if ($order->totals[$i]['class'] == 'ot_total'){
		   $total = preg_replace('/[\$,]/', '', $order->totals[$i]['text']);
		     $fax_info .= '<td  align="right"  ><font FACE="Lucida Sans, sans-serif" size=4> ' . $delivery_time .'</td><td  align="right" nowrap="nowrap" width="20%"><font FACE="Lucida Sans, sans-serif" size=4> ' . $order->totals[$i]['title'] . '</font></td> ' . "\n" ;

		   }else {
			  $fax_info .= '<td></td><td  align="right" nowrap="nowrap" colspam="2" ><font FACE="Lucida Sans, sans-serif" size=3> ' . $order->totals[$i]['title'] . '</font></td> ' . "\n" ;
 
		   }

	  if (($order->totals[$i]['class'] == 'ot_tip') && ($tip == '0')) {
	  $fax_info .= '<td align="right" nowrap="nowrap" ><font szie=3> Pay Driver </font> </td> </tr>' . "\n" . '<tr>';
	  }else {
	  $fax_info .= '<td align="right" nowrap="nowrap" ><font FACE="Lucida Sans, sans-serif" szie=3> <b>' .($order->totals[$i]['text']) .'</b> </font> </td> </tr>' . "\n" . '<tr>';
	  }
	}	
	$fax_info .= "</table><hr>";
	$before_tip = $total - $tip;
	$subtotal_tax = $before_tip - $shipping;
	$before_tip = '$'. $before_tip;
	$subtotal_tax = '$'. $subtotal_tax;
	$my_site = explode("/",  HTTP_SERVER);
  //comments area
	$fax_info .= '<table border="0" width="100%" cellspacing="0" cellpadding="2"> ' .
	'<tr><td align="left" width="60%">';
	$orders_comment = $db->Execute("select comments
                                    from " . TABLE_ORDERS_STATUS_HISTORY . "
                                    where orders_id = '" . zen_db_input($oID) . "'
                                    order by date_added ASC Limit 1");
	//nl2br(zen_db_output($orders_comment->fields['comments']))
    if ($orders_comment->fields['comments']) { 
	  $fax_info .= zen_db_output($orders_comment->fields['comments']) . "\n";
    } else {
	  $fax_info .= 'No Special Instructions';
    }
	$fax_info .= '</td><td class="order-totals-text" align="right" width="20%">Subtotal w Tax: ' .($subtotal_tax) . '</td> ' . "\n" . 
	'<td class="order-totals-text" align="right" width="20%">Subtotal w/o Tip: ' .($before_tip) . '</td> </tr>' . "\n";
	$fax_info .= "</table><hr>";
	$fax_info .=  '<font size=3> Site: '. preg_replace('/www\./', '', $my_site[2]). ' Red Passion: Phone or Fax (8 8 8) 387-3312 <br>';
    //$fax_info .= "<hr style="border-top: dotted 1px;" >";
//    $fax_info .=  (isset($order->info['cc_type']) && $order->info['cc_type'] != '') ? $order->info['cc_type'] . 
//	  ' <b>' . format_creditcard($order->info['cc_number']). "</b> Exp: <b>" . $order->info['cc_expires']."</b> CVV: <b>" . $order->info['cc_cvv'] . '</b> Zip: <b>'. $order->billing['postcode'] ."</b><br>" : '';
    $fax_info .=  (isset($order->info['cc_type']) && $order->info['cc_type'] != '') ? $order->info['cc_type'] . 
	  ' <b>' . format_creditcard($order->info['cc_number']). "</b> Exp: <b>" . $order->info['cc_expires']."</b> CVV: <b>" . $cvv . '</b> Zip: <b>'. $order->billing['postcode'] ."</b><br>" : '';
	  
    $fax_info .= '</b>#' . $zf_insert_id .  "&nbsp;" . 
	$order->customer['firstname'] . ' ' . $order->customer['lastname'] . ' ' . format_phone($order->customer['telephone']). ' Fee: $'. $shipping .
	' Tips: $' . $tip . ' <b>Total: $' . $total .'</b></font>';

//print to screen	
if (($my_option[1] !== 'deliveried') && ($my_option[1] !== 'upd')) {
  echo $fax_info;
}else {

echo	'<h2> You have emailed customer order '.$my_option[1].' status. </h2>
	<h4>You may type message onto form and click "Update Order" button. The message will be sent to coustomer.</h4>';
}
?>
<table border="0" cellspacing="0" cellpadding="2" class="noprint">
      <tr>
        <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><table border="1" cellspacing="0" cellpadding="5">
          <tr>
            <td class="smallText" align="center"><strong>Date Added</strong></td>
            <td class="smallText" align="center"><strong>Notified</strong></td>
            <td class="smallText" align="center"><strong>Status</strong></td>
            <td class="smallText" align="center"><strong>Comments</strong></td>
          </tr>
<?php
    $orders_history = $db->Execute("select orders_status_id, date_added, customer_notified, comments
                                    from " . TABLE_ORDERS_STATUS_HISTORY . "
                                    where orders_id = '" . zen_db_input($oID) . "'
                                    order by date_added");
//date('m/d/y  g:i A', $orders_history->fields['date_added'])
    if ($orders_history->RecordCount() > 0) {
      while (!$orders_history->EOF) {
        echo '          <tr>' . "\n" .
             '            <td class="smallText" align="center">' .  date('m/d/y  g:i A', strtotime($orders_history->fields['date_added'])) . '</td>' . "\n" .
             '            <td class="smallText" align="center">';
        if ($orders_history->fields['customer_notified'] == '1') {
          echo "Yes </td>\n";
        } else {
          echo " No </td>\n";
        }
        echo '            <td class="smallText">' . $orders_status_array[$orders_history->fields['orders_status_id']] . '</td>' . "\n";
        echo '            <td class="smallText">' . nl2br(zen_db_output($orders_history->fields['comments'])) . '&nbsp;</td>' . "\n" .
             '          </tr>' . "\n";
        $orders_history->MoveNext();
      }
    } else {
        echo '          <tr>' . "\n" .
             '            <td class="smallText" colspan="5">' . TEXT_NO_ORDER_HISTORY . '</td>' . "\n" .
             '          </tr>' . "\n";
    }
//get store phone
  $store_name_address = explode("\n", STORE_NAME_ADDRESS );
//  $MYCITY='Milwaukee';
//  $MYSTATE='WI';
//  $MYCAT = ' Restaurant';
  $MYPHONE = STORE_PHONE;
if ( $MYPHONE == '') {
 for ($i=1, $n=sizeof($store_name_address); $i<=$n; $i++) {
  /**
  if (strpos($store_name_address[$i], STORE_ZIPCODE) !== false) {
    $WHOLE_LINE = explode(",", $store_name_address[$i]) ;
	$MYCITY = $WHOLE_LINE[0];
	$MYSTATE= str_replace(STORE_ZIPCODE,"",$WHOLE_LINE[1]);
	
	if ( $MYCITY == '') {
		$MYSTATE= zen_get_zone_name(223,STORE_ZONE);
	}
  }
  
    if (strpos($store_name_address[$i], 'Restaurant') !== false) {
    $MYCAT = $store_name_address[$i] ;
  }
**/
//   if (preg_match( "/(\(\d+\))?([\s-]?\d+)+/", $store_name_address[$i])) {
   if (preg_match( "/(\d{3}-\d{4})/", $store_name_address[$i])) {
   $MYPHONE = $store_name_address[$i] ;
	break;
    }
 }
} 
?>
        </table></td>
      </tr>
      <tr>
        <td class="smallText"><br /><strong> Comments </strong></td>
      </tr>
      <tr><?php echo zen_draw_form('edit_order', 'show_order.php', 'GET'); ?>
	  <input type="hidden" name="red" value="order" /> 
	  <input type="hidden" name="oID" value="<?php echo $zf_insert_id . '-upd'; ?>" /> 
        <td class="smallText"><textarea name="comments" wrap="soft" cols="60" rows="5"> 
We couldn't reach you by phone please Call Restaurant <?php echo format_phone($MYPHONE); ?>. Thanks.</textarea> </td>
      </tr>
      <tr>
        <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" cellspacing="0" cellpadding="2" class="noprint">
          <tr>
            <td>
			  <table border="0" cellspacing="0" cellpadding="2">
              <tr>
                <td class="smallText"><strong>Status:</strong> <?php echo zen_draw_pull_down_menu('status', $orders_statuses, $order->info['orders_status']); ?></td>
                <td class="smallText"><strong>Notify Customer:</strong> <?php echo zen_draw_checkbox_field('notify', '', true); ?></td>
              </tr>
              </table>
			</td>
            <td valign="top"><input type="submit"  value= "Update Order"></td>
          </tr>
        </table></td>
      </form>
	  </tr>
  </table>
<?php
//build redfax page	
	$refax_info .= $fax_info . '</body></html>'; ;
	  $JattachArray = array();
	  $attachFileTextContent = $refax_info;
	  //$this->JattachArray = array("raw_data" => $attachFileTextContent, "order_number" => $zf_insert_id );
	  $JattachArray['raw_data'] = $attachFileTextContent;
	  $JattachArray['mime_type'] = 'text/html';
      $JattachArray['name'] = STORE_NAME . $zf_insert_id .'.html';   // filename that the $attachFileTextContent attachment will have inside the email
//set all options	  
//switch (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER) {	
$pieces = explode(",", SEND_EXTRA_ORDER_EMAILS_TO);

switch ($my_option[1]) {
case 'recall': 
//just email to rcfax for fax
  if (STORE_PHONE != '') {
	$call_url = 'https://service.ringcentral.com/ringout.asp?cmd=call&username=18883873312&ext=101&password=Alena1129&from='. STORE_PHONE .'&to=2622047707&clid=8883873312&prompt=0';
	$dir_result = utf8_encode(file_get_contents($call_url));
	}
break;
case 'fax': 
//just email to rcfax for fax
   if ((MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'rcfax.com') || (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'metrofax.com'))  {
   
    zen_mail('', MODULE_SHIPPING_STORE_FAX_NUMBER . '@rcfax.com', '',
     'empty', STORE_NAME, 'sales@redpassionhost.com', $html_msg, 'checkout_extra', $JattachArray);
	 
   }elseif (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'eprint') {
   
       zen_mail('', $pieces[1], MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
     'empty', STORE_NAME, 'spancfreedom@gmail.com', $html_msg, 'checkout_extra', $JattachArray);
	 
   }else {
   
   	zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
      $email_order_owner . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $JattachArray, 'htmlonly', $refax_info);
	  
   }
break;
case 'rcfax': 
//upload to rcfax
  if ((MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'rcfax.com') || (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'metrofax.com'))  {
 
	$myurl = 'https://service.ringcentral.com/faxapi.asp'; // RingCentral FaxOut API URL 
	$RCUsername = "18883873312";         // RingCentral Fax Username (10-digit RC phone number)
	$RCPassword = "Alena1129";                // RingCentral password (5-10 numeric digits)
	$recipientFax = MODULE_SHIPPING_STORE_FAX_NUMBER;   // Recipient 10-digit Fax number
//set data (in this example from post) 
        $mypostdata = array( 		
	    'Username' => $RCUsername,
            'Password' => $RCPassword,
            'Recipient' => $recipientFax,
            'coverpage' => '0',  //None =0
            'Resolution' => '2'  //Low =2
        );
//sample image 
$files['Attachment'] = $JattachArray['name'] ; 
//ringcentral api
$api_result = do_post_request($myurl, $mypostdata, $refax_info, $files); 
 if ($api_result != '0') {echo '<h1>  fax error: ' . $api_result. ' </h1>'; };
	 
   }elseif (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'eprint') {
   
       zen_mail('', $pieces[1], MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
     'empty', STORE_NAME, 'spancfreedom@gmail.com', $html_msg, 'checkout_extra', $JattachArray);
	 
   }else {
   
   	zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
      $email_order_owner . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $JattachArray, 'htmlonly', $refax_info);
	  
   }
break;
case 'metrofax': 
//upload to metrofax

  if ((MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'rcfax.com') || (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'metrofax.com'))  {
  
     $api_result = send_metrofax($zf_insert_id, $refax_info);
	 if ($api_result != '0') {echo '<h1>  fax error: ' . $api_result. ' </h1>'; };
   }elseif (MODULE_SHIPPING_ZIPSHIP_FAX_SERVER == 'eprint') {
   
       zen_mail('', $pieces[1], MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
     'empty', STORE_NAME, 'spancfreedom@gmail.com', $html_msg, 'checkout_extra', $JattachArray);
	 
   }else {
   
   	zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, MODULE_SHIPPING_STORE_FAX_NUMBER . EMAIL_ORDER_NUMBER_SUBJECT . $zf_insert_id,
      $email_order_owner . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', $JattachArray, 'htmlonly', $refax_info);
	  
   }
break;
case 'upd':

	if (isset($_GET['status']) && ($_GET['notify'] == 'on') && isset($_GET['comments'])) {
       $status = zen_db_prepare_input($_GET['status']);
       $comments = zen_db_prepare_input($_GET['comments']);
	   $notify = zen_db_prepare_input($_GET['notify']);
	   
	    $order_updated = false;
 //       $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
 //                                     date_purchased, COWOA_order  from " . TABLE_ORDERS . "
//                                      where orders_id = '" . (int)$zf_insert_id . "'");
		 $check_status = $db->Execute("select customers_name, customers_email_address, orders_status, order_delivery_date,
                                      date_purchased  from " . TABLE_ORDERS . "
                                      where orders_id = '" . (int)$zf_insert_id . "'");
		if ($check_status->fields['order_delivery_date'] == 'NONE') {
			$check_status->fields['order_delivery_date'] = 'ASAP';
		}
/**
	   if ( ($check_status->fields['orders_status'] != $status) || zen_not_null($comments)) {
          $db->Execute("update " . TABLE_ORDERS . "
                        set orders_status = '" . zen_db_input($status) . "', last_modified = now()
                        where orders_id = '" . (int)$zf_insert_id . "'");
		}
**/       
    }
	 $notify_comments = '';
          if (($_GET['notify'] == 'on') && zen_not_null($comments)) {
            $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
          }
//send emails

      $message = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" .
      EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id . "\n\n";
      if(!$check_status->fields['COWOA_order']) {
      $message .= EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL') . "\n\n";
      }
      $message .= EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($check_status->fields['date_purchased'])) . "\n\n" .
      strip_tags($notify_comments) .
      EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
      EMAIL_TEXT_STATUS_PLEASE_REPLY;


          $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
          $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id;
          $html_msg['EMAIL_TEXT_INVOICE_URL']  = '<a href="' . zen_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL') .'">'.str_replace(':','',EMAIL_TEXT_INVOICE_URL).'</a>';
          $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($check_status->fields['date_purchased']));
		  //$html_msg['EMAIL_TEXT_DELIVERY_DATE'] = EMAIL_TEXT_DELIVERY_DATE . ' ' . date('m/d/y  g:i A', strtotime($check_status->fields['order_delivery_date']));
		  $html_msg['EMAIL_TEXT_DELIVERY_DATE'] = EMAIL_TEXT_DELIVERY_DATE . ' ' . $check_status->fields['order_delivery_date'];
		  $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
          $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
          $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
          $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
          $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);

          $customer_notified = '0';
          if ($notify == 'on') {
            zen_mail($check_status->fields['customers_name'], $check_status->fields['customers_email_address'], EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
            $customer_notified = '1';

            //send extra emails
//          if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
              zen_mail('', SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . $my_option[1] . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
//            }
          }

          $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
                      (orders_id, orders_status_id, date_added, customer_notified, comments)
                      values ('" . (int)$zf_insert_id . "',
                      '" . zen_db_input($status) . "',
                      now(),
                      '" . zen_db_input($customer_notified) . "',
                      '" . zen_db_input($comments)  . "')");
          $order_updated = true;
    
		  
		  
break;
case 'deliveried':
       $status = '3';
       $comments = 'Your delvery order is on the way.';	   
	  if ($my_option[2] =='callback'){
		  $comments = 'We could not reach you by phone please Call Restaurant ' . format_phone($MYPHONE);
	  }
	  
	  if ($my_option[2] =='badcredit'){
		  $comments = 'Your Credit card rejected pasyment. We could not reach you by phone please Call Restaurant ' . format_phone($MYPHONE);
	  }
 
	   $notify = 'on';
	   
	    $order_updated = false;
//shipping_module_code
		 $check_status = $db->Execute("select customers_name, customers_email_address, orders_status, shipping_module_code, order_delivery_date,
                                      date_purchased  from " . TABLE_ORDERS . "
                                      where orders_id = '" . (int)$zf_insert_id . "'");

	   if ($check_status->fields['shipping_module_code'] !== 'zipship') {
		   $comments = 'Your order is ready for pickup.' ; 
		}
       	if ($check_status->fields['order_delivery_date'] == 'NONE') {
			$check_status->fields['order_delivery_date'] = 'ASAP';
		}

	 $notify_comments = '';
       //   if (($_GET['notify'] == 'on') && zen_not_null($comments)) {
            $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
      //    }
//send emails

      $message = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" .
      EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id . "\n\n";
      if(!$check_status->fields['COWOA_order']) {
      $message .= EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL') . "\n\n";
      }
      $message .= EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($check_status->fields['date_purchased'])) . "\n\n" .
      strip_tags($notify_comments) .
      EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ) .
      EMAIL_TEXT_STATUS_PLEASE_REPLY;


          $html_msg['EMAIL_CUSTOMERS_NAME']    = $check_status->fields['customers_name'];
          $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id;
          $html_msg['EMAIL_TEXT_INVOICE_URL']  = '<a href="' . zen_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $zf_insert_id, 'SSL') .'">'.str_replace(':','',EMAIL_TEXT_INVOICE_URL).'</a>';
          $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($check_status->fields['date_purchased']));
		  $html_msg['EMAIL_TEXT_DELIVERY_DATE'] = EMAIL_TEXT_DELIVERY_DATE . ' ' . $check_status->fields['order_delivery_date'];
		  $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($notify_comments);
          $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
          $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, $orders_status_array[$status] ));
          $html_msg['EMAIL_TEXT_NEW_STATUS'] = $orders_status_array[$status];
          $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);

          $customer_notified = '0';
          if ($notify == 'on') {
            zen_mail($check_status->fields['customers_name'], $check_status->fields['customers_email_address'], EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
            $customer_notified = '1';

            //send extra emails
//          if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
              zen_mail('', SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . $my_option[1] . $my_option[2] . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
//            }
          }

          $db->Execute("insert into " . TABLE_ORDERS_STATUS_HISTORY . "
                      (orders_id, orders_status_id, date_added, customer_notified, comments)
                      values ('" . (int)$zf_insert_id . "',
                      '" . zen_db_input($status) . "',
                      now(),
                      '" . zen_db_input($customer_notified) . "',
                      '" . zen_db_input($comments)  . "')");
          $order_updated = true;		  
		  
break;
case 'del':


//send emails

      $message = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" .
      EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id . "\n\n";
      $message .= EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($order->info['date_purchased'])) . "\n\n" .
      'Order was caceled by customer or restaurant' .
      EMAIL_TEXT_STATUS_UPDATED . sprintf(EMAIL_TEXT_STATUS_LABEL, 'Canceled' ) .
      EMAIL_TEXT_STATUS_PLEASE_REPLY;


          $html_msg['EMAIL_CUSTOMERS_NAME']    = $order->info['customers_name'];
          $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = EMAIL_TEXT_ORDER_NUMBER . ' ' . $zf_insert_id;
          $html_msg['EMAIL_TEXT_INVOICE_URL']  = 'NONE';
          $html_msg['EMAIL_TEXT_DATE_ORDERED'] = EMAIL_TEXT_DATE_ORDERED . ' ' . date('m/d/y  g:i A', strtotime($order->info['date_purchased']));
		  $html_msg['EMAIL_TEXT_DELIVERY_DATE'] = EMAIL_TEXT_DELIVERY_DATE . ' ' . 'NONE';
		  $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br('Order was canceled by customer or restaurant.');
          $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace('\n','', EMAIL_TEXT_STATUS_UPDATED);
          $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace('\n','', sprintf(EMAIL_TEXT_STATUS_LABEL, 'Canceled' ));
          $html_msg['EMAIL_TEXT_NEW_STATUS'] = 'Canceled';
          $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace('\n','', EMAIL_TEXT_STATUS_PLEASE_REPLY);

 
            zen_mail($order->info['customers_name'], $order->info['customers_email_address'], EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
           

            //send extra emails
 //        if (SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1' and SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO != '') {
              zen_mail('', SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . $my_option[1] . ' ' . EMAIL_TEXT_SUBJECT . ' #' . $zf_insert_id, $message, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
 //         }
           zen_remove_order($zf_insert_id, $_POST['restock']);
		  
		  
break;
case 'confirm':

//owner confirmed open the order
        $status = '3'; //deliveried

		 $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                      date_purchased  from " . TABLE_ORDERS . "
                                      where orders_id = '" . (int)$zf_insert_id . "'");

	   if ( ($check_status->fields['orders_status'] < $status) ) { //only return email when status = 1 or 2
		   
	zen_mail('', 'spanc07@gmail.com', MODULE_SHIPPING_STORE_FAX_NUMBER.' ' .'Opened & confirmed ' . $zf_insert_id,
     'Owner opened this order.', STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', ''); 
		 //  change to 3 so no more email
          $db->Execute("update " . TABLE_ORDERS . "
                        set orders_status = '" . zen_db_input($status) . "', last_modified = now()
                        where orders_id = '" . (int)$zf_insert_id . "'");
		}        		  
break;
case 'email':

//owner confirmed open the order
        $status = '3'; //deliveried

		 $check_status = $db->Execute("select customers_name, customers_email_address, orders_status,
                                      date_purchased  from " . TABLE_ORDERS . "
                                      where orders_id = '" . (int)$zf_insert_id . "'");

	   if ( ($check_status->fields['orders_status'] < $status) ) { //only return email when status = 1 or 2
		   
	zen_mail('', 'spanc07@gmail.com', MODULE_SHIPPING_STORE_FAX_NUMBER.' ' .'Opened & confirmed ' . $zf_insert_id,
     'Owner opened this order.', STORE_NAME, EMAIL_FROM, $html_msg, 'checkout_extra', ''); 
		 //  change to 3 so no more email
          $db->Execute("update " . TABLE_ORDERS . "
                        set orders_status = '" . zen_db_input($status) . "', last_modified = now()
                        where orders_id = '" . (int)$zf_insert_id . "'");
		}        		  
break;
default:
  echo ' Wrong Option ';
  }	

} 

	if ($order_exists == false) {
?>
		<?php echo  "<h2> Order# ". $oID. " is not exiting. Could be next order.</h2>"; ?>
</body>
</html>
<?php
}

	require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>