<?php

// trolley.tpl
// -------------------------------------------------------------------------------------------------
// Trolley template
//
// Revision   > $Rev: 160 $
// Date		  > $Date: 2009-12-08 13:00:05 +0000 (Tue, 08 Dec 2009) $
// Author     > RAK for DML
// Copyright  > (C) Digital Mail Limited (2005-2009)
// -------------------------------------------------------------------------------------------------

?>

<!-- ***************** -->
<!-- TROLLEY COMPONENT -->
<!-- ***************** -->

<?php

$adjust_scv_plan_info = '<b>Adjust this number:</b> Change the number\'s call-handling service (features) and it\'s price plan (cost)';

?>

<script language="javascript" type="text/javascript">

// CREATE 'PUBLIC' JS INTERFACE FOR COMPONENT
dmx.<?=$comp_name;?> = <?=$trolley_summary_json;?>;
dmx.<?=$comp_name;?>.name  			= '<?=$comp_name;?>';
dmx.<?=$comp_name;?>.xclass 		= 'trolley';
dmx.<?=$comp_name;?>.time_stamp 	= new Date();

<?php if (!$err_msg) : ?>

<?php

// Set infortext status for collapsed trolley
switch($status_icon_infotext)
{
	case 'trolley_go':
		$ct_info = 'You are logged in and<br />can proceed to ckeckout';
		break;
	case 'trolley_log':
		$ct_info = 'Log in / register to proceed to checkout';
		break;
	case 'trolley_empty':
		$ct_info = 'Your trolley is empty';
		break;
}

?>

// Ajax debugging?
dmx.<?=$comp_name;?>.ajax_debug = true;

// -------------------------------------------------------------------------------------------------
// COMPONENT METHODS

dmx.<?=$comp_name;?>.poll_start = function(interval)
{
	// interval, the interval between hits, in seconds
	if (interval < 1) return;
	dmx.<?=$comp_name;?>.poll = dmx.<?=$comp_name;?>.poll_trolley_summary.periodical(interval * 1000);
}

dmx.<?=$comp_name;?>.poll_trolley_summary = function()
{
	var params = <?=$xparams_json;?>;
	params.dmb1_SessRef		= dmx.trolley_id;
	params.skip_dmshop		= 1; // Skip dmShop if less than 60 seconds have elapsed
	params.ajax   			= 1;
	params.response_type	= 'json';
	params.ajax_debug   	= dmx.<?=$comp_name;?>.ajax_debug;

	// Poll
	var xajax = new Request.JSON( { url: '/dmx/core/php/xcom_server.php', data: params } );
	xajax.addEvent('onSuccess', function(response) {
			/*
			console.log(dmx.trolley_id);
			console.log(response.source);
			console.log('Deauthenticated in: ' + response.auth_s);
			console.log('Trolley dies in: ' + response.life_s);
			*/
			try
			{
				// Update the trolley if the total or session status has changed
				var update = false;
				if (response.trolley_id	!== dmx.trolley_id)
				{
					// Changing trolleys, as result of lifetime timeout
					// console.log('New trolley ID is ' + response.trolley_id);
					update = true;
					dmx.trolley_id 		= response.trolley_id;
					dmb1_session_ref 	= response.trolley_id;
				}
				if (response.total_inc 		!== dmx.<?=$comp_name;?>.total_inc) 		update = true;
				if (response.session_status !== dmx.<?=$comp_name;?>.session_status) 	update = true;
				if (update) dmx.<?=$comp_name;?>.update_trolley();
			}
			catch(error) {;}
		}
	);
	xajax.post();
}

dmx.<?=$comp_name;?>.update_trolley = function()
{
	// Update the trolley using AJAX

	// console.log('TROLLEY CHANGES');
	
	$clear(dmx.<?=$comp_name;?>.poll);
	
	var params = <?=$xparams_json;?>;
	params.dmb1_SessRef		= dmx.trolley_id;
	params.ajax   			= 1;
	params.ajax_update		= 1; // Component is updating itself
	params.skip_dmshop		= 1; // Initialise trolley from session, don't go via dmShop
	params.response_type	= 'html';
	params.dmx_glib			= '<?=$dmx_glib;?>';
	params.ajax_debug   	= dmx.<?=$comp_name;?>.ajax_debug;

	// Load by ajax
	var xajax = new Request.HTML( { url: '/dmx/core/php/xcom_server.php', data: params, update: '<?=$comp_name;?>' } );
	xajax.post();
}

dmx.<?=$comp_name;?>.show_typinv = function(index)
{
	dmx.<?=$comp_name;?>.change_focus(index);

	// Show typical invoice
	<?php if ($div_typinv) : ?>

	var params = new Object();
	params.dmb1_SessRef		= '<?=$dmx_session;?>';
	params.family 			= 'dmshop';
	params.xclass 			= 'typicalfirstinvoice';
	params.name	  			= '<?=$div_typinv;?>';
	params.ajax   			= 1;
	params.skip_dmshop		= 1; // Initialise trolley from session, don't go via dmShop
	params.response_type	= 'html';
	params.dmx_glib			= '<?=$dmx_glib;?>';
	params.ajax_debug   	= dmx.<?=$comp_name;?>.ajax_debug;
	params.index			= index;
	params.buttonfunc		= 'dmx.<?=$div_typinv;?>.kill(); return false;';

	<?php if ($hook_typinv) : ?>
	// This executes designer specified function in client page, and exits if return value is false, otherwise continues
	// It can modify the ajax request params if desired, otherwise should return them
	params = <?=$hook_typinv;?>(params);
	if (params == false) return;
	<?php endif; ?>

	$('<?=$div_typinv;?>').style.display = 'block';

	// Load by ajax
	var xajax = new Request.HTML( { url: '/dmx/core/php/xcom_server.php', data: params, update: '<?=$div_typinv;?>' } );
	xajax.post();
	return false;
	<?php else: ?>

	// We're not using ajax, so open typical invoice as usual
	return true;
	<?php endif; ?>
}

dmx.<?=$comp_name;?>.show_cce = function(index)
{
	// Show call cost explorer

	dmx.<?=$comp_name;?>.change_focus(index);

	if (dmx.<?=$div_cce;?> != undefined)
	{
		// Update existing CCE
		dmx.<?=$div_cce;?>.change_number(index);
		<?php if ($hook_cce_update) : ?>
		// This executes designer specified function in client page
		<?=$hook_cce_update;?>();
		<?php endif; ?>
	}
	else
	{
		// Load CCE
		var params = new Object();
		params.dmb1_SessRef		= '<?=$dmx_session;?>';
		params.family 			= 'dmshop';
		params.xclass 			= 'callcostexplorer';
		params.name	  			= '<?=$div_cce;?>';
		params.ajax   			= 1;
		params.response_type	= 'html';
		params.ajax_debug   	= dmx.<?=$comp_name;?>.ajax_debug;
		params.index			= index;

		<?php if ($hook_cce) : ?>
		// This executes designer specified function in client page, and exits if return value is false, otherwise continues
		// It can modify the ajax request params if desired, otherwise should return them
		params = <?=$hook_cce;?>(params);
		if (params == false) return;
		<?php endif; ?>

		// Load by ajax
		var xajax = new Request.HTML( { url: '/dmx/core/php/xcom_server.php', data: params, update: '<?=$div_cce;?>' } );
		xajax.post();
	}
	$('<?=$div_cce;?>').style.display = 'block';
}

dmx.<?=$comp_name;?>.change_focus = function(index)
{
	for (var i = 1; i <= <?=$num_items;?>; i++)
	{
		i == index ? $('<?=$comp_name;?>_r' + i).addClass('focuscol') : $('<?=$comp_name;?>_r' + i).removeClass('focuscol');
	}
}

dmx.<?=$comp_name;?>.confirm = function(e)
{
	if (typeof e != 'undefined') e.cancelBubble = true;
	<?php if ($transfer_target == 'new' || $transfer_target == 'new-force') : ?>
		document.forms.<?=$comp_name;?>_confirm.target = 'dmabs';
	<?php elseif ($transfer_target == 'same') : ?>
		document.forms.<?=$comp_name;?>_confirm.target = '_self';
	<?php elseif ($transfer_target == 'top') : ?>
		document.forms.<?=$comp_name;?>_confirm.target = '_top';
	<?php endif; ?>
	<?php if ($transfer_target == 'new-force') : ?>
		var dmabs = window.open('/dmx/core/js/confirm_handler.html', 'dmabs', 'width=1000,height=700,status=1,toolbar=1,scrollbars=1');
		dmabs.onload = function() { tst_submit_form(document.forms.<?=$comp_name;?>_confirm); }
		dmabs.focus();
	<?php else: ?>
		tst_submit_form(document.forms.<?=$comp_name;?>_confirm);
	<?php endif; ?>
}

<?php if ($embedded && $variant == 'collapsed') : ?>
	
	dmx.<?=$comp_name;?>.trolley_init = function()
	{
		var troll = $('<?=$comp_name;?>').getSize();
		$('msg_<?=$comp_name;?>').setStyle('height', troll.y - 3);
		$('<?=$comp_name;?>').addEvent('mouseover', function()
			{
				$('msg_<?=$comp_name;?>').setStyle('display', 'block');
			}
		);
		$('<?=$comp_name;?>').addEvent('mouseout', function()
			{
				$('msg_<?=$comp_name;?>').setStyle('display', 'none');
			}
		);
		$('<?=$comp_name;?>').addEvent('click', dmx.<?=$comp_name;?>.trolley_click_action);
		$('<?=$comp_name;?>').setStyle('cursor', 'pointer');
		$('msg_<?=$comp_name;?>').set('opacity', 0.8);
	}
	
	window.addEvent('domready', dmx.<?=$comp_name;?>.trolley_init);				

<?php endif; ?>

<?php if ($variant == 'collapsed' || $variant == 'compact') : ?>

	dmx.<?=$comp_name;?>.trolley_click_action = function(e)
	{
		if (typeof e != 'undefined') e.cancelBubble = true;
		sim_link = new Object();
		sim_link.href = '<?=DMX_SELF;?>?dmx_action=trolley_clicked&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley';
		<?php if ($embedded) : ?>
			<?php if ($transfer_target == 'new-force') : ?>
				var dmabs = window.open(sim_link.href, 'dmabs', 'width=1000,height=700,status=1,toolbar=1,scrollbars=1');
				dmabs.focus(); // NB:User can often disable this in javascript prefs, and there's nothing we can do
			<?php elseif ($transfer_target == 'new'): ?>
				var dmabs = window.open(sim_link.href, 'dmabs');
				dmabs.focus(); // NB:User can often disable this in javascript prefs, and there's nothing we can do
			<?php else : ?>
				top.location.href = sim_link.href;
			<?php endif; ?>
			return false;
		<?php else: ?>
			tst_follow_link(sim_link);
			return true;
		<?php endif; ?>
	}
	
<?php endif; ?>
		
<?php endif; // End if not $err_msg ?>

</script>

<style type="text/css">

.trolley .pad
{
	padding: 12px;
}

#<?=$comp_name;?>_typinv, #<?=$comp_name;?>_cce
{
	position: absolute;
	z-index: 150;
	top: 0px;
	left: 0px;
	display: none;
	background-color: #FFF;
	margin: 20px;
}

#<?=$comp_name;?>_cce
{
	margin: 30px 150px 0px 100px;
}

</style>

<?php if (!$ajax_update) : ?>
	<div class="dmb0" style="<?=$comp_width;?>">
	<div class="dmx">
	<div class="trolley">
	<div class="<?=$variant;?>">
	<div id="<?=$comp_name;?>" class="<?=$comp_name;?>">
<?php endif; ?>

<?php if ($variant != 'collapsed') : ?>
	<?php if ($showheader && $showborder) : ?>
	<h1 class="bordered">Trolley</h1>
	<?php elseif ($showheader) : ?>
	<h1>Trolley</h1>
	<?php endif; ?>
<?php endif; ?>

<?php if ($showborder) : ?>
<div class="border" style="<?=$box_size;?>">
<?php else: ?>
<div  style="<?=$box_size;?>">
<?php endif; ?>

<?php if (!$err_msg) : ?>

	<form name="<?=$comp_name;?>_confirm" action="<?=DMX_SELF;?>" target="_top" method="GET" style="display: none;">
	<input type="hidden" name="dmx_action" value="confirm_order">
	<input type="hidden" name="dmx_total_plus_outst" value="<?=$total_plus_outst;?>">
	<input type="hidden" name="dmx_cust_id" value="<?=$cust_id;?>">
	<input type="hidden" name="dmx_header_url" value="<?=$headerurl;?>">
	<input type="hidden" name="dmx_ganal_accno" value="<?=$ganal_accno;?>">
	<input type="hidden" name="dmx_ganal_trans_rep" value="<?=$ganal_trans_rep;?>">
	<input type="hidden" name="dmx_rc" value="<?=$rc_forms;?>">
	<input type="hidden" name="dmx_comp_name" value="<?=$comp_name;?>">
	<input type="hidden" name="dmx_comp_class" value="trolley">
	</form>

	<?php if ($variant == 'collapsed') : ?>

		<!-- TROLLEY COLLAPSED -->
		<style type="text/css">
		
		#<?=$comp_name;?>
		{
			position: relative;
		}
		
		#msg_<?=$comp_name;?>
		{
			position: absolute;
			top: 0px;
			left: 0px;
			width: 100%;
			height: 27px;
			text-align: center;
			padding-top: 3px;
			background-color: #36364D;
			display: none;
			z-index: 100;
			color: #FFF;
			font-weight: bold;
			line-height: 110%;
		}
		
		</style>
	
		<div>
			<div id="msg_<?=$comp_name;?>">Open full<br />trolley</div>
			<table class="vert_centered" align="center">
				<tr>
					<td>
						<a href="#" class="nu"><img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" class="infotext" /><span class="tipcontents"><!-- <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" />&nbsp; --><b>Your shopping trolley</b><br />Click here to see full details of your order</span></a>
						
					</td>
					<td>
						<span class="price"><strong><?=$currency_symbol;?><?=$total_inc;?></strong></span>
					</td>
					<td>
						<?php if ($logged_in) : ?>
							<?php if ($authenticated) : ?>
								<img src="<?=$dmx_glib;?>interface/sess_known_priv_14.gif" width="14" height="14" border="0" alt="" class="infotext" /><span class="tipcontents"><?=$ct_info;?></span>
							<?php else: ?>
								<img src="<?=$dmx_glib;?>interface/sess_known_unpriv_14.gif" width="14" height="14" border="0" alt="" class="infotext" /><span class="tipcontents"><?=$ct_info;?></span>
							<?php endif; ?>
						<?php else: ?>
							<img src="<?=$dmx_glib;?>interface/sess_anonymous.gif" width="14" height="14" border="0" alt="" class="infotext" /><span class="tipcontents"><?=$ct_info;?></span>
						<?php endif; ?>
					</td>
				</tr>
			</table>
		</div>
		<!-- END TROLLEY COLLAPSED -->

	<?php endif; ?>

	<?php if ($variant == 'compact') : ?>

		<!-- TROLLEY COMPACT -->
		<table class="vert_centered" style="width: 100%; border-spacing: 0px; margin-bottom: 2px;">
			<tr>
				<td>
					<?php if ($cust_id) : ?>
						<?=$cust_id;?> <?php if ($authenticated) : ?>(+)<?php else : ?>(-)<?php endif;?>
					<?php endif; ?>
				</td>
				<td style="text-align: right;"><a href="<?=DMX_SELF;?>?dmx_action=trolley_clicked&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="nu"><img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" class="infotext" /><span class="tipcontents"><!-- <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" />&nbsp; --><b>Your shopping trolley</b><br />Click here to see full details of your order </span></a></td>
			</tr>
		</table>
		<table class="vert_centered" style="width: 100%; border-spacing: 0px;" cellspacing="0">
		<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
	
		<?php if ($num_items > 0) : ?>
	
			<?php for ($i= 0; $i < $num_items; $i++) : ?>
				<tr id="<?=$comp_name;?>_r<?=($i+1);?>"<?php if ($focus == $i + 1) : ?> class="focuscol"<?php endif;?>>
					<td style="padding: 2px;">
						<?php if ($showicons) : ?>
							<!-- SERVICE GRAPHIC NUMBER, WITH ACTUAL NUMBER INSERTED -->
							<span class="icon_blocks">
								<a href="<?=DMX_SELF;?>?dmx_action=configure&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="infotext nu">
									<img src="<?=$dmx_glib;?>/numbers/butt_32.gif" width="12" height="32" alt="" />
									<span class="fullnum"><?=$item[$i]['sg_num'];?></span>
									<img src="<?=$dmx_glib;?>numbers/<?=$item[$i]['sg_icon'];?>_cap_32.gif" alt="" width="56" height="32">
									<img src="<?=$dmx_glib;?>numbers/<?=$item[$i]['sg_plan'];?>_32.gif" alt="" width="73" height="32">
								</a>
								<span class="tipcontents"><?=$adjust_scv_plan_info;?></span>
							</span>
							<!-- END SERVICE GRAPHIC NUMBER, WITH ACTUAL NUMBER INSERTED -->
						<?php else : ?>
							<a href="<?=DMX_SELF;?>?dmx_action=configure&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="infotext nu"><?=$item[$i]['formatted'];?><span class="tipcontents"><?=$adjust_scv_plan_info;?></span></a>
							<img src="<?=$dmx_glib;?>interface/sp_9.gif" width="14" height="9" alt="" style="padding-left: 10px;" class="infotext" /><span class="tipcontents"><?=$item[$i]['service'];?> <?=$item[$i]['plan'];?></span>
						<?php endif; ?>
					</td>
					<td style="text-align: right;"><a href="<?=DMX_SELF;?>?dmx_action=show_typical_invoice&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_num_f=<?=$item[$i]['formatted'];?>&dmx_popup=<?=$usepopup;?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" target="<?=$usepopup;?>" onclick="this.blur(); return dmx.<?=$comp_name;?>.show_typinv(<?=($i+1);?>);" class="<?=$price_class;?> infotext nu"><?=$currency_symbol;?><?=$item[$i]['price'];?><span class="tipcontents">See a breakdown of this price<br />in a typical first invoice</span></a></td>
				</tr>
				<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
			<?php endfor; ?>
	
			</table>
			<table class="vert_centered" style="width: 100%;">
	
			<?php if ($showtotals) : ?>
				<!-- VAT & TOTAL -->
				<tr>
					<td class="cell_plain_thin" style="text-align: right; width: 70%;">VAT</td>
					<td class="cell2f_thin" style="text-align: right; width: 30%;"><?=$currency_symbol;?><?=$total_tax;?></td>
				</tr>
				<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
				<tr>
					<td class="cell_plain_thin" style="text-align: right;"><span class="price"><strong>Total</strong></span></td>
					<td class="cell2i_thin" style="text-align: right;"><span class="price"><strong><?=$currency_symbol;?><?=$total_inc;?><strong></span></td>
				</tr>
				<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
				<!-- END VAT & TOTAL -->
			<?php endif; ?>
	
			<?php if ($showpreamble && $showactions) : ?>
				<tr>
					<td colspan="2" class="cell_plain">
						<?php if ($logged_in) : ?>
							<?php if ($checkout_ready) : ?>
								<?php if ($authenticated) : ?>
									<strong>All numbers are ready.</strong>
								<?php else: ?>
									<strong>All numbers are ready.<br />Login again to continue.</strong>
								<?php endif; ?>
							<?php else: ?>
								<strong>Configure all numbers to proceed.</strong>
							<?php endif; ?>
						<?php else: ?>
							<strong>Login / register to complete order.</strong>
						<?php endif; ?>
					</td>
				</tr>
			<?php endif; ?>
	
			<?php else: ?>
				<!-- EMPTY TROLLEY -->
				<tr><td colspan="2" class="cell2f">Your shopping trolley is empty.</td></tr>
				<!-- END EMPTY TROLLEY -->
				<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
			<?php endif; ?>
	
			<?php if ($showactions) : ?>
				<tr>
					<td colspan="2" class="cell_plain">
						<div class="grabut_left_forward">
							<ul>
								<li>
									<?php if ($logged_in) : ?>
										<?php if ($num_items > 0) : ?>
											<?php if ($authenticated) : ?>
												<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;">Confirm&nbsp;Order</a>
											<?php else: ?>
												<a href="<?=DMX_SELF;?>?dmx_action=reauthenticate&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley">Continue</a>
											<?php endif; ?>
										<?php elseif ($outst_num) : ?>
											<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;">Go&nbsp;to&nbsp;Your&nbsp;Account</a>
										<?php endif; ?>
									<?php elseif ($num_items > 0) : ?>
										<a href="<?=DMX_SELF;?>?dmx_action=display_loginregister&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley">Login&nbsp;/&nbsp;Register</a>
									<?php endif; ?>
								</li>
							</ul>
						</div>
					</td>
				</tr>
			<?php endif; ?>
	
			<?php if ($outst_num > 0) : ?>
				<tr><td colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="3" alt=""></td></tr>
				<tr>
					<td colspan="2">
						<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" align="right" class="infotext" /><span class="tipcontents"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" /> <b>Your account</b><br />Lists services ordered from this<br />shopping trolley that remain unpaid.<br />Currently <?=$currency_symbol;?><?=$outst_total;?> unpaid on <?=$outst_num;?> order<?php if ($outst_num > 1) : ?>s<?php endif;?>.<br /><br />Once you go to checkout, items<br />from your trolley ( <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" /> ) appear in<br />your 'clubhouse' and can be<br />paid for from your account.</span></a>
						<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;" class="infotext nu"><?=$outst_num;?> outstanding order<?php if ($outst_num > 1) :?>s<?php endif; ?> (<?=$currency_symbol;?><?=$outst_total;?>)<span class="tipcontents"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" /> <b>Your account</b><br />Lists services ordered from this<br />shopping trolley that remain unpaid.<br />Currently <?=$currency_symbol;?><?=$outst_total;?> unpaid on <?=$outst_num;?> order<?php if ($outst_num > 1) : ?>s<?php endif;?>.<br /><br />Once you go to checkout, items<br />from your trolley ( <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" /> ) appear in<br />your 'clubhouse' and can be<br />paid for from your account.</span></a>
					</td>
				</tr>
				<tr><td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
			<?php endif; ?>
	
			</table>
		<!-- END TROLLEY COMPACT -->

	<?php endif; ?>

	<?php if ($variant == 'full') : ?>

		<!-- TROLLEY FULL -->
	
		<?php if ($comp_err_msg) : ?>
		<span class="error"><?=$comp_err_msg;?><br></span>
		<?php elseif ($comp_msg) : ?>
		<?=$comp_msg;?><br>
		<?php endif; ?>
	
		<table class="vert_centered" style="width: 100%; border-spacing: 0px;" cellspacing="0" border="0">
			<tr class="detailed">
				<td colspan="2" style="vertical-align: bottom; padding-bottom: 2px;">
					<img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="">
					<?php if ($cust_id) : ?>
						<?=$cust_id;?> <?php if ($authenticated) : ?>(+)<?php else : ?>(-)<?php endif;?>
					<?php endif; ?>
				</td>
				<?php if ($num_items > 0) : ?>
					<td style="text-align: right; vertical-align: bottom; padding-bottom: 2px; width: 70px;">{GLOS:one_off}</td>
					<td style="text-align: right; vertical-align: bottom; padding-bottom: 2px; width: 70px;">{GLOS:monthly}</td>
					<td colspan="2" style="text-align: right; vertical-align: bottom; padding-bottom: 2px; width: 100px;">UK landline<br />{GLOS:call_rate} {GLOS:ppm}</td>
					<td style="text-align: right; vertical-align: bottom; padding-bottom: 2px; width: 80px;">Initial<br />Payment</td>
				<?php else: ?>
					<td colspan="7"></td>
				<?php endif; ?>
			</tr>
			<tr><td class="divider" colspan="7"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
	
			<?php if ($num_items > 0) : ?>
				<?php for ($i = 0; $i < $num_items; $i++) : ?>
					<tr id="<?=$comp_name;?>_r<?=($i+1);?>"<?php if ($focus == $i + 1) : ?> class="focuscol"<?php endif;?>>
						<td style="padding: 2px;">
							<?php if ($showicons) : ?>
								<!-- SERVICE GRAPHIC NUMBER, WITH ACTUAL NUMBER INSERTED -->
								<span class="icon_blocks">
									<a href="<?=DMX_SELF;?>?dmx_action=configure&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="infotext nu">
										<img src="<?=$dmx_glib;?>/numbers/butt_32.gif" width="12" height="32" alt="" />
										<span class="fullnum"><?=$item[$i]['sg_num'];?></span>
										<img src="<?=$dmx_glib;?>numbers/<?=$item[$i]['sg_icon'];?>_cap_32.gif" alt="" width="56" height="32">
										<img src="<?=$dmx_glib;?>numbers/<?=$item[$i]['sg_plan'];?>_32.gif" alt="" width="73" height="32">
									</a>
									<span class="tipcontents"><?=$adjust_scv_plan_info;?></span>
								</span>
								<!-- END SERVICE GRAPHIC NUMBER, WITH ACTUAL NUMBER INSERTED -->
							<?php else : ?>
								<a href="<?=DMX_SELF;?>?dmx_action=configure&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="infotext nu"><?=$item[$i]['formatted'];?><span class="tipcontents"><?=$adjust_scv_plan_info;?></span></a>
								<span style="padding-left: 10px;"><img src="<?=$dmx_glib;?>interface/sp_9.gif" width="14" height="9" alt="" class="infotext" /><span class="tipcontents"><?=$item[$i]['service'];?> <?=$item[$i]['plan'];?></span></span>
							<?php endif; ?>
						</td>
						<td style="text-align: center;">
							<?php if ($showoptions) : ?><a href="<?=DMX_SELF;?>?dmx_action=configure&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="img"><img src="<?=$dmx_glib;?>interface/tools_15.gif" width="15" height="15" style="border: 0px; padding-left: 10px;" alt="" class="infotext" /><span class="tipcontents">Change service<br />and call plan</span></a><?php endif; ?>
							<a href="<?=DMX_SELF;?>?dmx_action=delete&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" class="img"><img src="<?=$dmx_glib;?>interface/delete_15.gif" width="15" height="15" style="border: 0px; padding: 0px 10px;" alt="" class="infotext" /><span class="tipcontents">Remove number from trolley</span></a>
						</td>
						<td style="text-align: right;"><?=$currency_symbol;?><?=$item[$i]['setup'];?></td>
						<td style="text-align: right;"><?=$currency_symbol;?><?=$item[$i]['rental'];?></td>
						<td style="text-align: right;"<?php if ($item[$i]['payout']) : ?> class="payout"<?php endif;?>><?=$item[$i]['ukllppm'];?></td>
						<td style="text-align: right; width: 35px;">
							<?php if ($item[$i]['payout']) : ?><img src="<?=$dmx_glib;?>interface/payout_15.gif" width="14" height="15" alt="" class="infotext" /><span class="tipcontents"><b>Payout:</b> Calls to number can result in payout to you</span><?php endif; ?>
							<a href="#" onclick="this.blur(); dmx.<?=$comp_name;?>.show_cce(<?=($i+1);?>); return false;" class="img"><img src="<?=$dmx_glib;?>interface/globe_15.gif" width="15" height="15" alt="" style="border: 0px; padding: 0px;" class="infotext" /><span class="tipcontents">Open the 'Call Cost Explorer' to see<br />call rates for forwarding to non-UK landlines</span></a>
						</td>
						<td style="text-align: right;"><a href="<?=DMX_SELF;?>?dmx_action=show_typical_invoice&dmx_index=<?=($i+1);?>&dmx_num=<?=$item[$i]['native'];?>&dmx_num_f=<?=$item[$i]['formatted'];?>&dmx_popup=<?=$usepopup;?>&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley" target="<?=$usepopup;?>" onclick="this.blur(); return dmx.<?=$comp_name;?>.show_typinv(<?=($i+1);?>);" class="<?=$price_class;?> nu infotext"><?=$currency_symbol;?><?=$item[$i]['price'];?><span class="tipcontents">See a breakdown of this price<br />in a typical first invoice</span></a></td>
					</tr>
					<tr><td class="divider" colspan="7"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
				<?php endfor; ?>
			</table>
	
			<table class="vert_centered" style="width: 100%;">
	
				<?php if ($showtotals) : ?>
					<!-- VAT & TOTAL -->
					<tr>
						<td colspan="4" rowspan="2" class="cell_plain" style="text-align: left; vertical-align: top; line-height: 130%;">
							<?php if ($showpreamble && $showactions) : ?>
								<?php if ($logged_in) : ?>
									<?php if ($checkout_ready) : ?>
										<?php if ($authenticated) : ?>
											<strong>You are logged in and all numbers are ready.</strong>
										<?php else: ?>
											<strong>All numbers are ready.<br />Login again to continue with your order.</strong>
										<?php endif; ?>
									<?php else: ?>
										<strong>You need to configure all numbers to proceed.</strong>
									<?php endif; ?>
								<?php else: ?>
									<strong>Login or register to complete your order.</strong>
								<?php endif; ?>
							<?php endif; ?>
						</td>
						<td class="cell2f" style="text-align: right; white-space: nowrap;">Total ex. VAT</td>
						<td class="cell2f" style="text-align: right;"><?=$currency_symbol;?><?=$total_net;?></td>
					</tr>
					<tr>
						<td class="cell2f" style="text-align: right;">VAT</td>
						<td class="cell2f" style="text-align: right;"><?=$currency_symbol;?><?=$total_tax;?></td>
					</tr>
					<tr>
						<td colspan="4"></td>
						<td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td>
					</tr>
					<tr>
						<td colspan="4">
							<?php if ($showactions) : ?>
								<div class="grabut_left_forward">
									<ul>
										<li>
											<?php if ($logged_in) : ?>
												<?php if ($authenticated) : ?>
													<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;">Confirm&nbsp;Order</a>
												<?php else: ?>
													<a href="<?=DMX_SELF;?>?dmx_action=reauthenticate&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley">Continue With Order</a>
												<?php endif; ?>
											<?php else: ?>
												<a href="<?=DMX_SELF;?>?dmx_action=display_loginregister&dmx_rc=<?=$rc_links;?>&dmx_comp_name=<?=$comp_name;?>&dmx_comp_class=trolley">Login&nbsp;/&nbsp;Register</a>
											<?php endif; ?>
										</li>
									</ul>
								</div>
							<?php endif; ?>
						</td>
						<td class="cell2i" style="text-align: right; width: 68px;"><span class="price"><strong>Total</strong></span></td>
						<td class="cell2i" style="text-align: right; width: 68px;"><span class="price"><strong><?=$currency_symbol;?><?=$total_inc;?><strong></span></td>
					</tr>
					<tr>
						<td colspan="4"></td>
						<td class="divider" colspan="2"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td>
					</tr>
					<!-- END VAT & TOTAL -->
				<?php endif; ?>
			<?php else: ?>
				<!-- EMPTY TROLLEY -->
				<tr>
					<td colspan="6" class="cell_plain">Your shopping trolley is empty.</td>
				</tr>
				<tr>
					<td colspan="6" class="cell_plain">
						<?php if ($logged_in && $outst_num) : ?>
						<div class="grabut_left_forward"><ul><li>
						<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;">Go&nbsp;to&nbsp;Your&nbsp;Account</a>
						<?php endif; ?>
						</li></ul></div>
					</td>
				</tr>
				<!-- END EMPTY TROLLEY -->
			<?php endif; ?>
	
			<?php if ($outst_num > 0) : ?>
				<tr><td class="cell_plain" colspan="6"></td></tr>
				<tr><td class="cell_plain" colspan="6"></td></tr>
				<tr>
					<td colspan="6" style="text-align: right; padding-right: 0px;"><a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" align="right" class="infotext" /><span class="tipcontents"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" /> <b>Your account</b><br />Lists services ordered from this<br />shopping trolley that remain unpaid.<br />Currently <?=$currency_symbol;?><?=$outst_total;?> unpaid on <?=$outst_num;?> order<?php if ($outst_num > 1) : ?>s<?php endif;?>.<br /><br />Once you go to checkout, items<br />from your trolley ( <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" /> ) appear in<br />your 'clubhouse' and can be<br />paid for from your account.</span></a></td>
				</tr>
				<tr><td class="divider" colspan="6"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt=""></td></tr>
				<tr>
					<td colspan="5" class="cell_plain">
						<a href="#" onclick="dmx.<?=$comp_name;?>.confirm(event); return false;" class="infotext"><?=$outst_num;?> outstanding order<?php if ($outst_num > 1) :?>s<?php endif; ?><span class="tipcontents"><img src="<?=$dmx_glib;?>interface/account_15.gif" width="16" height="15" border="0" alt="" /> <b>Your account</b><br />Lists services ordered from this<br />shopping trolley that remain unpaid.<br />Currently <?=$currency_symbol;?><?=$outst_total;?> unpaid on <?=$outst_num;?> order<?php if ($outst_num > 1) : ?>s<?php endif;?>.<br /><br />Once you go to checkout, items<br />from your trolley ( <img src="<?=$dmx_glib;?>interface/trolley_15.gif" width="18" height="15" border="0" alt="" /> ) appear in<br />your 'clubhouse' and can be<br />paid for from your account.</span></a>
					</td>
					<td class="cell2i" style="text-align: right;"><strong><?=$currency_symbol;?><?=$outst_total;?></strong></td>
				</tr>
				<tr><td class="divider" colspan="6"><img src="<?=$dmx_glib;?>clear.gif" width="1" height="1" alt="" /></td></tr>
			<?php endif; ?>
	
		</table>
		<!-- END TROLLEY FULL -->

	<?php endif; ?>

<?php else : ?>
	<!-- ERROR HANDLING -->
	<?php if ($variant == 'collapsed') : ?>
	<div class="error" style="vertical-align: middle;">
		<span class="infotext">WE'RE SORRY<span class="tipcontents"><?=$err_msg;?></span></span>
	</div>
	<?php else: ?>
	<div style="vertical-align: middle;">
	<img src="<?=$dmx_glib;?>interface/error_32.gif" alt="" width="36" height="32" border="0" style="float: left; padding: 0 10px 0 0;"><span class="error">WE'RE SORRY<br><?=$err_msg;?></span>
	</div>
	<?php endif; ?>
	<!-- END ERROR HANDLING -->
<?php endif; ?>

</div>

<?php if (!$ajax_update) : ?>
	</div>
	</div>
	</div>
	</div>
	</div>
<?php endif; ?>

<div id="<?=$comp_name;?>_typinv"><img src="<?=$dmx_glib;?>interface/ajax_loader_col1.gif" width="16" height="16" alt="" class="loaderpad"> Loading Example Invoice</div>
<div id="<?=$comp_name;?>_cce"><img src="<?=$dmx_glib;?>interface/ajax_loader_col1.gif" width="16" height="16" alt="" class="loaderpad"> Loading Call Cost Explorer</div>

<?php if ($auto_sync_interval) : ?>
	<script language="javascript">
	dmx.<?=$comp_name;?>.poll_start(<?=$auto_sync_interval;?>);
	</script>
<?php endif; ?>

<!-- ********************* -->
<!-- END TROLLEY COMPONENT -->
<!-- ********************* -->
