{% extends 'obj_form.html' %}
{% load i18n %}
{% load tj_filters %}

{% block subtitle-1 %}
{% trans "营销活动" %}
{% endblock %}
{% block subtitle-2 %}
{% trans "投奖计划" %}
{% endblock %}


{% block form_content %}
{{ block.super }}

<style>
    input[type=radio],
    input[type=checkbox] {
        display: inline-block;
        width: auto;
        height: auto;
        border: none;
        box-shadow: none;
    }

    .input-num {
        display: inline-block;
        width: 100px;
        border: none;
        border-bottom: 1px solid gray;
    }
</style>

<div class="alert alert-success" role="alert" style="display: none">保存成功！</div>
<div class="form-group ">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'activity' %} </label>
    <div class="col-sm-10">{{ form.activity }}</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'award' %} </label>
	<div class="col-sm-10">
		<select class="form-control" name="award" id="awards_select"></select/>
	</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'tm_start' %} </label>
    <div class="col-sm-10">
		{{ form.tm_start }}
	</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'tm_end' %} </label>
    <div class="col-sm-10">
		{{ form.tm_end }}
	</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'win_scan_num' %} </label>
    <div class="col-sm-10">{{ form.win_scan_num }}</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'batch_no' %} </label>
    <div class="col-sm-10">{{ form.batch_no }}</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">{% get_verbose_field_name form.instance 'remark' %} </label>
    <div class="col-sm-10">{{ form.remark }}</div>
</div>

<div>
    <a class="btn btn-primary btn-save" type="submit" style="float:right;">{% trans '保存' %}</a>
</div>

<script>
    $(document).ready(function () {
	
		setDatePickerZh();
        $('.datetimepicker').datetimepicker({
            i18n:{
                zh:{
                    months:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月',],
                    dayOfWeek:["一", "二", "三", "四","五", "六", "日",]
                }
            },
            //timepicker:true,
            format:'Y-m-d H:i:s',        
        });
			
		$("#id_activity").change(function(){ 
			var activity_id = $(this).val();
			$.ajax({
				url:'obj/ajax/autoselect/activityawards/?id='+activity_id,
				success:function(res){
					console.log(res);
					var html = '';
					for(var i =0;i<res.length; i++){
						html+='<option value="'+res[i].value+'">'+res[i].label+'</option>';
					}
					$("#awards_select").html(html);
				}
			})
		})
		
        $('.btn-save').click(function () {
            $.SubmitForm('#obj_form form', '{{request.path}}',function (){
                //$('.alert').fadeIn();
            });
        });
    })


</script>

{% endblock %}