| Current Path : /var/www/html/llcfapp/public/http/ |
| Current File : /var/www/html/llcfapp/public/http/autoloader.js |
function getConfig(param){
var config = {
baseUrl : "api/index.php?auth=3fb542058bffb60d31cf14db5dcd144c&",
// baseUrl : location.href.split("public")[0]+"api/index.php?auth=3fb542058bffb60d31cf14db5dcd144c&",
toastHideAfter : 10000,
paymentBookTypes : ["3", "4"],
challanBookTypes : ["1"],
};
return config[param];
}
function getFormProps(param){
var form_props = {
login: {
form_id: "#login_form"
},
stu: {
resource: "Student",
createOne: "createOne",
updateOne: "updateOne",
createService: "createService",
updateService: "updateService",
getServiceById: "getServiceById",
getAllServices: "getAllServices",
getOneByGrNumber: "getOneByGrNumber",
getStudentsByClass: "getStudentsByClass",
getAllClasses: "getAllClasses",
getAll: "getAll",
form_id: "#create_student_form",
submit_btn: "#stu_submit",
grid: "#student_grid",
sgrid: "#student_service_grid",
service: "#student_service",
input_service_id: "#service_id",
input_service: "#service",
input_family_id: "#family_id",
input_id: "#id",
input_student_id: "#student_id",
input_father_cnic: "#father_cnic",
input_zakat: "#zakat",
input_stu_full_name: "#stu_full_name",
input_stu_form_b: "#stu_form_b",
input_stu_dob: "#stu_dob",
input_stu_gender: "#stu_gender",
input_gr_num: "#gr_num",
input_auto_gr_num: "#auto_gr_num",
input_class: "#class",
input_father_name: "#father_name",
input_mother_name: "#mother_name",
input_children_count: "#children_count",
input_donor_id: "#donor_id",
input_donation_expiry: "#donation_expiry",
input_donation_date: "#donation_date",
// zakat_yes: "#zakat_yes",
// zakat_no: "#zakat_no",
},
don: {
resource: "Donor",
createOne: "createOne",
updateOne: "updateOne",
getOneById: "getOneById",
getAll: "getAll",
getAllDonors: "getAllDonors",
form_id: "#create_donor_form",
submit_btn: "#don_submit",
grid: "#donor_grid",
input_id: "#id",
input_donor_name: "#donor_name",
input_donor_ref_name: "#donor_ref_name",
input_donor_whatsapp: "#donor_whatsapp",
input_donor_whatsapp_sec: "#donor_whatsapp_sec",
},
fam: {
resource: "Family",
createOne: "createOne",
updateOne: "updateOne",
createService: "createService",
updateService: "updateService",
getServiceById: "getServiceById",
getOneById: "getOneById",
getOneByCnic: "getOneByCnic",
getAll: "getAll",
getAllServices: "getAllServices",
service: "#family_service",
input_service_id: "#service_id",
form_id: "#create_family_form",
submit_btn: "#fam_submit",
grid: "#family_grid",
sgrid: "#family_service_grid",
input_id: "#id",
input_service: "#service",
input_family_id: "#family_id",
input_zakat: "#zakat",
input_father_cnic: "#father_cnic",
input_father_name: "#father_name",
input_father_phone: "#father_phone",
input_father_occup: "#father_occup",
input_religion: "#religion",
input_address: "#address",
input_children_count: "#children_count",
input_mother_name: "#mother_name",
input_mother_cnic: "#mother_cnic",
input_mother_occup: "#mother_occup",
input_emerg_name: "#emerg_name",
input_emerg_relation: "#emerg_relation",
input_emerg_num: "#emerg_num",
zakat_yes: "#zakat_yes",
zakat_no: "#zakat_no",
},
health: {
resource: "Health",
createOne: "createOne",
updateOne: "updateOne",
getOneById: "getOneById",
getAll: "getAll",
form_id: "#create_health_card_form",
submit_btn: "#health_submit",
grid: "#health_grid",
print: "#health_print",
input_student_id: "#student_id",
input_family_id: "#family_id",
input_gr_num: "#gr_num",
input_auto_gr_num: "#auto_gr_num",
input_stu_full_name: "#stu_full_name",
input_father_name: "#father_name",
input_stu_dob: "#stu_dob",
input_stu_age: "#stu_age",
input_stu_gender: "#stu_gender",
input_id: "#id",
input_checkup_date: "#checkup_date",
input_pulse: "#pulse",
input_body_temp: "#body_temp",
input_respiration: "#respiration",
input_bp: "#bp",
input_height_cm: "#height_cm",
input_weight: "#weight",
input_bmi: "#bmi",
input_bmi_percentile: "#bmi_percentile",
input_eye_left: "#eye_left",
input_eye_right: "#eye_right",
input_pallor: "#pallor",
input_lice: "#lice",
input_consciousness: "#consciousness",
input_diet: "#diet",
input_teeth: "#teeth",
input_history: "#history",
input_diagnosis: "#diagnosis",
input_management: "#management",
input_advice: "#advice",
input_refer: "#refer",
input_followup: "#followup",
input_session: "#session",
},
att: {
resource: "Attendance",
createOne: "createOne",
updateOne: "updateOne",
getOneByClassAndDate: "getOneByClassAndDate",
getAll: "getAll",
form_id: "#attendance_form",
container_id: "#attend-container",
spinner: "#spinner",
submit_btn: "#att_submit",
input_id: "#id",
input_class: "#class",
input_date: "#date",
input_h_date: "#h_date",
input_h_class: "#h_class",
grid: "#attendance_grid",
},
spear: {
resource: "Spear",
createOne: "createOne",
updateOne: "updateOne",
getOneById: "getOneById",
getOneBySemisCode: "getOneBySemisCode",
getAll: "getAll",
form_id: "#spear_form",
submit_btn: "#spear_submit",
grid: "#spear_grid",
input_id: "#id",
input_semis_code: "#semis_code",
input_school_name: "#school_name",
input_address: "#address",
input_hm_name: "#hm_name",
input_hm_contact_num: "#hm_contact_num",
input_hm_whatsapp_num: "#hm_whatsapp_num",
input_emerg_num: "#emerg_num",
input_teacher_count: "#teacher_count",
input_non_teacher_count: "#non_teacher_count",
input_medium: "#medium",
input_stu_count: "#stu_count",
input_class1: "#class1",
input_class2: "#class2",
input_class3: "#class3",
input_class4: "#class4",
input_class5: "#class5",
},
spstudent: {
resource: "SpStudent",
createOne: "createOne",
updateOne: "updateOne",
getOneById: "getOneById",
getAll: "getAll",
form_id: "#spear_student",
submit_btn: "#spear_student_submit",
grid: "#spstudent_grid",
input_id: "#id",
input_spear_id: "#spear_id",
input_semis_code: "#semis_code",
input_school_name: "#school_name",
input_hm_name: "#hm_name",
input_teacher_count: "#teacher_count",
input_medium: "#medium",
input_student_name: "#student_name",
input_gr_num: "#gr_num",
input_father_name: "#father_name",
input_father_cnic: "#father_cnic",
input_father_mobile: "#father_mobile",
input_b_form_num: "#b_form_num",
input_class: "#class",
input_dob: "#dob",
input_mother_name: "#mother_name",
input_religion: "#religion",
}
};
return form_props[param];
}
function setFormInputValues(data, entity, excludeFields = []){
Object.keys(entity).filter(x => x.indexOf('input_') > -1).forEach((x)=>{
if(entity[x] && excludeFields.indexOf(entity[x]) == -1){
if(data[x.replace('input_','')] && data[x.replace('input_','')] != ""){
$(entity[x]).val(data[x.replace('input_','')]);
$(entity[x]).addClass('alert-success');
}
}
});
}
// alert(window.location.href.split('?')[0]);
function resetForm(id,forceReload = false){
$(':input', id)
.not(':button, :submit, :reset, :hidden')
.val('')
.prop('checked', false)
.prop('selected', false)
.prop('disabled', true)
.removeClass('alert-success');
if(window.location.href.split('?')[1] || forceReload){
setTimeout(function(){window.location.href=window.location.href.split('?')[0]}, 3000)
}
}
function fillDropDownMenu(elem, data, dd_label_value, dd_default_option){
var options = `<option value='${dd_default_option[0]}'>${dd_default_option[1]}</option>`;
data.forEach((d)=>{
options += `<option value='${d[dd_label_value[0]]}'>${d[dd_label_value[1]]}</option>`;
});
elem.html(options);
}
// American Numbering System
var th = ['','thousand','million', 'billion','trillion'];
// uncomment this line for English Number System
// var th = ['','thousand','million', 'milliard','billion'];
var dg = ['zero','one','two','three','four', 'five','six','seven','eight','nine']; var tn = ['ten','eleven','twelve','thirteen', 'fourteen','fifteen','sixteen', 'seventeen','eighteen','nineteen']; var tw = ['twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety']; function toWords(s){s = s.toString(); s = s.replace(/[\, ]/g,''); if (s != parseFloat(s)) return 'not a number'; var x = s.indexOf('.'); if (x == -1) x = s.length; if (x > 15) return 'too big'; var n = s.split(''); var str = ''; var sk = 0; for (var i=0; i < x; i++) {if ((x-i)%3==2) {if (n[i] == '1') {str += tn[Number(n[i+1])] + ' '; i++; sk=1;} else if (n[i]!=0) {str += tw[n[i]-2] + ' ';sk=1;}} else if (n[i]!=0) {str += dg[n[i]] +' '; if ((x-i)%3==0) str += 'hundred ';sk=1;} if ((x-i)%3==1) {if (sk) str += th[(x-i-1)/3] + ' ';sk=0;}} if (x != s.length) {var y = s.length; str += 'point '; for (var i=x+1; i<y; i++) str += dg[n[i]] +' ';} return str.replace(/\s+/g,' ');}
$().ready(() => {
$('body .dropdown-toggle').dropdown();
if(window.location.href.indexOf('grid') == -1){
var include_validation = 'http/validation/'+location.href.split('?')[0].split('/')[location.href.split('/').length - 1].replace('.php','');
includeJsFile(include_validation.split('_')[0]+'.js');
}
var include_http = 'http/'+location.href.split('?')[0].split('/')[location.href.split('/').length - 1].replace('.php','');
includeJsFile(include_http.split('_')[0]+'.js');
//#region Reset form
$('#reset').click(()=>{window.location.href = window.location.href.split('?')[0]});
//#endregion
//#region Disable the submit button on all pages on document ready for 3 secs
$('input[type="submit"]').attr("disabled", true);
setTimeout( function () {
$('input[type="submit"]').attr("disabled", false);
}, 3000);
//#endregion
});
function includeJsFile(fileName) {
var _script = document.createElement('script');
_script.src = fileName;
document.body.appendChild(_script);
}
function getAutoGrNum(field){
dd = new Date();
var auto_gr = `B-${getYear(dd)}${getMonth(dd)}${getDay(dd)}${getHours(dd)}${getMinutes(dd)}${getSeconds(dd)}`;
console.log(auto_gr);
$(field).val(auto_gr);
}
function getMonth(d) {
//get the month
var month = d.getMonth();
//increment month by 1 since it is 0 indexed
//converts month to a string
//if month is 1-9 pad right with a 0 for two digits
month = (month + 1).toString().padStart(2, '0');
return month;
}
// function getDay with 1 parameter expecting date
// This function returns a string of type dd (example: 09 = The 9th day of the month)
function getDay(d) {
//get the day
//convert day to string
//if day is between 1-9 pad right with a 0 for two digits
var day = d.getDate().toString().padStart(2, '0');
return day;
}
// function getYear with 1 parameter expecting date
// This function returns the year in format yy (example: 21 = 2021)
function getYear(d) {
//get the year
var year = d.getFullYear();
//pull the last two digits of the year
year = year.toString().substr(-2);
return year;
}
function getHours(d) {
var hour = d.getHours();
if(hour > 12)
hour = (hour-12).toString().padStart(2, '0');
return hour;
}
function getMinutes(d) {
var mins = d.getMinutes();
mins = mins.toString().padStart(2, '0');
return mins;
}
function getSeconds(d) {
var sec = d.getSeconds();
sec = sec.toString().padStart(2, '0');
return sec;
}
//A function for formatting a date to MMddyy
function formatDate(d)
{
//return the string "MMddyy"
return getMonth(d) + getDay(d) + getYear(d);
}
function setDatePicker(element){
var now = new Date();
var month = (now.getMonth() + 1);
var day = now.getDate();
if (month < 10)
month = "0" + month;
if (day < 10)
day = "0" + day;
var today = now.getFullYear() + '-' + month + '-' + day;
if(element){
element.val(today);
}else{
return today;
}
}
var occupations = ["Waiter","Paramedic","Dentist","Trainconductor","Nurse","Electrician","Doctor","Businessman","Americanfootballplayer","Student","Surgeon","Doorman","Secretary","Soldier","Repairman","Scientist","Reporter","Constructionworker","Professor","Policeofficer","Postman","Photographer","Pilot","Catholicnun","Painter","Mechanic","Magician","Lifeguard","Lunchroomsupervisor","Clown","Housekeeper","Gardener","Geisha","Footballer","Forestranger","Builder","Foreman","Farmer","Flightattendant","Fireman","Engineer","Carpenter","Architect","Boxer","Cameraman","Detective","Journalist","Housewife","Diver","Pope","Priest","Salesman","Librarian","Pirate","Singer","Factory Worker ","Labour ","Ironer ","Painter ","Plumber ","Salesman ","Driver ","Shopkeeper ","Peon ","storekeeper ","Self Employee ","Tailor ","Security Guard ","Mobile Repairing ","Housewife ","Cloth Cropper ","Maid"];
//#region Remove Spinner and Checkmark
function updateProcessing(element) {
$('.spinner_progress').remove();
$('.checkmark').remove();
}
//#endregion
//#region Check internet connectivity
var disconnected = false;
function chkInternetStatus() {
if(navigator.onLine) {
// alert("Hurray! You're online!!!");
if(disconnected){
myToast({heading: 'Internet Check', text: "You are online", showHideTransition: 'slide', icon: 'success', hideAfter: 5000});
disconnected = false;
}
} else {
// alert("Oops! You're offline. Please check your network connection...");
disconnected = true;
myToast({heading: 'Internet Check', text: 'Internet disconnected', showHideTransition: 'fade', icon: 'error', hideAfter: 5000});
}
}
setInterval(function () {
chkInternetStatus();
},7000);
//#endregion
if(window.location.href.indexOf('_print') > -1){
window.onload = function () {
setTimeout( function () {
window.print(); // blocking - so close will not
// window.close(); // execute until this is done
}, 3000);
}
}