0

Hello,

I am trying something new and I do not know how to do it. I have table that list all the expenses claim, which these expenses needs to multiple approvals from different managers, where it will be like this:

<?php

$connect = mysql_connect("localhost","root","***") or die ("Could not connect");




mysql_select_db("expenses") or die ("Could not find the database");





$sql = mysql_query("SELECT * FROM expenses_claim");





$expCount = mysql_num_rows($sql); //Count the output amount




            echo "<table border='1'>
            <tr>
            <th>Expense ID</th>
            <th>Claimant Date</th>
            <th>Details</th>
            <th>Department Manager</th>
            <th>HR Manager</th>
            <th>Approval</th>
            <th>Finanace</th>
            </tr>";
          if ($expCount != 0){
            while($row = mysql_fetch_array($sql)){

            echo "<tr>";
            echo "<!--<td class='approve'><a href='approve.php?approve='></a> <a href='#' class='show_hide toggler'>Add</a></td>-->";
            echo "<td>" . $row['exp_id'] . "</td>";
            echo "<td>" . $row['claimant_date'] . "</td>";
            echo "<td><a href='exp_view.php?exp_id=". $row['exp_id']."?'>View Details</a><input type='hidden' onclick='display' value='show'/></br></td>";
            echo "<td><a href='approve.php?approveid=". $row['exp_id']."?'>Approve</a>•<a href='declain.php?exp_id=". $row['exp_id']."?'>Delete</a><br/></div></td>";;
            echo "<td><a href='approve1.php?approveid=". $row['exp_id']."?'>Approve</a>•<a href='declain.php?exp_id=". $row['exp_id']."?'>Delete</a><br/></div></td>";
            echo "<td><a href='approve2.php?approveid=". $row['exp_id']."?'>Approve</a>• <a href='declain.php?exp_id=". $row['exp_id']."?'>Delete</a><br/></td>";
            echo "</tr>";


            // $exp_list = print"$exp_id - $claimant_date   <a href='exp_view.php?exp_id=$exp_id?'>View</a></br>";

    }
    echo "</table></form>";
           }else{
           $exp_list = print "You have no expenses claim listed in the system";
            }
           mysql_close($connect);
?>





</body>
</html>

And the code in the below show when the manager click on Approve will insert the value into the database

<?php



          if (isset($_GET['approveid'])){ 
          echo '<div align="center"><font size="4" color="red">Please confirm your approve of the expense claim no. ' .$_GET['approveid']. '</font><p><p></p></p><br/><a href="approve.php?yesapprove=' .$_GET['approveid'].'">Yes</a> |<a href="list.php">No</a></div>';

          }
          if(isset($_GET['yesapprove'])){
              $approve = $_GET['yesapprove'];
              $connect = mysql_connect("localhost","root","****") or die ("Could not connect");

             mysql_select_db("expenses") or die ("Could not find the database");


             $sql1 =mysql_query("update expenses_claim set man_sign = 'Approved' where exp_id = '$approve'");


                     header("Location:list.php");
                     exit();
                      mysql_close($connect);
          }

          ?>

Once the manager approve I want to replace the value with Approved in the table instead of Approve | Decline. Also, The Approve | Decline options I want to hide them until the first manager approve.

I would be most grateful for any help or suggestion that will be help me in my project

2
Contributors
3
Replies
26
Views
3 Years
Discussion Span
Last Post by Gaetane
0

Hi Nadera :) Unfortunately, I'm not sure what the problem is. Are you getting error messages? Is the MYSQL not updating? A bit of information about that would help me alot. Then about hiding the approve/decline options until the first manager approves, I am unsure about what you mean. Could you provide a process explanation (so not the code, just what you want to have happen by who and by when)? Thanks!

0

There is no error message in my code and it is working, but I need help to be able to hide the Approve | Decline options, for example I have 4 managers:

department manager HR manager general manager finance manager
Approve| Decline Approve| Decline Approve| Decline Approve| Decline

I want to hide the hr manager, general manager, finance manager options. If the department manager approve the option of HR manager will show , if the HR manager approved the option will be displayed for the general manager and so on.

0

Okay... I don't think I need to write the code for you because you seem to have that sorted ;) but this is the approach I might use:

  1. Get user ID
  2. Get user group based on user ID: department manager, HR manager, general manager, finance manager
  3. Check level of approval on transaction so far: So if user is general manager check if department manager has approved, check if HR manager has approved, etc (whatever your decision tree is)
  4. If conditions are met, output button.

Depending on how your database is structured, you could do that in one query. Does that help?

Edited by Gaetane: Addition

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.