<?php
if($_REQUEST['action']=='Delete')
{
$del1=DB_query("delete from dbl_process_sale_order_details where parentid='".$_REQUEST['id']."'",$db);
$del2=DB_query("delete from dbl_process_charge_details where parentid='".$_REQUEST['id']."'",$db);
$del=DB_query("delete from dbl_process_sale_order where id='".$_REQUEST['id']."'",$db);
$s->pageLocation('index.php?route=DealerDistrbutions/Transaction/process_sale_order_index&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'');

}

if(isset($_POST['Direct']))
{
$chkecdId=implode(",",$_REQUEST['enquiry_id']);
$s->pageLocation('index.php?route=DealerDistrbutions/POORDER/direct_purchase_order&action=exciable&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'&id='.$chkecdId.'');

}
if(isset($_POST['DirectNon']))
{
$chkecdId=implode(",",$_REQUEST['enquiry_id']);
$s->pageLocation('index.php?route=DealerDistrbutions/POORDER/direct_purchase_order&action=non exciable&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'&id='.$chkecdId.'');
}

if($_REQUEST['Conver'])
{
	$chkecdId=implode(",",$_REQUEST['enquiry_id1']);
$s->pageLocation('index.php?route=DealerDistrbutions/Transaction/Mulit_process_order_creations&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].'&id='.$chkecdId.'');
}

?>
<?php
$table='dbl_enquiry_form';
$action=$_REQUEST['action'];
$daction=$_REQUEST['daction'];
$msgErr='';
$status=true;
 $modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$url="&modid=".$modid."&frmid=".$frmid;
$targetpage="index.php?route=DealerDistrbutions/Transaction/sale_order_creations_edit".$url;
$targetpage1="index.php?route=DealerDistrbutions/Transaction/process_sale_order_index".$url;
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Process  Details</h1>
<form id="myform" action="" method="post">
 <div align="left"><a href="index.php?route=DealerDistrbutions/Transaction/direct_sale_order_creations&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>"><input type="button" name="Direct" value="Direct Sale Order" class="search" /></a> 
 &nbsp;
 <input type="submit" name="Direct" value="Generate Exciable PO" class="search" onclick="return checkenqueryno1();"  /> 
 
<input type="submit" name="DirectNon" value="Generate Non Exciable PO" class="search" onclick="return checkenqueryno1();" /> 
<input type="submit" name="Conver" value="Generate Single  PickList Aganist Multiple SOI" class="search" onclick="return checkenqueryno3();" /> 
 </div>
<br />
 


<?php  include('Viewprocesssaleorder.php') ?> 
</form>
</div></div>


<script>
function checkenqueryno1()
{
	var myform = document.getElementById('myform');
	var inputTags = myform.getElementsByTagName('input');
	var checkboxCount = 0;
	var pocheck=0;
	for (var i=0, length = inputTags.length; i<length; i++) {
	var input=inputTags[i];
	if (inputTags[i].type == 'checkbox' && input.checked  && inputTags[i].name=='enquiry_id[]') {
	 checkboxCount++;
	}
	else if (inputTags[i].type == 'checkbox' && input.checked  && inputTags[i].name!='enquiry_id[]')
	{
	pocheck=1;
	}
	}
	if(checkboxCount<1 && pocheck==0)
	{
	alert("Please Check At List One  Check Box ");
	return false;
	}
	else if(pocheck==1)
	{
	alert("Please Check PO Check Box ");
	return false;
	}
	
	return true;
	
}

function checkenqueryno3()
{
	var myform = document.getElementById('myform');
	var inputTags = myform.getElementsByTagName('input');
	var checkboxCount = 0;
	var pickcheck=0;
	for (var i=0, length = inputTags.length; i<length; i++) {
	var input=inputTags[i];
	if (inputTags[i].type == 'checkbox' && input.checked && inputTags[i].name=='enquiry_id1[]') {
	checkboxCount++;
	}
	else if (inputTags[i].type == 'checkbox' && input.checked  && inputTags[i].name!='enquiry_id1[]')
	{
	pickcheck=1;
	}
	}
	if(checkboxCount<2 && pickcheck==0 )
	{
	alert("Please Check At Least Two Check Box Of Same Customer");
	return false;
	}
	else if(pickcheck==1)
	{
	alert("Please Check PickList Check Box ");
	return false;
	}
	
}
</script>

