Index: src/admin/orders.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/admin/orders.php	(revision 1ee1259a352d793fb433653a5c463d8d501a5902)
+++ src/admin/orders.php	(revision )
@@ -208,13 +208,20 @@
 require (DIR_WS_CLASSES.'order.php');
 if ((($_GET['action'] == 'edit') || ($_GET['action'] == 'update_order')) && ($order_exists)) {
 	$order = new order($oID);
+	if(empty($order->customer['ID']))
+	{
+		$customerId = $order->customer['csID'];
+	}
+	else
+	{
-	$customerId = $order->customer['ID'];
+		$customerId = $order->customer['ID'];
+	}
 
 	/**
 	 * Fetch data of first order
 	 */
 	$query          = xtc_db_query('SELECT `date_purchased` FROM `orders` WHERE `customers_id` = ' . $customerId
-	                               . ' ORDER BY `date_purchased` ASC LIMIT 1');
+	                               . ' OR `customers_cid` = ' . $customerId . ' ORDER BY `date_purchased` ASC LIMIT 1');
 	$result         = xtc_db_fetch_array($query);
 	$firstOrderDate = '-';
 	if(count($result) > 0)
@@ -226,7 +233,7 @@
 	 * Fetch data of last order
 	 */
 	$query         = xtc_db_query('SELECT `date_purchased` FROM `orders` WHERE `customers_id` = ' . $customerId
-	                              . ' ORDER BY `date_purchased` DESC LIMIT 1');
+	                              . ' OR `customers_cid` = ' . $customerId . ' ORDER BY `date_purchased` DESC LIMIT 1');
 	$result        = xtc_db_fetch_array($query);
 	$lastOrderDate = '-';
 	if(count($result) > 0)
@@ -237,7 +244,7 @@
 	/**
 	 * Fetch amount of orders
 	 */
-	$query          = xtc_db_query('SELECT COUNT(*) as `count` FROM  `orders` WHERE `customers_id` = ' . $customerId);
+	$query          = xtc_db_query('SELECT COUNT(*) as `count` FROM  `orders` WHERE `customers_id` = ' . $customerId . ' OR `customers_cid` = ' . $customerId);
 	$result         = xtc_db_fetch_array($query);
 	$amountOfOrders = '0';
 	if(count($result) > 0)
@@ -248,8 +255,8 @@
 	/**
 	 * Fetch total sum of customer orders
 	 */
-	$query         = xtc_db_query('SELECT `value` FROM `orders_total` LEFT JOIN `orders` USING (`orders_id`) WHERE `sort_order` = "99" AND customers_id = "'
-	                              . $customerId . '"');
+	$query         = xtc_db_query('SELECT `value` FROM `orders_total` LEFT JOIN `orders` USING (`orders_id`) WHERE `sort_order` = "99" AND (customers_id = "'
+	                              . $customerId . '" OR `customers_cid` = ' . $customerId.')');
 	$sumOrderTotal = 0;
 	while($result = xtc_db_fetch_array($query))
 	{
Index: src/admin/html/compatibility/order_details.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/admin/html/compatibility/order_details.php	(revision 1ee1259a352d793fb433653a5c463d8d501a5902)
+++ src/admin/html/compatibility/order_details.php	(revision )
@@ -549,10 +549,10 @@
 					</div>
 				</div>
 			</div>
-			
+
 			<?php
 			$belowOrderInfo = $orderExtender->get_output('below_order_info');
-			
+
 			foreach($belowOrderInfo as $moduleContent)
 			{
 				?>
@@ -697,10 +697,10 @@
 					</div>
 				<?php endif; ?>
 			</div>
-			
+
 			<?php
 			$belowWithdrawal = $orderExtender->get_output('below_history');
-			
+
 			foreach($belowWithdrawal as $moduleContent)
 			{
 				?>
@@ -788,13 +788,39 @@
 			<!--
 				CUSTOMER INFO BOX
 			-->
+
+			<?php
+
+			$mainCustomerIdEmpty = false;
+
+			if(empty($GLOBALS['order']->customer['ID']))
+			{
+				$customerId = $GLOBALS['order']->customer['csID'];
+				$mainCustomerIdEmpty = true;
+			}
+			else if(!empty($GLOBALS['order']->customer['csID']) && $GLOBALS['order']->customer['ID'] != $GLOBALS['order']->customer['csID'])
+			{
+				$customerId = $GLOBALS['order']->customer['csID'];
+			}
+			else
+			{
+				$customerId = $GLOBALS['order']->customer['ID'];
+			}
+
+			?>
 			<div class="frame-wrapper info customers">
 				<div class="frame-head info">
 					<label class="title"><?php echo str_replace(':', '', ENTRY_CUSTOMER); ?></label>
-					<label class="pull-right head-link"> <a href="<?php echo xtc_href_link('customers.php', 'cID='
-					                                                                                        . $GLOBALS['order']->customer['ID']
-					                                                                                        . '&action=edit'); ?>">
-							<?php echo ENTRY_OPEN_CUSTOMER ?>
+					<?php
+						if($mainCustomerIdEmpty==false)
+						{
+							echo '<label class="pull-right head-link">
+									<a href="'.xtc_href_link('customers.php', 'cID=' . $customerId . '&action=edit').'">';
+							echo ENTRY_OPEN_CUSTOMER;
+						}
+					?>
+
+
 						</a> </label>
 				</div>
 				<div class="frame-content simple-container">
@@ -835,18 +861,7 @@
 							<?php endif; ?>
 							<span><?php echo $GLOBALS['order']->customer['telephone']; ?></span><br />
 							<span><?php echo $GLOBALS['order']->info['status_name']; ?></span><br />
-							<span>
-								<?php
-								if(empty($GLOBALS['order']->customer['csID']))
-								{
-									echo $GLOBALS['order']->customer['ID'];
-								}
-								else
-								{
-									echo $GLOBALS['order']->customer['csID'];
-								}
-
-								?></span><br />
+							<span><?php	echo $customerId; ?></span><br />
 							<span><?php echo $GLOBALS['order']->info['language']; ?></span>
 						</div>
 					</div>
@@ -861,9 +876,16 @@
 						<div class="span6">
 							<span><?php echo $firstOrderDate; ?></span><br /> <span><?php echo $lastOrderDate; ?></span><br />
 							<span class="amount">
-								<a href="orders.php?cID=<?php echo $GLOBALS['order']->customer['ID']; ?>">
-									<?php echo $amountOfOrders; ?>
-								</a>
+								<?php
+									if($mainCustomerIdEmpty==false)
+									{
+										echo '<a href="orders.php?cID=' . $customerId . '">' . $amountOfOrders . '</a>';
+									}
+									else
+									{
+										echo $amountOfOrders;
+									}
+								?>
 							</span><br />
 							<span><?php echo $sumOrderTotal . ' ' . $GLOBALS['order']->info['currency']; ?></span>
 						</div>
@@ -979,10 +1001,10 @@
 					</div>
 				<?php endif; ?>
 			</div>
-			
+
 			<?php
 			$belowWithdrawal = $orderExtender->get_output('below_withdrawal');
-			
+
 			foreach($belowWithdrawal as $moduleContent)
 			{
 			?>
