<?php
namespace platyFramework;

/** @var ptyFormModel $form */
/** @var ptyItemModel $item */
/** @var string $postUrl */
/** @var string $title */
/** @var string $title_desc */

// ptyDebug(get_defined_vars());
$paidResult = json_decode($item->paidResult, true);

// $notiResult = $paidResult['inicis']['']
// ptyDebug($paidResult);
?>
<script src="<?= $this->request->moduleUrl ?>/ptyadmin/resources/AdminLTE-2.4.5/bower_components/ckeditor/ckeditor.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.32/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
    <section class="content-header">
        <h1>
            <?= $title ?>
            <small><?= $title_desc ?></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="<?= $this->request->appUrl ?>"><i class="fa fa-dashboard"></i> Home</a>
            </li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header">
                        <h3 class="box-title">주문 상품 정보</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th>ID</th>
                                <th>상품코드</th>
                                <th>이미지</th>
                                <th>주문상품명</th>
                                <th>수량</th>
                                <th>상품금액</th>
                                <th>총상품금액</th>
                                <!--                                    <th>배송비</th>-->
                                <th>처리상태</th>
                                <th>송장번호</th>
                            </tr>
                            <? foreach ($cartItems as $it) {
                                ?>
                                <tr>
                                    <td><?= $it['id'] ?></td>
                                    <td><a href="<?= $this->request->appUrl ?>/ptyshop/products/?sec_productId=<?= urlencode($it['productId']) ?>"><?= $it['productId'] ?></td>
                                    <td><img src="<?= $it['product_previewImageUrl'] ?>" width="50" alt=""></td>
                                    <? if ($it['optionTitle'] == "") { ?>
                                        <td><?= $it['productTitle'] ?></td>
                                    <? } else { ?>
                                        <td><?= $it['productTitle'] ?> <span class="label bg-green">옵션</span><?= $it['optionTitle'] ?></td>
                                    <? } ?>
                                    <td><?= $it['count'] ?></td>
                                    <td><?= number_format($it['price']) ?></td>
                                    <td><?= number_format($it['totalPrice']) ?></td>
                                    <td>
                                        <? foreach (ptyshopCartItemModel::getOrderStatus() as $v) { ?>
                                            <? if ($it['status'] == $v) { ?>
                                                <span class="animated flash label bg-red"><?= $v ?></span>
                                            <? } else { ?>
                                                <a href='<?= $this->request->appUrl ?>/ptyshop/cart/setStatus/?id=<?= $it['id'] ?>&status=<?= urlencode($v) ?>' class="label bg-gray"><?= $v ?></a>
                                            <? } ?>
                                        <? } ?>
                                    </td>
                                    <td>
                                        <form method="post" action="<?= $this->request->appUrl ?>/ptyshop/cart/setDeliveryNumber/?id=<?= $it['id'] ?>">
                                            <input class="form-control" style="display: inline-block; height: unset; width: 50%;" type="text" name="deliveryNumber" value="<?= $it['deliveryNumber'] ?>">
                                            <button type="submit" class="btn btn-info btn-xs">저장</button>
                                        </form>
                                    </td>
                                    <td>

                                    </td>
                                </tr>
                            <? } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <form class="form-horizontal" method="post" action="<?= $postUrl ?>" enctype="multipart/form-data">

            <div class="row">
                <div class="col-md-6">
                    <? // $form = ptyForm2Model::build("", $item, "ptypushItem");
                    ?>
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">결제 정보</h3>
                            <? if ($item->paid == 1) { ?>
                                <span class="label bg-primary">결제 성공</span>
                            <? } else { ?>
                                <? if ($paidResult['inicis']['authResult']['P_RMESG1'] != "") { ?>
                                    <span class="label bg-red">내부오류 <?= $paidResult['inicis']['authResult']['P_RMESG1'] ?></span>
                                <? } else { ?>
                                    <span class="label bg-orange">미결제</span>
                                <? } ?>
                            <? } ?>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <div class="box-body">
                            <?= $form->getInput("주문번호", 'orderId'); ?>
                            <?= $form->getInput("상품 판매 비용", 'price'); ?>
                            <?= $form->getInput("결제 방법", "payMethod"); ?>
                            <?= $form->getInput("주문 확인일", "regDateTime"); ?>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info btn-xs pull-right">저장</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="box box-info">

                        <div class="box-header with-border">
                            <h3 class="box-title">이니시스 결제 정보</h3>
                        </div>
                        <div class="box-body">
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">승인거래번호</label>
                                <div class="col-sm-10">
                                    <?= $paidResult['inicis']['notiResult']['P_TID'] ?>
                                </div>
                            </div>
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">결제유형</label>
                                <div class="col-sm-10">
                                    <?= $paidResult['inicis']['approvalResult']['P_TYPE'] ?>
                                </div>
                            </div>
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">승인금액</label>
                                <div class="col-sm-10">
                                    <?= number_format($paidResult['inicis']['notiResult']['P_AMT']) ?>
                                </div>
                            </div>
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">카드사</label>
                                <div class="col-sm-10">
                                    <?= $paidResult['inicis']['approvalResult']['P_FN_NM'] ?>
                                </div>
                            </div>
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">카드번호</label>
                                <div class="col-sm-10">
                                    <?= $paidResult['inicis']['notiResult']['P_CARD_NUM'] ?>
                                </div>
                            </div>
                            <div class='form-group'>
                                <label class="col-sm-2 control-label">가상계좌</label>
                                <div class="col-sm-10">
                                    은행명 : <span class="label bg-green"><?= $paidResult['inicis']['approvalResult']['P_FN_NM'] ?></span>
                                    계좌번호 : <span class="label bg-blue"><?= $paidResult['inicis']['approvalResult']['P_VACT_NUM'] ?></span>
                                    만료일 : <span class="label bg-gray"><?= $paidResult['inicis']['approvalResult']['P_VACT_DATE'] ?></span>
                                </div>
                            </div>
                            <? // $form->getInput("결제 확인일", "");
                            ?>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <? // $form = ptyForm2Model::build("", $item, "ptypushItem");
                    ?>
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">주문자 정보</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <div class="box-body">
                            <?= $form->getInput("구매자IP", "ip"); ?>
                            <?= $form->getInput("회원ID", "userId"); ?>
                            <?= $form->getInput("주문자명", "buyerName"); ?>
                            <?= $form->getInput("전화번호", "buyerPhoneNumber"); ?>
                            <? // $form->getInput("이메일", "");
                            ?>
                            <? // $form->getInput("주소", "");
                            ?>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info btn-xs pull-right">저장</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
                <div class="col-md-6">
                    <? // $form = ptyForm2Model::build("", $item, "ptypushItem");
                    ?>
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">수령자 정보</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <div class="box-body">
                            <?= $form->getInput("수령자명", "deliveryName"); ?>
                            <?= $form->getInput("전화번호", "deliveryPhoneNumber"); ?>
                            <?= $form->getInput("우편번호", "deliveryZipCode"); ?>
                            <?= $form->getInput("주소1", "deliveryAddress1"); ?>
                            <?= $form->getInput("주소2", "deliveryAddress2"); ?>
                            <?= $form->getInput("배송메세지", "deliveryMemo"); ?>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info pull-right">저장</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <? // $form = ptyForm2Model::build("", $item, "ptypushItem");
                    ?>
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">메모</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <div class="box-body">
                            <?= $form->getTextEdit("", "notes"); ?>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info pull-right btn-xs">저장</button>
                        </div>
                        <!-- /.box-footer -->
                    </div>
                </div>
            </div>
        </form>
    </section>
</div>
