// JavaScript Document
var thisSupplierId=0;
var thisOurSerial = '';
var thisExternalMintenanceId=0;
 $(".check").click(function(){
	 thisSupplierId=$(this).attr('data-supplierId');
	 thisOurSerial=$(this).attr('data-ourSerial');
	 thisExternalMintenanceId=$(this).attr('data-externalmaintenanceId');

	 showExternalMaintenanceGoReportModalBox();
 });
	 
 $(".closeReport").click(function(){
	 closeExternalMaintenanceGoReportModal();
 });
	 
 $('.insertcheckReport').click(function(e) {
	insertcheckReport();
});
 
 
 
////// Adding new check report with modal box /////////////

function insertcheckReport()
{
	$.ajax({
			type: 'POST',
			url: 'externalMaintenanceGoReportControllerAjax.php?do=insertcheckReport&externalMintenanceId='+thisExternalMintenanceId+'&supplierId='+thisSupplierId+'&ourSerial='+thisOurSerial,
			data: $("#externalMaintenanceGoReportInfo").serialize(),
			success: function(data) {
				//alert(data);
				location.reload(); 
					/*$('#externalMaintenanceGoReportModal').modal('hide');
					//empty modal box's inputs' values
					emptyExternalMaintenanceGoReportModalForm($i);*/
				
			}
				
			
        });
}

function showExternalMaintenanceGoReportModalBox()
{
	$('#externalMaintenanceGoReportModal').modal('show');
	emptyExternalMaintenanceGoReportModalForm();
}


function emptyExternalMaintenanceGoReportModalForm()
{
	$('#externalMaintenanceGoReportInfo').find(':input').each(function(){
		var type = this.type, tag = this.tagName.toLowerCase();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
		{
			this.value = '-1';
			//$("#"+this.id).select2("data", {id: '-1', text: "اختر المرحله التاليه"});
		}
		
	});
}


function closeExternalMaintenanceGoReportModal()
{
	$('#externalMaintenanceGoReportModal').modal('hide');
	emptyExternalMaintenanceGoReportModalForm();
}

/////////////////////////////////////////////////////////////////////////////////////////////
//                                  srtop many submits                                     //
/////////////////////////////////////////////////////////////////////////////////////////////


$("#a1").click(function(ev) {
		
// submit more than once return false
$(this).submit(function() {
return false;
});
// submit once return true

return true;
});
