{% 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 Laboratory Test</b></h4>

									<form  id="id_ajax_form_add_exam" action="/dashboard/add_exam/" class="form-horizontal" method="post" enctype="multipart/form-data">
                                        {% csrf_token %}
                                        {% if exam %}<input type="hidden"  name="exam_id" value="{{ exam.exam_id }}"/> {% endif %}
                                        <div>
                                                <div class="col-lg-3">
                                                    <div class="p-20">
                                                        <h5><b>Test Name:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             The <code>Test Name</code>is Unique.
                                                        </p>
                                                        <div class="input-group m-t-15">
												            <input type="text" class="form-control" autofocus required maxlength="25" name="exam_name" onKeyUp="this.value=this.value.toUpperCase();" placeholder="Enter Test Name" {% if exam %} value="{{ exam.exam_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>Test Code:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             The <code>Test code</code>is Unique.
                                                        </p>
                                                        <div class="input-group m-t-15">
												            <input type="text" class="form-control"  required maxlength="25" name="test_code" onKeyUp="this.value=this.value.toUpperCase();" placeholder="Enter Test Code" {% if exam %} value="{{ exam.test_code }}" {% 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>CPT Code:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             The <code>CPT Code</code>is Unique.
                                                        </p>
                                                        <div class="input-group m-t-15">
												            <input type="text" class="form-control" autofocus required maxlength="15" name="cpt_name" onKeyUp="this.value=this.value.toUpperCase();" placeholder="Enter CPT Code" {% if exam %} value="{{ exam.cpt_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>Case Type:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             Include this Test in any <code>Case Type</code>.
                                                        </p>
                                                        <div class="input-group m-t-15">
                                                              <select id="id_code_sub_cat" required name="exam_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 item.case_type_id == exam.exam_casetype.case_type_id %}selected{% endif %}> {{ item.case_type_name }}</option>
                                                                       {% endfor %}
                                                                    {% endif %}
                                                              </select>
                                                        </div>

                                                    </div>
                                                </div>

                                                <div class="col-lg-2">
                                                    <div class="p-20">
                                                        <h5><b>Default Price:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             <code>Default Price</code>.
                                                        </p>
                                                        <div class="input-group m-t-15">
												            <input type="number" class="form-control"  required maxlength="5" name="exam_price" id="defaultconfig" placeholder="Price" {% if exam %} value="{{ exam.exam_default_price }}" {% endif %}>
                                                            <span class="input-group-addon bg-custom b-0 text-white"><i class="ion-pricetag"></i></span>
                                                        </div>
											        </div>
                                                </div>


                                                <div class="col-lg-6">

                                                    <div class="p-20">
                                                        <h5><b>Description:(*)</b></h5>
                                                        <p class="text-muted m-b-15 font-13">
                                                             Please enter: Test <code>Description</code>.
                                                        </p>
                                                        <div class="input-group m-t-15">
                                                            <textarea id="textarea" name="exam_descript" class="form-control" maxlength="200" rows="2" placeholder="This description has a limit of 200 chars.">{% if exam %}{{ exam.exam_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>
                                                <div class="col-lg-12">
                                                    <h5><b>(*) Mandatory</b></h5>
                                                </div>


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

                                                        {% if not exam %}
                                                            <div class="col-lg-2">
                                                            </div>
                                                           <div class="col-lg-2">
                                                               <div class="m-b-30">
                                                                 <button type="submit" name="save_exam" value="ok" class="btn btn-default waves-effect waves-light">Add Test <i class="fa fa-plus"></i></button>
                                                               </div>
                                                           </div>
                                                        {% else %}
                                                            <div class="col-lg-2">
                                                                <div class="m-b-30">
                                                                    <a href="/dashboard/add_exam/">
                                                                      <button type="link" name="new_exam" value="ok" class="btn btn-default waves-effect waves-light">Add New <i class="fa fa-plus"></i></button>
                                                                    </a>
                                                                </div>
                                                            </div>
                                                            <div class="col-lg-2">
                                                                <div class="m-b-30">
                                                                   <button type="submit" name="edit_exam" value="ok" class="btn btn-default waves-effect waves-light">Update Test <i class="fa fa-save"></i></button>
                                                                </div>
                                                            </div>

                                                        {% endif %}


                                                </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>Test Name</th>
                                                            <th>Test Code</th>
                                                            <th>CPT Code</th>
                                                            <th>Case Type</th>
                                                            <th>Default Price</th>
                                                            <th>Description</th>
                                                            <th>Actions</th>
                                                        </tr>
                                                    </thead>
	                                                <tbody>
                                                    {% for exam in exams %}

                                                        {% if forloop.counter|divisibleby:2 %}
                                                            <tr class="gradeX">
                                                                <td>{{ exam.exam_name }}</td>
                                                                <td>{{ exam.test_code }}</td>
                                                                <td>{{ exam.cpt_name }}</td>
                                                                <td>{{ exam.exam_casetype.case_type_name }}</td>
                                                                <td>{{ exam.exam_default_price }}</td>
                                                                <td>{{ exam.exam_description }}</td>
                                                                <td class="actions">
                                                                    <a href="/dashboard/add_exam/{{ exam.exam_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                    <a href="/dashboard/add_exam/{{ exam.exam_id }}/" class="on-default remove-row"><i class="fa fa-trash-o"></i></a>
                                                                </td>
                                                            </tr>
                                                        {% else %}
                                                            <tr class="gradeC">
                                                                <td>{{ exam.exam_name }}</td>
                                                                <td>{{ exam.test_code }}</td>
                                                                <td>{{ exam.cpt_name }}</td>
                                                                <td>{{ exam.exam_casetype.case_type_name }}</td>
                                                                <td>{{ exam.exam_default_price }}</td>
                                                                <td>{{ exam.exam_description }}</td>
                                                                <td class="actions">
                                                                    <a href="/dashboard/add_exam/{{ exam.exam_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                    <a href="/dashboard/del_exam/{{ exam.exam_id }}/" class="on-default remove-row"><i class="fa fa-trash-o"></i></a>
                                                                </td>
                                                            </tr>
                                                        {% endif %}

                                                    {% endfor %}



                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <!-- end: page -->

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


                            	</div>

                            </div> <!-- end col -->
                        </div>


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

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

{% endblock %}