{% 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 'phone' %} </label>
    <div class="col-sm-10"> 
		<input type="text" name="phone" required="required" class="form-control">
	</div>
</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 'remark' %} </label>
    <div class="col-sm-10">{{ form.remark }}</div>
</div>
<input type="hidden" name="label_code" required="" id="id_label_code" class="form-control" value="1">
<div>
    <a class="btn btn-primary btn-save" type="submit" style="float:right;">{% trans '保存' %}</a>
</div>

<script>
    $(document).ready(function () {
	
	
		$("#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 %}