{% extends 'dashboard_screen/base.html' %}

{% block content %}

            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="content-page">
                <!-- Start content -->
                <div class="content">
                    <div class="container">
                        <div class="row">

                            <div class="col-lg-12">
                            	<div class="card-box">
                            		<h4 class="m-t-0 header-title"><b>Add New Result Code</b></h4>

									<form id="id_ajax_form_add_Result_code" action="/dashboard/add_result/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                        {% csrf_token %}
                                        {% if code %}<input type="hidden"  name="code_id" value="{{ code.code_id }}"/> {% endif %}
                                        <div>

                                            <div class="col-lg-2">
                                                    <div class="p-20">
                                                        <h5><b>Code Name:(*)</b></h5>
                                                        <div class="input-group m-t-15">
												            <input type="text" class="form-control" maxlength="3" autofocus required name="code_name" onKeyUp="this.value=this.value.toUpperCase();" {% if code %} value="{{ code.code_name }}" {% endif %}/>
                                                            <span class="input-group-addon bg-custom b-0 text-white"><i class="ion-beaker"></i></span>
                                                        </div>
											        </div>
                                            </div>
                                            <div class="col-lg-3">
                                                <div class="p-20">
                                                        <h5><b>Result Area:(*)</b></h5>

                                                         <div class="input-group m-t-15">
                                                              <select id="id_code_cat" required name="code_result_area" class="selectpicker show-tick" data-style="btn-white">
                                                                 <option value=""> Select Result Area</option>
                                                                 {% if categories %}
                                                                   {% for item in categories %}
                                                                     <option value="{{ item.cat_id }}" {% if code %}{% if code.code_result_area.cat_id == item.cat_id %}selected{% endif %}{% endif %}> {{ item.cat_name }}</option>
                                                                   {% endfor %}
                                                                {% endif %}
                                                               </select>
                                                         </div>
                                                </div>
                                            </div>


                                            <div class="col-lg-3">
                                                <div class="p-20">
                                                    <h5><b>Case Type:(*)</b></h5>

                                                    <div class="input-group m-t-15">
                                                          <select id="id_code_sub_cat" required name="code_case_type" class="selectpicker show-tick" data-style="btn-white">
                                                              <option value=""> Select Case Type</option>
                                                                {% if casetype %}
                                                                   {% for item in casetype %}
                                                                     <option value="{{ item.case_type_id }}" {% if code %}{% if item.case_type_id == code.code_casetype_result.case_type_id %}selected{% endif %}{% endif %}> {{ item.case_type_name }}</option>
                                                                   {% endfor %}
                                                                {% endif %}
                                                          </select>
                                                    </div>

                                                </div>
                                            </div>


                                            <div class="col-lg-3">
                                                <div class="p-20">
                                                    <h5><b>Result Type:(*)</b></h5>

                                                    <div class="input-group m-t-15">
                                                          <select id="id_result_type" required name="result_type" class="selectpicker show-tick" data-style="btn-white">
                                                              <option value="0" {% if not code.code_result_type %} selected{% else %}{% endif %}> Negative</option>
                                                              <option value="1" {% if code.code_result_type %} selected{% else %}{% endif %}> Positive</option>
                                                          </select>
                                                    </div>

                                                </div>
                                            </div>
                                            <div class="col-lg-12">

                                                <div class="col-lg-5">
                                                    <div class="p-20">
                                                            <h5><b>Sub Area:(*)</b></h5>

                                                             <div class="input-group m-t-15">
                                                                  <select id="id_code_subcat" required name="code_result_subarea" class="selectpicker show-tick" data-style="btn-white">
                                                                     <option value=""> Select SubArea</option>
                                                                     {% if resultsubcategory %}
                                                                       {% for item in resultsubcategory %}
                                                                         <option value="{{ item.subcat_id }}" {% if code %}{% if code.code_result_subcat.subcat_id == item.subcat_id %}selected{% endif %}{% endif %}> {{ item.subcat_name }}</option>
                                                                       {% endfor %}
                                                                    {% endif %}
                                                                   </select>
                                                             </div>
                                                    </div>
                                                </div>

                                                <div class="col-lg-6">
                                                    <div class="p-20">
                                                        <h5><b>Description:(*)</b></h5>

                                                        <div class="input-group m-t-15">
                                                                <textarea id="textarea" name="code_descript" class="form-control" maxlength="200" rows="2" placeholder="This description has a limit of 200 chars.">{% if code %}{{code.code_description}}{% endif %}</textarea>
                                                                <span class="input-group-addon bg-custom b-0 text-white"><i class="ion-beaker"></i></span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>


                                            <div class="col-lg-12">
                                                <h5><b>(*) Mandatory</b></h5>
                                            </div>


                                            <div class="col-lg-12">
                                                <div class="col-lg-10">
                                                </div>
                                                <div class="col-lg-2">
                                                    {% if not code %}
                                                       <div class="m-b-30">
                                                         <button type="submit" name="save_code" value="ok" class="btn btn-default waves-effect waves-light">Add Code <i class="fa fa-plus"></i></button>
                                                       </div>
                                                    {% else %}
                                                        <div class="m-b-30">
                                                           <button type="submit" name="edit_code" value="ok" class="btn btn-default waves-effect waves-light">Update Code <i class="fa fa-plus"></i></button>
                                                       </div>

                                                    {% endif %}

                                                </div>
                                            </div>



                                            <div class="col-lg-12">
                                                <div class="col-lg-5">
                                                </div>
                                                <div class="col-lg-5">
                                                  <label class="control-label ">{{ message }}</label>
                                                </div>
                                            </div>
                                        </div>
                                    </form>

                                    <div class="panel">


                                            <div class="panel-body">
                                                <div class="">
                                                    <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                                                        <thead>
                                                            <tr>
                                                                <th>Result Code</th>
                                                                <th>Result Area</th>
                                                                <th>Case Type</th>
                                                                <th>Result Type</th>
                                                                <th>Result Sub Area</th>
                                                                <th>Description</th>
                                                                <th>Actions</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                           {% if codes %}
                                                               {% for code in codes %}

                                                                    {% if forloop.counter|divisibleby:2 %}
                                                                        <tr class="gradeX">
                                                                            <td>{{ code.code_name }}</td>
                                                                            <td>{{ code.code_result_area.cat_name }}</td>
                                                                            <td>{{ code.code_casetype_result.case_type_name }}</td>
                                                                            <td>{{ code.show_result_type }}</td>
                                                                            <td>{{ code.code_result_subcat.subcat_name }}</td>
                                                                            <td>{{ code.code_description }}</td>
                                                                            <td class="actions">
                                                                                <a href="/dashboard/add_result/{{ code.code_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                                <a href="/dashboard/add_result/{{ code.code_id }}/" class="on-default remove-row"><i class="fa fa-trash-o"></i></a>
                                                                            </td>
                                                                        </tr>
                                                                    {% else %}
                                                                        <tr class="gradeC">
                                                                            <td>{{ code.code_name }}</td>
                                                                            <td>{{ code.code_result_area.cat_name }}</td>
                                                                            <td>{{ code.code_casetype_result.case_type_name }}</td>
                                                                            <td>{{ code.show_result_type }}</td>
                                                                            <td>{{ code.code_result_subcat.subcat_name }}</td>
                                                                            <td>{{ code.code_description }}</td>
                                                                            <td class="actions">
                                                                                <a href="/dashboard/add_result/{{ code.code_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                                <a href="/dashboard/add_result/{{ code.code_id }}/" class="on-default remove-row"><i class="fa fa-trash-o"></i></a>
                                                                            </td>
                                                                        </tr>
                                                                    {% endif %}

                                                               {% endfor %}
                                                           {% endif %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        <!-- end: page -->


                                    </div> <!-- end Panel -->


                                </div><!-- card box -->
                            </div>

                            <!-- End row -->

                        </div>

                    </div> <!-- container -->

                </div> <!-- content -->


{% endblock %}