<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<script language="javascript" type="text/javascript">
function chk(){
	var errorstr = '';
	var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
	var checked = false; 
	var buttons = document.shipmethod.ship_method; 
	var radio = document.shipmethod.ship_method; 
		if("undefined"==typeof(radio.length) )
	   {
		 if(radio.checked)
		  return radio.value;
		}else{
			for (var i=0; i<buttons.length; i++)  
			{  
				if (buttons[i].checked) {  
					checked = true; 
					break;  
				}  
			} 
		}
		<?php if(empty($shipopt)){?>
		checked = true; 
		<?php } ?>
		if(!checked) {
			errorstr += "- Please Select any shipping method.\n";
		}	
		if (errorstr != '')
		{
			msgstr = msgstr + errorstr;
			alert(msgstr);
			return false;
		}
		else
		{
			return true;
		}
	} 
</script>
            <div align="center">
            	<h2 class="title text-center mainhd">Checkout</h2>
            </div>
            <br />
            <div align="left" id="item_details_admin">
              <!--items display area start -->
              <div align="center" id="items_display_area_admin">
                <div align="left" class="inner_content_area_admin">
				<?php $session->flash(); ?>
                <form name="shipmethod" id="shipmethod" action="<?php echo $html->url('/carts/payment');?>" method="post">
			

				   <div id="admin_heading">Shipping Address</div>
				  <div id="grid_admin">
                    <div class="col-sm-6 col-md-4">
                      <p class="maintext_inner tblinr_hd">Name</p>
                    </div>
                    <div class="col-sm-6 col-md-8">
                     <span class="toplinks">
						
                       <p class="maintext_inner"><?php echo $shipadd["UserAddress"]["fname"]." ".$shipadd["UserAddress"]["lname"];?></p>
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div class="clearfix"></div>
                  <div id="grid_admin">
                    <div class="col-sm-6 col-md-4">
                         <p class="maintext_inner tblinr_hd">Address</p>
                    </div>
                    <div class="col-sm-6 col-md-8">
                      <span class="toplinks">
						<p class="maintext_inner">
						
						<?php 
						 if(isset($shipadd["UserAddress"]["address"]) && $shipadd["UserAddress"]["address"] <> '')
						  { 
						   echo $shipadd["UserAddress"]["address"].'<br/>';
						  } 
						  if(isset($shipadd["UserAddress"]["city"]) && $shipadd["UserAddress"]["city"] <> '')
						  { 
						   echo $shipadd["UserAddress"]["city"].'&nbsp;&nbsp;&nbsp;';
						  } 
						  if(isset($shipadd["UserAddress"]["state"]) && $shipadd["UserAddress"]["state"] <> '')
						  { 
						   echo $shipadd["UserAddress"]["state"].'&nbsp;&nbsp;&nbsp;';
						  } 
						   if(isset($shipadd["UserAddress"]["zip"]) && $shipadd["UserAddress"]["zip"] <> '')
						  { 
						   echo $shipadd["UserAddress"]["zip"].'<br/>';
						  } 


						  if(isset($shipadd["UserAddress"]["country_name"]) && $shipadd["UserAddress"]["country_name"] <> '')
						  { 
						   echo $shipadd["UserAddress"]["country_name"].'<br/>';
						  } 
						 
						  ?>		
						
						</p>
                        </span>
                    </div>
                    <div class="clearfix"></div>
                  </div>
				  
				  
				  
				  
				  
				  
                
				 <?php
				  if(isset($shipadd["UserAddress"]["phone"]) && $shipadd["UserAddress"]["phone"] <> '')
				  {?>				   
                  <div id="grid_admin">
                    <div class="col-sm-6 col-md-4">
                      <p class="maintext_inner tblinr_hd">Phone</p>
                    </div>
                    <div class="col-sm-6 col-md-8">
                     <span class="toplinks">
						<p class="maintext_inner"><?php echo $shipadd["UserAddress"]["phone"]; ?></p>
                      
                        </span>
					
                    </div>
                    <div class="clearfix"></div>
                  </div>
				 <?php } ?>
				  
				  
				   <?php
				  if(isset($shipadd["UserAddress"]["fax"]) && $shipadd["UserAddress"]["fax"] <> '')
				  {?>		
                  <div id="grid_admin">
                    <div class="col-sm-6 col-md-4">
                      <p class="maintext_inner tblinr_hd">Fax</p>
                    </div>
                    <div class="col-sm-6 col-md-8">
                     <span class="toplinks">
						<p class="maintext_inner"><?php echo $shipadd["UserAddress"]["fax"]; ?></p>
                      
                        </span>
					
                    </div>
                  </div>
                  <div class="clearfix"></div>
				  <?php } ?>
				  
				   <?php
				  if(isset($shipadd["UserAddress"]["mobile"]) && $shipadd["UserAddress"]["mobile"] <> '')
				  {?>		
                  <div id="grid_admin">
                    <div class="col-sm-6 col-md-4">
                      <p class="maintext_inner tblinr_hd">Mobile</p>
                    </div>
                    <div class="col-sm-6 col-md-8">
					  <span class="toplinks">
						<p class="maintext_inner"><?php echo $shipadd["UserAddress"]["mobile"]; ?></p>
                      </span>
						
                    </div>
                    <div class="clearfix"></div>
                  </div>
				 <?php } ?> 
				  
				  
				  
				   <?php 
						  $btn_flag='Y';
//                                                 / echo 'shipping'.$shipflag;EXIT;
						  if(isset($shipflag) &&  $shipflag == 'no') {
						   ?>  
							  <div id="grid_admin">				
								<div class="col-sm-6 col-md-4">
								  <p class="maintext_inner">&nbsp;</p>
								</div>									
								<div class="col-sm-6 col-md-8">
								  <span class="toplinks">
								   <p class="maintext_inner">
											<font color="red">
                                                                                        Sorry, there is no shipping service available to the address you provided.
                                                                                        </font><br>
                                                                                        <b>Flat Rate</b>
											<?php                                                
											if(isset($shipopt) && empty($shipopt)=== false)
											{ ?>
											<br />Shipping charge for first item : <?php echo $curlogo.$first_item; ?> <br>
                                                                                        For each additional item : <?php echo $curlogo.$additional_item; ?>
											<?php } else  $btn_flag='N'; ?>
									</span>
								</div>
								  </div>
						<?php }  ?>		
						
						
						
						 <?php 
						if(isset($shipopt) && empty($shipopt)=== false)
						{ ?>
				      <div id="grid_admin">				
						<div class="col-sm-6 col-md-4">
								  <p class="maintext_inner">&nbsp;</p>
						</div>		
						<div class="col-sm-6 col-md-8">
						  <span class="toplinks">
						    <p class="maintext_inner"><h4>Select a Shipping Method</h4></p>
							</span>
						</div>
						<div class="clearfix"></div>
					  </div>
					    <?php
							foreach($shipopt as $meth)
							{
								 ?> 
							  <div>				
								<div class="col-sm-6 col-md-4">
								  <p class="maintext_inner">&nbsp;</p>
								</div>									
								<div class="col-sm-6 col-md-8">
								  <span class="toplinks">
								   <p class="maintext_inner">
										<input type="radio" name="ship_method" value="<?php echo $shippingmethod.'|~@~|'.$meth['title'].'|~@~|'.$meth['cost'];?>">
		                                <?php echo html_entity_decode($meth['title']).'&nbsp;( '.$curlogo.$meth['cost'].' )';?></p>
									</span>
								</div>
								<div class="clearfix"></div>
						<?php }   } ?>		
				
					
          
				  
                 <div id="admin_bottom">
				<div class="col-sm-6 col-md-4">
				  <p class="maintext_inner">&nbsp;</p>
				</div>
				<div class="col-sm-6 col-md-8">
					<span class="toplinks">		
					   
					<input type="button" value="Cancel" onClick="javascript:history.go(-1);" class="btn-gry01" >
                                        <?php if($btn_flag == 'Y') { ?>
					<input type="submit" value="Continue" onClick="return chk();" class="btn-usr01" >
					<?php } ?>   
					
					</span>
				</div>
				<div class="float_clear1"></div>
			</div>
                
				
				
                <!--form area end -->
				</form>
              </div>
              <div align="left" class="float_clear1"></div>
            </div>
			 <?php if($prodtype == "Digital") { ?>
			 <script language="javascript" type="text/javascript">
			 document.shipmethod.submit();
			 </script>
			 <?php } ?>