<?php $option = $this->getOptionValue(); ?>
<?php $mcommerce = $option->getObject(); ?>
<?php $application = $this->getApplication(); ?>
<?php $order = $this->getCurrentOrder(); ?>
<div>

    <form id="orderEditForm" method="post" action="<?php echo $this->getUrl('mcommerce/application_order/editpost'); ?>">
        <div class="buttons">
            <button type="button" onclick="orders.close();" class="delete left"><i class="icon-arrow-left"></i></button>
            <button type="submit" class="default_button right">OK</button>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
        <fieldset class="edit_order_informations">
            <h4 class="subtitle">
                <span class="left area"><?php echo $this->_('Customer'); ?></span>
                <hr class="area reverse">
                <div class="clear"></div>
            </h4>
            <table class="list list-input">
                <tr>
                    <td class="label"><div><label for="customer_firstname"><?php echo $this->_('Firstname:'); ?></label></div></td>
                    <td><input type="text" id="customer_firstname" name="customer_firstname" class="required" value="<?php echo $order->getCustomerFirstname(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_lastname"><?php echo $this->_('Lastname:'); ?></label></div></td>
                    <td><input type="text" id="customer_lastname" name="customer_lastname" class="required" value="<?php echo $order->getCustomerLastname(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_email"><?php echo $this->_('Email:'); ?></label></div></td>
                    <td><input type="text" id="customer_email" name="customer_email" class="required" value="<?php echo $order->getCustomerEmail(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_phone"><?php echo $this->_('Phone:'); ?></label></div></td>
                    <td><input type="text" id="customer_phone" name="customer_phone" class="" value="<?php echo $order->getCustomerPhone(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_street"><?php echo $this->_('Street:'); ?></label></div></td>
                    <td><input type="text" id="customer_street" name="customer_street" class="" value="<?php echo $order->getCustomerStreet(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_postcode"><?php echo $this->_('Postcode:'); ?></label></div></td>
                    <td><input type="text" id="customer_postcode" name="customer_postcode" class="" value="<?php echo $order->getCustomerPostcode(); ?>" /></td>
                </tr>
                <tr>
                    <td class="label"><div><label for="customer_city"><?php echo $this->_('City:'); ?></label></div></td>
                    <td><input type="text" id="customer_city" name="customer_city" class="" value="<?php echo $order->getCustomerCity(); ?>" /></td>
                </tr>
            </table>
        </fieldset>
        <fieldset>
            <h4 class="subtitle">
                <span class="left area"><?php echo $this->_('Details'); ?></span>
                <hr class="area reverse">
                <div class="clear"></div>
            </h4>
            <table class="no-collapse" width="100%" cellspacing="10">
                <tr>
                    <th><?php echo $this->_('Status'); ?></th>
                    <td>
                        <select id="order_status_id" name="status_id">
                            <?php foreach(Mcommerce_Model_Order::getStatuses() as $status) : ?>
                            <option value="<?php echo $status->getId(); ?>"<?php if($status->getId() == $order->getStatusId()) : ?> selected="selected"<?php endif; ?>><?php echo $status->getLabel(); ?></option>
                            <?php endforeach ?>
                        </select>
                    </td>
                </tr>
            </table>
            <table width="100%" class="order_details">
                <col width="70%" />
                <col width="10%" />
                <col width="10%" />
                <col width="10%" />
                <tr>
                    <th align="left"><?php echo $this->_('Product'); ?></th>
                    <th><?php echo $this->_('Unit price'); ?></th>
                    <th><?php echo $this->_('Qty'); ?></th>
                    <th><?php echo $this->_('Total'); ?></th>
                </tr>
                <tr class="row_separator head_separator"><td colspan="4"><div style=""></div></td></tr>
            <?php foreach($order->getLines() as $line) : ?>
                <tr class="product">
                    <td><?php echo $line->getName(); ?></td>
                    <td align="right"><?php echo $line->getFormattedBasePriceInclTax(); ?></td>
                    <td align="center"><?php echo $line->getQty(); ?></td>
                    <td align="right"><?php echo count($line->getOptions()) ? $line->getFormattedBasePriceInclTax() : $line->getFormattedTotalInclTax(); ?></td>
                </tr>
                <?php foreach($line->getOptions() as $option) : ?>
                <tr class="option">
                    <td>+ <?php echo $option->getName(); ?></td>
                    <td align="right"><?php echo $option->getFormattedPriceInclTax(); ?></td>
                    <td align="center"><?php echo $option->getQty(); ?></td>
                    <td align="right"><?php echo $option->formatPrice($option->getPriceInclTax() * $option->getQty()); ?></td>
                </tr>
                <?php endforeach; ?>
                <tr class="row_separator"><td colspan="4"><div></div></td></tr>
            <?php endforeach; ?>
            </table>
            <table class="no-collapse" width="100%" cellspacing="10">
                <tr class="cart_totals">
                   <th class="a-left f-bold"><?php echo $this->_('Subtotal'); ?></th>
                   <td class="a-right"><?php echo $order->getFormattedTotalExclTax(); ?></td>
               </tr>
               <tr class="cart_totals">
                   <th class="a-left f-bold"><?php echo $this->_('Tax'); ?></th>
                   <td class="a-right"><?php echo $order->getFormattedTotalTax(); ?></td>
               </tr>
               <tr>
                    <th class="a-left f-bold"><?php echo $order->getDeliveryMethod(); ?></th>
                    <td class="a-right"><?php echo $order->getFormattedDeliveryCost(); ?></td>
                </tr>
               <tr class="cart_totals">
                   <th class="a-left f-bold"><?php echo $this->_('Total'); ?></th>
                   <td class="a-right"><?php echo $order->getFormattedTotal(); ?></td>
               </tr>
           </table>
        </fieldset>

        <?php if($order->getId()) : ?>
            <input type="hidden" name="order_id" id="order_id" value="<?php echo $order->getId() ?>" />
        <?php endif; ?>
        <input type="hidden" name="option_value_id" value="<?php echo $option->getId() ?>" />

    </form>
</div>