<style type="text/css">
    .modal-backdrop{bottom: 0;  z-index: 2;}
    #components{
        min-height: 556px;
    }
    .component:hover{cursor: move;}
    #target{
        min-height: 500px;
        padding: 25px 10px 0 10px;
    }
    #target .component{
        border: 1px solid #fff;padding: 8px 0;
    }
    #target .component:hover{
        border: 1px dashed #ddd !important;
    }
    #temp{
        width: 500px;
        background: white;
        border: 1px dotted #ccc;
        border-radius: 10px;
        z-index: 999999;
        padding-top: 12px;
    }
    ul#components{list-style: none;padding: 0;}
    ul#components li{height: 40px;line-height: 40px;padding: 0 15px;}
    ul#components li:hover{background: #f3f3f3;}

    label {margin-top: 0px;}
    .filed_label_name span{float: right;font-size: 22px;}
    .help_span_box{line-height: 38px;font-size: 18px;}
    close_other_input,.open_other_input{margin-left: 0 !important;margin-right: 10px;}
</style>


<div class="container-fluid" style="background:#f8f8f8;">
    <div class="row">
        <div class="col-sm-5 col-md-4">

            <form action="<?php echo site_url('thirdparty/form/index/create_form'); ?>" method="post" >
                <p class="btn-lg col-xs-24"></p>
                <p>
                <div class="input-group">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button">类型</button>
                    </span>
                    <select class="form-control" name="file_type" id="file_type">
                        <?php foreach ($type as $key => $value) { ?>
                            <option value="<?php echo $key; ?>" <?php if (isset($selected_type) && $selected_type == $key) echo 'selected'; ?>><?php echo $key; ?></option>
                        <?php } ?>
                    </select>
                </div>
                </p>
                <p class="btn-sm col-xs-24"></p>
                <p><button type="button" class="btn btn-primary btn-block" onclick="location.href = '<?php echo site_url("thirdparty/form/index/create_form"); ?>/' + $('#file_type').val();">新建表单→</button></p>
            </form>

            <p class="btn-lg col-xs-24"></p>
            <h4><a href="<?php echo site_url('thirdparty/form'); ?>"><strong>表单列表</strong></a></h4>
            <div class="center-col" style="background:#fff;border-right: 1px solid #ddd;">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>表单名</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($form_list as $key => $v) { ?>
                            <tr>
                                <td><?php echo $key + 1; ?></td>
                                <?php $admin_info = $this->session->userdata('session_admin'); ?>
                                <td><a href="<?php echo site_url('thirdparty/form/index/create_form/' . $v->form_sn); ?>"><?php echo $v->form_name; ?></a></td>

                                <td>
                        <li class="pull-left dropdown" style="list-style:none;">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <span class="glyphicon glyphicon-menu-hamburger"><b class="caret"></b></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li>    <a class="pull-left" href="javascript:void(0);" onclick="call_form('<?php echo $v->form_sn; ?>');">调用</a></li>
                                <?php if ($v->OPI_Name == $admin_info['OPI_Name']) { ?>
                                    <li> <a href="javascript:do_submit('','<?php echo site_url('thirdparty/form/index/delete/' . $v->form_sn); ?>');">删除</a></li>
                                    <li>
                                        <?php if ($v->form_status == 1) { ?>
                                            <a href="javascript:do_submit('','<?php echo site_url('thirdparty/form/index/stop/' . $v->form_sn . '/0'); ?>');">停用</a>
                                        <?php } else { ?>
                                            <a href="javascript:do_submit('','<?php echo site_url('thirdparty/form/index/stop/' . $v->form_sn . '/1'); ?>');">启用</a>
                                        <?php } ?>
                                    </li>
                                <?php } ?>
                            </ul>
                        </li>

                        </td>
                        </tr> 
                    <?php } ?>
                    </tbody>
                </table>
            </div>    

        </div>


        <div class="col-sm-19 col-md-20 nopadding">
            
            <div class="modal-content" style="-webkit-box-shadow: 0 0px 0px rgba(0,0,0,0.5);box-shadow: 0 0px 0px rgba(0,0,0,0.5);">
                <div class="modal-header" style="padding:10px 15px;">
                    <h4 class="modal-title" id="myLargeModalLabel">
                        表单编辑
                        <a class="pull-right" href="<?php echo site_url('thirdparty/form'); ?>" class="btn btn-default">返回首页》</a>
                    </h4>
                </div>
                <div class="modal-body" style="background:#f0f0f0;">
                    <div class="container-fluid">
                        <div class="row">

                            <div class="col-sm-5 nopadding-L">
                                <div class="col-xs-24" style="background:#fff;">
                                    <div class="row" style="background:#f7f7f7;padding:0 15px;">
                                        <h5>字段列表</h5>
                                    </div>
                                    <div class="row" style="padding:0px;height:566px;overflow-y: auto;">
                                        <ul id="components">
                                            <?php foreach ($fileds as $key => $filed) { ?>
                                                <li class="control-group component" data-content='<?php echo $filed; ?>'>
                                                    <?php echo $key; ?>
                                                </li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-19" style="background:#fff;min-height:600px;">
                                <div class="row" style="background:#f7f7f7;padding:8px 15px;">
                                    <span class="pull-left">
                                        <input type="text" id="new_form_name" name="form_name" value="<?php echo isset($form_data) ? $form_data->form_name : '新表单'; ?>" style="border: none;background: none;">
                                    </span>
                                    <?php
                                    $admin_info = $this->session->userdata('session_admin');
                                    if (!isset($form_data) || $form_data->OPI_Name == $admin_info['OPI_Name']) {
                                        ?>
                                        <a class="pull-right btn_create_form"  data-type="preview" href="javascript:void(0);">预览</a>
                                    <?php } ?>
                                </div>
                                <div class="row">

                                    <div class="col-xs-24" id="build">
                                        <?php if (isset($form_data)) { ?>
                                            <input type="hidden" id="form_sn" name="form_sn" value="<?php echo $form_data->form_sn; ?>">
                                        <?php } ?>
                                        <form id="target" class="form-horizontal">
                                            <?php if (isset($form_data)) { ?>
                                                <?php echo htmlspecialchars_decode($form_data->form_structure); ?>
                                            <?php } else { ?>
                                                <fieldset>
                                                    <div id="legend" class="component hidden"><legend class="valtype" data-valtype="text"></legend></div>
                                                    <?php $type_array = explode('|', $type[$selected_type]); ?>
                                                    <?php foreach ($type_array as $f) { ?>
                                                        <?php echo $fileds[$f]; ?>
                                                    <?php } ?>
                                                </fieldset>
                                            <?php } ?>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <a href="<?php echo site_url('thirdparty/form'); ?>" class="btn btn-default">返回首页</a>
                    <button type="button" data-type="btn" class="btn btn-primary btn_create_form">保存表单</button>

                </div>


            </div>
        </div>




    </div>
</div>










<div class="modal fade form_filed_dialog">
    <div class="modal-dialog" style="margin-top: 20%;width:450px;">
        <div class="modal-content">
            <div class="modal-header" style="padding:10px 15px;">
                <button type="button" class="close close_form_option"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myLargeModalLabel">字段属性设置</h4>
            </div>
            <div class="modal-body">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-24 btn-lg"></div>
                        <div class="col-xs-24">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-5 control-label">字段名</label>
                                    <div class="col-sm-18">
                                        <input type="text" class="form-control" id="filed_label" name="filed_label" value="Email">
                                    </div>
                                </div>

                                <div class="form-group radio_kuang">
                                    <label class="col-sm-5 control-label">选项值</label>
                                    <div class="col-sm-18">
                                        <textarea class="form-control radio_list_key" rows="7" name="radio_kuang"></textarea>
                                    </div>
                                </div>

                                <div class="form-group filed_other_option">
                                    <div class="col-sm-5 control-label">其他</div>
                                    <div class="col-sm-18">
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" id="filed_need" name="filed_need"> 设置为必填选项
                                            </label>
                                        </div>
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" id="filed_help" name="filed_help" onclick="$('.help_container').toggle();"> 添加帮助选项
                                            </label>
                                        </div>
                                        <div class="col-xs-24 well help_container" style="border: none;padding: 15px;margin-top: 10px;display:none;">
                                            <input class="form-control input-sm" id="filed_help_text" name="filed_help_text" placeholder="帮助说明文字">
                                            <div class="col-xs-24 btn-sm"></div>
                                            <input class="form-control input-sm" id="filed_help_link" name="filed_help_link" placeholder="链接（可不填）">
                                        </div>

                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="col-xs-offset-5 col-xs-18">
                            <button type="button" class="btn btn-default close_form_option">取消</button>
                            <button type="button" class="btn btn-primary btn_set_filed_options">保存</button>
                        </div>
                        <div class="col-xs-24 btn-lg"></div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

