Page 1 of 1

Approval problem

Posted: Wed Dec 29, 2010 10:53 am
by batowiise
Hi all,

I have two tables namely users and generalclaims. Two users have been assign the role of approving claims issued by normal users.

This is my logic flow;

After a normal user submits claims to be vetted, the first approving officer picks the claims us and either APPROVES or REJECTS it. After which the second approving officer also picks the claims up and either APPROVES or REJECTS it.

This is what is managed to produce;

Code: Select all

// When Approve is click
if (@$_REQUEST['Submit'] == "Approve") { 

		$entryid = $_REQUEST['entryid'];		
		$paidto = $_REQUEST['paidto'];		
		$modeofpayment = $_REQUEST['modeofpayment'];		
		$totalamount = $_REQUEST['totalamount'];		
		$status = $_REQUEST['status'];
		$firstapprover = $_REQUEST['firstapprover'];
		$secondapprover = $_REQUEST[' secondapprover '];	
		
		
		$sql_update="UPDATE generalclaims SET
		paidto='$paidto',
		modeofpayment='$modeofpayment',
		totalamount='$totalamount',
		status='$status',
		firstapprover='APPROVED',
		secondapprover='APPROVED'
		WHERE entryid='$entryid'";
		
		
		
		/* Passes query to database */ 
		
		$result = mysql_query($sql_update); 
		if (!$result) { 
		  echo("<p>Error performing query: " . mysql_error() . "</p><p><a href=\"" . $_SERVER['PHP_SELF'] . "?updaterecord=" .$entryid. "&Submit=Edit\">Click here</a> to return to Problem Log page"); 
		  exit(); 
		} 
		
		else{
			echo("Record updated successfully.");
		}

}
 
// When Reject is clicked
if (@$_REQUEST['Submit2'] == "Reject") { 

		$entryid = $_REQUEST['entryid'];		
		$paidto = $_REQUEST['paidto'];		
		$modeofpayment = $_REQUEST['modeofpayment'];		
		$totalamount = $_REQUEST['totalamount'];		
		$status = $_REQUEST['status'];
		$firstapprover = $_REQUEST['firstapprover'];
		$secondapprover = $_REQUEST['secondapprover'];			
		
		
		$sql_update="UPDATE generalclaims SET
		paidto='$paidto',
		modeofpayment='$modeofpayment',
		totalamount='$totalamount',
		status='$status',
		firstapprover='REJECTED',
		secondapprover='REJECTED'
		WHERE entryid='$entryid'";
		
		
		
		/* Passes query to database */ 
		
		$result = mysql_query($sql_update); 
		if (!$result) { 
		  echo("<p>Error performing query: " . mysql_error() . "</p><p><a href=\"" . $_SERVER['PHP_SELF'] . "?updaterecord=" .$entryid. "&Submit=Edit\">Click here</a> to return to Problem Log page"); 
		  exit(); 
		} 
		
		else{
			echo("Record updated successfully.");
		}

}   
My problem is that when the second approving officer logs into the system and either APPROVES or REJECT a claims that the first approving officer has worked on, the firstapprover and secondapprover fields always become the same.

Please what am I doing wrong.

Need your help.

Regards.

Isaac

Re: Approval problem

Posted: Wed Dec 29, 2010 12:03 pm
by rcrd.ortiz
Hi, first of all what should happen if one officer approves and the other officer rejects? I'm asking this because as your code is now, the second officer decission overrides the first officers decission since in both querys you set both the first and second officers field as approved or rejected, and that leads to the first officers approval or rejection dos not count since the second officer overrides it. Sorry for the sloppy writing, I'm on my phone.

Cheers,

rcrd

Re: Approval problem

Posted: Thu Dec 30, 2010 7:04 am
by batowiise
I created a different php file for the second approver which is now working fine. Thanks alot for your alert.