1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
   | // Multi order updates
if (isset($HTTP_POST_VARS['submit'])){
 if (($HTTP_POST_VARS['submit'] == BUS_SUBMIT)&&(isset($HTTP_POST_VARS['new_status']))){ // Fair enough, let's update ;)
  $status = tep_db_prepare_input($HTTP_POST_VARS['new_status']);
  if ($status == '') { // New status not selected
     tep_redirect(tep_href_link(FILENAME_ORDERS),tep_get_all_get_params());
  }
 
  foreach ($HTTP_POST_VARS['update_oID'] as $this_orderID){
    $order_updated = false;
    $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$this_orderID . "'");
    $check_status = tep_db_fetch_array($check_status_query);
    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
 
 
	if (($check_status['orders_status'] != $status) || tep_not_null($comments)) {
       tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$this_orderID . "'");
 
	   $customer_notified ='0';
 
	   $requpdate = "update " . TABLE_ORDERS_STATUS_HISTORY . " set orders_status_status_history_id = '" . tep_db_input($comments) . "', comments = now() where comments = '" . (int)$this_orderID . "'";
echo $requpdate;
 
          if (isset($HTTP_POST_VARS['notify'])) {
            $notify_comments = '';
            if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) {
              $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n";
            }
            $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $this_orderID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $this_orderID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]);
            tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
            $customer_notified = '1';
          }
          tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$this_orderID . "', '" . tep_db_input($status) . "', now(), '" . tep_db_input($customer_notified) . "', '" . tep_db_input($comments)  . "')");
          $order_updated = true;
    }
        if ($order_updated == true) {
         $messageStack->add("Order $this_orderID updated.", 'success');
        } else {
          $messageStack->add("Order $this_orderID not updated.", 'warning');
        }
        }// End foreach ID loop
  }
 }
 
// End Multi order updates | 
Partager