Approval problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
batowiise
Forum Commoner
Posts: 28
Joined: Fri Dec 17, 2010 7:11 am

Approval problem

Post 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
Last edited by Benjamin on Wed Dec 29, 2010 2:54 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
rcrd.ortiz
Forum Newbie
Posts: 11
Joined: Sun Dec 26, 2010 10:46 am

Re: Approval problem

Post 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
batowiise
Forum Commoner
Posts: 28
Joined: Fri Dec 17, 2010 7:11 am

Re: Approval problem

Post by batowiise »

I created a different php file for the second approver which is now working fine. Thanks alot for your alert.
Post Reply