<div id="main_borders">
  <div id="main_inner_borders">
    <h2><strong>
      <?=$this->lang->line('shopping_cart')?>
      </strong></h2>
       <? if ($this-> session-> flashdata('message')): ?>
    <div class='warning'>
      <?=$this-> session-> flashdata('message');?>
    </div>
    <? endif; ?>

<? if ($this->cart->contents()) { ?>
<?php echo form_open('page/update_cart'); ?>
<div id="cart_tbl">
<table cellpadding="6" cellspacing="1" style="width:100%" border="0">
<tr>
  <th><?=$this->lang->line('cart_qty')?></th>
  <th><?=$this->lang->line('cart_desc')?></th>
  <th style="text-align:right"><?=$this->lang->line('cart_price')?></th>
  <th style="text-align:right"><?=$this->lang->line('cart_sub')?></th>
  <th style="text-align:right"><?=$this->lang->line('cart_actions')?></th>
</tr>

<?php $i = 1; ?>
<?php foreach($this->cart->contents() as $items): ?>

	<?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
	
	<tr>
	  <td>
	  <?php echo form_input(array('name' => $i.'[qty]', 'id' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?>
	  <?php //echo $items['qty']; ?></td>
	  <td>
      <? // $name = iconv('utf-8','ISO-8859-1',$items['name']); 
	  $product_details = $this->MFuncs->getProductDetails($items['id']); ?>
		<?php echo $product_details['name']; ?>
					
			<?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
					
				<?php /*?><p>
					<?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
						
						<strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />
										
					<?php endforeach; ?>
				</p><?php */?>
				
			<?php endif; ?>
				
	  </td>
	  <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
	  <td style="text-align:right">&euro;<?php echo $this->cart->format_number($items['subtotal']); ?></td>
      <td style="text-align:right"><?=anchor('remove_product/'.$items['rowid'], $this->lang->line('remove_item'));?></td>

	</tr>

<?php $i++; ?>
<? 
$weight = 0;
$weight = $weight + ($product_details['weight'] * $items['qty']);
//echo $weight;
?>
<?php endforeach; ?>

<tr>
  <td colspan="2"> </td>
  <td class="right"><strong><?=$this->lang->line('cart_total')?></strong></td>
  <td class="right">&euro;<?php echo $this->cart->format_number($this->cart->total()); ?></td>
  <td>&nbsp;</td>
</tr>

</table>
<br />
<em><?=$this->lang->line('vat_included_cart')?></em>
</div><br />
        <div class="buttons">
<button type="submit" class="positive"> <?=$this->lang->line('cart_update')?> </button>
<?=anchor("complete_order_1", $this->lang->line('cart_complete'),array('id'=>'back_btn','class'=>'positive'))?></div>
 <?=form_close();?>
<br />
<br />
<br />
<h2><strong>
      <?=$title?>
      </strong></h2><br />
<? if ($postal_results==true) { ?>
<? $county = $this->MFuncs->GetCountybyPostal_new($postal_input); ?>
<? if ($county) { ?>
<h4><?=$this->lang->line('shipping_method')?></h4><br />
<P><img src="<?=base_url()?>images/new/plus_icon.png" align="absmiddle" />&nbsp;<strong><?=$this->lang->line('no_delivery');?></strong></P>
<? if (($county['flag']=='attica-center') || ($county['flag']=='attica-suberbs') || ($county['flag']=='attica-suberbs-out') || ($county['flag']=='attica-rest') || ($county['flag']=='attica-peir') || ($county['flag']=='attica-peir-out')) { ?>
 <?          if ($county['flag']=='attica-center') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(0, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(2.90, 2, '.', '');
			   } else {
			   $ship_total = number_format(4.96, 2, '.', '');
			   }
		   } elseif ($county['flag']=='attica-suberbs') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(3.90, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(6.90, 2, '.', '');
			   } else {
			   $ship_total = number_format(9.90, 2, '.', '');
			   }
		   } elseif ($county['flag']=='attica-suberbs-out') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(5.90, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(9.90, 2, '.', '');
			   } else {
			   $ship_total = number_format(13.90, 2, '.', '');
			   }
		   } elseif ($county['flag']=='attica-rest') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(2.90, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(4.96, 2, '.', '');
			   } else {
			   $ship_total = number_format(6.90, 2, '.', '');
			   }
		   } elseif ($county['flag']=='attica-peir') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(3.90, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(6.90, 2, '.', '');
			   } else {
			   $ship_total = number_format(9.90, 2, '.', '');
			   }
		   } elseif ($county['flag']=='attica-peir-out') {
			   if ($weight < 20000) {
			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
			   $ship_total = number_format(5.90, 2, '.', '');
			   } elseif ($weight < 50000) {
			   $ship_total = number_format(9.90, 2, '.', '');
			   } else {
			   $ship_total = number_format(13.90, 2, '.', '');
			   } 
		   }?>
<P><img src="<?=base_url()?>images/new/plus_icon.png" align="absmiddle" />&nbsp;<strong><?=$this->lang->line('courier_delivery');?>&nbsp;<?=$ship_total?> &euro;</strong></P>
<? } elseif (($county['flag']=='attica') || ($county['flag']=='greece') || ($county['flag']=='crete')) { ?>
 <? if ($county['flag']=='attica') { ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_attica_cost'); ?>
            <? if ($value_ship) { ?>
            <? $courier_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $courier_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_attica_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_attica_cost'); ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            <? } ?>
	<? if ($county['flag']=='greece') { ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_greece_cost'); ?>
            <? if ($value_ship) { ?>
            <? $courier_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $courier_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_greece_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_greece_cost'); ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            <? } ?>
	<? if ($county['flag']=='crete') { ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_crete_cost'); ?>
            <? if ($value_ship) { ?>
            <? $courier_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $courier_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? $i = ceil($weight/1000); ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_crete_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_crete_cost'); ?>
            <? if ($value_ship) { ?>
            <? $elta_ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $elta_ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            <? } ?>
<? if ($can_ship==true) { ?>
<P><img src="<?=base_url()?>images/new/plus_icon.png" align="absmiddle" />&nbsp;<strong><?=$this->lang->line('courier_delivery');?>&nbsp;<?=$courier_ship_total?> &euro;</strong></P>
<? } ?>
<P><img src="<?=base_url()?>images/new/plus_icon.png" align="absmiddle" />&nbsp;<strong><?=$this->lang->line('elta_delivery');?>&nbsp;<?=$elta_ship_total?> &euro;</strong></P>
<? } ?>
<? } else { ?>
<h4><?=$this->lang->line('transfer_estimator_not_valid_postal')?></h4>
<? } ?>
<? } ?>
<br />
		<? $attributes = array('class' => 'yform','AUTOCOMPLETE'=>'off'); ?> 
		<?=form_open('page/transfer_estimator_step2',$attributes); ?>
          <fieldset>
        <p>
          <?=$this->lang->line('transfer_estimator_txt')?>
        </p>
            <div class="type-text"> 
			<?=form_label(lang('postal'), 'postal')?> 
			<? $data = array('name'=>'postal','id'=>'postal','value'=>$this->input->post('postal'))?> 
			<?=form_input($data); ?> 
            </div>
          </fieldset>
          
          <div class="buttons">
          <button type="submit" class="positive"> 
		  <?=$this->lang->line('continue')?> 
          </button>
          </div>
          <?=form_close();?>
        </div>

<? } else { 
redirect('home','location');
} ?>
</div>
</div>