<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: account.billing.php,v 1.6 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__ );

$next_page = mosGetParam( $_REQUEST, "next_page", "account.index");
$Itemid = mosGetParam( $_REQUEST, "Itemid", null);

$missing_style = "style=\"color: Red; font-weight: Bold;\"";

if (!empty($_REQUEST['missing']))
    echo "<script> alert('"._CONTACT_FORM_NC."'); </script>\n";
else
  $_REQUEST['missing'] = '';
?>
<!-- Body starts here -->
<strong><? echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_TITLE ?></strong><br />
<?php
    $q =  "SELECT * FROM #__users WHERE ";
    $q .= "id='" . $auth["user_id"] . "' ";
    $q .= "AND address_type='BT' ";
    $db->query($q);
    if (!$db->num_rows()) {
        $q =  "SELECT * FROM #__pshop_user_info WHERE ";
        $q .= "user_id='" . $auth["user_id"] . "' ";
        $q .= "AND address_type='BT' ";
        $db->query($q);
    }
    $db->next_record();    
    
    $db_shoppergroup = new ps_DB;
    $q_sg = "SELECT shopper_group_id FROM #__pshop_shopper_vendor_xref";
    $q_sg .= " WHERE user_id ='".$auth["user_id"]."'";
    $db_shoppergroup->query($q_sg);
    $db_shoppergroup->next_record();
    
    $shopper_group_id = $db_shoppergroup->f("shopper_group_id");
?>
<!-- Registration form -->
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" name="edit billto">
  <input type="hidden" name="option" value="com_phpshop" />
  <input type="hidden" name="page" value="<?php echo $next_page; ?>" />
  <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
  <input type="hidden" name="func" value="shopperupdate" />
  <input type="hidden" name="username" value="<?php echo $auth["username"] ?>" />
  <input type="hidden" name="user_info_id" value="<?php $db->p("user_info_id"); ?>" />
  <input type="hidden" name="user_id" value="<?php echo $auth["user_id"] ?>" />
  <input type="hidden" name="shopper_group_id" value="<?php echo $shopper_group_id; ?>" />
  <input type="hidden" name="address_type" value="bt" />
  
  <table align="center" width="100%" cellspacing="0" cellpadding="6" border="0" />
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'username')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_USERNAME ?> :</td>
      <TD><?php $db->p("username") ?></TD>
    </TR>
    <TR> 
      <td <?php if (stristr($_REQUEST['missing'],'company')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_COMPANY_NAME ?> :</td>
      <td>
        <input type="text" class="inputbox" name="company" value="<?php $db->p("company") ?>" maxlength="64" size="16" />
      </td>
    </tr>
    <tr> 
        <td nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_TITLE ?>:</td>
        <td> <?php $ps_html->list_user_title($db->f("title"));
    ?>
        </td>
    </tr>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'last_name')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_LAST_NAME ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="last_name" value="<?php $db->p("last_name") ?>" maxlength="32" size="16" />
      </td>
    </tr>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'first_name')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_FIRST_NAME ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="first_name" value="<?php $db->p("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 $db->p("middle_name") ?>" maxlength="32" size="16" />
      </td>
    </tr>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'address_1')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ADDRESS_1 ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="address_1" value="<?php $db->p("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 $db->p("address_2") ?>" maxlength="64" size="32" />
      </td>
    </tr>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'city')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_CITY ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="city" value="<?php $db->p("city") ?>" maxlength="32" size="16" />
      </td>
    </tr>
    <?php if (CAN_SELECT_STATES == '1') {?>
          <tr> 
            <td <?php if (stristr($_REQUEST['missing'],'state')) echo $missing_style ?> nowrap align="right" >
            <?php echo $PHPSHOP_LANG->_PHPSHOP_SHOPPER_FORM_STATE ?>:</td>
            <td><?php $ps_html->list_states("state", $db->f("state")) ?></td>
          </tr>
    <?php } ?>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'zip')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_ZIP ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="zip" value="<?php $db->p("zip") ?>" maxlength="32" size="16" />
      </td>
    </tr>
    <tr> 
      <td <?php if (stristr($_REQUEST['missing'],'country')) echo $missing_style ?> align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_COUNTRY ?> :</TD>
      <td>
        <?php $ps_html->list_country("country", $db->sf("country")) ?>
      </td>
    </tr>
    <tr> 
      <td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_PHONE ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="phone_1" value="<?php $db->p("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 $db->p("fax") ?>" maxlength="32" size="16" />
      </td>
    </tr>
    <tr>
      <td align="right"><? echo $PHPSHOP_LANG->_PHPSHOP_USER_FORM_EMAIL ?> :</TD>
      <td>
        <input type="text" class="inputbox" name="user_email" value="<?php if($db->f("user_email")) $db->p("user_email"); else $db->p("email"); ?>" maxlength="64" size="32" />
      </td>
    </tr>
    <?php if (LEAVE_BANK_DATA == '1') { 
            $selected[0] = @$_REQUEST['bank_account_type']=="Checking" ? 'selected="selected"' : '';
            $selected[1] = @$_REQUEST['bank_account_type']=="Business Checking" ? 'selected="selected"' : '';
            $selected[2] = @$_REQUEST['bank_account_type']=="Savings" ? 'selected="selected"' : ''; ?>
            <tr>
                <td colspan="2" nowrap><strong><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_BANK_TITLE ?> </strong></td></tr>
            <tr>
                <td width="27%" nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_HOLDER ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_account_holder" size="24" value="<?php $db->p('bank_account_holder'); ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_NR ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_account_nr" size="24" value="<?php $db->p('bank_account_nr'); ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_SORT_CODE ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_sort_code" size="24" value="<?php $db->p('bank_sort_code');?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_NAME ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_name" size="24" value="<?php $db->p('bank_name'); ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_IBAN ?>:</td>
                <td width="73%" ><input type="text" class="inputbox" name="bank_iban" size="24" value="<?php $db->p('bank_iban'); ?>" /></td>
            </tr>
            <tr>
                <td width="27%" nowrap="nowrap" align="right" ><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE ?>:</td>
                <td width="73%" >
                  <select class="inputbox" name="bank_account_type">
                    <option <?php echo $selected[0] ?> value="Checking"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_CHECKING ?></option>
                    <option <?php echo $selected[1] ?> value="Business Checking"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_BUSINESSCHECKING ?></option>
                    <option <?php echo $selected[2] ?> value="Savings"><?php echo $PHPSHOP_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_SAVINGS ?></option>
                  </select>
                </td>
            </tr>
    <?php } ?>
    <tr>
      <td colspan="2" align="center"> 
        <input type="submit" class="button" name="submit" value="<? echo _E_SAVE ?>" />
      </td>
    </tr>
  </table>
</form>
<!-- Body ends here --> 
