<div class="modal bs-worktype-modal-lg" tabindex="-1" role="dialog" aria-labelledby="worktypeModalLabel" aria-hidden="true">
  <link type="text/css" rel="stylesheet" href="/css/webht/jquery.suggest.css" />
  <div class="modal-dialog">
    <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">
        <form class="form-add-work-type" method="post" action="<?php echo site_url('apps/workflow/index/do_add_work_type'); ?>">
          <div class="form-group">
            <label for="exampleInputPassword1">事务类型</label>
            <div class="input-group">
              <span class="input-group-addon nopadding noborder">
                <select name="wt_parentid" class="form-control noshadow" style="min-width:120px;border-right:none;">
                  <?php foreach ($typelist as $t) { ?>
                    <option value="<?php echo $t->wt_sn; ?>" <?php if(isset($type_info) && ($type_info->wt_parentid==$t->wt_sn || $type_info->wt_sn==$t->wt_sn)) echo 'selected'; ?>><?php echo $t->wt_name; ?></option>
                  <?php } ?>
                  <option value="0">无</option>
                </select>
              </span>
              <input type="text" name="wt_name" class="form-control noshadow" placeholder="名称" value="<?php if(isset($type_info))echo $type_info->wt_name; ?>">
            </div>
          </div>
          <div class="form-group">
            <label>简要描述</label>
            <textarea class="form-control" name="wt_description"><?php if(isset($type_info))echo $type_info->wt_description; ?></textarea>
          </div>
          <div class="form-group">
            <label for="exampleInputPassword1">选择表单</label>
            <select name="wt_form" class="form-control noshadow">
                <option value="0">选择表单</option>
                <?php foreach ($formlist as $f) { ?>
                    <option value="<?php echo $f; ?>" <?php if(isset($type_info) && $type_info->wt_form==$f)echo 'selected'; ?> ><?php echo $f; ?></option>
                <?php } ?>
            </select>
          </div>
          <div class="form-group">
            <div class="checkbox">
              <label>
                <input type="checkbox" name="wt_isneedkaoqin" value="1" <?php if(isset($type_info) && $type_info->wt_isneedkaoqin==1) echo 'checked'; ?>> 
                是否考勤
              </label>
              <label>
                <input type="checkbox" name="wt_isrest" value="1" <?php if(isset($type_info) && $type_info->wt_isrest==1) echo 'checked'; ?>> 
                是否为补休
              </label>
              <label>
                <input type="checkbox" name="wt_userdefined" value="1" <?php if(isset($type_info) && $type_info->wt_userdefined==1) echo 'checked'; ?>> 
                允许后勤审核时自定义考勤时间
              </label>
              <label>
                <input type="checkbox" name="wt_needmail" value="1" <?php if(isset($type_info) && $type_info->wt_needmail==1) echo 'checked'; ?>> 
                发送审核提醒邮件
              </label>
            </div>
          </div>
          <div class="form-group msg_list_box" style="position:relative;">
            <label>抄送邮箱</label>
            <input type="text" name="wt_msg_user" class="form-control msg_list noshadow" value="<?php if(isset($type_info->wt_msg_user))echo $type_info->wt_msg_user; ?>" placeholder='邮件地址 以英文分号";"分隔'>
          </div>
          <div class="form-group admin_list_box" style="position:relative;overflow:hidden;">
            <label for="exampleInputFile">审核流程</label>
            <input type="hidden" class="admin_list_sn" name="wt_step" value="<?php if(isset($type_info))echo $type_info->wt_step.';'; ?>">
            <div class="col-xs-24 role_tag_needed nopadding">
              <?php 
              $level=array();
              foreach ($rolelist as $role) {
                $level[$role->wt_sn]=$role->wt_name;
              }
              if(isset($type_info)){
                $steps=explode(';', $type_info->wt_step);
                foreach ($steps as $s) {
                  if (!empty($s)) {
              ?>
                <span class="role_tag_unneed label label-primary" data-tagid="<?php echo $s; ?>"><?php echo $level[$s]; ?>×</span>
              <?php    
                  }
                }
              }
              ?>
            </div>
            <div class="col-xs-24 nopadding">
            <?php foreach ($rolelist as $role) { ?>
              <span class="role_tag" data-tagid="<?php echo $role->wt_sn; ?>"><?php echo $role->wt_name; ?></span>
            <?php } ?>
            </div>
          </div>
          <div class="form-group">
            <select class="form-control" name="wt_linear">
              <option value="0" <?php if(isset($type_info) && $type_info->wt_linear==0) echo 'selected'; ?>>非线性流程(按设计好的流程走)</option>
              <option value="1" <?php if(isset($type_info) && $type_info->wt_linear==1) echo 'selected'; ?>>线性流程(1个步骤)</option>
              <option value="2" <?php if(isset($type_info) && $type_info->wt_linear==2) echo 'selected'; ?>>线性流程(2个步骤)</option>
              <option value="3" <?php if(isset($type_info) && $type_info->wt_linear==3) echo 'selected'; ?>>线性流程(3个步骤)</option>
              <option value="4" <?php if(isset($type_info) && $type_info->wt_linear==4) echo 'selected'; ?>>线性流程(4个步骤)</option>
              <option value="5" <?php if(isset($type_info) && $type_info->wt_linear==5) echo 'selected'; ?>>线性流程(5个步骤)</option>
            </select>
          </div>
          <input type="hidden" name="wt_sn" value="<?php if(isset($type_info))echo $type_info->wt_sn; ?>">
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <?php if(isset($type_info) && $type_info->wt_isdelete==0){ ?>
        <a href="javascript:void(0);" class="btn btn-danger ajax-link" data-title="停用" data-href="<?php echo site_url('apps/workflow/index/dalete_work_type/'.$type_info->wt_sn); ?>">停用</a>
        <?php }elseif(isset($type_info) && $type_info->wt_isdelete==1){ ?>
        <a href="javascript:void(0);" class="btn btn-danger ajax-link" data-title="启用" data-href="<?php echo site_url('apps/workflow/index/dalete_work_type/'.$type_info->wt_sn.'/0'); ?>">启用</a>
        <?php } ?>
        <button type="button" class="btn btn-info" onclick="ajaxSubmit('.form-add-work-type');"> 保 存 </button>
      </div>
    </div>
  </div>
  <script type="text/javascript" src="/js/jquery.suggest.js"></script>
<script type="text/javascript">
//自动提示
  var auto_complete_url="<?php echo site_url('apps/workflow/index/get_user_list'); ?>";
  $(".msg_list").suggest(auto_complete_url,{
        container: '.msg_list_box',
        onSelect: function() {
          var admin_list=$('.msg_list').val();
          var name_arr=admin_list.split(';');
          var newnamelist='';
          for (var i = 0; i < name_arr.length; i++) {
            if (!isNaN(name_arr[i])) {
              $('.msg_list_sn').val($('.msg_list_sn').val()+name_arr[i]+',');
            }else{
              newnamelist=newnamelist+name_arr[i]+';';
            }
          };
          $('.msg_list').val(newnamelist);
        },
        selectClass: '',
        matchClass: 'active',
        resultsClass: 'list-unstyled admin-list-unstyled'
  });
  //添加一审核级别
  $("body").on('click','.role_tag',function(){
    var wt_sn=$(this).attr('data-tagid');
    var html='<span class="role_tag_unneed label label-primary" data-tagid="'+wt_sn+'">'+$(this).text()+'×</span>';
    $(".role_tag_needed").append(html);
    $('.admin_list_sn').val()==''?$('.admin_list_sn').val(';'):'';
    $('.admin_list_sn').val($('.admin_list_sn').val()+wt_sn+';');
  });
  //移除一审核级别
  $("body").on('click','.role_tag_unneed',function(){
    $(this).remove();
    var wt_sn_string=';';
    $(".role_tag_unneed").each(function(){
      var wt_sn=$(this).attr('data-tagid');
      wt_sn_string+=wt_sn+';';
    });
    $('.admin_list_sn').val(wt_sn_string);
  });
</script>
</div>