{% extends "data_opform.html" %}
{% load i18n %}

	{% block form %}
	{% autoescape off %} 
<tr><td>

  <table width="100%" border="0" cellspacing="0" cellpadding="3">
     
             <tr>
                <th height="20">{{ form.department|field_as_label_tag }}</th>
                <td>{{form.department.as_widget }}</td>
                <td>{{form.department.errors }}</td>
                
             </tr>
     <!--
         ##修改时间：2014-03-05
         ##修改人：David.Dai@zkteco.com
         ##修改原因：新员工自助：让职位的显示具有树的效果
    -->
     {%if "USE_NEW_SELFSERVICE"|filter_config_option%}        
	 <tr>
        <th height="20">
        	<label for="id_parent" class="required">{% trans '调整后的职位' %}: </label>
        </th>
        <td>
        <input id="id_show_input" type="text" readonly="readonly" class="wZBaseCharField input_showDeptTree required position_tree" ></input>
		<span class="t_btn_showDeptTree">
		    <img id="id_drop_dept" onclick="javascript:$(this).parent().find('#show_deptment').show().bgiframe();" src="/media/img/sug_down_on.gif"></img>
		    <div id="show_deptment" style="display: none;">
		        <div class="title" onclick="javascript:$(this).parent().parent().find('#show_deptment').hide();">
		            <span class="close btn" >
		               {% trans '确定' %}
		            </span>
		        </div>
		        <div id="id_dept" class="dispayN">
		            <ul id="position_tree_by_dept" class="tree"></ul>
		        </div>
		    </div>
		
		</span>
		<div>
		
		</div></td>
        <td><td/>
        
     </tr>
     {%else%}
     <tr>
        <th height="20">{{ form.position|field_as_label_tag }}</th>
        <td>{{form.position.as_widget }}</td>
        <td>{{form.position.errors }}</td>
        
     </tr>
     {%endif%}
     <!--职位树结束-->
	<tr>
		{{form.changereason|field_as_td_h}}
		<td  >{{form.changereason.errors }}</td>
	  
		</tr>
	<tr>
    	{{form.remark|field_as_td_h}}
 
  		<td>
		{{form.remark.errors }}
	</td>
 
	</tr>
	 {% for i,k in form.errors.items %}
	   {{i}}{{k}}
	   {% endfor %}
  </table>
</td></tr>
	<tr>
		<td colspan="2" class="displayB">
			<div style="height:27px; display:block;"><ul class="errorlist" id="emp_select_error"></ul></div>
		</td>
	</tr>

{% endautoescape %}
{% endblock %}<!-- form -->

{% block addjs %}
	//##修改时间：2014-03-05
    //##修改人：David.Dai@zkteco.com
    //##修改原因：新旧版员工自助切换
	{%if not "USE_NEW_SELFSERVICE"|filter_config_option%}
	$("#id_position").focus(function(){
	    var url = "/{{request.surl}}personnel/select_position/personnel/Position/?department=";
	    var items = document.getElementsByName("department");
	    if(items.length !=0){
	        var array = items[0].value;
	    }
	    if (array=="" || typeof(array) == "undefined"){
	    	alert("请先选择部门!");
	        return false;
	    }
	    url+=array;
	    $.ajax({
	        type:"POST",
	        url:encodeURI(url),
	        dataType:"json",
	        success:function(msg){
	            var html_list = [];
	            html_list.push("<option value=''>---------</option>");
	            if(msg.length !=0){
	                for(var i=0;i<msg.length;i++){
	                    var row = "<option value='" + msg[i][0] + "'>" + msg[i][1] + " " + msg[i][2] + "</option>";
	                    html_list.push(row);
	                }
	            }
	            $("#id_position").html(html_list.join(""));
	        }
	    });
	});
	{%else%}
	before_submit = function(){
		if($("#id_show_input").val()==""){
			$('#id_info').html("<ul class='errorlist'><li>"+gettext('请选择部门!')+"</li></ul>")
			return false
		}
	    if($(".position_tree").val().trim().length==0){
			$('#id_info').html("<ul class='errorlist'><li>"+gettext('请选择职位!')+"</li></ul>")
			return false
		}else{
	          $('#id_info').html("")
	          return true
	    }
	}
	{%endif%}
	//=======================================
{% endblock %}


