<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */

/**
USAGE:

Simple:

<?php echo $this->getLayout()->createBlock('customer/widget_dob')
   ->setDate($this->getCustomer()->getDob())
   ->toHtml() ?>

For checkout/onepage/billing.phtml:

<?php echo $this->getLayout()->createBlock('customer/widget_dob')
   ->setDate($this->getCustomer()->getDob())
   ->setFieldIdFormat('billing:%s')
   ->setFieldNameFormat('billing[%s]')
   ->toHtml() ?>

NOTE: Regarding styles - if we leave it this way, we'll move it to boxes.css
      Alternatively we could calculate widths automatically using block input parameters.
*/

/**
 * @see Mage_Customer_Block_Widget_Dob
 */
?>

<?php
    /**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>

<?php if (Mage::helper('awmobile')->checkVersion('1.4.0.0')): ?>

<div>
    <label for="<?php echo $this->getFieldId('day')?>">
        <?php echo $this->__('Date of Birth') ?>
        <?php if ($this->isRequired()):?><span class="required">*</span><?php endif ?>
    </label>
</div>

<div class="customer-dob">

<?php
    $this->setDateInput('d',
        '<div class="input-box dob-day">
        <input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay()  . '" title="' . $this->__('Day')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
         </div>
        <label for="' . $this->getFieldId('day') . '" class="label-dob">' . $this->__('DD')  . '</label>'
    );

    $this->setDateInput('m',
        '<div class="input-box dob-month">
        <input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth()  . '" title="' . $this->__('Month')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
         </div>
        <label for="' . $this->getFieldId('month') . '" class="label-dob">' . $this->__('MM')  . '</label>'
    );

    $this->setDateInput('y',
        '<div class="input-box dob-year">
        <input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear()  . '" title="' . $this->__('Year')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
        </div>
        <label for="' . $this->getFieldId('year') . '" class="label-dob">' . $this->__('YYYY')  . '</label>'
    );
?>
<?php echo $this->getSortedDateInputs() ?>

    <div class="dob-full" style="display:none;">
        <input type="hidden" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" />
    </div>

    <div class="clear"></div>

    <div style="opacity: 0.999999; display:none;" class="validation-advice"></div>
</div>
<script type="text/javascript">
//<![CDATA[
    var customer_dob = new Varien.DOB('.customer-dob', <?php echo $this->isRequired() ? 'true' : 'false' ?>, '<?php echo $this->getDateFormat() ?>');
//]]>
</script>

<?php else: ?>
<?php
    /**
     * Magnto versions before 1.4.0.0
     */
?>
<div class="customer-dob">
    <label for="<?php echo $this->getFieldId('day')?>">
        <?php echo $this->__('Date of Birth') ?>
        <?php if ($this->isRequired()):?><span class="required">*</span><?php endif ?>
    </label>

    <div class="input-box dob-day">
        <input type="text" id="<?php echo $this->getFieldId('day')?>" name="<?php echo $this->getFieldName('day')?>" value="<?php echo $this->getDay() ?>" title="<?php echo $this->__('Day') ?>" class="input-text validate-custom" <?php echo $this->getFieldParams() ?> />
        <label for="<?php echo $this->getFieldId('day')?>" class="label-dob"><?php echo $this->__('DD') ?></label>
    </div>

    <div class="input-box dob-month">
        <input type="text" id="<?php echo $this->getFieldId('month')?>" name="<?php echo $this->getFieldName('month')?>" value="<?php echo $this->getMonth() ?>" title="<?php echo $this->__('Month') ?>" class="input-text validate-custom" <?php echo $this->getFieldParams() ?> />
        <label for="<?php echo $this->getFieldId('month')?>" class="label-dob"><?php echo $this->__('MM') ?></label>
    </div>

    <div class="input-box dob-year">
        <input type="text" id="<?php echo $this->getFieldId('year')?>" name="<?php echo $this->getFieldName('year')?>" value="<?php echo $this->getYear() ?>" title="<?php echo $this->__('Year') ?>" class="input-text validate-custom" <?php echo $this->getFieldParams() ?> />
        <label for="<?php echo $this->getFieldId('year')?>" class="label-dob"><?php echo $this->__('YYYY') ?></label>
    </div>

    <div class="dob-full" style="display:none;">
        <input type="hidden" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" />
    </div>

    <div style="opacity: 0.999999; display:none;" class="validation-advice"></div>
</div>
<script type="text/javascript">
//<![CDATA[
    var customer_dob = new Varien.DOB('.customer-dob', <?php echo $this->isRequired() ? 'true' : 'false' ?>, '<?php echo $this->getDateFormat() ?>');
//]]>
</script>

<?php endif; ?>

