<?php
namespace platyFramework;

/** @var ptyFormModel $form */
/** @var ptyItemModel $item */
/** @var string $postUrl */
/** @var string $title */
/** @var string $title_desc */
?>
<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>
    <?php // ptyDebug($item);
    ?>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- Horizontal Form -->
                <div class="box box-info">
                    <form class="form-horizontal" method="post" action="<?= $postUrl ?>" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="<?= $item->id ?>">
                        <div class="box-body">
                            <div class='col-md-12'>
                                <? if ($this->request->functionName == "edit") { ?>
                                    <?= $form->getDateTime("등록일", "regDateTime", "required placeholder='2018-01-01 00:00:00'"); ?>
                                <? } ?>
                                <?= $form->getSelect("노출여부", "enabled", array("활성화" => "1", "비활성화" => 0)); ?>
                                <?= $form->getInput("상품코드", "productId"); ?>
                                <?= $form->getInput("상품명", "title"); ?>
                                <?= $form->getInput("상품명 한줄 소개", "titleDesc"); ?>

                                <?= $form->getFile("미리보기 이미지", "previewImageUrl", 0, " onchange='checkUpload(this, 1);'", "모든 파일 첨부는 최대 " . ini_get("post_max_size") . " 까지 가능합니다"); ?>
                                <?= $form->getInput("소비자가", "customerPrice", "", "소비자가를 입력하면 판매가와 비교하여 세일율이 노출됩니다."); ?>
                                <?= $form->getInput("판매가", "price"); ?>
                                <?= $form->getInput("배송비", "deliveryPrice", "", "0: 무료 배송 (무료배송 아이콘이 노출됩니다)"); ?>
                                <?= $form->getInput("재고수", "inven", "", "-1: 무제한, 0:재고없음"); ?>
                                <?= $form->getSelect("최저가보장 노출 여부", "isLowerPrice", ["노출" => 1, "비노출" => 0]); ?>
                                <?= $form->getSelect("오늘 출발 노출 여부", "isTodayDelivery", ["노출" => 1, "비노출" => 0]) ?>
                                <?= $form->getInput("카테고리1", "category"); ?>
                                <?= $form->getInput("카테고리2", "category2"); ?>
                                <?= $form->getTextEdit("상품설명", "desc"); ?>
                                <?
                                $optionByForm = json_decode($item->optionByForm, true);
                                for ($i = 0; $i < 20; $i++) { ?>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"><? echo $i == 0 ? "옵션 설정" : ""; ?></label>
                                        <div class="col-sm-2">
                                            <input type="text" id="title" name="item[option][titleA][]" value="<?= $optionByForm['titleA'][$i] ?>" placeholder="옵션1단계 제목" class="form-control">
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" id="title" name="item[option][titleB][]" value="<?= $optionByForm['titleB'][$i] ?>" placeholder="옵션2단계 제목" class="form-control">
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" id="title" name="item[option][titleC][]]" value="<?= $optionByForm['titleC'][$i] ?>" placeholder="옵션3단계 제목" class="form-control">
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" id="title" name="item[option][quantity][]" value="<?= $optionByForm['quantity'][$i] ?>" placeholder="수량. -1 => 무제한, 0 => 품절" class="form-control">
                                        </div>
                                        <div class="col-sm-2">
                                            <input type="text" id="title" name="item[option][price][]" value="<?= $optionByForm['price'][$i] ?>" placeholder="가격. -1 => 상품가와 동일" class="form-control">
                                        </div>
                                    </div>
                                <? } ?>
                            </div>
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">저장</button>
                                <button type="button" class="btn btn-default ptyGoBack pull-right">취소</button>
                            </div>
                        </div>

                        <div class="box box-info">
                            <div class="box-header with-border">
                                <h3 class="box-title">상품 푸시 보내기</h3>
                            </div>
                            <div class="box-body">
                                <div class='col-md-12'>
                                    <?= ptypushItemModel::buildItem()->getEditForm("shopProductItem", $item->id, [
                                        "title" => $item->title, "content" => $item->titleDesc, "imageUrl" => $item->previewImageUrl
                                    ]); ?>
                                </div>
                            </div>
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">저장</button>
                                <button type="button" class="btn btn-default ptyGoBack pull-right">취소</button>
                            </div>
                        </div>
                </div>

                </form>
            </div>
        </div>
</div>
</section>
