  <br>
  <table border=1 cellspacing=1 cellpadding=2 width=928 style="border: 1px inset;">

  <tr valign=top>
  <td valign=top width=48 class=listheader>No.</td>
  <td valign=top width=150 class=listheader>Role</td>
  <td valign=top width=150 class=listheader>Project ID</td>
  <td valign=top width=100 class=listheader>Module</td>
  <td valign=top width=380 class=listheader>Outstanding Task</td>
  <td valign=top width=100 class=listheader>Options</td>
  </tr>

  <?
  // get all outstanding tasks!! (for each project!)
  // ALSO: DON'T FORGET ACCESS BY PROJECT (DISABLE VIEW BUTTON IF USER CAN'T ACCESS PROJECT!)

  include_once('models/projectModel.php');
  include_once('models/mroModel.php');
  include_once('models/itqModel.php');
  include_once('models/supplierModel.php');
  include_once('models/tradeModel.php');

  $myprojectModelPMS=new projectModelPMS;
  $mymroModel=new mroModel;
  $myitqModel=new itqModel;
  $mysupplierModel=new supplierModel;
  $mytradeModel=new tradeModel;

  $project_list=$myprojectModelPMS->getlist_projects($pubprojectpkey);
  $access_list=$myprojectModelPMS->getlist_useraccess($pubuserpkey);

  $dcount=0;

  foreach($project_list as $myproject) {

    $disabled = "";
    $pallowed = false;
    $gallowed = false;

    foreach ($access_list as $myaccess) {
      if ($myproject['projectpkey']==$myaccess['projectpkey']) {
        $allowed=true;
      }
    }

    if ((($allowed==true)&&($pubuseraccess['access_mro_edit']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unsubmitted mro
    //if (($pubuseraccess['access_mro_edit']==1)||($pubuserrole>=2)) {
      $mro_list = $mymroModel->getlist_mrobystatus($myproject['projectpkey'], 0);
      foreach ($mro_list as $mymro) {
        $dcount++;
        $trade_data = $mytradeModel->getdata_trade($mymro['mro_subtradepkey']);
        echo "<tr valign=top>";
        echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
        echo "<td valign=top width=150 class=listcontent>Purchasing Executive</td>";
        echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
        echo "<td valign=top width=100 class=listcontent>MRO</td>";
        echo "<td valign=top width=380 class=listcontent>Submit MRO No ".$mymro['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
        echo "<td valign=top width=100 class=listcontent>";
        echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=mro&task=view&itemid=".$mymro['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
        echo "</td>";
        echo "</tr>";
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_mro_recommendvariance']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unreviewed variance mro
    //if (($pubuseraccess['access_mro_recommendvariance']==1)||($pubuserrole>=2)) {
      $mro_list = $mymroModel->getlist_mrobystatus($myproject['projectpkey'], 1);
      foreach ($mro_list as $mymro) {
        if ($mymro['mro_type']!="1") {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($mymro['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Project Manager</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>MRO</td>";
          echo "<td valign=top width=380 class=listcontent>Review Variance MRO No ".$mymro['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=mro&task=view&itemid=".$mymro['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_mro_approvenormal']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved normal mro
    //if (($pubuseraccess['access_mro_approvenormal']==1)||($pubuserrole>=2)) {
      $mro_list = $mymroModel->getlist_mrobystatus($myproject['projectpkey'], 1);
      foreach ($mro_list as $mymro) {
        if ($mymro['mro_type']=="1") {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($mymro['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Project Manager</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>MRO</td>";
          echo "<td valign=top width=580 class=listcontent>Approve Normal MRO No ".$mymro['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=mro&task=view&itemid=".$mymro['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_mro_approvevariance']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved variance mro
    //if (($pubuseraccess['access_mro_approvevariance']==1)||($pubuserrole>=2)) {
      $mro_list = $mymroModel->getlist_mrobystatus($myproject['projectpkey'], 2);
      foreach ($mro_list as $mymro) {
        if ($mymro['mro_type']!="1") {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($mymro['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>CEO</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>MRO</td>";
          echo "<td valign=top width=580 class=listcontent>Approve Variance MRO No ".$mymro['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=mro&task=view&itemid=".$mymro['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&(($pubuseraccess['access_itq_edit']==1)||($pubuseraccess['access_itq_invite']==1)))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unsubmitted/unprinted itq
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyproject($myproject['projectpkey']);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        if (($myitq['itq_status']=="0")||($myitq['itq_status']==null)) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Purchasing Executive</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Submit/Print ITQ for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=generate&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    // approve50k, 100k, 1m, all

    if ((($allowed==true)&&($pubuseraccess['access_itq_evaluate']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unevaluated (keyed in) itq
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbystatus($myproject['projectpkey'],1);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        if ($myitq['itq_evalstatus']=="0") {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Purchasing Executive</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Tabulate ITQ for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=evaluate&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_itq_approve50k']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved itq (<=50k)
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyevalstatus($myproject['projectpkey'],1);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        $mymroamount = floatval($mymroModel->gettotal_mroitems($myitq['mro_pkey']));
        if ($mymroamount<=50000) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Project Manager</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Approve ITQ (<=50k) for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=approve&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_itq_approve100k']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved itq (<=100k)
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyevalstatus($myproject['projectpkey'],1);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        $mymroamount = floatval($mymroModel->gettotal_mroitems($myitq['mro_pkey']));
        //if (($mymroamount<=100000)&&($mymroamount>50000)) {
          if (($mymroamount<=100000)) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Purchasing Manager</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Approve ITQ (<=100k) for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=approve&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_itq_review']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unreviewed itq (>100k)
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyevalstatus($myproject['projectpkey'],1);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        $mymroamount = floatval($mymroModel->gettotal_mroitems($myitq['mro_pkey']));
        if ($mymroamount>100000) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Purchasing Manager</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Review ITQ (>100k) for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=review&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_itq_approve1m']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved recommended itq (<=1mil)
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyevalstatus($myproject['projectpkey'],2);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        $mymroamount = floatval($mymroModel->gettotal_mroitems($myitq['mro_pkey']));
        if (($mymroamount<=1000000)&&($mymroamount>100000)) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>CEO</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Approve ITQ (<=1mil) for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=approve&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

    if ((($allowed==true)&&($pubuseraccess['access_itq_approveall']==1))||($pubuserrole>=2)) { $disabled=""; } else { $disabled="disabled"; }

    // purchasing - unapproved recommended itq (<=1mil)
    //if (($pubuseraccess['access_itq_edit']==1)||($pubuserrole>=2)) {
      $itq_list = $myitqModel->getlist_itqbyevalstatus($myproject['projectpkey'],2);
      // (left join with mro)
      foreach ($itq_list as $myitq) {
        $mymroamount = floatval($mymroModel->gettotal_mroitems($myitq['mro_pkey']));
        if ($mymroamount>1000000) {
          $dcount++;
          $trade_data = $mytradeModel->getdata_trade($myitq['mro_subtradepkey']);
          echo "<tr valign=top>";
          echo "<td valign=top width=48 class=listnumber>".$dcount."</td>";
          echo "<td valign=top width=150 class=listcontent>Managing Director</td>";
          echo "<td valign=top width=150 class=listcontent>".$myproject['projectid']."</td>";
          echo "<td valign=top width=100 class=listcontent>ITQ</td>";
          echo "<td valign=top width=580 class=listcontent>Approve ITQ (>1mil) for MRO No ".$myitq['mro_id']." (".$trade_data['tradecode']." : ".$trade_data['tradedescription'].")</td>";
          echo "<td valign=top width=100 class=listcontent>";
          echo "<button name='go".$dcount."' id='go".$dcount."' ".$disabled." style='width: 90px;' onClick='location.href=\"index.php?module=itq&task=approve&itemid=".$myitq['mro_pkey']."\"'><img src='gfx/options/b_next.png' class='actionbutton'>&nbsp;View</button>";
          echo "</td>";
          echo "</tr>";
        }
      }
    //}

  }

  // master data (supplier++)

  ?>

  </table>
