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 : 18.118.105.93


Current Path : /var/www/html/pms/js/
Upload File :
Current File : /var/www/html/pms/js/users.js

function loadusers() {
  $('#loadtab').load('html/userslist.html?v=' + version, () => {
    $.ajax({
      type: 'POST',
      async: false,
      url: $host_url + 'loaduserslist',
      success: function logoutResponce(responce) {
        responce = eval('(' + responce + ')');
        console.log(responce);
        let table = ``;
        if (responce.error_code == 0) {
          let invdata = responce.data;
          let sty = '';
          for (let i = 0; i < invdata.length; i++) {
            // console.log(invdata[i].FCHKSTATUS);
            if (invdata[i].FDELETED != 'T') {
              table += `<tr>
                          <td>
                            <center>${i + 1}</center>
                          </td>
                          <td>
                            ${invdata[i].FUSERID}
                          </td>
                          <td>
                            ${invdata[i].FUSERNAME}
                          </td>
                          <td>
                          <center>${invdata[i].FMOBILE}</center>
                          </td>
                          <td>
                          <center>${invdata[i].FEMAIL}</center>
                          </td>
                          <td>
                          <center>${invdata[i].FCREADATE}</center>
                          </td>  
                          <td>
                          <center><button class = 'btn-success' onclick = "edituser('${
                            invdata[i].FUSERID
                          }')" >View</button></center>
                          </td>                         
                       </tr>`;
            }
          }
        } else {
          table = `<tr>
            <td colspan="4">
              <center><b>No Invoice Details found</b></center>
            </td>
            </tr>`;
        }
        $('#appuserbody').html(table);
      },
    });
  });
}

function saveuser() {
  let FUSERNAME = $('#FUSERNAME').val();
  let FUSERID = $('#FUSERID').val();
  let FEMAIL = $('#FEMAIL').val();
  let FMOBILE = $('#FMOBILE').val();
  let FPASSWORD = $('#FPASSWORD').val();
  let FCPASSWORD = $('#FCPASSWORD').val();

  console.log(FPASSWORD, FCPASSWORD);
  if (FPASSWORD != FCPASSWORD) {
    alert('Password did not match..!');
    $('#FCPASSWORD').val('');
    $('#FPASSWORD').focus();
    return;
  }

  $.ajax({
    type: 'POST',
    async: false,
    data:
      'FUSERNAME=' +
      FUSERNAME +
      '&FUSERID=' +
      FUSERID +
      '&FEMAIL=' +
      FEMAIL +
      '&FMOBILE=' +
      FMOBILE +
      '&FPASSWORD=' +
      FPASSWORD,
    url: $host_url + 'saveusers',
    success: function saveinvoiceResponce(responce) {
      responce = eval('(' + responce + ')');
      if (responce.error_code == 0) {
        alert(responce.data);
        loadusers();
      } else {
        alert(responce.data);
        return;
      }
    },
  });
}

function addUser() {
  $('#loadtab').load('html/users.html?v=' + version, () => {});
}

function edituser(id) {
  $.ajax({
    type: 'POST',
    async: false,
    data: 'FUSERID=' + id,
    url: $host_url + 'edituser',
    success: function editInvoiceResponce(responce) {
      responce = eval('(' + responce + ')');
      if (responce.error_code == 0) {
        $('#loadtab').load('html/users.html?v=' + version, () => {
          invdet = responce.data;
          $('#FUSERNAME').val(invdet.FUSERNAME);
          $('#FUSERID').val(invdet.FUSERID);
          $('#FEMAIL').val(invdet.FEMAIL);
          $('#FMOBILE').val(invdet.FMOBILE);

          document.getElementById('FPASSWORD').disabled = true;
          document.getElementById('FUSERID').disabled = true;
          document.getElementById('FCPASSWORD').disabled = true;
        });
      } else {
        alert(responce.data);
        return;
      }
    },
  });
}