// JavaScript Document $(function () { /* RESERVE VEHICLE */ $('#freserve form').iframePostForm ({ json : true, post : function () { var vreserve_msg; if (!$('.vreserve_msg').length) { $('#fres_title').after('
'); } if ($('#reserve_purpose').val().length && $('#reserve_destination').val().length && $('#reserve_contact').val().length) { $("#btnreserve").addClass('invisible'); $('.vreserve_msg') .html(' Processing vehicle request…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $("#btnreserve").removeClass('invisible'); $('.vreserve_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $("#btnreserve").removeClass('invisible'); $('.vreserve_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Vehicle has been successfully reserved.
'; html += 'This request will process on the next working day
'; pagenum = $("#cpage").val(); //searchtxt = $("#searchfolder").val(); $('.vreserve_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/dashboard_request.php?sec=table&page=" + pagenum, success: function(data) { $("#dashboard_table").html(data); } }); } } }); /* CLOSE VEHICLE */ $('#fview form').iframePostForm ({ json : true, post : function () { var creserve_msg; if (!$('.creserve_msg').length) { $('#fview_title').after(''); } if ($('#reserve_feedback').val().length) { $('.creserve_msg') .html(' Closing vehicle request…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.creserve_msg') .html('Your feedback are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.creserve_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Request has been successfully closed.
'; pagenum = $("#cpage").val(); //searchtxt = $("#searchfolder").val(); $('.creserve_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/dashboard_request.php?sec=table&page=" + pagenum, success: function(data) { $("#dashboard_table").html(data); $("#btnclose").addClass('invisible'); } }); } } }); /* EDIT RESERVATION */ $('#fedit form').iframePostForm ({ json : true, post : function () { var redit_msg; if (!$('.redit_msg').length) { $('#fedit_title').after(''); } processhtml = ' Updating reservation…'; $('.redit_msg') .html(processhtml) .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.redit_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { resulthtml = 'Reservation has been successfully updated.
'; pagenum = $("#cpage").val(); $('.redit_msg').slideUp(function () { $(this) .html(resulthtml) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/dashboard_request.php?sec=table&page=" + pagenum, success: function(data) { $("#dashboard_table").html(data); $("#btnreserve").addClass('invisible'); } }); } } }); /* APPROVE/RESCHEDULE RESERVATION */ $('#fapp form').iframePostForm ({ json : true, post : function () { var rapp_msg; if (!$('.rapp_msg').length) { $('#fapp_title').after(''); } var thisisresched = $('#thisisresched').val(); if (thisisresched == 1) { processhtml = ' Processing request reschedule…'; } else if (thisisresched == 2) { processhtml = ' Processing request reschedule thru carpool…'; } else { processhtml = ' Processing request…'; } $('.rapp_msg') .html(processhtml) .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.rapp_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { var thisisresched = $('#thisisresched').val(); if (thisisresched == 1) { resulthtml = 'Vehicle request has been successfully rescheduled.
'; } else if (thisisresched == 2) { resulthtml = 'Vehicle request has been successfully rescheduled thru carpool.
'; } else { if (response.rmessage) { resulthtml = '' + response.rmessage + '
'; } else { resulthtml = 'Vehicle request has been successfully approved.
'; } } pagenum = $("#cpage").val(); $('.rapp_msg').slideUp(function () { $(this) .html(resulthtml) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/dashboard_request.php?sec=table&page=" + pagenum, success: function(data) { $("#dashboard_table").html(data); $("#btnreserve").addClass('invisible'); $("#btnwait").addClass('invisible'); } }); } } }); /* ADD/EDIT FLEET */ $('#edit_vehicle').iframePostForm ({ json : true, post : function () { var vfleet_msg; if (!$('.vfleet_msg').length) { $('#edit_title').after(''); } if ($('#fleet_platenum1').val().length && $('#fleet_platenum2').val().length && $('#fleet_model').val().length && $('#fleet_type').val() != 0 && $('#fleet_brand').val() != 0) { $('.vfleet_msg') .html(' Processing vehicle…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.vfleet_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.vfleet_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Vehicle has been successfully saved.
'; pagenum = $("#fpage").val(); $('.vfleet_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/fleet_request.php?sec=table&page=" + pagenum, success: function(data) { $("#fleet_table").html(data); $(".btnsave").addClass('invisible'); } }); } } }); /* ADD/EDIT DRIVER */ $('#edit_driver').iframePostForm ({ json : true, post : function () { var vdriver_msg; if (!$('.vdriver_msg').length) { $('#edit_title').after(''); } if ($('#driver_name').val().length && $('#driver_bday').val().length && $('#driver_type').val() != 0) { $('.vdriver_msg') .html(' Processing driver…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.vdriver_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.vdriver_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Driver has been successfully saved.
'; pagenum = $("#dpage").val(); $('.vdriver_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/driver_request.php?sec=table&page=" + pagenum, success: function(data) { $("#driver_table").html(data); $(".btnsave").addClass('invisible'); } }); } } }); /* ADD/EDIT USER */ $('#edit_user').iframePostForm ({ json : true, post : function () { var vuser_msg; if (!$('.vuser_msg').length) { $('#edit_title').after(''); } if ($('#user_empnum').val().length && $('#user_fullname').val().length && $('#user_level').val() != 0 && $('#user_email').val().length && $('#user_telno').val().length) { if ($('#user_level').val() == 1 && $('#user_approver').val() == 0) { $('.vuser_msg') .html('Approver is required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } else { $('.vuser_msg') .html(' Processing user…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } } else { $('.vuser_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.vuser_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'User has been successfully saved.
'; pagenum = $("#upage").val(); $('.vuser_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/user_request.php?sec=table&page=" + pagenum, success: function(data) { $("#user_table").html(data); $(".btnsave").addClass('invisible'); } }); } } }); /* ADD/EDIT DEPT */ $('#edit_dept').iframePostForm ({ json : true, post : function () { var vdept_msg; if (!$('.vdept_msg').length) { $('#edit_title').after(''); } if ($('#dept_name').val().length && $('#dept_abbr').val().length) { $('.vdept_msg') .html(' Processing department…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.vdept_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.vdept_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', borderColor : '#9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Department has been successfully saved.
'; pagenum = $("#dpage").val(); $('.vdept_msg').slideUp(function () { $(this) .html(html) .css({ color : '#006100', background : '#c6efce', borderColor : '#006100', height : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/dept_request.php?sec=table&page=" + pagenum, success: function(data) { $("#dept_table").html(data); $(".btnsave").addClass('invisible'); } }); } } }); /* REGISTRATION */ $('#regis form').iframePostForm ({ json : true, post : function () { var regis_msg; if (!$('.regis_msg').length) { $('#lasttable').after(''); } if ($('#binFile').val().length) { var x = new Array('empnum', 'position', 'lastname', 'firstname', 'middlename', 'nickname', 'address_num', 'address_street', 'address_brgy', 'address_city', 'address_region', 'address_zip', 'address_country', 'provincial_address', 'contact', 'email', 'birthplace', 'sss', 'tin', 'philhealth', 'pagibig', 'father_name', 'father_comp', 'mother_name', 'mother_comp', 'schoolname[0]', 'schoolname[1]', 'skill[0]', 'comp_supervisor[0]', 'department', 'local', 'corp_email', 'emergency_name', 'emergency_address', 'emergency_telno'); for (var i = 0; i < x.length; i += 1) { l = document.forms['formreg'][x[i]]; if (l.value == null || l.value == '' || l.value == 0) { $('.regis_msg') .html('Some fields are required.' + x[i]) .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'border' : '2px solid #9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } else { $('.regis_msg') .html(' Registering your profile…') .css({ 'color' : '#006100', 'background' : '#c6efce', 'border' : '2px solid #006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); } } } else { $('.regis_msg') .html('Please select an image for uploading.') .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'border' : '2px solid #9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.regis_msg').slideUp(function () { $(this) .html(response.error) .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'borderColor' : '#9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); } else { html += 'Your profile has been successfully registered and subject for approval.
'; $('.regis_msg').slideUp(function () { $(this) .html(html) .css({ 'color' : '#006100', 'background' : '#c6efce', 'borderColor' : '#006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/act_request.php?sec=table", success: function(data) { $("#activity_table").html(data); } }); } } }); /* PROFILE */ $('#uprofile form').iframePostForm ({ json : true, post : function () { var uprofile_msg; if (!$('.uprofile_msg').length) { $('#lasttable').after(''); } var x = new Array('position', 'lastname', 'firstname', 'middlename', 'nickname', 'address_num', 'address_street', 'address_brgy', 'address_city', 'address_region', 'address_zip', 'address_country', 'provincial_address', 'contact', 'email', 'birthplace', 'sss', 'tin', 'philhealth', 'pagibig', 'father_name', 'father_comp', 'mother_name', 'mother_comp', 'schoolname[0]', 'schoolname[1]', 'skill[0]', 'comp_supervisor[0]', 'department', 'local', 'corp_email', 'emergency_name', 'emergency_address', 'emergency_telno'); for (var i = 0; i < x.length; i += 1) { l = document.forms['formpro'][x[i]]; if (l.value == null || l.value == '' || l.value == 0) { $('.uprofile_msg') .html('Some fields are required.') .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'border' : '2px solid #9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } else { $('.uprofile_msg') .html(' Updating your profile…') .css({ 'color' : '#006100', 'background' : '#c6efce', 'border' : '2px solid #006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); } } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.uprofile_msg').slideUp(function () { $(this) .html(response.error) .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'borderColor' : '#9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); } else { html += 'Your profile has been successfully updated.
'; $('.uprofile_msg').slideUp(function () { $(this) .html(html) .css({ 'color' : '#006100', 'background' : '#c6efce', 'borderColor' : '#006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); $.ajax( { url: "https://portal.megaworldcorp.com/ivr/lib/requests/act_request.php?sec=table", success: function(data) { $("#activity_table").html(data); } }); } } }); /* FORGOT PASSWORD */ $('#forgot form').iframePostForm ({ json : true, post : function () { var forgot_msg; if (!$('.forgot_msg').length) { $('#forgot_title').after(''); } if ($('#empidnum').val().length) { $('.forgot_msg') .html(' Processing…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.forgot_msg') .html('Employee ID is required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.forgot_msg').slideUp(function () { $(this) .html(response.error) .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown(); }); } else { html += 'Your password has been successfully reset and sent you your email.
'; $('.forgot_msg').slideUp(function () { $(this) .html(html) .css({ 'color' : '#006100', 'background' : '#c6efce', 'borderColor' : '#006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); } } }); /* CHANGE PASSWORD */ $('#fpass form').iframePostForm ({ json : true, post : function () { var fpass_msg; if (!$('.fpass_msg').length) { $('#fpass_title').after(''); } if ($('#opassword').val().length && $('#npassword').val().length && $('#cpassword').val().length) { $('.fpass_msg') .html(' Processing…') .css({ color : '#006100', background : '#c6efce', border : '2px solid #006100', height : 'auto' }) .slideDown(); } else { $('.fpass_msg') .html('All fields are required.') .css({ color : '#9c0006', background : '#ffc7ce', border : '2px solid #9c0006', height : 'auto' }) .slideDown() .effect('shake', {times: 3, distance: 5}, 420); return false; } }, complete : function (response) { var style, width, html = ''; if (!response.success) { $('.fpass_msg').slideUp(function () { $(this) .html(response.error) .css({ 'color' : '#9c0006', 'background' : '#ffc7ce', 'borderColor' : '#9c0006', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); } else { html += 'Your password has been successfully changed.
'; $('.fpass_msg').slideUp(function () { $(this) .html(html) .css({ 'color' : '#006100', 'background' : '#c6efce', 'borderColor' : '#006100', 'margin-top' : '10px', 'height' : 'auto' }) .slideDown(); }); } } }); });