Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
52 kB
3
Indexable
Never
 <div class="row">
                            <div class="col-md-12 d-flex align-items-end table-responsive">
                                <table class="table table-bordered border-dark text-center table-striped table-sm">
                                    <thead class="table-dark">
                                        <tr>
                                            <th scope="col">Qualification Level</th>
                                            <th scope="col">Qualification Name</th>
                                            <th scope="col">Board/University</th>
                                            <th scope="col">Discipline</th>
                                            <th scope="col">Start Year</th>
                                            <th scope="col">End Year</th>
                                            <th scope="col">% Marks/CGPA</th>
                                            <th scope="col">Edit</th>
                                            <th scope="col">Delete</th>
                                        </tr>
                                    </thead>
                                    {% if not scq %}
                                    <tbody class="fs-5 table-secondary" id="edu_tbody">
                                        <tr class="fs-5 table-secondary" id="del_default_msg_edu">
                                            <th colspan="9">You haven't provided your qualification yet</th>
                                        </tr>
                                    </tbody>
                                    {% else %}
                                    <tbody class="fs-5 table-secondary" id="edu_tbody">
                                        {% for i in scq %}
                                        <tr id="edu{{i.id}}">
                                            <td>{{i.degree.qualification_category}}</td>
                                            <td>
                                                {% if i.degree.degree_long_name == 'Others' %}
                                                    {{i.other_degree}}
                                                {% else %}
                                                    {{i.degree}}
                                                {% endif %}
                                            </td>
                                            <td>{{i.school_college}}</td>
                                            <td>
                                                {% if i.discipline.discipline_long_name == 'Others' %}
                                                    {{ i.other_discipline }}
                                                {% else %}
                                                    {{i.discipline}}
                                                {% endif %}
                                            </td>
                                            <td>{{i.start_year}}</td>
                                            <td>{{i.completion_year}}</td>
                                            <td>
                                                {{i.percentage_marks_cgpa}}
                                                {% if i.cpga_outoff %}
                                                /{{i.cpga_outoff}}
                                                {% endif %}
                                            </td>
                                            <td><i class="fas fa-edit" data-id="{{i.id}}" onclick="scqEdit(event)"></i></td>
                                            <td><i class="fa fa-trash" aria-hidden="true" data-id="{{i.id}}" onclick="scqDel(event)"></i></td>
                                        </tr>
                                        {% endfor %}
                                    </tbody>
                                    {% endif %}
                                </table>
                            </div>
                        </div>
                        <div class="row fs-5 text-center form-text note">
                            <span> <strong>Note: Mandatory Qualification Level -
                                {% for i in req_qual %}
                                    {{i.qualification_category}},
                                {% endfor %}
                            </strong></span>
                        </div>
                        <div class="row fs-4 text-center form-text note text-danger">
                            <span> <strong>
                                {{ error_edu }}
                            </strong></span>
                        <br>
                        </div>
                        <div class="row">
                            <div class="col-md-12 d-flex align-items-end justify-content-center  ">
                                <input class="btn btn-rounded btn-primary btn-add-qual " id="myBtn" type="button" value="+ Add More Qualification" data-bs-toggle="modal" data-bs-target="#myModal"/>
                            </div>
                        </div>
                        <br>
                    {% if form.programming_flag.label %}
                        <div class="row">
                            <div class="col-md-6 col-sm-3">
                                <div class="form-group" id="programming_flag">
                                <label for="programming_flag" class="bold">{{ form.programming_flag.label }}<span class="required"> *</span></label>
                                    {{ form.programming_flag|attr:'required:true'}}
                                    {% if form.programming_flag.errors %}
                                    <span class="alert-danger">Please select Programming Flag</span>
                                    {% endif %}
                                </div>
                            </div>
                        </div>
                    {% endif %}
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                <label for="math_proficiency_level" class="bold">{{ form.math_proficiency_level.label }}<span class="required"> *</span></label>
                                {{ form.math_proficiency_level|attr:'required:true'|attr:'oninvalid:setCustomValidity("Please Select Level of Studies in Mathematics")'|attr:'onchange:setCustomValidity("")'|attr:'class:form-control'}}
                                {% if form.math_proficiency_level.errors %}
                                    <span class="alert-danger">Please select Math Proficency Level</span>
                                {% endif %}
                                
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                <label for="prior_student_flag" class="bold">{{ form.prior_student_flag.label }}<span class="required"> *</span></label>
                                {{ form.prior_student_flag|attr:'required:true'|attr:'class:form-control'}}
                                {% if form.prior_student_flag.errors %}
                                    <span class="alert-danger">Please select Prior Student Flag</span>
                                {% endif %}
                            </div>
                        </div>
                        <div class="col-md-6" id="bits_student_lable_prior">
                            <div class="form-group" id="programming_flag">
                                <label for="bits_student_id">{{ form.bits_student_id.label }}</label>
                                {{ form.bits_student_id|attr:'required:true'|attr:'maxlength:50'|attr:'class:form-control'}}
                                {% if form.bits_student_id.errors %}
                                    <span class="alert-danger">Please enter BITS ID Number (prior) </span>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                <label for="other_bits_prog_flag" class="bold">{{ form.other_bits_prog_flag.label }}<span class="required"> *</span></label>
                                {{ form.other_bits_prog_flag|attr:'required:true'|attr:'class:form-control'}}
                                {% if form.other_bits_prog_flag.errors %}
                                    <span class="alert-danger">Please select BITS Programme Flag </span>
                                {% endif %}
                            </div>
                        </div>
                        <div class="col-md-6" id="bits_student_lable_present">
                            <div class="form-group" id="programming_flag">
                                <label for="present_bits_student_id">{{ form.present_bits_student_id.label }}</label>
                                {{ form.present_bits_student_id|attr:'required:true'|attr:'oninvalid:InvalidPID(this);'|attr:'oninput:InvalidPID(this);'|attr:'maxlength:15'|attr:'class:form-control'}}
                                {% if form.present_bits_student_id.errors %}
                                    <span class="alert-danger">Please enter BITS ID Number (present) </span>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                <label for="parallel_studies_flag" class="bold">{{ form.parallel_studies_flag.label }}<span class="required"> *</span></label>
                                {{ form.parallel_studies_flag|attr:'required:true'|attr:'oninvalid:setCustomValidity("Please select are you currently pursuing studies in any other university or college")'|attr:'onchange:setCustomValidity("")'|attr:'class:form-control'}}
                                {% if form.parallel_studies_flag.errors %}
                                    <span class="alert-danger">Please enter BITS ID Number (present) </span>
                                {% endif %}
                            </div>
                        </div>
                    </div>
                    <div class="row" id ="parallel_studies_uni">
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                <label for="other_uni_name">{{ form.other_uni_name.label }}<span class="required"> *</span></label>
                                {{ form.other_uni_name|attr:'required:true'|attr:'oninvalid:InvalidUniName(this);'|attr:'oninput:InvalidUniName(this);'|attr:'maxlength:50'|attr:'class:form-control'}}
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group" id="programming_flag">
                                    <label for="other_uni_prog">{{ form.other_uni_prog.label }}<span class="required"> *</span></label>
                                {{ form.other_uni_prog|attr:'required:true'|attr:'oninvalid:InvalidPgrm(this);'|attr:'oninput:InvalidPgrm(this);'|attr:'maxlength:45'|attr:'class:form-control'}}
                            </div>
                        </div>
                            
                    </div>




<br>
                <div class="row">
                    <div class="form-group">
                        <label for="currentEmpStatus" class="bold">Current Employment Status<span class="required">*</span></label>
                        {{ form.current_employment_status|attr:'required:true'|attr:'class:form-control'}}
                        <small class="form-text note">NOTE: It is mandatory to have full-time employment to enroll for this programme.</small>
                        {% if form.current_employment_status.errors %}
                            <span class="alert-danger">Please select Employment Status</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentOrg" class="bold">Current Organization<span class="required">*</span></label>
                        {% with org=user.email|get_ELOA_org %} 
                            {%if user.email|get_payfee_waiver_permission %}
                                {% render_field form.current_organization readonly="true" value=org %}
                            {% else %}
                                {{ form.current_organization|attr:'required:true'|attr:'class:form-control'|attr:'maxlength:250'}}
                            {% endif %}
                        {% endwith %}
                        {% if form.current_organization.errors %}
                            <span class="alert-danger">Please enter Current Organization</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentEmpNum" class="bold">Current Employee Number</label>
                        {% with org=user.email|get_ELOA_org_num %} 
                            {%if user.email|get_payfee_waiver_permission %}
                                {% render_field form.current_org_employee_number readonly="true" value=org %}
                            {% else %}
                                {{form.current_org_employee_number|attr:'maxlength:15'|attr:'class:form-control'}}
                            {% endif %}
                        {% endwith %}
                        {% if form.current_org_employee_number.errors %}
                            <span class="alert-danger">Please enter Employee Number</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentWorkLoc" class="bold">Current Work Location<span class="required">*</span></label>
                        {{ form.work_location|attr:'required:true'|attr:'class:form-control'}}
                        {% if form.work_location.errors %}
                            <span class="alert-danger">Please select Work Location</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentDesignation" class="bold">Current Work Designation<span class="required">*</span></label>
                        {{ form.current_designation|attr:'required:true'|attr:'class:form-control'|attr:'maxlength:30'}}
                        {% if form.current_designation.errors %}
                            <span class="alert-danger">Please select Current Designation</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentOrgIndustry" class="bold">Current Industry<span class="required">*</span></label>
                        {{ form.current_org_industry|attr:'required:true'|attr:'class:form-control'}}
                        {% if form.current_org_industry.errors %}
                            <span class="alert-danger">Please select Current Industry</span>
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="currentEmpDate" class="bold">Date of Joining Current Organization<span class="required">*</span></label>
                        {{ form.current_org_employment_date|attr:'required:true'|attr:'class:form-control'|attr:'type:date'|attr:'onchange:updateMinDate()'}}
                        <small class="form-text note">NOTE: Employment Start year is taken to be at least 10 years from your year of birth</small>
                        {% if form.current_org_employment_date.errors %}
                            <span class="alert-danger">Please select Date of Joining Current Organization</span>
                        {% endif %}
                    </div>
                    <br>    
                </div>
                <br>
                <div class="row">
                <br>
                <h4>Prior Employment </h4>
                <br>
                <br>
                    <div class="col-md-12 d-flex align-items-end table-responsive">
                        <table class="table table-bordered border-dark text-center table-striped table-sm">
                            <thead class="table-dark">
                                <tr>
                                    <th scope="col">Organization</th>
                                    <th scope="col">Designation Held</th>
                                    <th scope="col">Start Date</th>
                                    <th scope="col">End Date</th>
                                    <th scope="col">Edit</th>
                                    <th scope="col">Delete</th>
                                </tr>
                            </thead>
                            {% if not scwp %}
                            <tbody class="fs-5 table-secondary" id="exp_tbody">
                                <tr id="del_default_msg">
                                    <th colspan="9">You haven't provided your employment details yet</th>
                                </tr>
                            </tbody>
                            {% else %}
                            <tbody class="fs-5 table-secondary" id="exp_tbody">
                                {% for i in scwp %}
                                <tr id="exp{{i.id}}">
                                    <td>{{i.organization}}</td>
                                    <td>{{i.designations}}</td>
                                    <td>{{i.start_date}}</td>
                                    <td>{{i.end_date}}</td>
                                    <td><i class="fas fa-edit" data-id="{{i.id}}" onclick="scwpEdit(event)"></i></td>
                                    <td><i class="fa fa-trash" aria-hidden="true" data-id="{{i.id}}" onclick="scwpDel(event)"></i></td>
                                </tr>
                                {% endfor %}
                            </tbody>
                            {% endif %}
                        </table>
                    </div>
                </div>
                <div class="row fs-5 text-center form-text note">
                    <span> <strong>NOTE: Prior employment dates should be EARLIER than your current organization joining date. Start date should be < End Date
                    </strong></span>
                </div>
                <br>
                <div class="row">
                    <div class="col-md-12 d-flex align-items-end justify-content-center  ">
                        <input class="btn btn-rounded btn-primary btn-add-qual " id="myBtn" type="button" value="Add more Employment" data-bs-toggle="modal" data-bs-target="#myModal"/>
                    </div>
                </div>
                <br>
                <br>
                <br>







    <div class="modal" id="myModal1">
        <form action="">
        <div class="modal-dialog" role="document">
            {% if wizard.steps.current == '1' %}
            <div class="modal-content">
                <!-- Modal Header -->
                <div class="modal-header">
                    <h4 class="modal-title fw-bolder fs-3" id="exampleModalLabel">Add Qualification</h4>
                </div>
                <!-- Modal Body -->
                <div class="modal-body fw-bolder">
                    <div class="row">
                        <div class="col-md-5">
                            <label for="qualCat" class="fw-normal fs-4">Qualification Level <span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.qual_cat|attr:'required:true'|attr:'class:form-control'|attr:'onchange:QualCategory();' }}
                            {% if form.qual_cat.errors %}
                            <span class="alert-danger">Please select Qualification Level</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="degree" class="fw-normal fs-4">Qualification Name <span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.degree|attr:'required:true'|attr:'class:form-control'|attr:'onchange:OtherBox(this);'}}
                            {{ form.other_degree|attr:'class:form-control'|attr:'placeholder:Other Qualification' }}
                            {% if form.degree.errors %}
                            <span class="alert-danger">Please select Qualification Name</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="schoolCollege" class="fw-normal fs-4">Board/University<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.school_college|attr:'required:true'|attr:'class:form-control'}}
                            {% if form.school_college.errors %}
                            <span class="alert-danger">Please enter Board/University</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="discipline" class="fw-normal fs-4">Discipline<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.discipline|attr:'required:true'|attr:'class:form-control'|attr:'onchange:OtherBox(this);'}}
                            {{ form.other_discipline|attr:'class:form-control'|attr:'placeholder:Other Discipline'}} 
                            {% if form.discipline.errors %}
                            <span class="alert-danger">Please select Discipline</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="startYear" class="fw-normal fs-4">Start Year<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.start_year|attr:'required:true'|attr:'class:form-control'|attr:'type:number'|attr:'onchange:StartEndYear(this);'}}
                            {% if form.start_year.errors %}
                            <span class="alert-danger">Please enter Start Year</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="endYear" class="fw-normal fs-4">End Year<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.completion_year|attr:'required:true'|attr:'class:form-control'|attr:'type:number'|attr:'onchange:StartEndYear(this);'}}
                            {% if form.completion_year.errors %}
                            <span class="alert-danger">Please enter End Year</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="percentCpga" class="fw-normal fs-4" data-toggle="tooltip" data-placement="top"
                                title="Enter your percentage or CGPA">Select % Marks or CGPA :- <span
                                    class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            <input type="radio" id="percentMarks" name="marksOrCgpa" value="percent" checked>
                            <label for="percentMarks" class="fw-normal fs-4">Percentage</label>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" id="cgpa" name="marksOrCgpa" value="cgpa">
                            <label for="cgpa" class="fw-normal fs-4">CGPA</label>
                            <div class="row">
                                <div class="col-md-4">
                                    {{ form.percentage_marks_cgpa|attr:'required:true'|attr:'class:form-control'}}
                                </div>
                                <div class="col-md-4" id="cpgaContainer">
                                    {{ form.cpga_outoff | attr:'class:form-control' | attr:'placeholder:Out of' }}
                                </div>
                            </div>
                        </div>
                    </div>
                    <br>
                </div>
                <input type="hidden" value="" id="edit_rows">
                <!-- Modal Footer -->
                <div class="modal-footer">
                    <div class="row d-flex flex-row space-between">
                        <div class="col-md-6 ">
                            <button type="button" class="btn btn-rounded btn-primary btn-P fw-bold fs-4" data-dismiss="modal" onclick="closeModal()">Close</button>
                        </div>
                        <div class="col-md-6 ">
                            <button type="submit" class="btn btn-rounded btn-primary btn-P fw-bold fs-4" data-dismiss="modal" id="save_rec" name="Save" onclick="saveRec(event)">Save</button>
                        </div>
                    </div>
                </div>
            </div>
            {% endif %}
            {% if wizard.steps.current == '2' %}
            <div class="modal-content">
                <!-- Modal Header -->
                <div class="modal-header">
                    <h4 class="modal-title fw-bolder fs-3" id="exampleModalLabel1">Add Employment Details</h4>
                </div>
                <!-- Modal Body -->
                <div class="modal-body fw-bolder">
                    <div class="row">
                        <div class="col-md-5">
                            <label for="qualCat" class="fw-normal fs-4">Organization <span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.organization|attr:'required:true'|attr:'class:form-control' }}
                            {% if form.organization.errors %}
                            <span class="alert-danger">Please enter Organization</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="degree" class="fw-normal fs-4">Designations <span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.designations|attr:'required:true'|attr:'class:form-control'}}
                            {% if form.designations.errors %}
                            <span class="alert-danger">Please enter Designations</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="schoolCollege" class="fw-normal fs-4">Start Date<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.start_date|attr:'required:true'|attr:'class:form-control'|attr:'type:date'|attr:'onchange:updateMinDate()'}}
                            {% if form.start_date.errors %}
                            <span class="alert-danger">Please select Start Date</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-md-5">
                            <label for="discipline" class="fw-normal fs-4">End Date<span class="required">*</span></label>
                        </div>
                        <div class="col-md-6">
                            {{ form.end_date|attr:'required:true'|attr:'class:form-control'|attr:'type:date'|attr:'onchange:updateMinDate()'}}
                            {% if form.end_date.errors %}
                            <span class="alert-danger">Please select End Date</span>
                            {% endif %}
                        </div>
                    </div>
                    <br>
                </div>
                <input type="hidden" value="" id="edit_rows_exp">
                <!-- Modal Footer -->
                <div class="modal-footer">
                    <div class="row d-flex flex-row space-between">
                        <div class="col-md-6 ">
                            <button type="button" class="btn btn-rounded btn-primary btn-P fw-bold fs-4" data-dismiss="modal" onclick="closeModal()">Close</button>
                        </div>
                        <div class="col-md-6 ">
                            <button type="submit" class="btn btn-rounded btn-primary btn-P fw-bold fs-4" data-dismiss="modal" id="save_rec_exp" name="Save" onclick="saveExpRec(event)">Save</button>
                        </div>
                    </div>
                </div>
            </div>
            {% endif %}
        </div>
    </form>
    </div>





    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" integrity="sha384-3B6NwesSXE7YJlcLI9RpRqGf2p/EgVH8BgoKTaUrmKNDkHPStTQ3EyoYjCGXaOTS" crossorigin="anonymous">







        let modal = document.getElementById("myModal1");
        let btn = document.getElementById("myBtn");
        let span = document.getElementsByClassName("close")[0];
        $("#id_1-other_degree").hide();
        $("#id_1-other_discipline").hide();

        function expFieldsRefresh() {
            $("#id_2-organization").val('');
            $("#id_2-designations").val('');
            $("#id_2-start_date").val('');
            $("#id_2-end_date").val('');
        }

        function eduFieldsRefresh() {
            $("#id_1-qual_cat").val('');
            $("#id_1-degree").val('');
            $("#id_1-school_college").val('');
            $("#id_1-discipline").val('');
            $("#id_1-start_year").val('');
            $("#id_1-completion_year").val('');
            $("#percentMarks").prop('checked', true);
            $("#id_1-other_discipline").attr("type","hidden");
            $("#id_1-other_discipline").attr("required","false");
            $("#id_1-other_discipline").val('');
            $("#id_1-other_degree").attr("type","hidden");
            $("#id_1-other_degree").attr("required","false");
            $("#id_1-other_degree").val('');
            $('#id_1-cpga_outoff').prop('required',false);
            $('#cpgaContainer').hide();
            $('#id_1-percentage_marks_cgpa').val('');
            $('#id_1-cpga_outoff').val('');
            $('#id_1-percentage_marks_cgpa').attr('placeholder', '% marks');
            
        }

        btn.onclick = function () {
            modal.style.display = "block";
            $("#exampleModalLabel").text("Add Qualification");
            $("#exampleModalLabel1").text("Add Employment Details");
        }

        window.onclick = function (event) {
            if (event.target == modal) {
                expFieldsRefresh()
                eduFieldsRefresh()
                modal.style.display = "none";
            }
        }

        function openModal() {
            document.getElementById('myModal1').style.display = 'block';
            $("#exampleModalLabel").text("Add Qualification");
            $("#exampleModalLabel1").text("Add Employment Details");
        }

        function closeModal() {
            expFieldsRefresh()
            eduFieldsRefresh()
            document.getElementById('myModal1').style.display = 'none';
        }

        function QualCategory() {
            let select_id = $("#id_1-qual_cat").val();
            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:qual-category-ajax'%}",
                data: { 'select_id': select_id },
                cache: false,
                success: function (data) {
                    testvar_1 = data;
                },
                async: false,
                failure: function (data) { }
            });

            let alpha = Object.keys(testvar_1).sort(
                function (a, b) {
                    return testvar_1[a].toLowerCase() > testvar_1[b].toLowerCase() ? 1 : -1;
                });

            childSelect = $("#id_1-degree").empty();
            childSelect.append(new Option('Choose ', ''));
            for (let key in alpha) {
                let o = new Option(testvar_1[alpha[key]], alpha[key]);
                $(o).html(testvar_1[alpha[key]]);
                $(childSelect).append(o);
            }
        }

        function OtherBox(selectBox){
            let select_id = $("#"+selectBox.id ).val();
            let select_value = $("#"+selectBox.id +" option:selected" ).text();
            let select_input= selectBox.id === 'id_1-discipline' ? $("#id_1-other_discipline") : $("#id_1-other_degree");
            if (select_value == "Others"){
                select_input.attr("type", "text");
                select_input.show();
                select_input.attr("required","true");
            }
            else{
                select_input.attr("type","hidden");
                select_input.removeAttr("required");
                select_input.val('');
            }
        
        }

        function saveRec(event) {

            event.preventDefault();
            console.log("Saving")
            let quaLevel = $("#id_1-qual_cat").val();
            let quaName = $("#id_1-degree").val();
            let board = $("#id_1-school_college").val();
            let quaDisc = $("#id_1-discipline").val();
            let startYear = $("#id_1-start_year").val();
            let endYear = $("#id_1-completion_year").val();
            let percentage = $("#id_1-percentage_marks_cgpa").val();
            let outoff = $("#id_1-cpga_outoff").val();
            let percentMarks = $("#percentMarks").is(":checked")
            let cgpa = $('#cgpa').is(":checked")
            let other_degree = $("#id_1-other_degree").val();
            let other_discipline = $("#id_1-other_discipline").val();
            let errorMessage = 'Please fill in the following fields:\n';
            let csrfToken = "{{ csrf_token }}";

            if (!quaLevel || !quaName || !board || !quaDisc || !startYear || !endYear || !percentage) {

                if (!quaLevel) errorMessage += '- Qualification Level\n';
                if (!quaName) errorMessage += '- Qualification Name\n';
                if (!board) errorMessage += '- Board/University\n';
                if (!quaDisc) errorMessage += '- Discipline\n';
                if (!startYear) errorMessage += '- Start Year\n';
                if (!endYear) errorMessage += '- End Year\n';
                if (!percentage) errorMessage += '- Select % Marks or CGPA\n';

                alert(errorMessage)

            }else {

                let val = false;
                
                if ($("#id_1-degree option:selected" ).text() === "Others") {
                    if (!other_degree) {
                        errorMessage += '- Other Qualification Name\n';
                        val = true;
                    }
                }
                if ($("#id_1-discipline option:selected" ).text() === "Others") {
                    if (!other_discipline) {
                        errorMessage += '- Other Discipline\n';
                        val = true;
                    }
                }                
                if (cgpa) {
                    if (!outoff) {
                        errorMessage += '- Out of\n';
                        val = true;
                    }
                }
                if (val) {
                    alert(errorMessage)
                }else {

                    let param = {
                        "quaLevel": quaLevel,
                        "quaName": quaName,
                        "board": board,
                        "quaDisc": quaDisc,
                        "startYear": startYear,
                        "endYear": endYear,
                        "percentage": percentage,
                        "outoff": outoff,
                        "percentMarks": percentMarks,
                        "cgpa": cgpa,
                        "other_degree":other_degree,
                        "other_discipline":other_discipline,
                        "name":$(event.currentTarget).attr('name'),
                        "id": $("#edit_rows").val(),
                    };
                    
                    $.ajax({
                        url: "{% url 'registrationForm:add_or_edit_qualification' %}",
                        contentType: "application/json",
                        headers: {
                            'X-CSRFToken': csrfToken
                        },
                        type: 'POST',
                        data: JSON.stringify(param),
                        success: function (data) {
                            console.log('1111111111',data)
                            if($('#del_default_msg_edu')){
                                $('#del_default_msg_edu').remove();
                            }
                            if (data.id) {
                                tbody = $("#edu_tbody");
                                newRow = $("<tr id='edu"+data.id+"'>");
                                cell1 = $("<td>").text(data.quaLevel);
                                cell2 = data.quaName === 'Others' ? $("<td>").text(data.other_degree) : $("<td>").text(data.quaName); 
                                cell3 = $("<td>").text(data.board);
                                cell4 = data.quaDisc === 'Others' ? $("<td>").text(data.other_discipline) : $("<td>").text(data.quaDisc);
                                cell5 = $("<td>").text(data.startYear);
                                cell6 = $("<td>").text(data.endYear);
                                cell7 = data.outoff ? $("<td>").text(data.percentage +'.00/'+ data.outoff) : $("<td>").text(data.percentage + '.00');
                                cell8 = $("<td>").html('<i class="fas fa-edit" data-id="'+ data.id +'" onclick="scqEdit(event)"></i>');
                                cell9 = $("<td>").html('<i class="fa fa-trash" aria-hidden="true" data-id="'+ data.id +'" onclick="scqDel(event)"></i>');
                                newRow.append(cell1, cell2, cell3, cell4, cell5, cell6, cell7, cell8, cell9);
                                tbody.append(newRow);
                            } else {
                                let rowToUpdate = $('#edu' + $("#edit_rows").val());
                                rowToUpdate.find('td:eq(0)').text(data.quaLevel);
                                rowToUpdate.find('td:eq(1)').text(data.quaName === 'Others' ? data.other_degree : data.quaName);
                                rowToUpdate.find('td:eq(2)').text(data.board);
                                rowToUpdate.find('td:eq(3)').text(data.quaDisc === 'Others' ? data.other_discipline: data.quaDisc);
                                rowToUpdate.find('td:eq(4)').text(data.startYear);
                                rowToUpdate.find('td:eq(5)').text(data.endYear);
                                rowToUpdate.find('td:eq(6)').text(data.outoff ? data.percentage +'.00/'+ data.outoff : data.percentage);
                            }
                            eduFieldsRefresh()
                            document.getElementById('myModal1').style.display = 'none';
                        },
                        error: function (xhr, status, error) {
                            console.error("AJAX request failed. Status:", status, "Error:", error);
                        }
                    });
                }
            }
            
        }

        function saveExpRec(event) {
            
            event.preventDefault();

            let org = $("#id_2-organization").val();
            let desc = $("#id_2-designations").val();
            let startDate = $("#id_2-start_date").val();
            let endDate = $("#id_2-end_date").val();
            let csrfToken = "{{ csrf_token }}";
            let errorMessage = 'Please fill in the following fields:\n';

            if (!org || !desc || !startDate || !endDate) {
                if (!org) errorMessage += '- Organization\n';
                if (!desc) errorMessage += '- Designations\n';
                if (!startDate) errorMessage += '- Start Date\n';
                if (!endDate) errorMessage += '- End Date\n';

                alert(errorMessage);
            } else {
                let param = {
                    "organization": org,
                    "designations": desc,
                    "start_date": startDate,
                    "end_date": endDate,
                    "name": $(event.currentTarget).attr('name'),
                    "id": $("#edit_rows_exp").val(),
                };

                $.ajax({
                    url: "{% url 'registrationForm:add_or_edit_exp' %}",
                    contentType: "application/json",
                    headers: {
                        'X-CSRFToken': csrfToken
                    },
                    type: 'POST',
                    data: JSON.stringify(param),
                    success: function (data) {
                        if (data.id) {
                            if($('#del_default_msg')){
                                $('#del_default_msg').remove();
                            }
                            tbody = $("#exp_tbody");
                            newRow = $("<tr id='exp"+data.id+"'>");
                            cell1 = $("<td>").text(data.organization);
                            cell2 = $("<td>").text(data.designations);
                            cell3 = $("<td>").text(data.start_date);
                            cell4 = $("<td>").text(data.end_date);
                            cell5 = $("<td>").html('<i class="fas fa-edit" data-id="'+ data.id +'" onclick="scwpEdit(event)"></i>');
                            cell6 = $("<td>").html('<i class="fa fa-trash" aria-hidden="true" data-id="'+ data.id +'" onclick="scwpDel(event)"></i>');
                            newRow.append(cell1, cell2, cell3, cell4, cell5, cell6);
                            tbody.append(newRow);
                        } else {
                            let rowToUpdate = $('#exp' + $("#edit_rows_exp").val());
                            rowToUpdate.find('td:eq(0)').text(data.organization);
                            rowToUpdate.find('td:eq(1)').text(data.designations);
                            rowToUpdate.find('td:eq(2)').text(data.start_date);
                            rowToUpdate.find('td:eq(3)').text(data.end_date);
                        }
                        expFieldsRefresh()
                        document.getElementById('myModal1').style.display = 'none';

                    },
                    error: function (xhr, status, error) {
                        console.error('AJAX Error:', error);
                    }
                });
            }
        }

        function StartEndYear(element) {
            let val = element.id === "id_1-start_year" ? parseInt($("#id_1-completion_year").val()) : parseInt($("#id_1-start_year").val());
            let valid = false;
            let msg = "";
            let inputValue = $(element).val();
            let currentDate = new Date();
            let currentYear =currentDate.getFullYear();

            if (inputValue.length !== 4) {
                alert('Please enter a valid Year');
                $(element).val('');
                $(element).focus();
            } else if ( parseInt(inputValue) > currentYear) {
                alert('Please enter a proper Year');
                $(element).val('');
                $(element).focus();
            } else if (element.id === "id_1-start_year") {
                if (val) {
                    valid = parseInt(inputValue) > val;
                    msg = valid ? "Start Year must be less than End Year" : "";
                }
            } else {
                if (val) {
                    valid = parseInt(inputValue) < val;
                    msg = valid ? "End Year must be greater than Start Year" : "";
                }
            }
            if (valid) {
                alert(msg);
                $(element).val('');
                $(element).focus();
            }
        }


        function scqDel(event) {
            let confirmed = window.confirm('Are you sure you want to delete this item?');
            let csrfToken = "{{ csrf_token }}";
            let itemId = event.currentTarget.dataset.id;

            if (confirmed) {
                $.ajax({
                    url: "{% url 'registrationForm:del_qualification' %}",
                    contentType: "application/json",
                    headers: {
                        'X-CSRFToken': csrfToken
                    },
                    type: 'POST',
                    data: JSON.stringify({ 'id': itemId }),
                    success: function (data) {
                        $('#edu' + itemId).remove();
                    }
                });
            }
        }

        function scwpDel(event) {
            let confirmed = window.confirm('Are you sure you want to delete this item?');
            let csrfToken = "{{ csrf_token }}";
            let itemId = event.currentTarget.dataset.id;

            if (confirmed) {
                $.ajax({
                    url: "{% url 'registrationForm:del_exp' %}",
                    contentType: "application/json",
                    headers: {
                        'X-CSRFToken': csrfToken
                    },
                    type: 'POST',
                    data: JSON.stringify({ 'id': itemId }),
                    success: function (data) {
                        $('#exp' + itemId).remove();
                    }
                });
            }
        }

        function scwpEdit(element) {
            let modal = document.getElementById("myModal1");
            modal.style.display = "block";
            $("#exampleModalLabel1").text("Edit Employment Details");
            $("#edit_rows_exp").val(event.currentTarget.dataset.id);
            $("#save_rec_exp").attr('name', 'EditAndSave');

            let organization = $("#id_2-organization")
            let designations = $("#id_2-designations")
            let startDate = $("#id_2-start_date")
            let endDate = $("#id_2-end_date")
            let csrfToken = "{{ csrf_token }}";

            $.ajax({
                    url: "{% url 'registrationForm:get_exp' %}",
                    contentType: "application/json",
                    headers: {
                        'X-CSRFToken': csrfToken
                    },
                    type: 'GET',
                    data: { 'id': event.currentTarget.dataset.id, },
                    success: function (data) {
                        organization.val(data.organization);
                        designations.val(data.designations);
                        startDate.val(data.start_date);
                        endDate.val(data.end_date);
                    }
                });
        }

        function scqEdit(element) {
            let modal = document.getElementById("myModal1");
            modal.style.display = "block";
            $("#exampleModalLabel").text("Edit Qualification");
            $("#edit_rows").val(event.currentTarget.dataset.id);
            $("#save_rec").attr('name', 'EditAndSave');

            let quaLevel = $("#id_1-qual_cat");
            let quaName = $("#id_1-degree");
            let board = $("#id_1-school_college");
            let quaDisc = $("#id_1-discipline");
            let startYear = $("#id_1-start_year");
            let endYear = $("#id_1-completion_year");
            let percentage = $("#id_1-percentage_marks_cgpa");
            let outoff = $("#id_1-cpga_outoff")
            let cgpa = $('#cgpa')
            let other_degree = $("#id_1-other_degree");
            let other_discipline = $("#id_1-other_discipline");
            let csrfToken = "{{ csrf_token }}";

            $.ajax({
                    url: "{% url 'registrationForm:get_qualification' %}",
                    contentType: "application/json",
                    headers: {
                        'X-CSRFToken': csrfToken
                    },
                    type: 'GET',
                    data: { 'id': event.currentTarget.dataset.id },
                    success: function (data) {
                        startYear.val(data.startYear);
                        endYear.val(data.endYear);
                        board.val(data.board);
                        quaLevel.val(data.quaLevel);
                        QualCategory();
                        quaName.val(data.quaName);
                        quaDisc.val(data.quaDisc);
                        percentage.val(data.percentage);
                        if (data.outoff) {
                            $("#cpgaContainer").attr("type", "text");
                            $("#cpgaContainer").show();
                            $('#id_1-cpga_outoff').prop('required',true);
                            $('#id_1-percentage_marks_cgpa').attr('placeholder', 'CGPA');
                            cgpa.prop('checked', true);
                            outoff.val(data.outoff);
                        }
                        if (data.other_degree) {
                            other_degree.attr("type", "text");
                            other_degree.show();
                            other_degree.attr("required","true");
                            other_degree.val(data.other_degree);
                        }
                        if (data.other_discipline) {
                            other_discipline.attr("type", "text");
                            other_discipline.show();
                            other_discipline.attr("required","true");
                            other_discipline.val(data.other_discipline);
                        }
                    }
                });
        }








Leave a Comment