function makeHttpObject() 
{
    try {return new XMLHttpRequest();}
    catch (error) {}
    try {return new ActiveXObject("Msxml2.XMLHTTP");}
    catch (error) {}
    try {return new ActiveXObject("Microsoft.XMLHTTP");}
    catch (error) {}
    throw new Error("Could not create HTTP request object.");
}

function req_fr_item_apprv()
{
	    var ph_no = document.getElementById('ph_no').value;
		var item_name = document.getElementById('product_name').value;
		//alert(item_name);
		var cat_name = document.getElementById('cat_name').value;
				
		//Customer SMS
		if(item_name!="" && cat_name!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			//request.open("GET", "https://portal.mobtexting.com/api?method=sms.normal&api_key=7fb0f81b41c5f8e7fe576f0ef1c8264c&to=9448686868&sender=CWINVT&message=Dear CEO, requesting to approve the new raw material "+item_name+"  under "+cat_name+"  Category. Regards, Team Store", true);
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526784715000&message=Dear CEO, requesting you to approve the new raw material "+item_name+"  under "+cat_name+"  Category. Regards, Team Store Cakewala", true);
			request.send(null);	
			alert("MSG Sent for Approval");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function item_apprv()
{
	
		var item_name = document.getElementById('product_name').value;
		//alert(item_name);
		var cat_name = document.getElementById('cat_name').value;
				
		//Customer SMS
		if(item_name!="" && cat_name!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to=9945342744,8884100908&sender=CWINVT&service=T&template_id=1207161526837235573&message=Dear Store Team, Raw Materiel "+item_name+" under "+cat_name+" category has been approved. Regards, CEO Cakewala", true);
			request.send(null);	
			alert("Approved MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function vendor_creation()
{
	    var ph_no = document.getElementById('ph_no').value;
		var vendor_name = document.getElementById('sname').value;
		//alert(vendor_name);
						
		//Customer SMS
		if(vendor_name!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526845869043&message=Dear CEO, The new Vendor "+vendor_name+" has been created. Regards, Team Store Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function item_issued()
{
	var ph_no = document.getElementById('ph_no').value;
	var branch = document.getElementById('branch').value;
	var req_no = document.getElementById('req_no').value;
	var iss_no = document.getElementById('iss_no').value;
	var req_status = document.getElementById('req_status').value;
	var req_pending_count = document.getElementById('req_pending_count').value;
	//var ph_no = "9591547504";
	//alert(ph_no);
				
	//Customer SMS
	if(ph_no!="")
	{
		if(req_status == 'Closed')
		{
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161527015475184&message=Dear "+branch+", for your indent no "+req_no+" items has been issued with the no "+iss_no+", indent is "+req_status+". Regards, Team Store Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
			//}
		}
		else
		{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161527029832412&message=Dear "+branch+", for your indent no "+req_no+" items has been issued with the no "+iss_no+", indent is "+req_status+" with "+req_pending_count+" item(s). Regards, Team Store Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
		}
	}
	else
	{
		alert("Message Not Sent,Information not Sufficient");
	}
	
	
//form.submit();
	//}
}

function req_fr_po_apprv()
{
	
		var po_no = document.getElementById('po_no').value;
		//alert(item_name);
		var ph_no = document.getElementById('ph_no').value;
		var aprv_status = document.getElementById('aprv_status').value; 
						
		//Customer SMS
		if(aprv_status == 'Indirect')
		{
			if(po_no!="")
			{	
				//if (confirm("Are u sure want to send the message!") == true) 
				//{
				var request = makeHttpObject();	
				request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526854203029&message=Dear CEO, requesting you to approve the new purchase order "+po_no+". Regards, Team Store Cakewala", true);
				request.send(null);	
				//alert("MSG Sent for Approval");
				//}
			}
			else
			{
				alert("Message Not Sent,Information not Sufficient");
			}
		}
	
	
//form.submit();
	//}
}

function po_apprv()
{
	
		var po_no = document.getElementById('po_no').value;
		//alert(item_name);
		var ph_no = document.getElementById('ph_no').value;
		//alert(po_no);		
		//Customer SMS
		if(po_no!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526860003396&message=Dear Store Team, The Purchase Order "+po_no+" has been approved. Regards, CEO Cakewala", true);
			request.send(null);
			//alert("Approved MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function product_request()
{
	var ph_no = document.getElementById('ph_no').value;
	var req_no = document.getElementById('req_no').value;
	var branch = document.getElementById('branch').value;
	var outlet = document.getElementById('outlet').value;
	var ord_type = document.getElementById('ord_type').value;
	//alert(ph_no);
				
	//Customer SMS
	if(ph_no!="")
	{
		var request = makeHttpObject();	
		request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161960972612992&message=Dear "+outlet+", The "+ord_type+" no "+req_no+" has been raised by "+branch+", - Cakewala.", true);
		request.send(null);	
		//alert("MSG Sent");
		//}
		
	}
	else
	{
		alert("Message Not Sent,Information not Sufficient");
	}
	
	
//form.submit();
	//}
}

//product approval
function req_fr_product_apprv()
{
	
		var product_name = document.getElementById('product_name').value;
		//alert(product_name);
		var cat_name = document.getElementById('cat_name').value;
		var ph_no = document.getElementById('ph_no').value;	
		//Customer SMS
		if(product_name!="" && ph_no!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526867276735&message=Dear CEO, requesting you to approve the new product "+product_name+"  under "+cat_name+"  Category. Regards, Master Chef Cakewala", true);
			request.send(null);	
			alert("MSG Sent for Approval");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function product_apprv()
{
	var product_name = document.getElementById('product_name').value;
	//alert(product_name);
	var cat_name = document.getElementById('cat_name').value;
	var ph_no = document.getElementById('ph_no').value;		
	//Customer SMS
	if(product_name!="" && ph_no!="")
	{	
		//if (confirm("Are u sure want to send the message!") == true) 
		//{
		var request = makeHttpObject();	
		request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526966852116&message=Dear Master Chef, Product "+product_name+" under "+cat_name+" category has been approved. Regards, CEO Cakewala", true);
		request.send(null);	
		alert("Approved MSG Sent");
		//}
	}
	else
	{
		alert("Message Not Sent,Information not Sufficient");
	}

//form.submit();
	//}
}

function grn_remark_notify()
{
	
		var ph_no = document.getElementById('phno').value;		
		//Customer SMS
		alert(ph_no);
		if(ph_no!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526974409507&message=Dear Store Team, You have comments on GRN. Regards, CEO Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function pay_advice()
{
	
		var ph_no = document.getElementById('ph_no').value;
		var vendor = document.getElementById('vendor').value;
		var total_amt = document.getElementById('ttl_amt').value;
		var tr_date = document.getElementById('tr_date').value;
		//Customer SMS
		//alert(ph_no);
		if(ph_no!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526980396723&message=Dear " +vendor+", An amount of " +total_amt+ " payment has been done on " +tr_date+ ". Regards, Team Accounts Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function in_ticket()
{
	
		var ph_no = document.getElementById('ph_no').value;
		var dept = document.getElementById('dept').value;
		var rmk = document.getElementById('remark').value;
		var inw_no = document.getElementById('inw_no').value;
		var inw_date = document.getElementById('inw_date').value;
		var dc_no = document.getElementById('dc_no').value;
		//Customer SMS
		//alert(ph_no);
		if(ph_no!="")
		{	
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161526989191136&message=Remarks By : " +dept+ " " +rmk+  " Ref :"+" " +inw_no+ " " +inw_date+ " "+"DC No :"+" " +dc_no+ " "+ "Regards, Team Cakewala", true);
			request.send(null);	
			alert("MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}

function voucher_pending()
{
	
		var ph_no = document.getElementById('ph_no1').value;
		var vendor = document.getElementById('vnd_name').value;
		var total_amt = document.getElementById('ttl_amt1').value;
		var vch_no = document.getElementById('vch_no').value;
		//Customer SMS
		//alert(vendor);
		if(ph_no!="")
		{	
			//if (confirm("Are u sure want to send the message!") == true) 
			//{
			var request = makeHttpObject();	
			request.open("GET", "https://portal.mobtexting.com/api/v2/sms/send?access_token=7fb0f81b41c5f8e7fe576f0ef1c8264c&to="+ph_no+"&sender=CWINVT&service=T&template_id=1207161527000926526&message=Dear CEO a voucher " +vch_no+" for vendor " +vendor+ ", an amount of Rs. " +total_amt+ " is pending for approval. Regards, Team Accounts Cakewala", true);
			request.send(null);	
			//alert("MSG Sent");
			//}
		}
		else
		{
			alert("Message Not Sent,Information not Sufficient");
		}
	
	
//form.submit();
	//}
}