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

<? if ($this->cart->contents()) { ?>
<div id="cart_tbl">
      <table class="full" border="0">
        <tr>
          <th><?=$this->lang->line('cart_qty')?></th>
          <th><?=$this->lang->line('cart_desc')?></th>
          <th><?=$this->lang->line('cart_price')?></th>
          <th><?=$this->lang->line('cart_sub')?></th>
        </tr>
        <?		$order_details = $this->MFuncs->GetOrderDetails($orderdata['id']);
		if ($order_details) {
		$total = 0;
		$weight = 0;
		$bot_num = 0;
		$pack_total = 0;
		$ship_total = 0;
    	foreach($order_details as $result=>$order_det):
        $product_details = $this->MFuncs->getProductDetails($order_det['product_id']); 
        $product_category = $this->MFuncs->getProductCat($order_det['product_id']); ?>
        <tr>
          <td><?=$order_det['quantity']?></td>
          <td><?=$product_details['name']?></td>
          <td><?=$order_det['price']?></td>
          <td>&euro;
            <?=$order_det['price']*$order_det['quantity']?></td>
          <? $total = $total + $order_det['price']*$order_det['quantity']; ?>
          <? $weight = $weight + ($product_details['weight'] * $order_det['quantity']); ?>
          <? if ($product_category['cat_id']!='7') { ?>
          <? $bot_num = $bot_num + $order_det['quantity']; 
		  } ?>
        </tr>
        <? endforeach ?>
        <? $pay_on_arrival_cost=0; ?>
        <? $can_ship=true; ?>
        <tr>
          <td colspan="2"></td>
          <td><strong>
            <?=$this->lang->line('cart_total')?>
            </strong></td>
  <td>&euro;<?=number_format($total, 2, '.', '')?></td>
</tr>
<? if ($orderdata['offer_code']!=0) { ?>
 <tr>
 <td colspan='2'> </td>
 <td><strong><?=$this->lang->line('cart_discount')?></strong></td>
 <td>&euro; <?=number_format($total*$orderdata['offer_code'], 2, '.', '')?></td>
 </tr>
 <? $total = $total - ($total*$orderdata['offer_code']); ?>
 <tr>
 <td colspan='2'> </td>
 <td><strong><?=$this->lang->line('cart_total')?></strong></td>
 <td>&euro; <?=number_format($total, 2, '.', '')?></td>
 </tr>
 <? } ?>
		<? if (($select==true) &&($sel_loc==true)) { ?>
        <? if ($orderdata['same_address']=='No') { ?>
 			<? $c_id = $orderdata['country_id']; ?>
        <? } elseif ($orderdata['same_address']=='Yes') { ?>
            <? $c_id = $userdata['country_id']; ?>
        <? } ?>
       <? if ($c_id!='1') { ?>
       <? if ($orderdata['ship_method']=='courier_economy') { ?>
       <? 	//$rounded_weight = round($weight/1000, 2);
	   		$rounded_weight = ceil($weight/1000);
			$insurance_cost = $rounded_weight*0.05;
			if ($insurance_cost>10) { $insurance_cost=10; }
			$country_zone = $this->MFuncs->getCountryZone($c_id);
			$value = $this->MFuncs->getTNT_Cost_economy($rounded_weight, $country_zone['tnt_zones']);
			$ship_total = ($value['price']*0.205) + $value['price'];
			//if (($country_zone['zones']=='F') || ($country_zone['zones']=='FCY') || ($country_zone['zones']=='M')) {
			$ship_total = ($ship_total*0.23) + $ship_total;
			//}
			$ship_total = $insurance_cost + $ship_total;
			$ship_total = number_format($ship_total, 2, '.', ''); ?>
        <? } elseif ($orderdata['ship_method']=='courier_express') { ?>
       <? 	//$rounded_weight = round($weight/1000, 2);
	   		$rounded_weight = ceil($weight/1000);
			$insurance_cost = $rounded_weight*0.05;
			if ($insurance_cost>10) { $insurance_cost=10; }
			$country_zone = $this->MFuncs->getCountryZone($c_id);
			if ($rounded_weight<=30) {
			$value = $this->MFuncs->getTNT_Cost_express($rounded_weight, $country_zone['tnt_zones_express']);
			$total_ship_cost = $value['price'];
			} else {
			$value = $this->MFuncs->getTNT_Cost_express(30, $country_zone['tnt_zones_express']);
			$extra_cost_pk = $this->MFuncs->getTNT_extra_Cost($country_zone['tnt_zones_express']);
			$extra_ship_cost = (($rounded_weight-30) * $extra_cost_pk['price']);
			$total_ship_cost = $extra_ship_cost + $value['price'];
			}
			$ship_total = ($total_ship_cost*0.205) + $total_ship_cost;
			//if (($country_zone['zones']=='F') || ($country_zone['zones']=='FCY') || ($country_zone['zones']=='M')) {
			$ship_total = ($ship_total*0.23) + $ship_total;
			//}
			$ship_total = $insurance_cost + $ship_total;
			$ship_total = number_format($ship_total, 2, '.', ''); ?>
        <? }?>
        <? } else { ?>
       <? if (($orderdata['ship_method']=='courier') || ($orderdata['ship_method']=='elta') ){
		   $pack_total = (ceil($bot_num/2))*0.53;
           if ($orderdata['ship_dest']=='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 ($orderdata['ship_dest']=='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 ($orderdata['ship_dest']=='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 ($orderdata['ship_dest']=='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 ($orderdata['ship_dest']=='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 ($orderdata['ship_dest']=='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, '.', '');
			   }
/////
//			   if ($weight == 0) { 
//			   $ship_total = number_format(0, 2, '.', '');
//			   } 
//			   elseif ($weight < 3000) {
//			   //$ship_total = number_format(3.45 + $pack_total, 2, '.', ''); 
//			   $ship_total = number_format(3.57, 2, '.', '');
//			   } else {
//			   //$ship_total = 3.45 + $pack_total;
//			   $ship_total = 3.57;
//			   $weight = $weight - 3000;
//			   $i = ceil($weight/1000);
//			   $ship_total = number_format($ship_total + ($i*1.00), 2, '.', '');
//			   }

		   } elseif ($orderdata['ship_dest']=='attica') { ?>
            <? $i = ceil($weight/1000); ?>
			<? if ($orderdata['ship_method']=='courier') { ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_attica_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } elseif ($orderdata['ship_method']=='elta') { ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_attica_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_attica_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            
            <? } ?>
	   
		  <? } elseif ($orderdata['ship_dest']=='greece') { ?>
            <? $i = ceil($weight/1000); ?>
			<? if ($orderdata['ship_method']=='courier') { ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_greece_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } elseif ($orderdata['ship_method']=='elta') { ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_greece_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_greece_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            
            <? } ?>
 		  <? } elseif ($orderdata['ship_dest']=='crete') { ?>
            <? $i = ceil($weight/1000); ?>
			<? if ($orderdata['ship_method']=='courier') { ?>
            <? if ($i>35) { ?>
            <? $can_ship=false; ?>
            <? } else { ?>
            <? $can_ship=true; ?>
            <? } ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'courier_crete_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } elseif ($orderdata['ship_method']=='elta') { ?>
            <? if ($i>20) { ?>
            <? $value_ship = $this->MFuncs->getCourierCost(20, 'elta_crete_cost'); ?>
			<? $remaining_weight = $i - 20; ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'] + ($remaining_weight*0.60), 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } else { ?>
            <? $value_ship = $this->MFuncs->getCourierCost($i, 'elta_crete_cost'); ?>
            <? if ($value_ship) { ?>
            <? $ship_total = number_format($value_ship['price'], 2, '.', ''); ?>
			<? } else { ?>
            <? $ship_total = number_format(0, 2, '.', ''); ?>
            <? } ?>
            <? } ?>
            
            <? } ?>
         
          
          <? } ?>
		   
		   <? } elseif ($orderdata['ship_method']=='day_delivery') {
        			   $ship_total = number_format(14.76, 2, '.', '');
			}
			}
		 ?>
         <? if ($can_ship==false) { ?>
        <tr>
          <td colspan="1"></td>
          <td colspan="3"><strong>
            <?=$this->lang->line('cannot_ship_txt')?>
            </strong></td>
        </tr>
        <?=$ship_total=0;?>
         <? } else { ?>
        <tr>
          <td colspan="2"></td>
          <td><strong>
            <?=$this->lang->line('ship_total')?>
            </strong></td>
          <td>&euro;
            <?=$ship_total?></td>
        </tr>
        <? } ?>
 <? if (($orderdata['ship_dest']=='attica') || ($orderdata['ship_dest']=='greece') || ($orderdata['ship_dest']=='crete')) { ?>
	 <? if ($orderdata['pay_method']=='Cash') { ?>
		 <? if ($orderdata['ship_method']=='elta') { ?>
        <tr>
          <td colspan="2"></td>
          <td><strong>
            <?=$this->lang->line('cash_on_delivery_total')?>
            </strong></td>
          <td>&euro;
            <?=$pay_on_arrival_cost = number_format(2.30, 2, '.', '');?></td>
        </tr>
         <? } elseif ($orderdata['ship_method']=='courier') { ?>
        <tr>
          <td colspan="2"></td>
          <td><strong>
            <?=$this->lang->line('cash_on_delivery_total')?>
            </strong></td>
          <td>&euro;
            <?=$pay_on_arrival_cost = number_format(5.17, 2, '.', '');?></td>
        </tr>
         <? } ?>
     <? } ?>       
 <? } ?>       
        <tr>
          <td colspan="2"></td>
          <td><strong>
            <?=$this->lang->line('gen_total')?>
            </strong></td>
          <td>&euro;
            <?=$ship_total + $pay_on_arrival_cost + $total?></td>
        </tr>
        <? } ?>
        <? //=$sum = number_format($total, 2, '.', '');?>
        <?	} ?>
      </table>
<br />
<em><?=$this->lang->line('vat_included_cart')?></em>
</div>      
<div id="orderForm">
        <? if (($orderdata['same_address']=='No') && ($orderdata['country_id']!='1') && ($sel_loc==false) && ($select==false)) { ?>
        <? if ($weight > 70000) { ?>
        <div class="note">(*) <?=$this->lang->line('cannot_send');?></div>
        <? } else { ?>
				  <? $attributes = array('class' => 'yform','AUTOCOMPLETE'=>'off'); ?>
                  <?=form_open('page/shipping_method_abroad_new',$attributes); ?>
                        <fieldset>
                            <legend><?=$this->lang->line('select_shipping_method')?></legend>
                            <? $country_det = $this->MFuncs->getCountryZone($orderdata['country_id']); ?>
                            <? if ($country_det['tnt_zones']!='0') { ?>
                        <div class="type-check">
                               <?=form_radio('select', 'courier_economy', FALSE); ?>
                               <?=form_label($this->lang->line('courier_delivery_abroad_economy'))?>
                        </div>
							<? } ?>
                            <? if ($country_det['tnt_zones_express']!='0') { ?>
                       <div class="type-check">
                               <?=form_radio('select', 'courier_express', FALSE); ?>
                               <?=form_label($this->lang->line('courier_delivery_abroad_express'))?>
                        </div>
							<? } ?>
                        </fieldset>
                        <br />
                        <p align="justify"><?=$this->lang->line('delivery_methods_costs_abroad_new')?></p>
        <div class="note">(*) <?=$this->lang->line('change_settings');?></div>
        <div class="buttons">
		<?=anchor("complete_order_2/false", $this->lang->line('btn_back'),array('id'=>'back_btn','class'=>'positive'))?>

<button type="submit" class="positive"> <?=$this->lang->line('continue')?> </button></div>
 <?=form_close();?>
 <? } ?>
        <? } elseif  (($orderdata['same_address']=='Yes') && ($userdata['country_id']!='1') && ($sel_loc==false) && ($select==false)) { ?>
        <? if ($weight > 70000) { ?>
        <div class="note">(*) <?=$this->lang->line('cannot_send');?></div>
        <? } else { ?>
				  <? $attributes = array('class' => 'yform','AUTOCOMPLETE'=>'off'); ?>
                  <?=form_open('page/shipping_method_abroad_new',$attributes); ?>
                        <fieldset>
                            <legend><?=$this->lang->line('select_shipping_method')?></legend>
                            <? $country_det = $this->MFuncs->getCountryZone($orderdata['country_id']); ?>
                            <? if ($country_det['tnt_zones']!='0') { ?>
                        <div class="type-check">
                               <?=form_radio('select', 'courier_economy', FALSE); ?>
                               <?=form_label($this->lang->line('courier_delivery_abroad_economy'))?>
                        </div>
							<? } ?>
                            <? if ($country_det['tnt_zones_express']!='0') { ?>
                       <div class="type-check">
                               <?=form_radio('select', 'courier_express', FALSE); ?>
                               <?=form_label($this->lang->line('courier_delivery_abroad_express'))?>
                        </div>
							<? } ?>
                       </fieldset>
                        <br />
                        <p align="justify"><?=$this->lang->line('delivery_methods_costs_abroad_new')?></p>
        <div class="note">(*) <?=$this->lang->line('change_settings');?></div>
        <div class="buttons">
		<?=anchor("complete_order_2/false", $this->lang->line('btn_back'),array('id'=>'back_btn','class'=>'positive'))?>

<button type="submit" class="positive"> <?=$this->lang->line('continue')?> </button></div>
 <?=form_close();?>
 <? } ?>
		<? } else { ?>
<? if (($sel_loc==false) && ($select==false)) { ?>
  <? $attributes = array('class' => 'yform','AUTOCOMPLETE'=>'off'); ?>
  <?=form_open('page/shipping_method_new2',$attributes); ?>
        <fieldset>
            <legend><?=$this->lang->line('select_shipping_method')?></legend>
        <div class="type-check">
               <?=form_radio('select', 'take_over', FALSE); ?>
               <?=form_label($this->lang->line('no_delivery'))?>
		</div>
        <div class="type-check">
               <?=form_radio('select', 'courier', FALSE); ?>
               <?=form_label($this->lang->line('courier_delivery'))?>
		</div>
        <? 		if ($orderdata['same_address']=='Yes') { 
				$postal = str_replace (" ", "", $userdata['postal']);		
				$county = $this->MFuncs->GetCountybyPostal_new($postal);
				} else {
				$postal = str_replace (" ", "", $orderdata['postal']);		
				$county = $this->MFuncs->GetCountybyPostal_new($postal);
				} ?>
<? if (($county['flag']=='attica') || ($county['flag']=='greece') || ($county['flag']=='crete')) { ?>
        <div class="type-check">
               <?=form_radio('select', 'elta', FALSE); ?>
               <?=form_label($this->lang->line('elta_delivery'))?>
		</div>
<? } ?>
<?php /*?>        <div class="type-check">
               <?=form_radio('select', 'day_delivery', FALSE); ?>
               <?=form_label($this->lang->line('day_delivery'))?>
		</div>
<?php */?>		</fieldset>
        <br />
        <p align="justify"><?=$this->lang->line('delivery_methods_costs_new')?></p>
<? } elseif (($sel_loc==true) && ($select==false)) {  ?>
   <? $attributes = array('class' => 'yform','AUTOCOMPLETE'=>'off'); ?>
  	<?=form_open('page/shipping_destination2',$attributes); ?>
       <fieldset>
         <legend><?=$this->lang->line('select_destination')?></legend>
         <? echo "<p><label for='destination'></label>";
			$options = array(''=>'Select one...', 'attica' => $this->lang->line('attika'), 'greece' => $this->lang->line('greece'), 'islands' => $this->lang->line('islands'));
			echo form_dropdown('destination',$options, '') ."</p>"; ?>
		</fieldset>
<? }?>
		<? if (($select==false) &&($sel_loc==false)) { ?>
        <div class="note">(*) <?=$this->lang->line('change_settings');?></div>
        <? } ?>
        <div class="buttons">
        <? if (($select==true) &&($sel_loc==true)) { ?>
		<?=anchor("complete_order_2_2_new2", $this->lang->line('btn_back'),array('id'=>'back_btn','class'=>'positive'))?>

		<?=anchor("complete_order_3_new2", $this->lang->line('continue'),array('id'=>'continue','class'=>'positive'))?>
</div>
		<? } elseif (($select==false) &&($sel_loc==true)) { ?>        
		<?=anchor("complete_order_2_2_new2", $this->lang->line('btn_back'),array('id'=>'back_btn','class'=>'positive'))?>

<button type="submit" class="positive"> <?=$this->lang->line('continue')?> </button></div>
 <?=form_close();?>
		<? } elseif (($select==false) &&($sel_loc==false)) { ?>        
		<?=anchor("complete_order_2/false", $this->lang->line('btn_back'),array('id'=>'back_btn','class'=>'positive'))?>

<button type="submit" class="positive"> <?=$this->lang->line('continue')?> </button></div>
 <?=form_close();?>
		<? }?>
        <? } ?>
</div><div style="clear:both"></div>
</div>
<? } else { 
redirect('home','location');
} ?>

</div>