// JavaScript Document
// Chekc Internet Status
function getOnlineConnectionStatus()
{
var msg = '0';
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=checkConnection",
async : false,
success:function(result)
{
msg = result.trim();
}
});
return msg;
}
/* --------------------- Server IP Address ----------------- */
function setServerIpAddress()
{
var options = {
url: main_pos_root+"modal/server_modal.php?modeType=serverIpAddress",
title :'Server IP Address',
size: eModal.size.lgs,
buttons: [
{text: 'OK', style: 'primary ',close: false, click: validateServerIPAddress },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateServerIPAddress()
{
var counter = 1;
var serverIpAdd = $("#serverIpAddressForm #serverIpAdd").val();
//console.log(main_pos_root+"modal/server_modal.php?modeType=setServerIpAddress&serverIpAdd="+serverIpAdd);
$.ajax({
type : "POST",
url: main_pos_root+"modal/server_modal.php?modeType=setServerIpAddress&serverIpAdd="+serverIpAdd,
success:function(result)
{
eModal.close();
window.setTimeout(function(){ location.reload();});
}
});
}
/* --------------------- Clock Date and Time ----------------- */
// Get Clock Date and Time
function clock_set()
{
var monthNames = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"];
var dayNames = ["Sun","Mon","Tues","Wed","Thur","Fri","Sat"]
var newDate = new Date();
newDate.setDate(newDate.getDate());
$('#Date').html(dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear());
setInterval( function() { var seconds = new Date().getSeconds(); $("#sec").html(( seconds < 10 ? "0" : "" ) + seconds); },1000);
setInterval( function() { var minutes = new Date().getMinutes(); $("#min").html(( minutes < 10 ? "0" : "" ) + minutes); },1000);
setInterval( function() { var hours = new Date().getHours(); $("#hours").html(( hours < 10 ? "0" : "" ) + hours); },1000);
}
// use for Full screen and Normal Screen
function toggleFullScreen()
{
if ((o.parent.document.fullScreenElement && window.parent.document.fullScreenElement !== null) || // alternative standard method
(!window.parent.document.mozFullScreen && !window.parent.document.webkitIsFullScreen))
{
// current working methods
if (window.parent.document.documentElement.requestFullScreen) { window.parent.document.documentElement.requestFullScreen(); }
else if (window.parent.document.documentElement.mozRequestFullScreen) { window.parent.document.documentElement.mozRequestFullScreen(); }
else if (window.parent.document.documentElement.webkitRequestFullScreen)
{
window.parent.document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
var content = ' ';
$('#fullscr').html(content);
}
else
{
if ( window.parent.document.cancelFullScreen) { window.parent.document.cancelFullScreen(); }
else if ( window.parent.document.mozCancelFullScreen) { window.parent.document.mozCancelFullScreen(); }
else if ( window.parent.document.webkitCancelFullScreen){ window.parent.document.webkitCancelFullScreen(); }
var content = ' ';
$('#fullscr').html(content);
}
}
/* --------------------- Mobile and Email Validation ----------------- */
function checkMobileFormat(mobile)
{
var msg = true;
var mobileRegex = /^[0-9]+$/;
if(!mobileRegex.test(mobile)) { msg = "Please enter a valid Mobile Number"; }
else if(isNaN(mobile)) { msg = "Please enter only digits. ";}
else if(mobile.length != 10) { msg = "Mobile must have 10 digits "; }
return msg;
}
// Check Email Format
function checkEmailFormat(email)
{
var msg = true;
var emailRegex = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
if(!emailRegex.test(email)) { msg = "Please enter a valid Email-ID"; }
return msg;
}
/* ---------------------------- Store Local Setting Set ---------------------------- */
function setPackingOrderFlag()
{
var packingOrder = 0;
if($("input[name='packing_order']").is(':checked')) { packingOrder = 1; }
if($("input[name='home_delivery']").is(':checked'))
{
$("#packing_order").attr('checked', 'checked');
packingOrder = 1;
}
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setPackingOrder&packingOrder="+packingOrder,
async : false,
success:function(result){}
});
}
function setBreadcumTabFlag(displayDivId)
{
//console.log(main_pos_root+"ajax/getlocalsetting.php?&mod=setBreadcumTabFlag&displayDivId="+displayDivId);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setBreadcumTabFlag&displayDivId="+displayDivId,
async : false,
success:function(result){}
});
}
function setHomeDeliveryFlag()
{
var homeDelivery = 0;
if($("input[name='home_delivery']").is(':checked'))
{
homeDelivery = 1;
$("#packing_order").attr('checked', 'checked');
}
//alert(main_pos_root+"ajax/getlocalsetting.php?&mod=setHomeDelivery&homeDelivery="+homeDelivery);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setHomeDelivery&homeDelivery="+homeDelivery,
async : false,
success:function(result){}
});
}
function setPackingOrderNote()
{
var packing_note = $("#packing_note").val();
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setPackingOrderNote&packing_note="+packing_note,
async : false,
success:function(result){}
});
}
function setPosPrinterFlag(printType)
{
var posPrinter = 0;
if(parseInt(printType) == 58) { if($("input[name='posPrinter58']").is(':checked')) { posPrinter = 58; } }
else if(parseInt(printType) == 80) { if($("input[name='posPrinter80']").is(':checked')) { posPrinter = 80; } }
else if(parseInt(printType) == 'taxInvoice') { if($("input[name='posTaxInvoicePrint']").is(':checked')) { posPrinter = 'taxInvoice'; } }
else
{
if($("input[name='posPrinter58']").is(':checked')) { posPrinter = 58; }
if($("input[name='posPrinter80']").is(':checked')) { posPrinter = 80; }
if($("input[name='posTaxInvoicePrint']").is(':checked')) { posPrinter = 'taxInvoice'; }
}
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setPosPrinter&posPrinter="+posPrinter,
async : false,
success:function(result){}
});
window.setTimeout(function(){ location.reload();});
}
function setPosAutoPrinterEnableFlag()
{
var autoPrintFlag = 0;
if($("input[name='autoPrinterEnableStatus']").is(':checked')) { autoPrintFlag = 1; }
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=autoPrinterEnableStatus&autoPrintFlag="+autoPrintFlag,
async : false,
success:function(result){}
});
window.setTimeout(function(){ location.reload();});
}
function setPosPrinterImageFlag()
{
var supportFlag = 0;
if($("input[name='posPrintImageSupport']").is(':checked')) { supportFlag = 1; }
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=posPrinterImageSupport&supportFlag="+supportFlag,
async : false,
success:function(result){}
});
window.setTimeout(function(){ location.reload();});
}
function setPosUndeCompositFlag()
{
var compositFlag = 0;
if($("input[name='posUndeCompositScheme']").is(':checked')) { compositFlag = 1; }
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=posUndeCompositFlag&compositFlag="+compositFlag,
async : false,
success:function(result){}
});
window.setTimeout(function(){ location.reload();});
}
/* ---------------------------- Database Sync Function ---------------------------- */
function shoposUpdateRequiredModal()
{
var txtmessage = '';
txtmessage += "";
txtmessage += '
';
var options =
{
message: txtmessage,
title : "Shopos Update",
size: eModal.size.lgs,
label: "OK",
};
return eModal.confirm(options)
.then(function ()
{
var downloadPath = 'https://www.dropbox.com/s/90kroaralqxu5wu/SHOPOS_SETUP.exe?dl=0';
window.open(downloadPath, '_blank');
})
}
// Online Database Synchronize Serive Call
function sqliteDbSynchronize()
{
var onlineStatus = getOnlineConnectionStatus();
if (onlineStatus =='1')
{
$('.loader').removeClass('posHide');
$('#db_sync').html(' Updating Transaction...');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=StoreSqliteSync",
async : true,
cache : false,
success:function(result)
{
$('.loader').addClass('posHide');
$('#db_sync').html(' Sync With Shopview');
window.setTimeout(function(){ location.reload();});
}
});
}
else
{
var showMsg = 'warning@@@@Database sync is not working. Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
function dbSynchronize()
{
var onlineStatus = getOnlineConnectionStatus();
if (onlineStatus =='1')
{
var txtmessage = '';
txtmessage += "";
txtmessage += '';
var options = {
message: txtmessage,
title : "Database Sync With Shopview",
size: eModal.size.lgs,
label: "OK",
};
return eModal.confirm(options)
.then(function ()
{
$('.loader').removeClass('posHide');
$('#db_sync').html(' Updating Masters...');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=StoreSync",
async : true,
cache : false,
success:function(result)
{
$('#db_sync').html(' Sync With Shopview');
$('.loader').addClass('posHide');
window.setTimeout(function(){ location.reload();});
}
});
})
}
else
{
var showMsg = 'warning@@@@Database sync is not working. Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
function dbProductImageSync()
{
var onlineStatus = getOnlineConnectionStatus();
if (onlineStatus =='1')
{
var txtmessage = '';
txtmessage += "";
txtmessage += '';
var options = {
message: txtmessage,
title : "Sync With Shopview",
size: eModal.size.lgs,
label: "OK",
};
return eModal.confirm(options)
.then(function ()
{
$('.loader').removeClass('posHide');
$('#db_sync').html(' Updating Masters...');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=StoreProImageSync",
async : true,
cache : false,
success:function(result)
{
$('#db_sync').html(' Sync With Shopview');
$('.loader').addClass('posHide');
window.setTimeout(function(){ location.reload();});
}
});
})
}
else
{
var showMsg = 'warning@@@@Database sync is not working. Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
function logoutShopos()
{
var onlineStatus = getOnlineConnectionStatus();
if (onlineStatus =='1')
{
var txtmessage = '';
txtmessage += "";
txtmessage += '';
var options = {
message: txtmessage,
title : "Shopos Logout",
size: eModal.size.lgs,
label: "OK",
};
return eModal.confirm(options)
.then(function ()
{
$('.loader').removeClass('posHide');
$('#db_sync').html(' Updating Masters...');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=StoreSync",
async : true,
cache : false,
success:function(result)
{
$('#db_sync').html(' Sync With Shopview');
$('.loader').addClass('posHide');
window.setTimeout(function(){ window.location = 'logout.php'});
}
});
})
.fail(function()
{
window.setTimeout(function(){ window.location = 'logout.php'});
})
}
else
{
window.setTimeout(function(){ window.location = 'logout.php'});
}
}
function posCurrentOrderSync()
{
//eModal.close();
var onlineStatus = getOnlineConnectionStatus();
if (onlineStatus =='1')
{
$('.loader').removeClass('posHide');
$('#db_sync').html(' Updating Transaction...');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=OrderSqliteSync",
async : true,
cache : false,
success:function(result)
{
$('.loader').addClass('posHide');
$('#db_sync').html(' Sync With Shopview');
}
});
}
else
{
var showMsg = 'warning@@@@Database sync is not working. Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
/* ---------------------------- -------------------- Right Side Button Control Function ---------------------------- -------------------- */
// This fucntion use to set the Active Cursor Field Id Set
function setActiveFocus(field_id,form_name)
{
$('#setTextFoucs').val(field_id);
$('#setFormFoucs').val(form_name);
}
/* ----------------------- Live Order Function ----------------------- */
// get the latest Online Order for Show Blink the Icon
function getNewLiveOrderAlert()
{
var onlineStatus = getOnlineConnectionStatus();
if(onlineStatus =='1')
{
console.log(main_pos_root+"ajax/dbsyncboth.php?mod=liveOrderCount");
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=liveOrderCount",
async : false,
success:function(result)
{
var resultArr = result.split('####');
var new_order = resultArr[0].trim();
var pending_order = resultArr[1].trim();
var old_order = $("#liveOrderCountPos").val();
if(parseInt(pending_order) >0)
{
pending_order = pending_order+' Pending Online Orders';
$("#livePendingOrderPos").html(pending_order);
$("#liveOrderIcon").addClass("blink");
}
else
{
$("#livePendingOrderPos").html('');
$("#liveOrderIcon").removeClass("blink");
}
if(old_order !='' && old_order>0 && parseInt(new_order) > parseInt(old_order) )
{
//var orderAudio = document.getElementById("newLiveOrderAudio");
//orderAudio.play();
document.getElementById("newLiveOrderAudio").play();
$("#btn_blink").attr("display","block");
$("#btn_blink").addClass("blink_me");
(function blink() { $('.blink_me').fadeOut(700).fadeIn(700, blink);})();
$("#liveOrderCountPos").val(new_order);
}
else if(old_order =='')
{
$("#liveOrderCountPos").val(new_order);
$("#btn_blink").hide();
}
}
});
}
}
function liveOrderListScreen()
{
var onlineStatus = getOnlineConnectionStatus();
if(onlineStatus =='1')
{
var orderAudio = document.getElementById("newLiveOrderAudio");
orderAudio.pause();
// Hide the New Ticket
document.getElementById("btn_blink").style.display = "none";
$("#btn_blink").removeClass("blink_me");
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=liveOrderListViewScreen",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
//window.setTimeout(function(){ location.reload();},1);
}
else
{
var showMsg = 'warning@@@@Online Order can not displayed . Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
function findLiveOrderList()
{
var onlineStatus = getOnlineConnectionStatus();
if(onlineStatus =='1')
{
$('.loader').removeClass('posHide');
var searchKey = $('#liveOrderSearchForm #searchKey').val();
var liveOrderType = $('#liveOrderSearchForm #liveOrderType').val();
var ordStartDate = $('#liveOrderSearchForm #ordStartDate').val();
var ordEndDate = $('#liveOrderSearchForm #ordEndDate').val();
var dataArr = '&liveOrderType='+liveOrderType+'&ordStartDate='+ordStartDate+'&ordEndDate='+ordEndDate+'&searchKey='+searchKey
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=liveOrderSearch"+dataArr,
async : false,
success:function(result) { }
});
$('.loader').addClass('posHide');
liveOrderListScreen();
}
else
{
var showMsg = 'warning@@@@Online Order can not displayed . Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
function getLiveOrderDetail(liveOrderId)
{
var onlineStatus = getOnlineConnectionStatus();
if(onlineStatus =='1')
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=getLiveOrderDetail&liveOrderId="+liveOrderId,
title : 'Live Order Detail : '+liveOrderId,
size: eModal.size.lgs,
buttons: [ {text: 'Close', style: 'default ', close: true } ],
};
return eModal.ajax(options);
}
else
{
var showMsg = 'warning@@@@Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
// Displaye Large Image
function viewOrderImage(liveOrderId,invoice_no,imagePath)
{
var txtmessage = '';
txtmessage += '';
var subTitle = 'Order Image : '+invoice_no+' '+invoice_no+'';
txtmessage += ' .modal-dialog { width: 100%; } ';
txtmessage += ' @media (min-width: 768px) {.modal-dialog { padding: 0rem 45rem; }}';
txtmessage += ' .modal-title { font-size: 3rem; }';
txtmessage += '.modal-header .close { font-size: 4rem; }';
txtmessage += '.btn-primary { font-size: 2.5rem; padding: 1rem 1.3rem; float:left; }';
txtmessage += '.btn-danger { font-size: 2.5rem; padding: 1rem 1.3rem; float:right; }';
txtmessage += '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Live Order Processing : " + liveOrderId,
size: eModal.size.lgs,
label: "Yes",
};
return eModal.confirm(options)
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=liveOrderProcessing&liveOrderId="+liveOrderId,
async : false,
success:function(result)
{
result = result.trim();
var resArr = result.split("####");
if(parseInt(resArr[0]) != 0)
{
$("#refereshDiv").html(resArr[0]);
}
// Display msg Function
getDisplayAlertMsg(resArr[1]);
}
});
})
}
function storeLiveOrderCancel()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=storeLiveOrderCancel",
async : false,
success:function(result)
{
result = result.trim();
var resArr = result.split("####");
if(parseInt(resArr[0]) != 0)
{
$("#refereshDiv").html(resArr[0]);
}
// Display msg Function
getDisplayAlertMsg(resArr[1]);
}
});
}
function liveOrderChangeStatus(actionType,liveOrderId)
{
var dataArr = '&actionType='+actionType+'&liveOrderId='+liveOrderId;
var confirmMsg = "Are you confirm to Change Status into "+actionType +" : "+liveOrderId;
return eModal
.confirm(confirmMsg, 'Confirm')
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/dbsyncboth.php?mod=liveOrderChangeStatus"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
var resArr = result.split("####");
if(actionType == 'Complete')
{
if(parseInt(resArr[0]) == 1)
{
var showMsg = 'success@@@@'+resArr[1];
}
else
{
var showMsg = 'warning@@@@'+resArr[1];
}
getDisplayAlertMsg(showMsg);
}
else
{
if(parseInt(resArr[0]) != 0)
{
$("#refereshDiv").html(resArr[0]);
}
// Display msg Function
getDisplayAlertMsg(resArr[1]);
}
}
});
})
}
function changeLiveOrderStatus(liveOrderId)
{
var onlineStatus = getOnlineConnectionStatus();
if(onlineStatus =='1')
{
console.log(main_pos_root+"modal/pos_modal.php?modeType=changeLiveOrderStatus&liveOrderId="+liveOrderId);
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=changeLiveOrderStatus&liveOrderId="+liveOrderId,
title : 'Order Status Change : '+liveOrderId,
size: eModal.size.lgs,
buttons: [ {text: 'Close', style: 'default ', close: true } ],
};
return eModal.ajax(options);
}
else
{
var showMsg = 'warning@@@@Please connect to the internet .';
getDisplayAlertMsg(showMsg);
}
}
// ************************************ New Design Fucntion **********************// Get the Set Main Category ID
function setMainCategoryId(mainCategory)
{
//console.log(main_pos_root+"ajax/getlocalsetting.php?&mod=setMainCategory&mainCategory="+mainCategory);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setMainCategory&mainCategory="+mainCategory,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#breadcumSubcate").html(res_val[0]);
$("#tabSubCategory").html(res_val[1]);
$("#breadcumSubcate").show();
$("#breadcumProduct").hide();
breadcrumbDivDisplay('subCategoryHome');
}
});
}
// Get the Set Sub Category ID
function setSubCategoryId(subCategory)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=setSubCategory&subCategory="+subCategory,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#breadcumProduct").html(res_val[0]);
$("#tabCategoryProduct").html(res_val[1]);
$("#breadcumSubcate").show();
$("#breadcumProduct").show();
breadcrumbDivDisplay('productListHome');
}
});
}
// ***************************************** Pos Aboutus Modal ************************************
function getPosMoreOptionModal()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=MoreOPtionModal",
title : 'More Options',
size: eModal.size.lgs,
buttons: [ {text: 'OK', style: 'default ', close: true } ],
};
return eModal.ajax(options);
}
function posAboutModal()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=posAboutUsModal",
title : 'About SHOPOS',
size: eModal.size.lgs,
buttons: [
{text: 'OK', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// JavaScript Document
/* **********************Add Item IN Cart Fucntion **************** */
var setID;
function getDisplayAlertMsg(displayMsg)
{
clearInterval(setID);
$('#notificationMsg').hide();
var dataArr = displayMsg.split('@@@@');
var msg_color = dataArr[0];
var msg_content = dataArr[1];
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-right",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "3000",
"extendedTimeOut": false,
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
if( msg_content === undefined )
{
}
else
{
toastr[msg_color](msg_content);
setID = setInterval(function(){$('#notificationMsg').show();}, 6000);
}
}
// ***************************************** Add New Product ************************************
function masterProductListScreen()
{
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=productListViewScreen",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
//window.setTimeout(function(){ location.reload();},1);
}
function findMasterProductList()
{
$('.loader').removeClass('posHide');
var searchKey = $('#mstProductSearchForm #searchKey').val();
var brandId = $('#mstProductSearchForm #proBrandId').val();
var mainCateId = $('#mstProductSearchForm #proMainCateId').val();
var displayFlag = $('#mstProductSearchForm #proDisplayFlag').val();
var dataArr = '&brandId='+brandId+'&mainCateId='+mainCateId+'&displayFlag='+displayFlag+'&searchKey='+searchKey
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=masterProductSearch"+dataArr,
async : false,
success:function(result) { }
});
$('.loader').addClass('posHide');
masterProductListScreen()
}
function viewHsnCodeList()
{
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=HsnCodeList",
title : 'HSN Code List',
size: eModal.size.lgs,
buttons: [
{text: 'Close', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function masterProDelFlag(product_id,status)
{
$('.loader').removeClass('posHide');
$.ajax({
type : "POST",
url: main_pos_root+"ajax/product_detail.php?mod=StoreProDeleteFlag&product_id="+product_id+'&status='+status,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
$('.loader').addClass('posHide');
getDisplayAlertMsg(dataArr[1]);
}
});
masterProductListScreen();
}
// Add Item Prepare Status and Item Recipe Modal
function productDeatilInfoModal(product_id)
{
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=ProductDetailModal&product_id="+product_id,
title : 'Product Detail',
size: eModal.size.lgs,
buttons: [
{text: 'Close', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function addNewProductForm()
{
var product_id = '';
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=addProductForm&product_id="+product_id,
title : 'Add Product',
size: eModal.size.lgs,
buttons: [
{text: 'Add Product', style: 'primary ',close: false, click: validateAddProductForm },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateAddProductForm()
{
var counter = 1;
var formName = '#addProductForm';
var proSku = $(formName+" #proSku").val();
var proName = $(formName+" #proName").val();
var proBrand = $(formName+" #proBrand").val();
var proSize = $(formName+" #proSize").val();
var proUnit = $(formName+" #proUnit").val();
var proMrp = $(formName+" #proMrp").val();
var proPurchase = $(formName+" #proPurchase").val();
var proPrice = $(formName+" #proPrice").val();
var proHsnCode = $(formName+" #proHsnCode").val();
var proCgstTax = $(formName+" #proCgstTax").val();
var proSgstTax = $(formName+" #proSgstTax").val();
var proIgstTax = $(formName+" #proIgstTax").val();
var proDisplayFlag = $(formName+" #proDisplayFlag").val();
if(proSku == '') { $(formName+' #proSku_EBox').html('Please Provide Product SKU'); counter = 0; }
if(proName == '') { $(formName+' #proName_EBox').html('Please Provide Product Name'); counter = 0; }
if(proBrand == '') { $(formName+' #proBrand_EBox').html('Please Provide Product Manufacturer'); counter = 0; }
if(proSize == '') { $(formName+' #proSize_EBox').html('Please Provide Product Size'); counter = 0; }
if(proUnit == '') { $(formName+' #proUnit_EBox').html('Please Select Product Unit'); counter = 0; }
if(proMrp == '') { $(formName+' #proMrp_EBox').html('Please Provide Product MRP'); counter = 0; }
else if(parseFloat(proMrp) < 0 ) { $(formName+' #proMrp_EBox').html('MRP Greater than and Equal To Zero.'); counter = 0; }
else if(isNaN(proMrp)) { $(formName+' #proMrp_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proPurchase == '') { $(formName+' #proPurchase_EBox').html('Provide Product Purchase Price'); counter = 0; }
else if(parseFloat(proPurchase) <0) { $(formName+' #proPurchase_EBox').html('Purchase Price Greater than and Equal To Zero.'); counter = 0; }
else if(isNaN(proPurchase)) { $(formName+' #proPurchase_EBox').html('Please Enter Only Digit.'); counter = 0; }
else if(isNaN(proPurchase)>parseFloat(proMrp)) { $(formName+' #proPurchase_EBox').html('Purchase Price Less than and Equal To MRP.'); counter = 0; }
if(proPrice == '') { $(formName+' #proPrice_EBox').html('Please Provide Product Selling Price'); counter=0; }
else if(parseFloat(proPrice) <0) { $(formName+' #proPrice_EBox').html('Selling Price Greater than and Equal To Zero.'); counter=0; }
else if(isNaN(proPrice)) { $(formName+' #proPrice_EBox').html('Please Enter Only Digit.'); counter=0; }
else if(isNaN(proPrice) > parseFloat(proMrp)) { $(formName+' #proPrice_EBox').html('Sell Price Less than and Equal To MRP.'); counter=0; }
else if(parseFloat(proPrice) < parseFloat(proPurchase)){ $(formName+' #proPrice_EBox').html('Sell Price Greater than and Equal To Purchase.'); counter=0; }
if(proCgstTax == '') { $(formName+' #proCgstTax_EBox').html('Please Provide CGST Tax'); counter = 0; }
else if(parseFloat(proCgstTax) < 0 ) { $(formName+' #proCgstTax_EBox').html('CGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proCgstTax) > 100) { $(formName+' #proCgstTax_EBox').html('CGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proCgstTax)) { $(formName+' #proCgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proSgstTax == '') { $(formName+' #proSgstTax_EBox').html('Please Provide SGST Tax'); counter = 0; }
else if(parseFloat(proSgstTax) < 0 ) { $(formName+' #proSgstTax_EBox').html('SGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proSgstTax) > 100) { $(formName+' #proSgstTax_EBox').html('SGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proSgstTax)) { $(formName+' #proSgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proIgstTax == '') { $(formName+' #proIgstTax_EBox').html('Please Provide IGST Tax'); counter = 0; }
else if(parseFloat(proIgstTax) < 0 ) { $(formName+' #proIgstTax_EBox').html('IGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proIgstTax) > 100) { $(formName+' #proIgstTax_EBox').html('IGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proIgstTax)) { $(formName+' #proIgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proDisplayFlag == '') { $(formName+' #proDisplayFlag_EBox').html('Please Select Any One Option'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
var dataArr = '&proSku='+proSku+'&proName='+proName+'&proBrand='+proBrand+'&proSize='+proSize+'&proUnit='+proUnit;
dataArr += '&proMrp='+proMrp+'&proPurchase='+proPurchase+'&proPrice='+proPrice+'&proHsnCode='+proHsnCode;
dataArr += '&proCgstTax='+proCgstTax+'&proSgstTax='+proSgstTax+'&proIgstTax='+proIgstTax+'&proDisplayFlag='+proDisplayFlag;
$.ajax({
type : "POST",
url: main_pos_root+"ajax/product_detail.php?mod=AddNewProduct"+dataArr,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
if(dataArr[0] == 0)
{
$(formName+' #proSku_EBox').html(dataArr[1]);
return false;
}
else
{
getDisplayAlertMsg(dataArr[1]);
// close the Modal
eModal.close();
window.setTimeout(function(){ location.reload();},1);
}
}
});
}
}
function editProductForm(product_id)
{
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=editProductForm&product_id="+product_id,
title : 'Edit Product',
size: eModal.size.lgs,
buttons: [
{text: 'Update Detail', style: 'primary ',close: false, click: validateEditProductForm },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateEditProductForm()
{
var counter = 1;
var formName = '#editProductForm';
var product_id = $(formName+" #product_id").val();
var proMrp = $(formName+" #proMrp").val();
var proPurchase = $(formName+" #proPurchase").val();
var proPrice = $(formName+" #proPrice").val();
var proHsnCode = $(formName+" #proHsnCode").val();
var proCgstTax = $(formName+" #proCgstTax").val();
var proSgstTax = $(formName+" #proSgstTax").val();
var proIgstTax = $(formName+" #proIgstTax").val();
var proDisplayFlag = $(formName+" #proDisplayFlag").val();
if(proMrp == '') { $(formName+' #proMrp_EBox').html('Please Provide Product MRP'); counter = 0; }
else if(parseFloat(proMrp) < 0 ) { $(formName+' #proMrp_EBox').html('MRP Greater than and Equal To Zero.'); counter = 0; }
else if(isNaN(proMrp)) { $(formName+' #proMrp_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proPurchase == '') { $(formName+' #proPurchase_EBox').html('Provide Product Purchase Price'); counter = 0; }
else if(parseFloat(proPurchase) <0) { $(formName+' #proPurchase_EBox').html('Purchase Price Greater than and Equal To Zero.'); counter = 0; }
else if(isNaN(proPurchase)) { $(formName+' #proPurchase_EBox').html('Please Enter Only Digit.'); counter = 0; }
else if(isNaN(proPurchase)>parseFloat(proMrp)) { $(formName+' #proPurchase_EBox').html('Purchase Price Less than and Equal To MRP.'); counter = 0; }
if(proPrice == '') { $(formName+' #proPrice_EBox').html('Please Provide Product Selling Price'); counter=0; }
else if(parseFloat(proPrice) <0) { $(formName+' #proPrice_EBox').html('Selling Price Greater than and Equal To Zero.'); counter=0; }
else if(isNaN(proPrice)) { $(formName+' #proPrice_EBox').html('Please Enter Only Digit.'); counter=0; }
else if(isNaN(proPrice) > parseFloat(proMrp)) { $(formName+' #proPrice_EBox').html('Sell Price Less than and Equal To MRP.'); counter=0; }
else if(parseFloat(proPrice) < parseFloat(proPurchase)){ $(formName+' #proPrice_EBox').html('Sell Price Greater than and Equal To Purchase.'); counter=0; }
if(proCgstTax == '') { $(formName+' #proCgstTax_EBox').html('Please Provide CGST Tax'); counter = 0; }
else if(parseFloat(proCgstTax) < 0 ) { $(formName+' #proCgstTax_EBox').html('CGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proCgstTax) > 100) { $(formName+' #proCgstTax_EBox').html('CGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proCgstTax)) { $(formName+' #proCgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proSgstTax == '') { $(formName+' #proSgstTax_EBox').html('Please Provide SGST Tax'); counter = 0; }
else if(parseFloat(proSgstTax) < 0 ) { $(formName+' #proSgstTax_EBox').html('SGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proSgstTax) > 100) { $(formName+' #proSgstTax_EBox').html('SGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proSgstTax)) { $(formName+' #proSgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proIgstTax == '') { $(formName+' #proIgstTax_EBox').html('Please Provide IGST Tax'); counter = 0; }
else if(parseFloat(proIgstTax) < 0 ) { $(formName+' #proIgstTax_EBox').html('IGST Greater than and Equal To Zero.'); counter = 0; }
else if(parseFloat(proIgstTax) > 100) { $(formName+' #proIgstTax_EBox').html('IGST Less than and Equal To 100.'); counter = 0; }
else if(isNaN(proIgstTax)) { $(formName+' #proIgstTax_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(proDisplayFlag == '') { $(formName+' #proDisplayFlag_EBox').html('Please Select Any One Option'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
var dataArr = '&product_id='+product_id;
dataArr += '&proMrp='+proMrp+'&proPurchase='+proPurchase+'&proPrice='+proPrice+'&proHsnCode='+proHsnCode;
dataArr += '&proCgstTax='+proCgstTax+'&proSgstTax='+proSgstTax+'&proIgstTax='+proIgstTax+'&proDisplayFlag='+proDisplayFlag;
//alert(main_pos_root+"ajax/product_detail.php?mod=EditProductDetail"+dataArr);
$.ajax({
type : "POST",
url: main_pos_root+"ajax/product_detail.php?mod=EditProductDetail"+dataArr,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
if(dataArr[0] == 1)
{
getDisplayAlertMsg(dataArr[1]);
// close the Modal
eModal.close();
window.setTimeout(function(){ location.reload();},1);
}
}
});
}
}
// Add Item Prepare Status and Item Recipe Modal
function itemPrepareRecipeModal(product_id)
{
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=itemPrepareRecipeModal&product_id="+product_id,
title :'Item Prepare Recipe',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ',close: false, click: validateitemPrepareRecipe },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateitemPrepareRecipe()
{
var product_id = $("#itemPreRecipeForm #product_id").val();
var item_prepare = $('#itemPreRecipeForm input[name="item_prepare"]:checked').val();
var item_recipe = $("#itemPreRecipeForm #item_recipe").val();
var dataArr = '&product_id='+product_id+'&item_prepare='+item_prepare+'&item_recipe='+item_recipe;
$.ajax({
type : "POST",
url: main_pos_root+"ajax/product_detail.php?mod=AddItemPrepareRecipe"+dataArr,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
if(dataArr[0] == 1)
{
getDisplayAlertMsg(dataArr[1]);
masterProductListScreen();
}
}
});
}
// Add Item Prepare Status and Item Recipe Modal
function productInventoryList(product_id)
{
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=ProductInventoryListModal&product_id="+product_id,
title : 'Product Inventory List',
size: eModal.size.lgs,
buttons: [
{text: 'Close', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
/* ********************** Window Print Invoice Function **************** */
function printOrderInvoice(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=PrintSaleOrder&id="+order_id,
async : false,
success:function(result)
{
result = result.trim();
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + result + '');
popupWin.document.close();
}
});
}
function printReturnInvoice(return_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=PrintReturnOrder&id="+return_id,
async : false,
success:function(result)
{
result = result.trim();
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + result + '');
popupWin.document.close();
}
});
}
function printDiv(divName)
{
var divToPrint = document.getElementById(divName);
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + divToPrint.innerHTML + '');
popupWin.document.close();
}
function printTableInvoice(tableRowid)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=PrintTableOrder&id="+tableRowid,
async : false,
success:function(result)
{
result = result.trim();
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + result + '');
popupWin.document.close();
}
});
}
function PrintEstimatedInvoice(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=PrintEstimatedOrder&id="+order_id,
async : false,
success:function(result)
{
result = result.trim();
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + result + '');
popupWin.document.close();
}
});
}
/* ********************** Pos Print Tax Invoice Function **************** */
function printOrderTaxInvoice(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=OrderTaxInvoice&id="+order_id,
async : false,
success:function(result)
{
result = result.trim();
var popupWin = window.open('','_blank','width=400,height=600');
popupWin.document.open();
popupWin.document.write('' + result + '');
popupWin.document.close();
}
});
}
/* ********************** Pos Print Invoice Function **************** */
function printEscposOrderInvoice(order_id)
{
//alert(main_pos_root+"ajax/order_invoice.php?&mod="+modeType+'&id='+id);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=EscposOrderInvoice&order_id="+order_id,
async : false,
success:function(result) { }
});
}
function printEscposReturnInvoice(return_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=EscposReturnInvoice&return_id="+return_id,
async : false,
success:function(result) { }
});
}
function printEscposEstimatedInvoice(order_id)
{
//alert(main_pos_root+"ajax/order_invoice.php?&mod="+modeType+'&id='+id);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/order_invoice.php?&mod=EscposEstimatedInvoice&order_id="+order_id,
async : false,
success:function(result) { }
});
}
/* ********************** Table Order Function **************** */
function orderTableMode(currentTable)
{
$.ajax({
type : "POST",
url: main_pos_root+"ajax/tableOrderDetail.php?mod=Hold&new_table="+currentTable,
success:function(result) { }
});
// Set the Table View Mode
tableViewMode();
}
function holdTableOrder(newTable)
{
$.ajax({
type : "POST",
url: main_pos_root+"ajax/tableOrderDetail.php?mod=Hold&new_table="+newTable,
success:function(result)
{
var result = result.trim();
$("#refereshDiv").html(result);
eModal.close();
}
});
}
// tabel Order Detail Modal
function tableOrderDetailModal(table_name)
{
var titleMsg = ''+table_name+'';
var options = {
url: main_pos_root+"modal/table_order_modal.php?modeType=tableOrderDetail&table_name="+table_name,
title :'Table Product List '+titleMsg,
size: eModal.size.lgs,
buttons: [ {text: 'Cancel', style: 'default ', close: true }],
};
return eModal.ajax(options);
}
// Split the table Order
function splitTableOrderDetail(table_name)
{
var titleMsg = ''+table_name+'';
var options = {
url: main_pos_root+"modal/table_order_modal.php?modeType=SplitTableOrder&table_name="+table_name,
title :'Split Order Bill '+titleMsg,
size: eModal.size.lgs,
buttons: [ {text: 'Cancel', style: 'default ', close: true }],
};
return eModal.ajax(options);
}
function validateTableSplitForm()
{
var qtyFlag = 1;
var counter = 0;
var quant = $("input[name='chk[]']");
$.each(quant,function(index,item)
{
if($("input[name='chk[]']").eq(index).is(':checked'))
{
counter = counter + 1;
var actualQty = parseFloat($("input[name='actualQty[]']").eq(index).val());
var paidQty = parseFloat($("input[name='qty[]']").eq(index).val());
if((actualQty < paidQty) || (paidQty <=0))
{
qtyFlag = 0;
$("input[name='qty[]']").eq(index).addClass('field-error');
}
}
});
if(counter == 0)
{
$('#splitTable_EBox').html('Please Select Atleast One Product'); return false;
}
else
{
if(qtyFlag == 0)
{
$('#splitTable_EBox').html('Paid Quantity Not less than Zero and Greater Than Actual Quantity');
return false;
}
else
{
splitBillProceed('splitTableOrderForm');
}
}
}
function splitBillProceed(form_name)
{
var data_content = $('#'+form_name).serialize();
$.ajax({
type : "GET",
url : main_pos_root+"ajax/tableOrderDetail.php",
data: data_content,
async : true,
success:function(result)
{
result = result.trim();
eModal.close();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
window.setTimeout(function(){ location.reload();});
}
});
}
//********************************** Kitchen Note **************************************
// Get the Product Recipe Detail
function viewProductRecipe(product_id)
{
var options = {
url: main_pos_root+"modal/kitchen_note_modal.php?modeType=productRecipe&product_id="+product_id,
title :'Product Recipe',
size: eModal.size.lgs,
buttons: [{text: 'Cancel', style: 'default ', close: true }],
};
return eModal.ajax(options);
}
// Kitchen Note Modal
function getkitchenNote(product_id,dateTime)
{
var dataArr = '&product_id='+product_id+'&dateTime='+dateTime;
var options = {
url: main_pos_root+"modal/kitchen_note_modal.php?modeType=AddKitchenNote"+dataArr,
title :'Kitchen Note',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ',close: false, click: validateKitchenNoteInfo },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Add the Kitchen Note
function validateKitchenNoteInfo()
{
var product_id = $("#getKitcheNoteForm #product_id").val();
var dateTime = $("#getKitcheNoteForm #dateTime").val();
var kitchen_note = $("#getKitcheNoteForm #kitchen_note").val();
var dataArr = '&product_id='+product_id+'&dateTime='+dateTime+'&kitchen_note='+kitchen_note;
$.ajax({
type : "POST",
url: main_pos_root+"cart_update.php?modeType=addProductKitchenNote"+dataArr,
success:function(result)
{
result = result.trim();
var dataArr = result.split("####");
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
if(dataArr[1] !=''){ getDisplayAlertMsg(dataArr[1]); }
eModal.close();
}
});
}
function displayKitechNote(order_id,product_id)
{
var dataArr = '&product_id='+product_id+'&order_id='+order_id;
var options = {
url: main_pos_root+"modal/kitchen_note_modal.php?modeType=viewOrderKitchenNote"+dataArr,
title :'Kitchen Note',
size: eModal.size.lgs,
buttons: [{text: 'Cancel', style: 'default ', close: true }],
};
return eModal.ajax(options);
}
//******************************** Description Note ***************************
// Kitchen Note Modal
function getDescriptionNote(product_id,dateTime)
{
var dataArr = '&product_id='+product_id+'&dateTime='+dateTime;
var options = {
url: main_pos_root+"modal/kitchen_note_modal.php?modeType=AddDescriptionNote"+dataArr,
title :'Description Note',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ',close: false, click: validateProDescriptionInfo },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Add the Kitchen Note
function validateProDescriptionInfo()
{
var product_id = $("#getDescriptionNoteForm #product_id").val();
var dateTime = $("#getDescriptionNoteForm #dateTime").val();
var description_note = $("#getDescriptionNoteForm #description_note").val();
var dataArr = '&product_id='+product_id+'&dateTime='+dateTime+'&description_note='+description_note;
//alert(main_pos_root+"cart_update.php?modeType=addProductDescriptionNote"+dataArr);
$.ajax({
type : "POST",
url: main_pos_root+"cart_update.php?modeType=addProductDescriptionNote"+dataArr,
success:function(result)
{
result = result.trim();
var dataArr = result.split("####");
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
if(dataArr[1] !=''){ getDisplayAlertMsg(dataArr[1]); }
eModal.close();
}
});
}
/* ********************** Suspended Order List Modal Fucntion **************** */
// Suspended Order List
function getEstimatedOrderList()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=EstimatedOrder",
title :'Estimated Sale',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Delete Suspended Order
function estimatedDeleteOrder(order_id)
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/suspended_sales.php?mod=estimatedOrderDelete&order_id="+order_id,
success: function(msg)
{
// Display msg Function
getDisplayAlertMsg(msg.trim());
getEstimatedOrderList();
}
});
}
function checkUnEstimatedCart(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/suspended_sales.php?mod=check_cart",
success:function(msg)
{
var result = parseInt(msg.trim());
if(result >0)
{
var confirmMsg = "Your Current Cart is not Enpty. Continue with current Cart. Press ok...";
return eModal
.confirm(confirmMsg, 'Confirm')
.fail(function () { unEstimatedOrder(order_id,'flag'); });
}
else
{
// Unsuspend order
unsespenOrder(order_id);
}
}
});
}
// Unsuspend order
function unEstimatedOrder(order_id,flag)
{
if (flag === undefined) { flag = 1; }
$.ajax({
type : "GET",
url : main_pos_root+"ajax/suspended_sales.php?mod=unEstimatedOrder&order_id="+order_id,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
getDisplayAlertMsg(dataArr[1]);
// close the Modal
eModal.close();
}
});
}// JavaScript Document
// Display the Customer View Mode
function customerListScreen()
{
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=customerListScreen",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
//window.setTimeout(function(){ location.reload();},1);
}
// Get the Customer Details on the Basis of Customer Mobile
function getCustName()
{
var mobile = document.getElementById('cust_mobile').value;
//alert(main_pos_root+"ajax/customerInfo.php?mod=custDetail&mobile="+mobile);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/customerInfo.php?mod=custDetail&mobile="+mobile,
async : false,
success:function(result)
{
if(result != '')
{
var val = result.split("###");
if(val[0] === undefined) { var name = ''; } else{ var name = val[0].trim(); }
if(val[1] === undefined) { var email = ''; } else{ var email = val[1].trim(); }
if(val[2] === undefined) { var address = ''; } else{ var address = val[2].trim(); }
if(val[3] === undefined) { var gst_number = ''; } else{ var gst_number = val[3].trim(); }
$('#cust_name').focus();
$("#cust_name").val(name);
$("#cust_email").val(email);
$("#cust_address").val(address);
$("#cust_gstNumber").val(gst_number);
}
}
});
}
// Display the Customer View Mode
function selectCustOrderDate()
{
var ordSelDate = $('#ordSelDate').val();
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=CustSelOrderdate&ordSelDate="+ordSelDate,
async : false,
success:function(result){}
});
customerListScreen();
}
// Get the customer Auto Suggestion List
function getCustomerNameSuggestion()
{
var min_length = 0;
var keyword = $('#customerSearchForm #cusomerMobile').val();
if (keyword.length > min_length)
{
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=customerNameSearch&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#customerSearchForm #custNameSuggestionList').hide();
$('#customerSearchForm #custNameSuggestionList').html('');
}
else
{
$('#customerSearchForm #custNameSuggestionList').show();
$('#customerSearchForm #custNameSuggestionList').html(response);
}
}
});
}
else
{
$('#customerSearchForm #custNameSuggestionList').hide();
$('#customerSearchForm #custNameSuggestionList').html('');
}
}
// Get Customer Order List
function setCustomerSuggestMobile(customerMobile)
{
$('#customerSearchForm #custNameSuggestionList').hide();
$('#customerSearchForm #custNameSuggestionList').html('');
if(customerMobile !='')
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/customerInfo.php?mod=customerOrderList&customerMobile="+customerMobile,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
// Add Customer Credit Amount
function addCustomerCreditAmount(credit_balance,order_id)
{
if (order_id === undefined) { order_id = ''; }
var title = 'Credit Balance Rs.'+credit_balance +'';
var options = {
url: main_pos_root+"modal/customer_info.php?modeType=addCustomerCreditAmount&order_id="+order_id,
title : 'Amount Receive '+title,
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ',close: false, click: validateCustomerCreditAmount },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateCustomerCreditAmount()
{
var counter = 1;
var order_id = $("#addCreditAmountForm #order_id").val();
var maxCredit = $("#addCreditAmountForm #maxCredit").val();
var creditAmount = $("#addCreditAmountForm #creditAmount").val();
creditAmount = parseInt(creditAmount);
if(creditAmount == '') { $('#addCreditAmountForm #creditAmount_EBox').html('Enter the Credit Amount Receive '); counter = 0; }
else
{
if(isNaN(creditAmount)) { $('#addCreditAmountForm #creditAmount_EBox').html('Enter Only Digit '); counter = 0; }
else
{
if(parseInt(maxCredit) < parseInt(creditAmount))
{
$('#addCreditAmountForm #creditAmount_EBox').html('Amount Receive Must be Equal Maximum Credit');
counter = 0;
}
}
}
if(counter ==0 ) { return false;}
else
{
var dataArr = '&maxCredit='+maxCredit+'&creditAmount='+creditAmount+'&order_id='+order_id;
$.ajax({
type : "GET",
url : main_pos_root+"ajax/customerInfo.php?mod=custCreditAmountReceived"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
}
function getOrderInvoiceNo(order_id)
{
var invoice_no = '';
$.ajax({
type: "GET",
global: false,
url: main_pos_root+"ajax/customerInfo.php?mod=order_invoice&order_id="+order_id,
async : false,
success: function(msg)
{
invoice_no = msg;
}
});
return invoice_no;
}
function getCustOrderDetail(order_id)
{
var invoice_no = getOrderInvoiceNo(order_id);
var options = {
url: main_pos_root+"modal/customer_info.php?modeType=customerOrderDetail&order_id="+order_id,
title :'Order Product List '+invoice_no+'',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// JavaScript Document
function cartSaleViewScreen()
{
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=cartSaleViewScreen",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
//window.setTimeout(function(){ location.reload();},1);
}
// Customer Information Detil Modal
function getCartCustInfoModal(paymentType,amountDue)
{
if(amountDue === undefined) { amountDue = ''; }
if(paymentType == 'Telephone')
{
var options = {
url: main_pos_root+"modal/customer_info.php?modeType=CartCustomerInfo&paymentType="+paymentType,
title :'Customer Information',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ', close: false, click: validateCartCustInfo },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
else
{
var options = {
url: main_pos_root+"modal/customer_info.php?modeType=CartCustomerInfo&paymentType="+paymentType,
title :'Customer Information',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ', close: false, click: validateCartCustInfo },
{text: 'Skip', style: 'default ', close: false , click: validateSkipCartCustInfo }
],
};
return eModal.ajax(options);
}
}
function validateCartCustInfo()
{
var counter = 1;
var formName = '#customerInfoForm';
var pressButtonFlag = $(formName+" #pressButtonFlag").val();
var paymentType = $(formName+" #paymentType").val();
var amountDue = $(formName+" #amountDue").val();
var mobile = $(formName+" #cust_mobile").val();
var name = $(formName+" #cust_name").val();
var email = $(formName+" #cust_email").val();
var address = $(formName+" #cust_address").val();
var cust_dob = $(formName+" #cust_dob").val();
var cust_doa = $(formName+" #cust_doa").val();
var gstNumber = $(formName+" #cust_gstNumber").val();
email = email.toLowerCase();
var emailRegex = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
if(1==1)
{
if(name == '') { $(formName+' #custName_Ebox').html('Please Enter Customer Name'); counter = 0; }
if(mobile == "") { $(formName+" #custMobile_Ebox").html('Please Enter Mobile Number'); counter = 0; }
else
{
var msg = checkMobileFormat(mobile);
if(msg != true) { $(formName+" #custMobile_Ebox").html(msg); counter = 0; }
}
if(email != "")
{
var msg = checkEmailFormat(email);
if(msg != true) { $(formName+" #custEmail_Ebox").html(msg); counter = 0; }
}
if(paymentType == 'Telephone' || paymentType == 'Credit')
{
if(address == '') { $(formName+' #custAddress_Ebox').html('Please Enter Customer Address'); counter = 0; }
}
}
if(counter ==0 ) { return false;}
else
{
amountDue = amountDue.replace(',','');
var dataArr = '&cust_name='+name+'&cust_mobile='+mobile+'&cust_email='+email+'&cust_address='+address;
dataArr += '&cust_gstNumber='+gstNumber+'&cust_dob='+cust_dob+'&cust_doa='+cust_doa+'&ordStaus='+paymentType;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/customerInfo.php?mod=updateCustInfo"+dataArr,
success: function(){ }
});
var paymentType = paymentType.toUpperCase();
if(pressButtonFlag == 1)
{
$(formName+" #pressButtonFlag").val('0');
if(paymentType == 'HOLD') { cartOrderCompleteAction('1'); }
else if(paymentType == 'ESTIMATION') { cartOrderCompleteAction('2'); }
else if(paymentType == 'PAYMENT') { cartSalePaymentModal(amountDue); }
else if(paymentType == 'CREDIT') { cartSalePaymentModal(amountDue); }
else if(paymentType == 'TELEPHONE') { setCartActiveTable('Telephone'); }
else if(paymentType == 'RETAIL SALE') { setCartActiveTable('Retail Sale'); }
else if(paymentType == 'ESTIMATION') { setCartActiveTable('Estimation'); }
else if(paymentType == 'PAYMENT_RETURN'){ cartReturnRefundModal(amountDue); }
else if(paymentType == 'CREDIT_RETURN') { cartReturnRefundModal(amountDue); }
else { eModal.close(); }
}
else
{
var showMsg = 'warning@@@@Please Wait For Processing';
getDisplayAlertMsg(showMsg);
}
}
}
// Customer Information Validation Form
function validateSkipCartCustInfo()
{
var counter = 1;
var formName = '#customerInfoForm';
var pressButtonFlag = $(formName+" #pressButtonFlag").val();
var paymentType = $(formName+" #paymentType").val();
var amountDue = $(formName+" #amountDue").val();
var mobile = $(formName+" #cust_mobile").val();
var name = $(formName+" #cust_name").val();
var email = $(formName+" #cust_email").val();
var address = $(formName+" #cust_address").val();
var cust_dob = $(formName+" #cust_dob").val();
var cust_doa = $(formName+" #cust_doa").val();
var gstNumber = $(formName+" #cust_gstNumber").val();
email = email.toLowerCase();
var emailRegex = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
if(paymentType == 'Telephone' || paymentType == 'Credit')
{
if(mobile == "") { $(formName+" #custMobile_Ebox").html('Please Enter Mobile Number'); counter = 0; }
else
{
var msg = checkMobileFormat(mobile);
if(msg != true) { $(formName+" #custMobile_Ebox").html(msg); counter = 0; }
}
if(email != "")
{
var msg = checkEmailFormat(email);
if(msg != true) { $(formName+" #custEmail_Ebox").html(msg); counter = 0; }
}
if(name == '') { $(formName+' #custName_Ebox').html('Please Enter Customer Name'); counter = 0; }
if(address == '') { $(formName+' #custAddress_Ebox').html('Please Enter Customer Address'); counter = 0; }
}
else
{
if(email != "")
{
var msg = checkEmailFormat(email);
if(msg != true) { $(formName+" #custEmail_Ebox").html(msg); counter = 0; }
}
if(mobile != '')
{
var msg = checkMobileFormat(mobile);
if(msg != true) { $(formName+" #custMobile_Ebox").html(msg); counter = 0; }
}
}
if(counter ==0 ) { return false;}
else
{
amountDue = amountDue.replace(',','');
var dataArr = '&cust_name='+name+'&cust_mobile='+mobile+'&cust_email='+email+'&cust_address='+address;
dataArr += '&cust_gstNumber='+gstNumber+'&cust_dob='+cust_dob+'&cust_doa='+cust_doa+'&ordStaus='+paymentType;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/customerInfo.php?mod=updateCustInfo"+dataArr,
success: function(){ }
});
var paymentType = paymentType.toUpperCase();
if(pressButtonFlag == 1)
{
$(formName+" #pressButtonFlag").val('0');
if(paymentType == 'HOLD') { cartOrderCompleteAction('1'); }
else if(paymentType == 'ESTIMATION') { cartOrderCompleteAction('2'); }
else if(paymentType == 'PAYMENT') { cartSalePaymentModal(amountDue); }
else if(paymentType == 'CREDIT') { cartSalePaymentModal(amountDue); }
else if(paymentType == 'TELEPHONE') { setCartActiveTable('Telephone'); }
else if(paymentType == 'RETAIL SALE') { setCartActiveTable('Retail Sale'); }
else if(paymentType == 'ESTIMATION') { setCartActiveTable('Estimation'); }
else if(paymentType == 'PAYMENT_RETURN'){ cartReturnRefundModal(amountDue); }
else if(paymentType == 'CREDIT_RETURN') { cartReturnRefundModal(amountDue); }
else { eModal.close(); }
}
else
{
var showMsg = 'warning@@@@Please Wait For Processing';
getDisplayAlertMsg(showMsg);
}
}
}
/* --------------------- Sale Cart Auto Suggestion ----------------- */
function cartProductEditCancel()
{
document.getElementById('cartItemEditDiv').style.display = "none";
document.getElementById('itemRetailDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
if($(window).width() <= 767)
{
showCartDiv();
}
}
// Get Scan Product Auto Suggestion List
function cartSaleProductSuggestion()
{
var min_length = 0;
var keyword = $('#productSearchForm #scanProBarcode').val();
if (keyword.length > min_length)
{
//alert(main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleProductSearch&keyword="+keyword);
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleProductSearch&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#productSearchForm #cartSaleProSuggestionList').hide();
$('#productSearchForm #cartSaleProSuggestionList').html('');
}
else
{
$('#productSearchForm #cartSaleProSuggestionList').show();
$('#productSearchForm #cartSaleProSuggestionList').html(response);
}
}
});
}
else
{
$('#productSearchForm #cartSaleProSuggestionList').hide();
$('#productSearchForm #cartSaleProSuggestionList').html('');
}
}
function addSaleCartProduct(proUpc,foucusType,inventory_id)
{
if(proUpc !='')
{
console.log(main_pos_root+"cart_update.php?modeType=addSaleCartProduct&proUpc="+proUpc+'&inventory_id='+inventory_id);
var start = (new Date()).getTime();
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=addSaleCartProduct&proUpc="+proUpc+'&inventory_id='+inventory_id,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
if(res_val.length >2)
{
console.log(res_val[2]);
if(res_val[2] !='' && res_val[2] =='MultipleInventory'){ getMultipleInventoryProModal(proUpc); }
if(res_val[2] !='' && res_val[2] =='NewProduct') { addNewProductForm(); }
if(res_val[2] !='' && res_val[2] =='CustomizeProduct') { getCustomizeProductModal(proUpc,inventory_id); }
if(res_val[2] !='' && res_val[2] =='ComboProduct') { getComboProductModal(proUpc,inventory_id); }
}
else
{
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
}
});
var end = (new Date()).getTime();
console.log("Add To cart executed in " + (end - start) + "ms")
}
if(parseInt(foucusType) == 1)
{
$('#productSearchForm #cartSaleProSuggestionList').hide();
$('#productSearchForm #cartSaleProSuggestionList').html('');
$('#productSearchForm #scanProBarcode').val('');
$('#productSearchForm #scanProBarcode').focus();
}
//console.log('Result Close'+$.now());
}
/* --------------------- Multiple Inventory Poduct Modal ----------------- */
function getMultipleInventoryProModal(proUpc)
{
//console.log(main_pos_root+"modal/product_modal.php?modeType=CustomizeProModal&proUpc="+proUpc);
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=multipleInventoryProModal&proUpc="+proUpc,
title : 'Add Product ( Multiple Inventory )',
size: eModal.size.lgs,
buttons: [ {text: 'Close', style: 'default ', close: true } ],
};
return eModal.ajax(options);
}
/* --------------------- Customize Poduct Modal ----------------- */
function getCustomizeProductModal(proUpc,inventory_id)
{
//console.log(main_pos_root+"modal/product_modal.php?modeType=CustomizeProModal&proUpc="+proUpc);
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=CustomizeProModal&proUpc="+proUpc+'&inventory_id='+inventory_id,
title : 'Add Product ( Customize Product )',
size: eModal.size.lgs,
buttons: [ {text: 'Close', style: 'default ', close: true } ],
};
return eModal.ajax(options);
}
function addSaleCustomizeProduct(product_id,pro_customize_id,inventory_id)
{
if(product_id !='' && pro_customize_id !='' && inventory_id !='')
{
var dataArr = '&product_id='+product_id+'&pro_customize_id='+pro_customize_id+'&inventory_id='+inventory_id;
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=addSaleCustomizeProduct"+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
}
/* --------------------- Combo Poduct Modal ----------------- */
function getComboProductModal(proUpc,inventory_id)
{
var dataArr = '&proUpc='+proUpc+'&inventory_id='+inventory_id;
var options = {
url: main_pos_root+"modal/product_modal.php?modeType=comboProductModal"+dataArr,
title : 'Add Combo Product',
size: eModal.size.lgs,
buttons: [
{text: 'ADD', style: 'primary ', close: false, click: validateAddSaleComboProduct },
{text: 'Cancel', style: 'default ', close: true },
],
};
return eModal.ajax(options);
}
function validateAddSaleComboProduct()
{
var formName = '#addSaleComboProItem';
var comboProItem = new Array();
var j = 0;
var counter = 1;
var product_id = $(formName +" #product_id").val();
var inventory_id = $(formName +" #inventory_id").val();
var comboProCount = $(formName +" #comboProCount").val();
for (var i=1; i <=comboProCount; i++ )
{
var comboItemMaxQty = $(formName +" #comboItemMaxQty_"+i).val();
var itemSelectedCount = 0;
$.each($(formName +" a[name='comboItemPro_"+i+"[]']"), function()
{
var comboProItemId = $(this).attr("id");
var comboProItemIdArr = comboProItemId.split("_");
var comboItemSort = comboProItemIdArr[1];
var comboItemProId = comboProItemIdArr[2];
var customizeProId = comboProItemIdArr[3];
var proQtyValue = $(formName+ " #"+comboProItemId).html();
itemSelectedCount = parseInt(itemSelectedCount) + parseInt(proQtyValue);
if(parseInt(proQtyValue) >0)
{
comboProItem[j] = comboItemSort+'@@'+comboItemProId+'@@'+customizeProId+'@@'+proQtyValue
j++;
}
});
if(itemSelectedCount != comboItemMaxQty)
{
$(formName +" #comboItem_"+i+"_EBox").html('Please Choose Any'+comboItemMaxQty);
counter = 0;
}
}
if(counter ==0 ) { return false;}
else
{
//console.log(main_pos_root+"cart_update.php?modeType=addSaleComboProduct&product_id="+product_id+'&combo_pro_item='+comboProItem);
var dataArr = '&product_id='+product_id+'&inventory_id='+inventory_id+'&combo_pro_item='+comboProItem
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=addSaleComboProduct"+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
}
function increaseValuecart(field_id)
{
var proQtyValue = $("#addSaleComboProItem #"+field_id).html();
proQtyValue = parseInt(proQtyValue);
proQtyValue = isNaN(proQtyValue) ? 0 : proQtyValue;
proQtyValue++;
$("#addSaleComboProItem #"+field_id).html(proQtyValue);
}
function decreaseValuecart(field_id)
{
var proQtyValue = $("#addSaleComboProItem #"+field_id).html();
proQtyValue = parseInt(proQtyValue);
proQtyValue = isNaN(proQtyValue) ? 0 : proQtyValue;
proQtyValue < 1 ? proQtyValue = 1 : '';
proQtyValue--;
$("#addSaleComboProItem #"+field_id).html(proQtyValue);
}
/* --------------------- Sale Cart ----------------- */
function saleCartEmpty()
{
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=emptycartProduct",
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartProductEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function cartProductDelete(product_id,date_added)
{
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=cartProductDelete&product_id="+product_id+"&date_added="+date_added,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartProductEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function cartProductEditScreen(product_id,date_added,editType)
{
document.getElementById('itemRetailDiv').style.display = "none";
document.getElementById('cartItemEditDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
$("#cart_"+product_id).addClass("cartProEdit");
if($(window).width() <=767) { hideCartDiv(); }
var dataArr = '&product_id='+product_id+'&date_added='+date_added+'&editType='+editType;
//console.log(main_pos_root+"ajax/getlocalsetting.php?&mod=cartProEditScreen"+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=cartProEditScreen"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
$("#cartItemEditDiv").html(result);
}
});
}
function setCartEditVal(editType,inputVal)
{
if(editType == 'cartProQty')
{
var existValue = $("#cartQtyUpdateForm #cartProQty").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 4) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 4) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 3 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#cartQtyUpdateForm #cartProQty").val(existValue);
}
if(editType == 'cartProPrice')
{
var existValue = $("#cartPriceUpdateForm #cartProPrice").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#cartPriceUpdateForm #cartProPrice").val(existValue);
}
if(editType == 'cartProDisc' || editType == 'cartProDiscPer' || editType == 'cartProDiscFix')
{
var existValue = $("#cartDiscUpdateForm #cartProDisc").val();
var proDiscType = $("#cartDiscUpdateForm #proDiscType").val();
var discLength = 2;
if(proDiscType == 'Fixed') { discLength = 4; }
if(editType != 'cartProDisc')
{
$("#cartDiscUpdateForm #cartProDisc").val(inputVal);
}
else
{
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < discLength) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == discLength) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#cartDiscUpdateForm #cartProDisc").val(existValue);
}
}
}
function cartEditValueUpdate(editType)
{
var counter = 1;
var errorMsg = '';
if(editType == 'cartProQty')
{
var product_id = $("#cartQtyUpdateForm #product_id").val();
var add_dateTime = $("#cartQtyUpdateForm #add_dateTime").val();
var product_qty = $("#cartQtyUpdateForm #cartProQty").val();
var modeType = 'cartProQtyUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_qty='+product_qty
}
if(editType == 'cartProPrice')
{
var product_id = $("#cartPriceUpdateForm #product_id").val();
var add_dateTime = $("#cartPriceUpdateForm #add_dateTime").val();
var product_price = $("#cartPriceUpdateForm #cartProPrice").val();
if(product_price == "") { errorMsg = 'Please Enter Product Price'; counter = 0; }
else if(isNaN(product_price)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(product_price) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'cartProPriceUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_price='+product_price
}
if(editType == 'cartProDisc')
{
var product_id = $("#cartDiscUpdateForm #product_id").val();
var add_dateTime = $("#cartDiscUpdateForm #add_dateTime").val();
var proDiscType = $("#cartDiscUpdateForm #proDiscType").val();
var product_disc = $("#cartDiscUpdateForm #cartProDisc").val();
var product_price = $("#cartDiscUpdateForm #product_price").val();
if(proDiscType == 'Fixed')
{
if(product_disc == "") { errorMsg = 'Please Enter Product Discount'; counter = 0; }
else if(isNaN(product_disc)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(product_disc) <0) { errorMsg = 'Greater than and equal to zero'; counter = 0; }
else if(parseFloat(product_disc) > product_price) { errorMsg = 'Less than Product Price'; counter = 0; }
product_disc = (parseFloat(product_disc).toFixed(2) *100)/parseFloat(product_price).toFixed(2);
product_disc = parseFloat(product_disc).toFixed(2);
}
else
{
if(product_disc == "") { errorMsg = 'Please Enter Product Discount'; counter = 0; }
else if(isNaN(product_disc)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(product_disc) <0) { errorMsg = 'Greater than and equal to zero'; counter = 0; }
else if(parseFloat(product_disc) >100) { errorMsg = 'Less than and equal to 100 %'; counter = 0; }
}
var modeType = 'cartProDiscUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_disc='+product_disc
}
if(editType == 'cartProTopping')
{
var product_id = $("#cartToppingUpdateForm #product_id").val();
var add_dateTime = $("#cartToppingUpdateForm #add_dateTime").val();
var topping_selection = $("#cartToppingUpdateForm #topping_selection").val();
var topping_price_type = $("#cartToppingUpdateForm #topping_price_type").val();
var proToppingCheckBox = 'cartProTopping_'+product_id+'[]';
var proExraToppingCheckBox = 'cartProExtraTopping_'+product_id+'[]';
var proTopping = new Array();
var proExtraTopping = new Array();
var i = 0;
var j = 0;
$.each($("#cartToppingUpdateForm input[name='"+proToppingCheckBox+"']:checked"), function()
{
proTopping[i] = $(this).val(); i++;
});
$.each($("#cartToppingUpdateForm input[name='"+proExraToppingCheckBox+"']:checked"), function()
{
proExtraTopping[j] = $(this).val(); j++;
});
if(topping_selection >0 && proTopping.length >0 && parseInt(topping_selection) < proTopping.length)
{
errorMsg = 'Please Select Any '+topping_selection+' Topping'; counter = 0;
}
var modeType = 'cartProToppingUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&proTopping='+proTopping+'&proExtraTopping='+proExtraTopping;
dataArr += '&topping_price_type='+topping_price_type
}
if(editType == 'cartProComboTopping')
{
var formName = '#cartComboToppingUpdateForm';
var product_id = $(formName+ " #product_id").val();
var add_dateTime = $(formName+ " #add_dateTime").val();
var comboItemCount = $(formName+ " #comboItemCount").val();
var modeType = 'cartProComboToppingUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&comboItemCount='+comboItemCount;
for (var itemRow =1; itemRow <=comboItemCount; itemRow++ )
{
var itemRowArr = new Array();
var k = 0;
$.each($(formName+ " input[name='comboItemProId_"+itemRow+"[]']"), function()
{
var itemProId = $(this).val();
itemRowArr[k] = itemProId;
k++;
var toppingSelectionField = 'comboItemToppingSelection_'+itemRow+'_'+itemProId;
var toppingPriceTypeField = 'comboItemToppingPriceType_'+itemRow+'_'+itemProId;
var comboProToppingCheckBox = 'cartComboProTopping_'+itemRow+"_"+itemProId+'[]';
var comboProExraToppingCheckBox = 'cartComboProExtraTopping_'+itemRow+"_"+itemProId+'[]';
var proToppingField = 'proTopping_'+itemRow+"_"+itemProId;
var proExtraToppingField = 'proExtraTopping_'+itemRow+"_"+itemProId;
var proTopping = new Array();
var proExtraTopping = new Array();
var topping_selection = 0;
var topping_price_type = 1;
var i = 0;
var j = 0;
if ($(toppingSelectionField).length) { topping_selection = $(formName+ " #"+toppingSelectionField).val(); }
if ($(toppingSelectionField).length) { topping_price_type = $(formName+ " #"+toppingPriceTypeField).val(); }
$.each($(formName+ " input[name='"+comboProToppingCheckBox+"']:checked"), function() { proTopping[i] = $(this).val(); i++; });
$.each($(formName+ " input[name='"+comboProExraToppingCheckBox+"']:checked"), function() { proExtraTopping[j] = $(this).val(); j++; });
if(topping_selection >0 && proTopping.length >0 && parseInt(topping_selection) < proTopping.length)
{
errorMsg = 'Please Select proper Topping on Items'; counter = 0;
}
dataArr += '&'+toppingPriceTypeField+'='+topping_price_type;
dataArr += '&'+proToppingField+'='+proTopping + '&'+proExtraToppingField+'='+proExtraTopping;
});
dataArr += '&itemRowIdList_'+itemRow+'='+itemRowArr
}
}
if(counter ==0)
{
var displayMsg = 'warning@@@@'+errorMsg;
getDisplayAlertMsg(displayMsg);
}
else
{
console.log(main_pos_root+"cart_update.php?modeType="+modeType+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType="+modeType+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartProductEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
/* --------------------- Sale Payment ----------------- */
function cartSalePaymentModal(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
var options = {
url: main_pos_root+"modal/payment_detail.php?modeType=cartSalePayment&amount_due="+amount_due,
title :'Payment Information Sale Amount Due : '+amount_due+'',
size: eModal.size.lgs,
buttons: [
{text: 'Close', style: 'default ', close: true },
{text: 'Complete', style: 'primary ', close: false , click: checkSaleCartPaymentComplete }
],
};
return eModal.ajax(options);
}
function cartSaleAddPayment()
{
var counter = 1;
var cardType = cardNumber = transactionId = '';
var formName = '#add_payment_form';
var paymentType = $(formName +' input[name="payment_type"]:checked').val();
var amount_tendered = $(formName +" #amount_tendered").val();
if(amount_tendered == '') { $(formName +' #amount_tendered_EBox').html('Please Enter Amount'); counter = 0; }
else if(parseFloat(amount_tendered)== 0){ $(formName +' #amount_tendered_EBox').html('Please Enter Amount'); counter = 0; }
if(paymentType !='' && paymentType == 'Card')
{
var cardType = $(formName +' input[name="cardType"]:checked').val();
var cardNumber = $(formName +" #cardNumber").val();
var transactionId = $(formName +" #transactionId").val();
if(cardType === undefined || cardType == ''){ cardType = 'Visa'; }
if(cardNumber == '') { $(formName +' #cardNumber_EBox').html('Enter Card Last Four Digit'); counter = 0; }
if(transactionId == '') { $(formName +' #transactionId_EBox').html('Enter Transaction ID'); counter = 0; }
if(cardNumber != '' && cardNumber.length != 4) { $(formName +' #cardNumber_EBox').html('Enter Only Four Digit'); counter = 0; }
}
if(counter ==0 ) { return false;}
else
{
if(parseFloat(amount_tendered) < 0) { amount_tendered = amount_tendered *-1;}
var dataArr = '&payment_type='+paymentType+'&amount_tendered='+amount_tendered;
dataArr += '&card_type='+cardType+'&card_number='+cardNumber+'&transaction_id='+transactionId;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/payment_info_cart.php?mod=CartSaleAddPayment"+dataArr,
success: function(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
cartSalePaymentModal(amount_due);
}
});
}
}
function cartSaleDeletePayment(payment_type)
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/payment_info_cart.php?mod=cartSaleDeletePayment&payment_type="+payment_type,
async : false,
success: function(amount_due)
{
amount_due = parseFloat(amount_due).toFixed(2);
cartSalePaymentModal(amount_due);
}
});
}
function checkSaleCartPaymentComplete()
{
var ordComplete = $("#add_payment_form #ordComplete").val();
$.ajax({
type : "POST",
url: main_pos_root+"ajax/payment_info_cart.php?mod=checkSalePaymentComplete",
success: function(amount_due)
{
amount_due = parseFloat(amount_due).toFixed(2);
if(amount_due >0)
{
cartSalePaymentModal(amount_due); }
else
{
if(ordComplete ==1)
{
$("#add_payment_form #ordComplete").val('0');
cartOrderCompleteAction('5');
}
else
{
var showMsg = 'warning@@@@Please Wait For Processing';
getDisplayAlertMsg(showMsg);
}
}
}
});
}
function chkSaleCreditNote()
{
var counter = 1;
var cn_id = $("#add_payment_form #cn_id").val();
if(cn_id == '') { $('#add_payment_form #cn_id_EBox').html('Please Enter Credit Note Id'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/payment_info_cart.php?mod=chkCreditNote&id="+cn_id,
async : false,
success:function(result)
{
if(!isNaN(result))
{
$("#add_payment_form #amount_tendered").val(result.trim());
$("#add_payment_form #cn_id_EBox").html('');
addPayment();
}
else
{
$("#add_payment_form #cn_id_EBox").html(result);
return false;
}
}
});
}
}
function cartOrderCompleteAction(orderStatus)
{
var mod = 'order_suspended';
if(orderStatus == 1) { mod = 'order_suspended'; }
else if(orderStatus == 2) { mod = 'estimation_order'; }
else if(orderStatus == 5) { mod = 'sale_order'; }
//console.log(main_pos_root+"ajax/cart_order_sale.php?mod="+mod+"&order_status="+orderStatus);
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cart_order_sale.php?mod="+mod+"&order_status="+orderStatus,
success: function(msg)
{
var resArr = msg.split('####');
$("#refereshDiv").html(resArr[1]);
eModal.alert(resArr[0], 'Thanks to support Local Business');
}
});
}
function currentRunningCartPrint()
{
var mod = 'estimation_order';
var orderStatus = '2';
//alert(main_pos_root+"ajax/cart_order_sale.php?mod="+mod+"&order_status="+orderStatus);
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cart_order_sale.php?mod="+mod+"&order_status="+orderStatus,
success: function(msg)
{
$("#refereshDiv").html(msg);
eModal.alert(resArr[0], 'Thanks to support Local Business');
}
});
}
/* --------------------- Telephone Fucntion ----------------- */
function setCartActiveTable(tableViewName)
{
$.ajax({
type : "POST",
url: main_pos_root+"ajax/tableOrderDetail.php?mod=Hold&newTable="+tableViewName,
success:function(msg)
{
$("#refereshDiv").html(msg.trim());
}
});
// close the Modal
eModal.close();
}
/* ********************** Coupon Function **************** */
function storeCouponModal()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=StoreCouponList",
title : 'Active Promo Code',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function storeCouponApplied(store_coupon_id)
{
$.ajax({
type : "POST",
url: main_pos_root+"cart_update.php?modeType=cartCouponApplied&store_coupon_id="+store_coupon_id,
success:function(result)
{
result = result.trim();
var dataArr = result.split("####");
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
getDisplayAlertMsg(dataArr[1]);
eModal.close();
}
});
}
function appliedCouponRemove(store_coupon_id)
{
$.ajax({
type : "POST",
url: main_pos_root+"cart_update.php?modeType=removeAppliedCoupon&store_coupon_id="+store_coupon_id,
success:function(result)
{
result = result.trim();
var dataArr = result.split("####");
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
getDisplayAlertMsg(dataArr[1]);
eModal.close();
}
});
}
/* ********************** Cod Detail Function **************** */
// Get Store COD Order List
function codOrderList()
{
var options = {
url: main_pos_root+"modal/cod_order_detail.php?modeType=CodOrderList",
title :'Check-In Delivery Order',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// View COD Order Detail
function codOrderView(order_id)
{
var subTitle = 'Order Id : '+order_id+'';
console.log(main_pos_root+"modal/cod_order_detail.php?modeType=CodOrderDetail&order_id="+order_id);
var options = {
url: main_pos_root+"modal/cod_order_detail.php?modeType=CodOrderDetail&order_id="+order_id,
title :'Delivery Order Details '+subTitle,
size: eModal.size.lgs,
buttons: [
{text: 'Back', style: 'primary ', close: true, click: codOrderList },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function codOrderPayment(order_id,amount_due)
{
amount_due = parseFloat(amount_due).toFixed(2);
var subTitle = 'Amount Due : '+amount_due+'';
var options = {
url: main_pos_root+"modal/cod_order_detail.php?modeType=CodOrderPayment&amount_due="+amount_due+'&order_id='+order_id,
title :'Payment Information '+subTitle ,
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true, click: removeCodPaymentInfo },
{text: 'Complete', style: 'primary ', close: false , click: checkCodPaymentComplete }
],
};
return eModal.ajax(options);
}
function chkCODCreditNote()
{
var counter = 1;
var creditNoteId = $("#addCodPaymentForm #creditNoteId").val();
if(creditNoteId == '') { $('#addCodPaymentForm #creditNoteId_EBox').html('Please Enter Credit Note Id'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/payment_info_cart.php?mod=chkCreditNote&id="+creditNoteId,
async : false,
success:function(result)
{
if(!isNaN(result))
{
$("#addCodPaymentForm #amount_tendered").val(result.trim());
$("#addCodPaymentForm #creditNoteId_EBox").html('');
addCodPayemnt();
}
else
{
$("#addCodPaymentForm #creditNoteId_EBox").html(result);
return false;
}
}
});
}
}
function addCodPayemnt()
{
var counter = 1;
var paymentType = $('#addCodPaymentForm input[name="payment_type"]:checked').val();
var amount_tendered = $("#addCodPaymentForm #amount_tendered").val();
var order_id = $("#addCodPaymentForm #order_id").val();
if(amount_tendered == '') { $('#addCodPaymentForm #amount_tendered_EBox').html('Please Enter Amount'); counter = 0; }
else if(isNaN(amount_tendered)) { $('#addCodPaymentForm #amount_tendered_EBox').html('Please Enter Only Digit.'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
if(parseFloat(amount_tendered) < 0) { amount_tendered = amount_tendered *-1;}
var dataArr = '&payment_type='+paymentType+'&amount_tendered='+amount_tendered+'&order_id='+order_id;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cod_payment_info.php?mod=addCodPayment"+dataArr,
success: function(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
codOrderPayment(order_id,amount_due);
}
});
}
}
function deleteCodPayment(order_id,payment_type)
{
var dataArr = '&payment_type='+payment_type+'&order_id='+order_id;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cod_payment_info.php?mod=deleteCodPaymentType"+dataArr,
async : false,
success: function(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
codOrderPayment(order_id,amount_due);
}
});
}
function removeCodPaymentInfo()
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cod_payment_info.php?mod=removeCurrentCodPayment",
success: function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
function checkCodPaymentComplete()
{
var order_id = $("#addCodPaymentForm #order_id").val();
$.ajax({
type : "POST",
url: main_pos_root+"ajax/cod_payment_info.php?mod=checkCodPaymentComplete&order_id="+order_id,
success: function(amount_due)
{
amount_due = parseFloat(amount_due).toFixed(2);
if(amount_due >0) { codOrderPayment(order_id,amount_due); }
else{ completeCodPaymentInfo(order_id); }
}
});
}
function completeCodPaymentInfo(order_id)
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cod_payment_info.php?mod=updateCodPayment&order_id="+order_id,
success: function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
/* ********************** Hold Sale Function **************** */
function holdCurrentSaleOrder()
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/suspended_sales.php?mod=HoldCurrentSaleOrder",
success: function(result)
{
result = result.trim();
var resultArr = result.split("@@@@");
if(resultArr[0] == 1)
{
var amountDue = parseFloat(resultArr[1]).toFixed(2);
getCartCustInfoModal('Hold',amountDue);
}
else
{
var showMsg = 'warning@@@@'+resultArr[1];
getDisplayAlertMsg(showMsg);
}
}
});
}
// Suspended Order List
function storeHoldOrderListModal()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=StoreHoldSale",
title :'Suspended Sale',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Delete Suspended Order
function deleteHoldSaleOrder(order_id)
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/suspended_sales.php?mod=deleteHoldSale&order_id="+order_id,
success: function(msg)
{
// Display msg Function
getDisplayAlertMsg(msg.trim());
storeHoldOrderListModal();
}
});
}
function checkCurrentSaleCart(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/suspended_sales.php?mod=checkCurrentSaleCart",
success:function(msg)
{
var result = parseInt(msg.trim());
if(result >0)
{
var txtmessage = '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Unhold Order",
size: eModal.size.lgs,
label: "Ok",
};
return eModal.confirm(options)
.fail(function () { unsuspendHoldSaleOrder(order_id); });
}
else
{
// Unsuspend order
unsuspendHoldSaleOrder(order_id);
}
}
});
}
// Unsuspend order
function unsuspendHoldSaleOrder(order_id)
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/suspended_sales.php?mod=UnsuspendHoldSale&order_id="+order_id,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
getDisplayAlertMsg(dataArr[1]);
// close the Modal
eModal.close();
}
});
}
/* ---------------------------- -------------------- Kitchen Screen Function ---------------------------- -------------------- */
// update the Kitchen Prepare iten Status and SortingS
function updateKitchenStatus(order_id,product_id,dateTime,action_staus,sorting)
{
var dataArr = '&order_id='+order_id+'&product_id='+product_id+'&dateTime='+dateTime+'&status='+action_staus+'&sorting='+sorting;
$.ajax({
type : "GET",
url : main_pos_root+"ajax/kitchen_detail.php?mod=udpateStatus"+dataArr,
async : false,
success:function(result)
{ }
});
}
// Update the Kitchen Product List with Status
function kitchenDivContentRefresh()
{
$.ajax({
type: "GET",
url : main_pos_root+"ajax/kitchen_detail.php?mod=kitchenDivReferesh",
async : false,
success : function(result)
{
var result = result.trim();
var data_arr = result.split("####");
$('#sortable1').html(data_arr[0]);
$('#sortable2').html(data_arr[1]);
$('#sortable3').html(data_arr[2]);
$('#sortable4').html(data_arr[3]);
$('#sortable5').html(data_arr[4]);
}
});
}
// JavaScript Document
function saleReturnOrderId()
{
var options = {
url: main_pos_root+"modal/pos_modal.php?modeType=saleReturnModal",
title :'Return Order',
size: eModal.size.lgs,
buttons: [
{text: 'OK', style: 'primary ',close: false, click: validateSaleReturnOrderId },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
function validateSaleReturnOrderId()
{
var counter = 1;
var invoice_no = $("#returnOrderForm #orderId").val();
if(invoice_no == '') { $('#returnOrderForm #orderId_Ebox').html('Please Enter Order Invoice Id'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
$.ajax({
type : "POST",
url: main_pos_root+"cart_update.php?modeType=saleOrderReturn&invoice_no="+invoice_no,
success:function(result)
{
result = result.trim();
var dataArr = result.split('####');
if(dataArr.length == 1) { getDisplayAlertMsg(dataArr[0]); }
else
{
$("#refereshDiv").html(dataArr[0]);
// Display msg Function
getDisplayAlertMsg(dataArr[1]);
}
eModal.close();
}
});
}
}
function cartReturnProdEditCancel()
{
document.getElementById('cartItemEditDiv').style.display = "none";
document.getElementById('itemRetailDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
if($(window).width() <= 767)
{
showCartDiv();
}
}
// Get Scan Product Auto Suggestion List
function cartReturnProductSuggestion()
{
var min_length = 0;
var keyword = $('#productReturnSearchForm #scanProBarcode').val();
if (keyword.length > min_length)
{
//alert(main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleReturnProSearch&keyword="+keyword);
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleReturnProSearch&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#productReturnSearchForm #cartReturnProSuggestionList').hide();
$('#productReturnSearchForm #cartReturnProSuggestionList').html('');
}
else
{
$('#productReturnSearchForm #cartReturnProSuggestionList').show();
$('#productReturnSearchForm #cartReturnProSuggestionList').html(response);
}
}
});
}
else
{
$('#productReturnSearchForm #cartReturnProSuggestionList').hide();
$('#productReturnSearchForm #cartReturnProSuggestionList').html('');
}
}
function addReturnCartProduct(proUpc,foucusType)
{
if(proUpc !='')
{
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=addReturnCartProduct&proUpc="+proUpc,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
if(parseInt(foucusType) == 1)
{
$('#productReturnSearchForm #cartReturnProSuggestionList').hide();
$('#productReturnSearchForm #cartReturnProSuggestionList').html('');
$('#productReturnSearchForm #scanProBarcode').val('');
$('#productReturnSearchForm #scanProBarcode').focus();
}
}
function saleReturnCartEmpty()
{
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=saleReturnCartEmpty",
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartReturnProdEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function cartReturnProductDelete(product_id,date_added)
{
//alert(main_pos_root+"cart_update.php?modeType=addImageCartProduct&product_id="+product_id);
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType=cartReturnProductDelete&product_id="+product_id+"&date_added="+date_added,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartReturnProdEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function cartRetutnProEditScreen(product_id,date_added,editType)
{
document.getElementById('itemRetailDiv').style.display = "none";
document.getElementById('cartItemEditDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
$("#cart_"+product_id).addClass("cartProEdit");
if($(window).width() <=767) { hideCartDiv(); }
var dataArr = '&product_id='+product_id+'&date_added='+date_added+'&editType='+editType;
//alert(main_pos_root+"ajax/getlocalsetting.php?&mod=cartProEditScreen"+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=cartReturnProEditScreen"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
$("#cartItemEditDiv").html(result);
}
});
}
function setCartReturnEditVal(editType,inputVal)
{
if(editType == 'cartProQty')
{
var existValue = $("#cartQtyUpdateForm #cartProQty").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 4) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 4) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 3 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#cartQtyUpdateForm #cartProQty").val(existValue);
}
}
function cartReturnEditValueUpdate(editType)
{
var counter = 1;
var errorMsg = '';
if(editType == 'cartProQty')
{
var product_id = $("#cartQtyUpdateForm #product_id").val();
var add_dateTime = $("#cartQtyUpdateForm #add_dateTime").val();
var product_qty = $("#cartQtyUpdateForm #cartProQty").val();
var modeType = 'cartReturnProQtyUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_qty='+product_qty
}
if(counter ==0)
{
$displayMsg = 'warning@@@@'+errorMsg;
getDisplayAlertMsg(displayMsg);
}
else
{
$.ajax({
type : "GET",
url : main_pos_root+"cart_update.php?modeType="+modeType+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
cartProductEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
/* ********************** Return Payment Fucntion **************** */
function cartReturnRefundModal(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
var options = {
url: main_pos_root+"modal/payment_detail.php?modeType=cartReturnPayment&amount_due="+amount_due,
title :'Payment Refund Refund Amount Due : '+amount_due+'',
size: eModal.size.lgs,
buttons: [
{text: 'Close', style: 'default ', close: true },
{text: 'Complete', style: 'primary ', close: false , click: checkReturnPaymentComplete }
],
};
return eModal.ajax(options);
}
function addRefundPayemnt()
{
var counter = 1;
var formName = '#addRefundForm';
var paymentType = $(formName +' input[name="payment_type"]:checked').val();
var amount_tendered = $(formName +" #amount_tendered").val();
if(amount_tendered == '') { $(formName +' #amount_tendered_EBox').html('Please Enter Amount'); counter = 0; }
else if(parseFloat(amount_tendered)== 0){ $(formName +' #amount_tendered_EBox').html('Please Enter Amount'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
if(parseFloat(amount_tendered) < 0) { amount_tendered = amount_tendered *-1;}
var dataArr = '&payment_type='+paymentType+'&amount_tendered='+amount_tendered;
$.ajax({
type: "GET",
url: main_pos_root+"ajax/payment_info_cart.php?mod=CartSaleReturnAddPayment"+dataArr,
success: function(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
cartReturnRefundModal(amount_due);
}
});
}
}
function deleteRefundPayment(payment_type)
{
$.ajax({
type: "GET",
url: main_pos_root+"ajax/payment_info_cart.php?mod=CartSaleReturnDeletePayment&payment_type="+payment_type,
async : false,
success: function(amount_due)
{
amount_due = amount_due.trim();
amount_due = parseFloat(amount_due).toFixed(2);
cartReturnRefundModal(amount_due);
}
});
}
function checkReturnPaymentComplete()
{
$.ajax({
type : "POST",
url: main_pos_root+"ajax/payment_info_cart.php?mod=checkReturnPaymentComplete",
success: function(amount_due)
{
amount_due = parseFloat(amount_due).toFixed(2);
if(amount_due >0)
{
cartReturnRefundModal(amount_due);
}
else
{
cartReturnProcessComplete();
}
}
});
}
function cartReturnProcessComplete()
{
var orderStatus = '111';
//console.log(main_pos_root+"ajax/cart_order_sale.php?mod=return_order&order_status="+orderStatus);
$.ajax({
type: "GET",
url: main_pos_root+"ajax/cart_order_sale.php?mod=return_order&order_status="+orderStatus,
success: function(msg)
{
var resArr = msg.split('####');
$("#refereshDiv").html(resArr[1]);
eModal.alert(resArr[0], 'Thanks to support Local Business');
}
});
}
// JavaScript Document
// Vendor Stock selected Date Set
function getVendorStockSelectedDate()
{
var vendorStockDate = $('#stockSelDate').val();
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=VendorSelStockdate&vendorStockDate="+vendorStockDate,
async : false,
success:function(result)
{
}
});
vendorListScreen();
}
/*---------------------------Vendor Name Suggestion ------------------ */
function vendorListScreen()
{
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=vendorListScreen",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
//window.setTimeout(function(){ location.reload();},1);
}
// Get the Vendor Auto Suggestion List
function getVendorNameSuggestion()
{
var min_length = 0;
var keyword = $('#vendorSearchForm #scanVendor').val();
if (keyword.length > min_length)
{
//alert(main_pos_root+"ajax/getsuggestionList.php?mod=vendorNameSearch&keyword="+keyword);
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=vendorNameSearch&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#vendorSearchForm #vendorNameSuggestionList').hide();
$('#vendorSearchForm #vendorNameSuggestionList').html('');
}
else
{
$('#vendorSearchForm #vendorNameSuggestionList').show();
$('#vendorSearchForm #vendorNameSuggestionList').html(response);
}
}
});
}
else
{
$('#vendorSearchForm #vendorNameSuggestionList').hide();
$('#vendorSearchForm #vendorNameSuggestionList').html('');
}
}
// Get the Vendor Invoice List
function setVendorSuggestId(vendor_id)
{
$('#vendorSearchForm #vendorNameSuggestionList').hide();
$('#vendorSearchForm #vendorNameSuggestionList').html('');
if(vendor_id !='')
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?mod=vendorInvoiceList&vendor_id="+vendor_id,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
// View Vendor Ladger Report
function vendorLedgerReportList()
{
var options = {
url: main_pos_root+"modal/vendor_detail.php?modeType=LedgerReportList",
title :'Ledger Report',
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// View Vendor Invoice Detail
function getVendorInvoiceView(invoice_rec_id,invoice_number)
{
var title_info = 'Invoice Number : '+invoice_number+'';
var options = {
url: main_pos_root+"modal/vendor_detail.php?modeType=InvoiceDetail&invoice_rec_id="+invoice_rec_id,
title :'Invoice Details '+title_info,
size: eModal.size.lgs,
buttons: [
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Vendor Edit the Invoice
function vendorInvoiceEdit(invoice_rec_id)
{
var dataArr = '&invoice_rec_id='+invoice_rec_id;
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?&mod=vendorEditInvoice"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
getDisplayAlertMsg(res_val[1]);
window.setTimeout(function(){ location.reload();},1);
eModal.close();
}
});
}
// Add Vender Payment Modal
function vendorPaymentModal(vendor_id,debit_balance,invoice_no)
{
if (invoice_no === undefined) { invoice_no = ''; }
var dataArr = '&vendor_id='+vendor_id+'&invoice_no='+invoice_no;
var options = {
url: main_pos_root+"modal/vendor_detail.php?modeType=AddVenderPayment"+dataArr,
title : 'Amount Receive Debit Balance Rs.'+debit_balance +'',
size: eModal.size.lgs,
buttons: [
{text: 'Save', style: 'primary ',close: false, click: validateDebitAmount },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Validate Add Vender Payment Amount
function validateDebitAmount()
{
var counter = 1;
var vendor_id = $("#addDebitAmountForm #vendor_id").val();
var maxDedit = $("#addDebitAmountForm #maxDedit").val();
var invoice_no = $("#addDebitAmountForm #invoice_no").val();
var debitAmount = $("#addDebitAmountForm #debitAmount").val();
debitAmount = parseInt(debitAmount);
if(debitAmount == '') { $('#addDebitAmountForm #debitAmount_EBox').html('Enter the Debit Amount Receive '); counter = 0; }
else
{
if(isNaN(debitAmount)) { $('#addDebitAmountForm #debitAmount_EBox').html('Enter Only Digit '); counter = 0; }
else
{
if(parseInt(maxDedit) < parseInt(debitAmount))
{
$('#addDebitAmountForm #debitAmount_EBox').html('Amount Payment Must be Equal Maximum Debit');
counter = 0;
}
}
}
if(counter == 0 ) { return false;}
else
{
var dataArr = '&vendor_id='+vendor_id+'&invoice_no='+invoice_no+'&maxDedit='+maxDedit+'&debitAmount='+debitAmount;
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?mod=debitPayment"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
eModal.close();
}
});
}
}
// Get the Vendor Invoice Number Modal
function getStockReceiveInvoice()
{
var title_info = 'Receive Product';
var options = {
url: main_pos_root+"modal/vendor_detail.php?modeType=StockReceiveInvoice",
title :'Vendor Bill Detail '+title_info,
size: eModal.size.lgs,
buttons: [
{text: 'Ok', style: 'primary ',close: false, click: validateStockReceiveInvoice },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Validate the Invoice Modal
function validateStockReceiveInvoice()
{
var counter = 1;
var invoiceNumber = $("#stockReceiveForm #invoiceNumber").val();
if(invoiceNumber == '') { $('#stockReceiveForm #invoiceNumber_Ebox').html('Please Enter Invoice Number'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
var dataArr ='&invoiceNumber='+invoiceNumber;
//alert(main_pos_root+"ajax/getlocalsetting.php?&mod=vendorStockReceiveMode&"+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=vendorStockReceiveMode&"+dataArr,
async : false,
success :function(result)
{
result = result.trim();
var res_val = result.split("@@@@");
if(parseInt(res_val[0]) == 0)
{
$('#stockReceiveForm #invoiceNumber_Ebox').html(res_val[1]);
// Display msg Function
}
else
{
$("#refereshDiv").html(res_val[1]);
window.setTimeout(function(){ location.reload();},1);
eModal.close();
}
}
});
}
}
// Get the Vendor Invoice Number Modal
function getStockReturnInvoice()
{
var title_info = 'Return Product';
var options = {
url: main_pos_root+"modal/vendor_detail.php?modeType=StockReturnInvoice",
title :'Vendor Bill Detail '+title_info,
size: eModal.size.lgs,
buttons: [
{text: 'Ok', style: 'primary ',close: false, click: validateStockReturnInvoice },
{text: 'Cancel', style: 'default ', close: true }
],
};
return eModal.ajax(options);
}
// Validate the Invoice Modal
function validateStockReturnInvoice()
{
var counter = 1;
var invoiceNumber = $("#stockReturnForm #invoiceNumber").val();
if(invoiceNumber == '') { $('#stockReturnForm #invoiceNumber_Ebox').html('Please Enter Return Invoice Number'); counter = 0; }
if(counter ==0 ) { return false;}
else
{
var dataArr ='&invoiceNumber='+invoiceNumber;
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=vendorStockReturnMode&"+dataArr,
async : false,
success :function(result)
{
result = result.trim();
var res_val = result.split("@@@@");
if(parseInt(res_val[0]) == 0)
{
$('#stockReturnForm #invoiceNumber_Ebox').html(res_val[1]);
// Display msg Function
}
else
{
$("#refereshDiv").html(res_val[1]);
window.setTimeout(function(){ location.reload();},1);
eModal.close();
}
}
});
}
}
/*---------------------------Stock Receive Function ------------------ */
// Get Scan Product Auto Suggestion List
function cartStockProductSuggestion()
{
var min_length = 0;
var keyword = $('#stockSearchForm #scanProBarcode').val();
if (keyword.length > min_length)
{
//alert(main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleProductSearch&keyword="+keyword);
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=cartStockProductSearch&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#stockSearchForm #cartStockProSuggestionList').hide();
$('#stockSearchForm #cartStockProSuggestionList').html('');
}
else
{
$('#stockSearchForm #cartStockProSuggestionList').show();
$('#stockSearchForm #cartStockProSuggestionList').html(response);
}
}
});
}
else
{
$('#stockSearchForm #cartStockProSuggestionList').hide();
$('#stockSearchForm #cartStockProSuggestionList').html('');
}
}
function addStockCartProduct(proUpc,foucusType)
{
if(proUpc !='')
{
//alert(main_pos_root+"stock_cart_update.php?modeType=addStockCartProduct&proUpc="+proUpc);
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=addStockCartProduct&proUpc="+proUpc,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
if(res_val.length >2)
{
if(res_val[2] !='' && res_val[2] =='NewProduct') { addNewProductForm(); }
}
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
if(parseInt(foucusType) == 1)
{
$('#stockSearchForm #cartStockProSuggestionList').hide();
$('#stockSearchForm #cartStockProSuggestionList').html('');
$('#stockSearchForm #scanProBarcode').val('');
$('#stockSearchForm #scanProBarcode').focus();
}
}
function stockCartProEditCancel()
{
document.getElementById('cartItemEditDiv').style.display = "none";
document.getElementById('itemRetailDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
if($(window).width() <= 767)
{
showCartDiv();
}
}
function stockCartEmpty()
{
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=emptycartProduct",
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockCartProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function stockCartProductDelete(product_id,date_added)
{
//alert(main_pos_root+"stock_cart_update.php?modeType=stockCartProductDelete&product_id="+product_id+"&date_added="+date_added);
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=stockCartProductDelete&product_id="+product_id+"&date_added="+date_added,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockCartProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function stockCartProductEditScreen(product_id,date_added,editType)
{
document.getElementById('itemRetailDiv').style.display = "none";
document.getElementById('cartItemEditDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
$("#cart_"+product_id).addClass("cartProEdit");
if($(window).width() <=767) { hideCartDiv(); }
var dataArr = '&product_id='+product_id+'&date_added='+date_added+'&editType='+editType;
//alert(main_pos_root+"ajax/getlocalsetting.php?&mod=cartProEditScreen"+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=stockCartProEditScreen"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
$("#cartItemEditDiv").html(result);
}
});
}
function setStockCartEditVal(editType,inputVal)
{
if(editType == 'cartProQty')
{
var existValue = $("#stockCartQtyUpdateForm #cartProQty").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 4) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 4) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 3 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartQtyUpdateForm #cartProQty").val(existValue);
}
if(editType == 'cartProMrp')
{
var existValue = $("#stockCartMrpUpdateForm #cartProMrp").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartMrpUpdateForm #cartProMrp").val(existValue);
}
if(editType == 'cartProPurchase')
{
var existValue = $("#stockCartPurchaseUpdateForm #cartProPurchase").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartPurchaseUpdateForm #cartProPurchase").val(existValue);
}
if(editType == 'cartProPrice')
{
var existValue = $("#stockCartPriceUpdateForm #cartProPrice").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartPriceUpdateForm #cartProPrice").val(existValue);
}
if(editType == 'cartProNetAmount')
{
var existValue = $("#stockCartNetAmtUpdateForm #cartProNetAmount").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartNetAmtUpdateForm #cartProNetAmount").val(existValue);
}
}
function stockCartEditValueUpdate(editType)
{
var counter = 1;
var errorMsg = '';
if(editType == 'cartProQty')
{
var product_id = $("#stockCartQtyUpdateForm #product_id").val();
var add_dateTime = $("#stockCartQtyUpdateForm #add_dateTime").val();
var product_qty = $("#stockCartQtyUpdateForm #cartProQty").val();
var modeType = 'stockCartProQtyUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_qty='+product_qty
}
if(editType == 'cartProMrp')
{
var product_id = $("#stockCartMrpUpdateForm #product_id").val();
var add_dateTime = $("#stockCartMrpUpdateForm #add_dateTime").val();
var pro_mrp = $("#stockCartMrpUpdateForm #cartProMrp").val();
if(pro_mrp == "") { errorMsg = 'Please Enter Product MRP'; counter = 0; }
else if(isNaN(pro_mrp)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(pro_mrp) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'stockCartProMrpUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&pro_mrp='+pro_mrp
}
if(editType == 'cartProPurchase')
{
var product_id = $("#stockCartPurchaseUpdateForm #product_id").val();
var add_dateTime = $("#stockCartPurchaseUpdateForm #add_dateTime").val();
var pro_purchase = $("#stockCartPurchaseUpdateForm #cartProPurchase").val();
if(pro_purchase == "") { errorMsg = 'Please Enter Product Purchase'; counter = 0; }
else if(isNaN(pro_purchase)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(pro_purchase) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'stockCartProPurchaseUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&pro_purchase='+pro_purchase
}
if(editType == 'cartProPrice')
{
var product_id = $("#stockCartPriceUpdateForm #product_id").val();
var add_dateTime = $("#stockCartPriceUpdateForm #add_dateTime").val();
var product_price = $("#stockCartPriceUpdateForm #cartProPrice").val();
if(product_price == "") { errorMsg = 'Please Enter Product Price'; counter = 0; }
else if(isNaN(product_price)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(product_price) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'stockCartProPriceUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_price='+product_price
}
if(editType == 'cartProNetAmount')
{
var product_id = $("#stockCartNetAmtUpdateForm #product_id").val();
var add_dateTime = $("#stockCartNetAmtUpdateForm #add_dateTime").val();
var net_amount = $("#stockCartNetAmtUpdateForm #cartProNetAmount").val();
if(net_amount == "") { errorMsg = 'Please Enter Product Total Price'; counter = 0; }
else if(isNaN(net_amount)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(net_amount) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'stockCartProNetAmountUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&net_amount='+net_amount
}
if(counter ==0)
{
$displayMsg = 'warning@@@@'+errorMsg;
getDisplayAlertMsg(displayMsg);
}
else
{
//alert(main_pos_root+"stock_cart_update.php?modeType="+modeType+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType="+modeType+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockCartProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
// Vendor Invoice Action ( Complete Invoice and Cancel Invoice)
function vendorStockReceiveComplete()
{
var txtmessage = '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Stock Receving Invoice Complete",
size: eModal.size.lgs,
label: "Yes",
};
return eModal.confirm(options)
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?&mod=vendorStockReceiveComplete",
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
});
}
function vendorStockReceiveCancel()
{
var txtmessage = '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Stock Receving Invoice Cancel",
size: eModal.size.lgs,
label: "Yes",
};
return eModal.confirm(options)
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?&mod=vendorStockReceiveCancel",
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
});
}
/*---------------------------Stock Return Function ------------------ */
// Get Scan Product Auto Suggestion List
function returnStockProductSuggestion()
{
var min_length = 0;
var keyword = $('#stockReturnSearchForm #scanProBarcode').val();
if (keyword.length > min_length)
{
//alert(main_pos_root+"ajax/getsuggestionList.php?mod=cartSaleProductSearch&keyword="+keyword);
$.ajax({
type: "GET",
url : main_pos_root+"ajax/getsuggestionList.php?mod=returnStockProductSuggestion&keyword="+keyword,
success : function(response)
{
if(response == "")
{
$('#stockReturnSearchForm #returnStockProSuggestionList').hide();
$('#stockReturnSearchForm #returnStockProSuggestionList').html('');
}
else
{
$('#stockReturnSearchForm #returnStockProSuggestionList').show();
$('#stockReturnSearchForm #returnStockProSuggestionList').html(response);
}
}
});
}
else
{
$('#stockReturnSearchForm #returnStockProSuggestionList').hide();
$('#stockReturnSearchForm #returnStockProSuggestionList').html('');
}
}
function addReturnStockCartProduct(proUpc,foucusType)
{
if(proUpc !='')
{
//alert(main_pos_root+"stock_cart_update.php?modeType=addStockCartProduct&proUpc="+proUpc);
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=addReturnStockCartProduct&proUpc="+proUpc,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
if(parseInt(foucusType) == 1)
{
$('#stockReturnSearchForm #returnStockProSuggestionList').hide();
$('#stockReturnSearchForm #returnStockProSuggestionList').html('');
$('#stockReturnSearchForm #scanProBarcode').val('');
$('#stockReturnSearchForm #scanProBarcode').focus();
}
}
function stockRetuenProEditCancel()
{
document.getElementById('cartItemEditDiv').style.display = "none";
document.getElementById('itemRetailDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
if($(window).width() <= 767)
{
showCartDiv();
}
}
function stockReturnCartEmpty()
{
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=emptyReturncartProduct",
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockRetuenProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function stockReturnCartProDelete(product_id,date_added)
{
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType=stockReturnCartProDelete&product_id="+product_id+"&date_added="+date_added,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockRetuenProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
function stockReturnProEditScreen(product_id,date_added,editType)
{
document.getElementById('itemRetailDiv').style.display = "none";
document.getElementById('cartItemEditDiv').style.display = "block";
$(".cartDivBreakHr").removeClass("cartProEdit");
$("#cart_"+product_id).addClass("cartProEdit");
if($(window).width() <=767) { hideCartDiv(); }
var dataArr = '&product_id='+product_id+'&date_added='+date_added+'&editType='+editType;
//alert(main_pos_root+"ajax/getlocalsetting.php?&mod=cartProEditScreen"+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?&mod=stockReturnProEditScreen"+dataArr,
async : false,
success:function(result)
{
result = result.trim();
$("#cartItemEditDiv").html(result);
}
});
}
function setStockReturnEditVal(editType,inputVal)
{
if(editType == 'cartProQty')
{
var existValue = $("#stockCartQtyUpdateForm #cartProQty").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 4) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 4) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 3 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartQtyUpdateForm #cartProQty").val(existValue);
}
if(editType == 'cartProPurchase')
{
var existValue = $("#stockCartPurchaseUpdateForm #cartProPurchase").val();
if(inputVal == '-1') // Backspace // Remoce one Digit
{
existValue = existValue.substring(0, existValue.length - 1);
if(existValue == ''){ existValue = '0'; }
}
else if(inputVal == 'clr') // Clear // Remoce All Digit
{
existValue = '0';
}
else
{
if(existValue ==0) { existValue = '';}
var resArr = existValue.split(".");
if(resArr.length == 1 && existValue.length < 5) { existValue = existValue + inputVal; }
if(resArr.length == 1 && existValue.length == 5) { if(inputVal == '.') { existValue = existValue + inputVal;} }
if(resArr.length == 2 && resArr[1].length < 2 ) { existValue = existValue + inputVal; }
existValue = existValue.replace("..", ".");
}
$("#stockCartPurchaseUpdateForm #cartProPurchase").val(existValue);
}
}
function stockReturnEditValueUpdate(editType)
{
var counter = 1;
var errorMsg = '';
if(editType == 'cartProQty')
{
var product_id = $("#stockCartQtyUpdateForm #product_id").val();
var add_dateTime = $("#stockCartQtyUpdateForm #add_dateTime").val();
var product_qty = $("#stockCartQtyUpdateForm #cartProQty").val();
var modeType = 'stockReturnProQtyUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&product_qty='+product_qty
}
if(editType == 'cartProPurchase')
{
var product_id = $("#stockCartPurchaseUpdateForm #product_id").val();
var add_dateTime = $("#stockCartPurchaseUpdateForm #add_dateTime").val();
var pro_purchase = $("#stockCartPurchaseUpdateForm #cartProPurchase").val();
if(pro_purchase == "") { errorMsg = 'Please Enter Product Purchase'; counter = 0; }
else if(isNaN(pro_purchase)) { errorMsg = 'Please Provide Only Digit'; counter = 0; }
else if(parseFloat(pro_purchase) < 0) { errorMsg = 'Greater Than Zero'; counter = 0; }
var modeType = 'stockReturnProPurchaseUpdate';
var dataArr = '&product_id='+product_id+'&add_dateTime='+add_dateTime+'&pro_purchase='+pro_purchase
}
if(counter ==0)
{
$displayMsg = 'warning@@@@'+errorMsg;
getDisplayAlertMsg(displayMsg);
}
else
{
//alert(main_pos_root+"stock_cart_update.php?modeType="+modeType+dataArr);
$.ajax({
type : "GET",
url : main_pos_root+"stock_cart_update.php?modeType="+modeType+dataArr,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
stockRetuenProEditCancel();
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
}
}
function vendorStockReturnComplete()
{
var txtmessage = '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Stock Return Invoice Complete",
size: eModal.size.lgs,
label: "Yes",
};
return eModal.confirm(options)
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?&mod=vendorStockReturnComplete",
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
});
}
function vendorStockReturnCancel()
{
var txtmessage = '';
txtmessage += '';
var options = {
message: txtmessage,
title : "Stock Return Invoice Cancel",
size: eModal.size.lgs,
label: "Yes",
};
return eModal.confirm(options)
.then(function ()
{
$.ajax({
type : "GET",
url : main_pos_root+"ajax/vendor_detail.php?&mod=vendorStockReturnCancel",
async : false,
success:function(result)
{
result = result.trim();
var res_val = result.split("####");
$("#refereshDiv").html(res_val[0]);
// Display msg Function
getDisplayAlertMsg(res_val[1]);
}
});
});
}// JavaScript Document
// ***************************************** Table Order ************************************
function tableViewOrderScreen()
{
$('.loader').removeClass('posHide');
$.ajax({
type : "GET",
url : main_pos_root+"ajax/getlocalsetting.php?mod=setTableViewMode",
async : false,
success:function(result)
{
result = result.trim();
$("#refereshDiv").html(result);
$('.loader').addClass('posHide');
}
});
window.setTimeout(function(){ location.reload();},1);
}