<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: account.shipto.php,v 1.8 2005/01/27 19:34:00 soeren_nb Exp $
* @package mambo-phpShop
* @subpackage HTML
* Contains code from PHPShop(tm):
* 	@copyright (C) 2000 - 2004 Edikon Corporation (www.edikon.com)
*	Community: www.phpshop.org, forums.phpshop.org
* Conversion to Mambo and the rest:
* 	@copyright (C) 2004-2005 Soeren Eberhardt
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* mambo-phpShop is Free Software.
* mambo-phpShop comes with absolute no warranty.
*
* www.mambo-phpshop.net
*/
mm_showMyFileName( __FILE__ );

$page_name = "Add a Shipping Address";
$Itemid = mosGetParam( $_REQUEST, "Itemid", null );

$vars['country'] = empty( $_REQUEST['country'] ) ? $vendor_country : $_REQUEST['country'];

if (!empty($_REQUEST['user_info_id'])) {
  $q =  "SELECT * from #__pshop_user_info WHERE user_info_id='".$_REQUEST['user_info_id']."' ";
  $q .=  " AND user_id='".$auth['user_id']."'";
  $q .=  " AND address_type='ST'";
  $db->query($q);
  $db->next_record();
  if ($db->num_rows()) {
      define('_ADDRESS_UPDATE', '1');
  }
}


/*****************************
** Checkout Bar Feature
**/
 if (SHOW_CHECKOUT_BAR == '1' && $next_page=="checkout.index") {
    
     echo "<h3>". $PHPSHOP_LANG->_PHPSHOP_CHECKOUT_TITLE ."</h3>";
     
     // This is the file, where the checkout symbols are displayed
    // 1 - 2 - 3 - 4 , you know ;-)
    include_class('checkout');
    include(PAGEPATH. 'checkout_bar.php'); 
    
 }
/**
** End Checkout Bar Feature
*****************************/

echo "<br />".$PHPSHOP_LANG->_PHPSHOP_SHIPTO_TEXT;
?>
<!-- Registration form -->
<form action="<?php echo SECUREURL ?>index.php" method="post" name="AddShipto" />
<input type="hidden" name="option" value="com_phpshop" />
<input type="hidden" name="Itemid" value="<?php echo $Itemid ?>" />
<?php 
   if (isset($_REQUEST['next_page'])) {
?>
<input type="hidden" name="page" value="<?php echo $_REQUEST['next_page'] ?>" />
<?php
   }
   else {
?>
<input type="hidden" name="page" value="account.index" />
<?php
   }
   if (!empty($_REQUEST['user_info_id'])) {
?>
<input type="hidden" name="func" value="userAddressUpdate" />
<input type="hidden" name="user_info_id" value="<?php echo $_REQUEST['user_info_id'] ?>" />
<?php 
   }
   else {
?>
<input type="hidden" name="func" value="userAddressAdd" />
<?php } ?>
<input type="hidden" name="user_id" value="<?php echo $auth["user_id"] ?>" />
<input type="hidden" name="address_type" value="st" />
<table align="center" width="100%" cellspacing="0" cellpadding="6" border="0">
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ADDRESS_LABEL ?>:</td>
<td><input type="text"  class="inputbox" name="address_type_name" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("address_type_name"); else echo isset($address_type_name) ? $address_type_name : "" ; ?>"
      maxlength="64" size="16" /></td></tr>
<tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_COMPANY_NAME ?>:</td>
<td><input type="text"  class="inputbox" name="company" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("company"); else echo isset($company) ? $company : "" ;  ?>"
     maxlength="64" size="16" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_LAST_NAME ?>:</td>
<td><input type="text"  class="inputbox" name="last_name" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("last_name"); else echo isset($last_name) ? $last_name : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_FIRST_NAME ?>:</td>
<td><input type="text"  class="inputbox" name="first_name" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("first_name"); else echo isset($first_name) ? $first_name : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_MIDDLE_NAME ?>:</td>
<td><input type="text"  class="inputbox" name="middle_name" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("middle_name"); else echo isset($middle_name) ? $middle_name : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>

<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ADDRESS_1 ?>:</td>
<td><input type="text"  class="inputbox" name="address_1" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("address_1"); else echo isset($address_1) ? $address_1 : "" ;  ?>"
	maxlength="64" size="32" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ADDRESS_2 ?>:</td>
<td><input type="text"  class="inputbox" name="address_2" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("address_2"); else echo isset($address_2) ? $address_2 : "" ;  ?>" maxlength=64 size=32></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_CITY ?>:</td>
<td><input type="text"  class="inputbox" name="city" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("city"); else echo isset($city) ? $city : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>

<?php 
if (CAN_SELECT_STATES == '1') {?>
<tr>
  <td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_STATE ?>:</td>
  <td><?php $ps_html->list_states("state", $db->sf("state")) ?></td>
</tr>
  <?php 
} ?>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ZIP ?>:</td>
<td><input type="text"  class="inputbox" name="zip" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("zip"); else echo isset($zip) ? $zip : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_COUNTRY ?>:</td>
<td><?php $ps_html->list_country("country",$db->sf("country"))  ?>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_PHONE ?>:</td>
<td><input type="text"  class="inputbox" name="phone_1" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("phone_1"); else echo isset($phone_1) ? $phone_1 : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>
<tr>
<td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_FAX ?>:</td>
<td><input type="text"  class="inputbox" name="fax" value="<?php if (defined('_ADDRESS_UPDATE'))  $db->p("fax"); else echo isset($fax) ? $fax : "" ;  ?>"
	maxlength="32" size="16" /></td></tr>
</table>
<table width="70%" align="center">
<tr><td width="50%"align="center">
<input type="submit" class="button" name="submit" value="<? echo _E_SAVE ?>" />
</form>
</td>
<?php

if (!empty($_REQUEST['user_info_id'])) { ?>
<td width="50%"align="center">
<form action="<?php echo SECUREURL ?>index.php" method="post"  />
<input type="hidden" name="option" value="com_phpshop" />
<?php 
   if (!empty($_REQUEST['next_page'])) { ?>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="page" value="<?php echo $_REQUEST['next_page'] ?>" />
<?php }
  else { ?>
<input type="hidden" name="page" value="account.index" />
<?php   } ?>
<input type="hidden" name="func" value="useraddressdelete" />
<input type="hidden" name="user_info_id" value="<?php echo $_REQUEST['user_info_id'] ?>" />
<input type="hidden" name="user_id" value="<?php echo $auth["user_id"] ?>" />
<input type="submit" class="button" name="submit" value="<? echo _E_REMOVE ?>" />
</form>
</td>
<?php } ?>
</table>
<!-- Body ends here -->
