<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php require('load_this/load_bigware_11.php');

  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . NAME_OF_FILE_GROUPORDERS);

        $languages = go_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
        	if ($languages[$i]['code'] == $language){
	          $language_id = $languages[$i]['id'];
        	}
        }
          
          
$orders_statuses = array();
  $orders_status_array = array();
  $orders_status_query = go_db_query("select orders_status_id, orders_status_name from " . DB_TBL_ORDERS_STATUS . " where language_id = '" . $language_id . "'");
  while ($orders_status = go_db_fetch_array($orders_status_query)) {
    $orders_statuses[] = array('id' => $orders_status['orders_status_id'],
                               'text' => $orders_status['orders_status_name']);
    $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name'];
  }

//print_r($orders_status_array);
	
$action = (isset($_GET['action']) ? $_GET['action'] : '');

if (go_not_null($action)) {
    switch ($action) {
      case 'update_order':
			//print_r($_POST);
			
			$status = go_db_producing_input($_POST['status']);
			$post_keys = array_keys($_POST);
			
			for ($o=0;$o<50;$o++){
			 $oID[$o]=$_POST["orders_id_".$o];
			 if ($oID[$o]!=""){
			 go_db_query("update " . DB_TBL_ORDERS . " set orders_status = '" . go_db_input($status) . "', last_modified = now() where orders_id = '" . (int)$oID[$o] . "'");
			 
			 $check_status_query[$o] = go_db_query("select attendees_name, attendees_email_address, orders_status, date_purchased from " . DB_TBL_ORDERS . " where orders_id = '" . (int)$oID[$o] . "'");
       $check_status[$o] = go_db_fetch_array($check_status_query[$o]);
			 
       $customer_notified = '0';
          if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) {
					  $email = SHOP_NAME . "\n" . EMAIL_SEPARATOR . "\n" .'Order Number:' . ' ' . $oID[$o] . "\n" . 'Detailed Invoice:' . ' ' . go_catalog_href_link(NAME_OF_FILE_CATALOG_MEMBER_HISTORY_INFO, 'order_id=' . $oID[$o], 'SSL') . "\n" .  'Date Ordered:' . ' ' . go_date_long($check_status[$o]['date_purchased']) . "\n\n" . $notify_comments . sprintf(STATUS_UPDATE_EMAIL . "\n\n" . NEW_STATUS_EMAIL . ' %s' . "\n\n" . NEW_STATUS_ANSWER_EMAIL . "\n", $orders_status_array[$status]);
						go_mail($check_status[$o]['attendees_name'], $check_status[$o]['attendees_email_address'], NEW_STATUS_SUBJECT_EMAIL, $email, SHOP_OWNER, SHOP_OWNER_EMAIL_ADDRESS);
						$messageStack->add_session(NEW_STATUS_WHICH_COSTUMER . " " . $check_status[$o]['customers_name'] . "<br>", 'success');
            $customer_notified = '1';
					}

          go_db_query("insert into " . DB_TBL_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, attendee_notified, comments) values ('" . (int)$oID[$o] . "', '" . go_db_input($status) . "', now(), '" . go_db_input($customer_notified) . "', '" . go_db_input($comments)  . "')");

          $order_updated = true;

        
			 
			 }//if
			}
			
			
			if ($order_updated == true) {
         $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
        } else {
          $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
        }
		go_forward(go_href_link(NAME_OF_FILE_GROUPORDERS));
		break;		
		}//switch
	
}//if			
include(FOLDER_RELATIV_CLASSES . 'class_bigware_9.php');
?>
<!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=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="load_this/style.css">
<script language="javascript" src="load_this/menu.js"></script>
<script language="javascript" src="load_this/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php');?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
  <td width="<?php echo FRAME_WIDTH; ?>" valign="top">
  </td>
  <td width="100%" valign="top">
	 <table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php

require(FOLDER_RELATIV_INCLUDES . 'load_bigware_5.php');
require(FOLDER_RELATIV_INCLUDES . 'load_bigware_3.php');
//require(FOLDER_RELATIV_INCLUDES . 'load_bigware_2.php');

?>
   <tr>
    <td width="100%">
		 <table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
       <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
       <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('pixel_trans.gif', 1, ABOVE_PICTURE_HEIGHT); ?></td>
      </tr>
     </table>
		</td>
   </tr>
   <tr>
    <td>
		 <table cellpadding="5" border="0" width="100%" cellspacing="0">
      <tr>
       <td valign="top">
		    <table border="0" cellpadding="5" cellspacing="0" width="100%">
      
				 
<?php

    require('main_bigware_90.php');
		echo go_fetch_form('status', NAME_OF_FILE_GROUPORDERS, go_get_all_get_parameter(array('action')) . 'action=update_order');
				 
				 for ($o=0;$o<50;$o++){ 
				  if (($o==0)||($o%3==0)) echo '<tr id="defaultSelected" class="tbCountData" >' . "\n"; ?>
				  <td class="TbInsideData"><?php echo NEW_STATUS_ORDER_NUMBER; ?><input type="text" size=5 name="orders_id_<?php echo $o; ?>"></td>
					<?php 
					if (($o==2)||($o%3==2)) {echo '</tr>';}
					}
				?>
			 
			 <tr>
			  <td colspan=5 align="right">
				 <b><?php echo ENTRY_NOTIFY_CUSTOMER; ?></b> <?php echo go_fetch_checkbox_field('notify', '', true); ?>
				 <?php echo go_fetch_pull_down_menu('status', $orders_statuses); ?>
				  <?php echo go_picture_submit('button_update.gif', PICTURE_UPDATE); ?>
						</td></tr></form>
      
      </table>
		 </td>
    </tr>
   </table>
	</td>
 </tr>
</table></td></tr></table>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>
