<?php include_once(mvc::$cfg['PATH_TPL'].'public/topSeller.php');?>
<div class="maintb">
    <?php include_once(mvc::$cfg['PATH_TPL'].'seller/leftMenu.php');?>
    <div class="main_middle">
        <div class="mod-main ">
            <div class="template">
                <form method="post" id="template_form" onsubmit="return SETTEMPLATE.checkTemplate('template_form')">
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title"><i class="required">*</i>模板名称</label>
                            <input type="text" value="<?php echo $detail[0]['frt_name'];?>" class="form-control" name="name" maxlength="32" placeholder="请输入模板名称" autocomplete="off" />
                        </div>
                    </div>
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title"><i class="required">*</i>产品地址</label>
                            <span id="province_box"></span>
                        </div>
                    </div>
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title">发货时间</label>
                            <select name="send_hour" id="send_hour" class="form-control">
                                <option value="0">请选择</option>
                                <option <?php if ($detail[0][ 'frt_send_hour']==12){?> selected="" <?php }?> value="12">12小时</option>
                                <option <?php if ($detail[0][ 'frt_send_hour']==24){?> selected="" <?php }?> value="24">24小时</option>
                                <option <?php if ($detail[0][ 'frt_send_hour']==48){?> selected="" <?php }?> value="48">48小时</option>
                            </select>
                        </div>
                    </div>
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title">是否包邮</label>
                            <label><input type="radio" checked="" id="free1" value="N" name="is_free" /><b>自定义运费</b></label>&nbsp;&nbsp;
                            <label><input type="radio" id="free2" <?php if ($detail[0][ 'frt_is_free']=='Y'){?> checked="" <?php }?> value="Y" name="is_free" /><b>包邮</b></label>
                        </div>
                    </div>
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title">计价方式</label>
                            <label><input type="radio" checked="" id="method1" value="0" name="method" /><b>数量</b></label>&nbsp;&nbsp;
                            <label><input type="radio" id="method2" <?php if ($detail[0][ 'frt_valuation_method']=='1'){?> checked="" <?php }?> value="1" name="method" /><b>重量</b></label>
                        </div>
                    </div>
                    <div class="txt_row txt_anyrow">
                        <label class="txt_title"><i class="required">*</i>运送方式</label>
                        <div class="text_right">
                            <div id="express1" class="express_table">
                                <label>
                                    <input type="checkbox" <?php if ($detail[0][ 'frt_id']&&in_array(0, $method)){?> checked="" <?php }?> onclick="SETTEMPLATE.showTable(this,'express1');" name="default[0][send_method]" value="0" /><b>快递</b>
                                </label>
                                <div class="table_content">
                                    <?php if ($detail[0]['frt_is_free']=='N'&&in_array(0, $method)){?>
                                    <table class="table table-bordered my_list marb10" id="">
                                        <?php foreach ($detail[0]['link'] as $k => $v){
                                            if($v['ftl_shipping_method']==0&& $v['ftl_default']=='Y'){?>
                                        <thead>
                                            <tr class="info">
                                                <th colspan="7">
                                                    默认运费1
                                                    <input class="form-control myinput" type="text" value="<?php echo $v['ftl_begin_count'];?>" name="default[0][<?php echo $v['ftl_id'];?>][num]">
                                                    <method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>内
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_begin_money']);?>" name="default[0][<?php echo $v['ftl_id'];?>][price]" type="text">元，每增加
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" name="default[0][<?php echo $v['ftl_id'];?>][addnum]" type="text">
                                                    <method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>，增加运费
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_next_money']);?>" name="default[0][<?php echo $v['ftl_id'];?>][addprice]" type="text">元
                                                </th>
                                            </tr>
                                        </thead>
                                        <?php }}?>
                                        <tbody>
                                            <?php if(in_array('N', $exit[0])){?>
                                            <tr>
                                                <th colspan="2">运送到</th>
                                                <th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
                                                <th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
                                                <th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
                                                <th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
                                                <th width="50px">操作</th>
                                            </tr>
                                            <?php }?>
                                            <?php foreach ($detail[0]['link'] as $k => $v){if($v['ftl_shipping_method']=='0' && $v['ftl_default']=='N'){?>
                                            <tr>
                                                <td>
                                                    <?php echo trim($v['path']);?>
                                                    <input class="form-control myinput" num="<?php echo $v['ftl_id'];?>" parent="<?php echo $v['parentPath'];?>" value="<?php echo $v['ftl_cities'];?>" type="hidden" name="default[0][<?php echo $v['ftl_id'];?>][area]">
                                                </td>
                                                <td width="50px">
                                                    <a class="a_blue" href="javascript:" onclick="SETTEMPLATE.show(this,0,2)">编辑</a>
                                                </td>
                                                <td>
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_begin_count'];?>" num="<?php echo $v['ftl_id'];?>" type="text" name="default[0][<?php echo $v['ftl_id'];?>][begin_count]">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_begin_money']);?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][begin_money]" type="text">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][next_count]" type="text">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_next_money']);?>" num="<?php echo $v['ftl_id'];?>" name="default[0][<?php echo $v['ftl_id'];?>][next_money]" type="text">
                                                </td>
                                                <td>
                                                    <a class="a_blue" href="javascript:void(0)" onclick="deleteCity(this)">删除</a>
                                                </td>
                                            </tr>
                                            <?php }}?>
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <th colspan="7">
                                                    <a class="a_blue" href="javascript:void(0)" onclick="SETTEMPLATE.show(this,express1,1)">为指定地区城市设置运费</a>
                                                </th>
                                            </tr>
                                        </tfoot>
                                    </table>
                                    <?php }?>
                                </div>
                            </div>
							<div class="padtb5"></div>
                            <div id="express2" class="express_table dowm">
                                <label>
                                    <input type="checkbox" <?php if ($detail[0][ 'frt_id']&&in_array(1, $method)){?> checked="" <?php }?> onclick="SETTEMPLATE.showTable(this,'express2');" name="default[1][send_method]" value="1" /><b>EMS</b>
                                </label>
                                <div class="table_content">
                                    <?php if ($detail[0]['frt_is_free']=='N'&&in_array(1, $method)){?>
                                    <table class="table table-bordered my_list marb10" id="">
                                        <?php foreach ($detail[0]['link'] as $k => $v){if ($v['ftl_shipping_method']=='1'&& $v['ftl_default']=='Y'){?>
                                        <thead>
                                            <tr class="info">
                                                <th colspan="7">
                                                    默认运费2
                                                    <input class="form-control myinput" type="text" value="<?php echo $v['ftl_begin_count'];?>" name="default[1][<?php echo $v['ftl_id'];?>][num]">
                                                    <method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>内
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_begin_money']);?>" name="default[1][<?php echo $v['ftl_id'];?>][price]" type="text">元，每增加
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" name="default[1][<?php echo $v['ftl_id'];?>][addnum]" type="text">
                                                    <method><?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?></method>，增加运费
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_next_money']);?>" name="default[1][<?php echo $v['ftl_id'];?>][addprice]" type="text">元
                                                </th>
                                            </tr>
                                        </thead>
                                        <?php }}?>
                                        <tbody>
                                            <?php if(in_array('N', $exit[1])){?>
                                            <tr>
                                                <th colspan="2">运送到</th>
                                                <th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
                                                <th width="100px">首<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
                                                <th>续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>数（<?php if ($detail[0]['frt_valuation_method']=='1'){echo 'kg';}else{echo '件';}?>）</th>
                                                <th width="100px">续<?php if ($detail[0]['frt_valuation_method']=='1'){echo '重';}else{echo '件';}?>价格（元）</th>
                                                <th width="50px">操作</th>
                                            </tr>
                                            <?php }?>
                                            <?php foreach ($detail[0]['link'] as $k => $v){if ($v['ftl_shipping_method']=='1' && $v['ftl_default']=='N'){?>
                                            <tr>
                                                <td>
                                                    <?php echo trim($v['path']);?>
                                                    <input class="form-control myinput" num="<?php echo $v['ftl_id'];?>" parent="<?php echo $v['parentPath'];?>" value="<?php echo $v['ftl_cities'];?>" type="hidden" name="default[1][<?php echo $v['ftl_id'];?>][area]">
                                                </td>
                                                <td width="50px">
                                                    <a class="a_blue" href="javascript:" onclick="SETTEMPLATE.show(this,0,2)">编辑</a>
                                                </td>
                                                <td>
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_begin_count'];?>" num="<?php echo $v['ftl_id'];?>" type="text" name="default[1][<?php echo $v['ftl_id'];?>][begin_count]">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_begin_money']);?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?>][begin_money]" type="text">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput" value="<?php echo $v['ftl_next_count'];?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?>][next_count]" type="text">
                                                </td>
                                                <td>
                                                    <input class="form-control myinput myinput3" value="<?php echo sprintf('%.2f',$v['ftl_next_money']);?>" num="<?php echo $v['ftl_id'];?>" name="default[1][<?php echo $v['ftl_id'];?>][next_money]" type="text">
                                                </td>
                                                <td>
                                                    <a class="a_blue" href="javascript:void(0)" onclick="deleteCity(this)">删除</a>
                                                </td>
                                            </tr>
                                            <?php }}?>
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <th colspan="7">
                                                    <a class="a_blue" href="javascript:void(0)" onclick="SETTEMPLATE.show(this,express2,1)">为指定地区城市设置运费</a>
                                                </th>
                                            </tr>
                                        </tfoot>
                                    </table>
                                    <?php }?>
                                </div>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
					<div class="padtb5"></div>
                    <div class="txt_row">
                        <div class="txt_main">
                            <label class="txt_title"></label>
                            <label>
                                <input type="checkbox" name="frt_default" value="Y" <?php if ($detail[0][ 'frt_default']=='Y'){?> checked <?php }?>/><b>设为默认模板</b>
                            </label>
                        </div>
                    </div>
                    <input type="hidden" name="frt_tid" value="<?php echo $detail[0]['frt_id'];?>">
                    <input type="hidden" <?php if ($detail[0][ 'frt_id']){?> value="edit" <?php }else{?> value="add" <?php }?> name="tag">
					<div class="sub_btns">
                        <input type="submit" class="btn btn-danger" value="提交">
                    </div>
                    <div class="txt_tips login_error"></div>
                </form>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<!-- Modal -->
<div class="modal" id="template_box" tabindex="-1" role="dialog" aria-labelledby="template_box">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">选择地区</h4>
            </div>
            <div class="modal-body" id="mymodal"></div>
            <div class="modal-footer center"></div>
        </div>
    </div>
</div>
<?php include_once(mvc::$cfg['PATH_TPL'].'public/footAll.php');?>
<script type="text/javascript" src="/static/js/collhop.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script type="text/javascript" src="/static/js/addr.js?ver=<?php echo mvc::$cfg['VER']['js'];?>"></script>
<script>
$(document).ready(function() {
    ADDR.init('province_box', "<?php echo $detail[0]['frt_send_pct'];?>", 'province');
    
    addSellerTemplateInit();
})
</script>
