[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]

[{if $readonly}]
    [{assign var="readonly" value="readonly disabled"}]
[{else}]
    [{assign var="readonly" value=""}]
[{/if}]

[{assign var="oCurr" value=$edit->getOrderCurrency()}]
[{assign var="banktransferData" value=$edit->getHeidelpayBankTransferData()}]

<form name="transfer" id="transfer" action="[{$oViewConf->getSelfLink()}]" method="post">
    [{$oViewConf->getHiddenSid()}]
    <input type="hidden" name="cur" value="[{$oCurr->id}]">
    <input type="hidden" name="oxid" value="[{$oxid}]">
    <input type="hidden" name="cl" value="[{$oView->getClassName()}]">
</form>

[{if $oHeidelpayViewConfig->isModuleDemoVersion()}]
    <div class="extension_warning">[{oxmultilang ident="d3_d3heidelpay_is_demo"}]</div>
[{/if}]

<table cellspacing="0" cellpadding="0" border="0" width="100%">
    [{if $banktransferData}]
        <tr>
            <td valign="top" class="edittext" width="100%">
                <table border="0" width="100%" border="0" class="listTable box">
                    <tr>
                        <th colspan="2">
                            <h2>[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_banktransferdata"}]</h2>
                        </th>
                    </tr>
                    [{if $banktransferData->Type == "d3_d3heidelpay_models_payment_billsafe"}]
                        <tr>
                            <td class="listitem">
                                [{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_Billsafe_Note"}]
                            </td>
                            <td class="listitem" style="white-space: normal;">[{$banktransferData->Billsafe_Note}]</td>
                        </tr>
                        <tr>
                            <td class="listitem">
                                [{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_Billsafe_LegalNote"}]
                            </td>
                            <td class="listitem2" style="white-space: normal;">[{$banktransferData->Billsafe_LegalNote}]</td>
                        </tr>
                        <tr>
                            <td class="listitem">
                                [{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_billsafePDFUrl"}]
                            </td>
                            <td class="listitem">
                                <a href="[{$banktransferData->Billsafe_PdfUrl}]"
                                   target="[{$banktransferData->Billsafe_PdfUrl}]">[{$banktransferData->Billsafe_PdfUrl}]</a>
                            </td>
                        </tr>
                        <tr>
                            <td class="listitem2">
                                [{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_bankname"}]
                            </td>
                            <td class="listitem2">[{$banktransferData->Bankname}]</td>
                        </tr>
                    [{/if}]
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_holder"}]</td>
                        <td class="listitem">[{$banktransferData->Holder}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_iban"}]</td>
                        <td class="listitem">[{$banktransferData->Iban}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_bic"}]</td>
                        <td class="listitem">[{$banktransferData->Bic}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_amount"}]</td>
                        <td class="listitem">[{$banktransferData->Amount}] [{$banktransferData->Currency}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_reason"}]</td>
                        <td class="listitem">[{$banktransferData->Reference}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_UniqueID"}]</td>
                        <td class="listitem">[{$banktransferData->UniqueID}]</td>
                    </tr>
                    <tr>
                        <td class="listitem">[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_transactionid"}]</td>
                        <td class="listitem">[{$banktransferData->TransactionID}]</td>
                    </tr>
                </table>
            </td>
        </tr>
    [{/if}]
    <tr>
        <td valign="top" class="edittext" width="100%">
            [{block name="admin_order_heidelpay_form"}]

                [{* showing all transactions for this order  *}]
                [{assign var='transactions' value=$oView->getTransactions()}]
                [{assign var='transactions' value=$transactions->reverse()}]

                [{if !empty($transactions)}]
                    <table border="0" class="d3hptransactions box">
                        <tr>
                            <th colspan="3">Ergebnis</th>
                            <th>Datum</th>
                            <th>Credit/Debit</th>
                            <th>Methode</th>
                            <th>Zahlungstyp</th>
                            <th>Txn-ID</th>
                            <th>Unique ID</th>
                            <th>Short ID</th>
                        </tr>
                        [{foreach from=$transactions item='transaction' key='index' name='transactions'}]

                            [{assign var='transactionLogReader' value=$transaction->getTransactiondata()}]
                            [{assign var='sClassName' value='class="listitem"'}]
                            [{assign var='blTransactionSuccessfull' value=false}]
                            [{assign var='sAmount' value=$transactionLogReader->getAmount()}]
                            [{assign var="sPaymentType" value=$transactionLogReader->getPaymentcode()|substr:0:2}]
                            [{assign var="sPaymentMethod" value=$transactionLogReader->getPaymentcode()|substr:3}]
                            [{assign var='sUniqueId' value=$transactionLogReader->getUniqueid()}]
                            [{assign var='criterionTags' value=$transactionLogReader->getCriterionTags()}]
                            [{if false == empty($sUniqueId)}]
                                [{if $smarty.foreach.transactions.index is odd}]
                                    [{assign var='sClassName' value='class="listitem2"'}]
                                [{/if}]
                                [{if $transactionLogReader->getResult() == 'ACK'}]
                                    [{assign var='blTransactionSuccessfull' value=true}]
                                [{/if}]

                                [{if !$blTransactionSuccessfull}]
                                    [{assign var='sAmount' value="<del>$sAmount</del>"}]
                                [{/if}]

                                [{if $sPaymentMethod == 'PA'}]
                                    [{assign var='sAmount' value="($sAmount)"}]
                                [{/if}]
                                <tr>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]"
                                           class="d3hpopen d3hpdisplay d3modcfg_icon action_plus_inactive"></a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]"
                                           class="d3hpopen d3modcfg_icon [{if $blTransactionSuccessfull}]status_ok[{else}]status_failed[{/if}]"
                                           title="[{$transactionLogReader->getResult()}]"></a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]" class="d3hpopen">[{$transactionLogReader->getReason()}]</a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]"
                                           class="d3hpopen">[{$transactionLogReader->getTimestamp()}]</a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]" class="d3hpopen">
                                            [{$sAmount}] [{$transactionLogReader->getCurrency()}]
                                        </a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]" class="d3hpopen">
                                            [{oxmultilang ident='d3_d3heidelpay_method_'|cat:$sPaymentMethod}]
                                            ([{$sPaymentMethod}])
                                        </a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]" class="d3hpopen">
                                            [{oxmultilang ident='d3_d3heidelpay_payment_'|cat:$sPaymentType}]
                                            ([{$sPaymentType}])
                                        </a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]"
                                           class="d3hpopen">[{$transactionLogReader->getTransactionid()}]</a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]"
                                           class="d3hpopen">[{$sUniqueId}]</a>
                                    </td>
                                    <td [{$sClassName}]>
                                        <a rel="[{$index}]" class="d3hpopen">[{$transactionLogReader->getShortid()}]</a>
                                    </td>
                                </tr>
                                [{if false == empty($criterionTags)}]
                                    <tr class="d3hphidden [{$index}]">
                                        <td colspan="10" [{$sClassName}] style="text-align:left;">
                                            <h4>[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_criteriontags"}]</h4>
                                            <div style="overflow:auto;height: 140px;width: 960px;">
                                                <table width="100%">
                                                    [{foreach from=$criterionTags item="criterionValue" key="criterionName" name="criterionTags"}]
                                                        [{assign var='criterionClassname' value="listitem"}]

                                                        [{if $smarty.foreach.criterionTags.iteration is even by 2}]
                                                            [{assign var='criterionClassname' value="listitem2"}]
                                                        [{/if}]
                                                        <tr >
                                                            <td class="[{$criterionClassname}]" style="text-align:left;">[{oxmultilang ident=$criterionName noerror=true}]:</td>
                                                            <td class="[{$criterionClassname}]" style="text-align:left;">
                                                                <div style="width: 666px;overflow-y: hidden;">[{$criterionValue}]</div>
                                                            </td>
                                                        </tr>
                                                    [{/foreach}]
                                                </table>
                                                <br>
                                            </div>
                                        </td>
                                    </tr>
                                [{/if}]
                                <tr class="d3hphidden [{$index}]">
                                    <td colspan="9" [{$sClassName}]>
                                        <form action="[{$oViewConf->getSelfLink()}]" method="post">
                                            <div>
                                                [{$oViewConf->getHiddenSid()}]
                                                <input type="hidden" name="cur" value="[{$oCurr->id}]">
                                                <input type="hidden" name="cl" value="[{$oView->getClassName()}]">
                                                <input type="hidden" name="fnc" value="runPaymentAction">
                                                <input type="hidden" name="oxid" value="[{$oxid}]">
                                                <input type="hidden" name="editval[oxorder__oxid]" value="[{$oxid}]">
                                                <input type="hidden" name="d3TransactionId" value="[{$index}]">
                                                <input type="hidden"
                                                       name="d3TransactionUniqueId"
                                                       value="[{$sUniqueId}]">
                                                <input type="hidden"
                                                       id="paymentAction[{$index}]"
                                                       name="paymentAction"
                                                       value="">

                                            </div>
                                            <ul class="hpactions">
                                                [{foreach from=$oView->getActions($transactionLogReader) item='button'}]
                                                    <li>
                                                        <button name="[{$button.name}]" value="[{$button.value}]"
                                                                [{if $button.disabled || $transactionLogReader->getResult() != 'ACK'}]disabled="disabled"[{/if}]
                                                                rel="[{$index}]"
                                                                class="d3hptransaction">[{$button.title}]</button>
                                                    </li>
                                                [{/foreach}]
                                            </ul>
                                            <div class="hpfieldset" id="fieldset[{$index}]">
                                                <label class="d3hplabel">
                                                    Betrag
                                                    <input type="text"
                                                           name="data[betrag]"
                                                           value="[{$transactionLogReader->getAmount()}]">
                                                    &nbsp;[{$edit->oxorder__oxcurrency->value}]
                                                </label>
                                                <label class="d3modcfg_btn icon status_ok">
                                                    <input type="submit"
                                                           id="submit[{$index}]"
                                                           value="[{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_submit"}]">
                                                    <span></span>
                                                </label>
                                            </div>
                                        </form>
                                    </td>
                                    <td [{$sClassName}] valign="top">
                                        <a rel="[{$index}]" class="d3modcfg_icon d3hpclose action_minus_inactive"
                                           title="[{oxmultilang ident="CATEGORY_UPDATE_CLOSE"}]"></a>
                                    </td>
                                </tr>
                            [{/if}]
                        [{/foreach}]
                    </table>
                    [{if $oView->checkDisplayBasicFunctions()}]
                        <div class="extension_warning">[{oxmultilang ident="D3_HEIDELPAY_RESTRICTIONINFO_ORDER"}]</div>
                    [{/if}]

                [{else}]
                    [{oxmultilang ident="d3_d3heidelpay_controllers_admin_order_heidelpay_is_not_heidelpay"}]
                [{/if}]
            [{/block}]
        </td>
    </tr>
</table>

[{oxscript add='
jQuery(".d3hpopen").click(function(){
    var id = jQuery(this).attr("rel");
    jQuery("." + id).toggle();
    jQuery(".d3hpdisplay[rel=\'" + id + "\']").toggleClass("action_plus_inactive action_minus_inactive");
});

jQuery(".d3hpclose").click(function(){
    var id = jQuery(this).attr("rel");
    jQuery("#" + id).toggle();
    jQuery(".d3hpdisplay[rel=\'" + id + "\']").toggleClass("action_plus_inactive action_minus_inactive");
});
var originalValue = "";
jQuery("button.d3hptransaction").click(function(){
    var hiddenId = "#paymentAction" + jQuery(this).attr("rel");
    var submitId = "#submit" + jQuery(this).attr("rel");
    var fieldsetId = "#fieldset" + jQuery(this).attr("rel");
    jQuery(hiddenId).attr("name", jQuery(this).attr("name"));
    jQuery(hiddenId).attr("value", jQuery(this).attr("value"));

    if(originalValue == "") {
        originalValue = jQuery(submitId).attr("value");
    }

    jQuery(submitId).attr("value", jQuery(this).text() + " " + originalValue);
    jQuery(fieldsetId).show();
    return false;
});

'}]

[{include file="bottomnaviitem.tpl"}]

[{include file="bottomitem.tpl"}]
