0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.149.254.229


Current Path : /var/www/oasis/js/
Upload File :
Current File : /var/www/oasis/js/UpdateCollDet.js

function CallUpdateCollDet() {
    $('#page_main_div').load('../html_modules/UpdateCollDet.html', function () {
        document.getElementById('display_module_name').innerHTML =
            'College Details Update'
        document.getElementById('module_name_for_save').value =
            'College Details Update'
        getDefaultHeadFooterLinks('College Details Update')
        getcollDet()
    })
}

function getcollDet() {
    $.ajax({
        type: 'GET',
        url: $host_url + 'getCollDet',
        success: (response) => {
            var { error_code, data, status } = JSON.parse(response)
            // console.log(error_code, data);
            var html = ``
            if (error_code == -1)
                alert('No data found, please try after sometime.')

            if (error_code == 0) {
                Object.keys(data).forEach(() => {
                    html = `
          <table class="content-tbl" cellpadding="5" cellspacing="2" width="99%" id="mainTable>

          <tr class="tblRow">
            <td  valign="middle" align="right" width="140px">College Code : </td>
            <td  valign="middle">
              <input name="fcollcode" id="fcollcode" placeholder=" College Code " 
                value="${data['fcollcode']}"  type="text" class="textInputEnabled" style="text-align:center;height:20px; width:100px;" size="10" disabled />
            </td>
          </tr>
          <tr class="tblRow">
            <td  valign="middle" align="right">College Name : </td>
            <td  valign="middle">
              <input name="fcollname" id="fcollname" placeholder="College Name " value="${data['fcollname']}"  type="text" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" size="80" disabled /></br>
            </td>
          </tr>

          <tr class="tblRow">
          <td  valign="middle" align="right">Place:</td>
          <td  valign="middle">
            <input name="ftown" id="fplace" placeholder=" Town" value="${data['ftown']}"  type="text" class="textInputEnabled" style="text-align:left;height:20px; width:100%;"  size="80" disabled />
          </td>
          </tr>

          <tr class="tblRow">
            <td valign="top" align="right">Address : </td>
            <td valign="middle">
              <input name="fcolladdr1" size=50  id="colladdr1" maxlength=50 type="text"  value="${data['fcolladd1']}" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" /><br>
              <input name="fcolladdr2" size=50  id="colladdr2" maxlength=50 type="text"  value="${data['fcolladd2']}" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" /><br>
              <input name="fcolladdr3" size=50  id="colladdr3" maxlength=50 type="text"  value="${data['fcolladd3']}" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" /><br>
              <input name="fcolladdr4" size=50  id="colladdr4" maxlength=50 type="text"  value="${data['fcolladd4']}" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
            </td>
          </tr>
          <tr class="tblRow">
              <td valign="middle" align="right">Current Location : </td>
              <td>
              <input type="text" size="50" value="" id="fcoordinates"  name="fcoordinates" class="textInputEnabled" style="text-align:left;height:20px; width:80%;"/>  
              <button onClick="getLocation();return false;" type="button" name="flocation" style="background-color: #008CBA; border: none; color: white; padding: 7px 15px; text-align: center;
                 text-decoration: none; display: inline-block; font-size: 11px; cursor: pointer;border-radius: 3px">Get Location</button>
                <input type="hidden" value="" id="lat" name="flat"/>
                <input type="hidden" value="" id="long"  name="flong"/>
              </td>
          </tr>
          <tr class="tblRow">
          <td  valign="middle"></td>
          <td  valign="middle" align="right" style="color:red;">
            Make sure you are located at the right place of the institution and click "Get Location" to get the current location coordinates.
          </td>
          </tr>

          <tr class="tblRow">
          <td  valign="middle" align="right">Principal Name : </td>
          <td  valign="middle"><input name="fprincipalname" id="fprincipalname" placeholder=" Principal Name " value="${data['fprincipalname']}"  type="text" size="50" class="textInputEnabled" style="text-align:left;height:20px; width:100%;"/>
          </td>
          </tr>
          <tr class="tblRow">
            <td  valign="middle" align="right">Email ID (for communication): </td>
            <td  valign="middle"><input name="femailid" id="femailid" placeholder=" Email " value="${data['femail']}"  type="text" size="50" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
            </td>
          </tr>
          <tr class="tblRow">
            <td  valign="middle" align="right">Mobile No. (for communication): </td>
            <td  valign="middle"><input name="fmobile" maxlength="10" id="fmobile" placeholder=" Mobile Number " value="${data['fmobile']}"  type="text" size="30" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
            </td>
          </tr>
          <tr class="tblRow">
            <td  valign="middle" align="right">Alternate Mobile No. : </td>
            <td  valign="middle"><input name="faltmobile" maxlength="10" id="faltmobile" placeholder=" Alternate Mobile " value="${data['faltmobile']}"  type="text" size="30" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
            </td>
          </tr>
          <tr class="tblRow">
          <td  valign="middle" align="right">Land Line Number : </td>
          <td  valign="middle"><input name="fphone" id="fphone" placeholder=" Land Line Number " value="${data['fphone']}"  type="text" size="30" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
          </td>
          </tr>
          <tr class="tblRow">
          <td  valign="middle" align="right">Fax Number : </td>
          <td  valign="middle"><input name="ffax" id="ffax" placeholder=" Fax Number " value="${data['ffax']}"  type="text" size="30" class="textInputEnabled" style="text-align:left;height:20px; width:100%;" />
          </td>
          </tr>
          </table>
          <br>

          `
                })
                $('#CollForm').html(html)
            }
        },
    })
}

function getLocation() {
    console.log('getLocation()')
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function (position) {
            getAddress(position)
        })
    } else {
        console.log('navigator.geolocation not working')
    }
}

function getAddress(position) {
    console.log(
        'The location in lat lon format is: [',
        position.coords.latitude,
        ',',
        position.coords.longitude,
        ']'
    )
    var lat = position.coords.latitude
    var long = position.coords.longitude
    var fcoordinates = position.coords
    console.log('fcoordinates', fcoordinates.latitude, fcoordinates.longitude)
    document
        .getElementById('fcoordinates')
        .setAttribute(
            'value',
            fcoordinates.latitude + ',' + fcoordinates.longitude
        )
    document.getElementById('lat').setAttribute('value', lat)
    document.getElementById('long').setAttribute('value', long)
}

function getUpdatedDet() {
    var values = {}
    var finalData = []
    $('tr.tblRow td input').each(function () {
        values[$(this).attr('name')] = encodeURIComponent($(this).val())
    })

    finalData.push(values)
    console.log(finalData)
    //  <span class="remodal-cancel" onclick='getUpdatedDet()'>Update</span>

    $.ajax({
        type: 'POST',
        url: $host_url + 'updateCollProfile',
        data: '&data=' + JSON.stringify(finalData),
        success: (response) => {
            var { error_code, data, status } = JSON.parse(response)
            if (error_code == 0) {
                setTimeout(function () {
                    alert(data['msg'])
                    window.location.reload()
                }, 1000)
            } else alert(data['msg'])
        },
    })
}