<?php
include('../../includes/checkSession.php');
include('../../includes/topmenunewest.php');
$id = $company_id = $_SESSION['id'];
?>

<html><head>
   <meta charset="utf-8"><title>pmAnywhere - Scope Module</title>
    <link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />
    <script src="../includes/js/jquery.min.js"></script>
    <script src="03-01Scope-01Standards01.js"></script>
	<script src="03-00Scope-01Toggle01.js"></script>
	
</head>
<style>     .actionTD a{text-decoration:none;} </style>
	
<body style="backgrond-color:#E8E8E8">
<!----------------------- Div For errors and warnings--------------------------------->

<!----------------------- Div For errors and warnings--------------------------------->

<!----------------------- Div For errors and warnings--------------------------------->
<div><h5 class="msg">
        <?php if (isset($_REQUEST["msg"])) { ?>
            <?php echo $_REQUEST["msg"]; ?>
        <?php } ?>
    </h5></div>



<script>
    function showConfirm(did) {
        if (confirm("Are you sure to delete? Press OK to Delete.") )
        {
            window.location.href = "03-03Scope-01PDRI01-DB01.php?del=" + did;
        }
    }
</script>

<div style="overflow-x:auto;">
   <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
    <div id="formdiv" > <!--div for the form (style="display:none;")-->

        <!--<table name="entryformheading" align="center" width="80%" class="table1" border="0" cellpadding="0">

             <tr>

              <th>

              <div style='float: left; text-align: left'><button id="hideformdiv" class="button1">&#x25bc;</button>

              Add</div>

              <div style='float: right; text-align: right'>&nbsp;</div>

              </th>

            </tr>

          </table>-->


        <?php
        if(isset($_GET['Edit']) && !empty($_GET['Edit'])) {
            $pdriID = $_REQUEST['Edit'];
            $result = mysql_query("SELECT * FROM pdri where pdri_id='$pdriID'");
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            $project_id = $row["project_id"];
            //$client_id = $row["client_id"];
            $pdri_name = $row["pdri_name"];
            $pdri_rev = $row["pdri_rev"];

            $editUrl = "?Edit=" . $_GET['Edit'];
        }
        ?>




        <form align="center" action="03-03Scope-01PDRI01-DB01.php<?php if(isset($editUrl)) echo $editUrl; ?>"  method="post" style="margin-top:20px">

          <fieldset>

                <legend align="center">

                    <button id="hideformdiv" class="button1" title="Click to Hide">&nbsp;&nbsp;&nbsp;PROJECT DEFINITION RATING INDEX&nbsp;&nbsp;&nbsp;</button></legend>

                <table name="entryform" align="center" class="table1" width="80%" border="0" cellpadding="0">
                    <tr>
                      <td width="12%" align="left"><strong>Project Name*</strong></td>
                      <td width="20%" align="left">
						  
					    <select name="projname"  id="projname" required>
                            <option value="">Select</option>
                            <?php
                                                $result = mysql_query("SELECT * FROM projects where companySerial='$id' AND projStatus='1' order by projectName ASC");
                                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                                    ?>
                            <option <?php if($project_id == $row[projectSerial]) echo 'selected'; ?> value="<?php echo $row['projectSerial']; ?>"><?php echo $row['projectName']; ?></option>
                            <?php } ?>
                          </select>
						  <a href="http://pm4.pmanywhere.co/Interface/02-options/02-03Options-01Projects01.php"><img src="img/Adding.png" width="8" height="8" alt=""/></a>
						  </td>
						
                      <td width="13%" align="left"><strong>PDRI Title*</strong></td>
                      <td width="20%" align="left">
                        <input name="pdriname" type="text" value="<?php echo $pdri_name; ?>"  id="pdriname" required placeholder="Name" />
                      </td>
						
                      <td width="12%" align="left"><strong>Rev*</strong></td>
     <td width="20%" align="left">
       <input name="pdrirev" type="text" value="<?php echo $pdri_rev; ?>"  id="pdrirev" required  placeholder="Rev"/>
     
       <button style="vertical-align: bottom" class="button1" title="Save">&#x25ba;</button>
		 <!--<a href="03-01Scope-01Standards01-IV01.php" class="button1" title="View Suggestions from pmAnywhere">&#x25bc;</a>-->
                      
                      </td>
                    </tr>



                </table>

            </fieldset></form>

        <br></div>
    <?php } ?>
</div>




<a name="activeanchor"></a>
<div style="overflow-x:auto;">
	<?php
    $result = mysql_query("SELECT pdri.*,projects.projectName FROM projects,pdri where pdri.companyID='$id' AND (pdri.pdri_status='1' OR pdri.pdri_status='3' OR pdri.pdri_status='4') AND projects.projectSerial=pdri.project_id ORDER BY creationDate DESC,pdri_name ASC");
    $resultTotalScore = mysql_query("SELECT SUM(SUBSTRING_INDEX(rating_points, ',', -1)) AS totalScore FROM pdri_rating_detail");
    $rowTotalScore = mysql_fetch_object($resultTotalScore);
    ?>


    <div>
        <table align="center" name="tabletitle" class="table1 tableActiveFilter" width="80%" border="0" cellpadding="0">
            <tr>
                <th>
                    <div style='float: left; text-align: left'>
             <a href="#archiveanchor"><button class="button1" title="View Archived">&#x25bc;</button></a><button id="showformdiv" class="button1" title="Show/ Hide the Form">&#x25b2;&#x25bc;</button>
             &nbsp;Active PDRIs (<?php echo mysql_num_rows($result);?>)</div>

                    <div style='float: right; text-align: right'>
                        <select style="width:45%" id="PagingRows">
                            <option value="10"> Show 10 Rows</option>
                            <option value="20"> Show 20 Rows</option>
                            <option value="50"> Show 50 Rows</option>
                            <option value="100" selected> Show 100 Rows</option>
                            <option value="all"> Show All Rows</option>
                        </select>
                        <input style="width:50%" id="SearchMeasure" type="search" placeholder="Type to Search">
                    </div>
                </th>
            </tr>
        </table>
    </div>
</div>



<div style="overflow-x:auto;">

    <table align="center" class="table2 tableActive"  name="datatable" border="0" width="80%" cellpadding="1">

        <tr>
    <th width="10%"  class="sorting" sorting="dateCreated"  align="left" valign="top" bgcolor="#E2E2E2">Date Created<br />(y.m.d) </th>
    <th width="20%" class="sorting" sorting="projectCode"  align="left" valign="top" bgcolor="#E2E2E2">Project<br>Name</th>
    <th width="20%" class="sorting" sorting="name"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br>Title</th>
    <th width="10%" class="sorting" sorting="rev"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br />Rev</th>
    <th width="10%" class="sorting" sorting="score"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br>Score</th>
    <th width="10%" class="sorting" sorting="preparedBy"  align="left" valign="top" bgcolor="#E2E2E2">Prepared<br />By</th>
    <th width="10%" class="sorting" sorting="sentStatus"  align="left" valign="top" bgcolor="#E2E2E2">Sent<br /> Status</th>
    <th width="10%"  align="right" valign="top" bgcolor="#E2E2E2" scope="col"> Actions<br /> Status </th>
        </tr>


       <?php
         //  $result = mysql_query("SELECT pdri.*,projects.projectName,client.clientCode FROM projects,client,pdri where pdri.companyID='$id' AND pdri.pdri_status='1' AND projects.projectSerial=pdri.project_id AND client.clientSerial=pdri.client_id  ORDER BY creationDate DESC,  pdri_name ASC");
                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                    $PreparedBy = "";
    if ($row["pdri_PreparedBy"] == 0) {
        $resultPre = mysql_query("SELECT firstName, lastName FROM login where loginId='" . $id . "'");
        $PreparedBy .= mysql_result($resultPre, 0, 0);
        $PreparedBy .=" " . mysql_result($resultPre, 0, 1);
    } else {
        $resultPre = mysql_query("SELECT internal_personnel_firstName, internal_personnel_lastName FROM internal_personnel where internal_personnel_id='" . $row["pdri_PreparedBy"] . "'");
        $PreparedBy .= mysql_result($resultPre, 0, 0);
        $PreparedBy .=" " . mysql_result($resultPre, 0, 1);
    }
 ?>
		

            <tr class="tableData" trid="<?php echo $row['pdri_id']; ?>">
              <td  class="tdData dateCreated" align="left" valign="top"  ><?php echo $row["creationDate"]; ?></td>
              <td  class="tdData projectCode" align="left" valign="top"><?php echo $row["projectName"]; ?></td>
              <td  class="tdData name"  align="left" valign="top" ><?php echo $row["pdri_name"]; ?><br /></td>
              <td  class="tdData rev" align="left" valign="top" ><?php echo $row["pdri_rev"]; ?></td>
              <td  class="tdData score" align="left" valign="top" ><?php
                      $rowScore = mysql_fetch_object(mysql_query("select sum(pdri_sec_value) AS score from pdri_values where pdri_id='{$row['pdri_id']}'"));
                      echo !empty($rowScore->score) ? $rowScore->score : 0;
                      ?>/<?php echo $rowTotalScore->totalScore; ?></td>
              <td  class="tdData preparedBy" align="left" valign="top" ><?php echo $PreparedBy; ?><br /></td>
              <td  class="tdData sentStatus" align="left" valign="top" >
                <?php if($row["pdri_status"]==3){?>
                Sent for Review
  <?php } elseif($row["pdri_status"]==4) echo 'LOCKED'; else echo "Not Sent for Review" ?>
             </td>
				
              <td align="right" valign="top" ><a href="03-03Scope-01PDRI02c.php?pid=<?php echo $row["pdri_id"]; ?>"><img style="margin-top:3px" src="img/expand.png" width="13" height="13" border="0" /></a>&nbsp;&nbsp;&nbsp;
				  
				  
				  <?php if (($uacc == "Full Control" || $uacc == "Consolidate")  && $row["pdri_status"] == 1) { ?>
                    <a href="03-03Scope-01PDRI01.php?Edit=<?php echo $row['pdri_id']; ?>"><img src="img/edit.png" width="13" height="13" alt="" title="Edit"/></a>&nbsp;&nbsp;&nbsp;
            <?php } else { ?>
                    <a href="javascript:void(0)"><img src="img/edit.png" width="13" height="13" alt="" title="Edit"/></a>&nbsp;&nbsp;&nbsp;
            <?php } ?>
		   

					
                    <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
                           <?php } else { ?>
                    <?php } ?>  

                    <?php if (($uacc == "Full Control" || $uacc == "Consolidate") && $row["pdri_status"] == 1) { ?>
                    <a href="03-03Scope-01PDRI01-DB01.php?InActive=<?php echo $row['pdri_id']; ?>">
                        <img src="img/hide.png" width="13" height="13" alt="" title="Archive"/></a>&nbsp;&nbsp;&nbsp;
                    <?php } else { ?>
                    <a href="javascript:void(0)">
                        <img src="img/hide.png" width="13" height="13" alt="" title="Archive"/></a>
                    <?php } ?>

              </td>

            </tr>

            <tr class="trid<?php echo $row['pdri_id']; ?> notetr">

                <td colspan="12" align="left"><em> <img src="img/information.png" width="12" height="12" alt=""/></em></td>

            </tr>

        <?php }  ?>


    </table>

</div>

<table width="80%" class="table1 ActiveTablePaging" align="center" border="0" cellpadding="1">

    <tbody>

    <tr>

        <td align="right" >

            <span class="pagingInfo"></span>



            &nbsp;

            <button class="button2 BtnPrev" title="Previous Page">&#9668;</button>

            &nbsp;

            <button class="button2 BtnNext" title="Next Page">&#x25ba;</button>

            <div id="pagination"></div>

        </td>

    </tr>

    </tbody>

</table>





<!-- HIDDEN TABLE-->

<a name="archiveanchor"></a><br>
<hr class="hrstyle1">
<br>





<div style="overflow-x:auto;">
<?php
$result = mysql_query("SELECT pdri.*,projects.projectName FROM projects,pdri where pdri.companyID='$id' AND (pdri.pdri_status='0') AND projects.projectSerial=pdri.project_id ORDER BY creationDate DESC,pdri_name ASC");

?>

    <div id="hiddendiv" > <!--- style="display:none" ------>
        <table align="center" name="tabletitle" class="table1 tableInActiveFilter" width="80%" border="0" cellpadding="1">
            <tr>
                <th>
                    <div style='float: left; text-align: left'>
                        <button id="hidehiddendiv" class="button1" title="Hide">&nbsp;&nbsp;&nbsp;</button><a href="#activeanchor"><button class="button1" title="Show Active">&#x25b2;</button></a>&nbsp;Archived PDRIs (<?php echo mysql_num_rows($result);?>)</div>

                    <div style='float: right; text-align: right'>
                        <select style="width:45%" id="PagingRows">
                            <option value="10">Show 10 Rows</option>
                            <option value="20"> Show 20 Rows</option>
                            <option value="50" selected> Show 50 Rows</option>
                            <option selected value="100"> Show 100 Rows</option>
                            <option value="all"> Show All Rows</option>
                        </select>
                        <input style="width:50%" id="SearchMeasureHide" type="search" placeholder="Type to Search">
                    </div>

                </th>

            </tr>

        </table>




        <table align="center" class="table2 tableInActive"  name="datatable" border="0" width="80%" cellpadding="1">

            <tr>
     <th width="10%"  class="sorting" sorting="dateCreated"  align="left" valign="top" bgcolor="#E2E2E2">Date Created<br />(y.m.d) </th>
    <th width="20%" class="sorting" sorting="projectCode"  align="left" valign="top" bgcolor="#E2E2E2">Project<br>Name</th>
    <th width="20%" class="sorting" sorting="name"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br>Title</th>
    <th width="10%" class="sorting" sorting="rev"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br />Rev</th>
    <th width="10%" class="sorting" sorting="score"  align="left" valign="top" bgcolor="#E2E2E2">PDRI<br>Score</th>
    <th width="10%" class="sorting" sorting="preparedBy"  align="left" valign="top" bgcolor="#E2E2E2">Prepared<br />By</th>
    <th width="10%" class="sorting" sorting="sentStatus"  align="left" valign="top" bgcolor="#E2E2E2">Sent<br /> Status</th>
    <th width="10%"  align="right" valign="top" bgcolor="#E2E2E2" scope="col"> Actions<br /> Status </th>
            </tr>


            <?php
            //  $result = mysql_query("SELECT pdri.*,projects.projectName,client.clientCode FROM projects,client,pdri where pdri.companyID='$id' AND pdri.pdri_status='1' AND projects.projectSerial=pdri.project_id AND client.clientSerial=pdri.client_id  ORDER BY creationDate DESC,  pdri_name ASC");
            while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $PreparedBy = "";
                if ($row["pdri_PreparedBy"] == 0) {
                    $resultPre = mysql_query("SELECT firstName, lastName FROM login where loginId='" . $id . "'");
                    $PreparedBy .= mysql_result($resultPre, 0, 0);
                    $PreparedBy .=" " . mysql_result($resultPre, 0, 1);
                } else {
                    $resultPre = mysql_query("SELECT internal_personnel_firstName, internal_personnel_lastName FROM internal_personnel where internal_personnel_id='" . $row["pdri_PreparedBy"] . "'");
                    $PreparedBy .= mysql_result($resultPre, 0, 0);
                    $PreparedBy .=" " . mysql_result($resultPre, 0, 1);
                }
                ?>


                <tr class="tableDataHide" trid="<?php echo $row['pdri_id']; ?>">
                    <td  class="tdDataHide dateCreated" align="left" valign="top"  ><?php echo $row["creationDate"]; ?></td>
                    <td  class="tdDataHide projectCode" align="left" valign="top"><?php echo $row["projectName"]; ?></td>
                    <td  class="tdDataHide name"  align="left" valign="top" ><?php echo $row["pdri_name"]; ?><br /></td>
                    <td  class="tdDataHide rev" align="left" valign="top" ><?php echo $row["pdri_rev"]; ?></td>
                    <td  class="tdDataHide score" align="left" valign="top" ><?php
                            $rowScore = mysql_fetch_object(mysql_query("select sum(pdri_sec_value) AS score from pdri_values where pdri_id='{$row['pdri_id']}'"));
                            echo !empty($rowScore->score) ? $rowScore->score : 0;
                            ?>/<?php echo $rowTotalScore->totalScore; ?></td>
                    <td  class="tdDataHide preparedBy" align="left" valign="top" ><?php echo $PreparedBy; ?><br /></td>
                    <td  class="tdDataHide sentStatus" align="left" valign="top" >
                        <?php  echo "Not Sent for Review" ?>
                    </td>

                    <td align="right" valign="top" >


                        <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
                            <a href="03-03Scope-01PDRI01-DB01.php?Active=<?php echo $row['pdri_id']; ?>"><img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a>
                        <?php } else { ?>
                            <a href="javascript:void(0)"><img src="img/show.png" width="13" height="13" alt="" title="Unhide"/></a>
                        <?php } ?>

                        &nbsp;&nbsp;&nbsp;


                        <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
                            <a href="javascript:void(0)" onClick="showConfirm('<?php echo $row['pdri_id']; ?>')">

                                <img src="img/delete.png" width="13" height="13" alt="" title="Delete" />

                            </a>
                        <?php } else { ?>
                            <a href="javascript:void(0)" >

                                <img src="img/delete.png" width="13" height="13" alt="" title="Delete" />

                            </a>
                        <?php } ?>


                    </td>

                </tr>

                <tr class="trid<?php echo $row['pdri_id']; ?> notetr">

                    <td colspan="12" align="left"><em> <img src="img/information.png" width="12" height="12" alt=""/></em></td>

                </tr>

            <?php }  ?>


        </table>


        <table width="80%" class="table1 InActiveTablePaging" align="center" border="0" cellpadding="1">

            <tbody>

            <tr>

                <td align="right" > <span class="pagingInfo"></span>



                    &nbsp;

                    <button class="button2 BtnPrev" title="Previous Page">&#9668;</button>

                    &nbsp;

                    <button class="button2 BtnNext" title="Next Page">&#x25ba;</button></td>

            </tr>

            </tbody>

        </table>

    </div>

</div>

<br>

<br>









</body>

</html>







<?php include('../includes/footer.php'); ?>

