<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
/*include('../includes/header_in.php');*/
/*include('../includes/topmenuin.php');*/
$id= $company_id = $_SESSION['id'];
$expand_id=$_REQUEST['expand_id'];

if (strpos($_REQUEST['error'], 'Duplicate') !== false) {
    ?>
	<script>
    alert("Record not saved due to duplicate sheet OR revision numbers");
    </script>
	<?php
}
$allowed = "accept='.dwg,.dxf,.dgn,.dwf,.pdf,.jpg,.jpeg,.png,.bmp,.stl,.xps,.xls,.doc,.xlsx,.docx,.xml,.csv,.xps'";
?>

<html><head><meta charset="utf-8"><title>pmAnywhere - Scope</title>
<link href="03-00Scope-Styles0.css" rel="stylesheet" type="text/css" />
<script src="../includes/js/jquery.min.js"></script>
		   <script src="../sorttable.js"></script>

	
	
<script type='text/javascript'>
    $(document).ready(function () {
        $(".priority").hover(function () {
            $(this).attr("src", "img/prioritylow.png");
        }, function () {
            $(this).attr("src", "img/priorityhigh.png");
        });
    });
</script>
	
	
<script>
$(document).on('change', '#attachmentedit', function() {
    var file = $(this)[0]; // note the [0] to return the DOMElement from the jQuery object
	//alert(file.files[0].name);
	var exts=['.dwg', '.dxf','.dgn','.dwf','.pdf','.jpg','.jpeg','.png','.bmp','.stl','.xps','.xls','.doc','.xlsx','.docx','.xml','.csv','.xps'];
    if((new RegExp('(' + exts.join('|').replace(/\./g, '\\.') + ')$', "i")).test(file.files[0].name))
	{
		//alert("ok");
	}
	else 
	{
		document.getElementById("attachmentedit").value = "";
		alert("Only file extensions like dwg, dxf, dgn, dwf, pdf, jpg, jpeg, png, bmp, stl, xps, xls, doc, xlsx, docx, xml, csv, xps are allowed");
		//return false;
	}
});

</script>

</head>

<div><br></div>
	<style>
        .imgbtn{width:14px; height:14px; border:none; padding: 0}
        .es{display:none}
    </style>
<div style="overflow-x:auto;">
<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>-->

  <fieldset>
<legend align="center">REVIEW/ COMMENTS/ ACTIONS</legend>
      <?php
      $result = mysql_query("SELECT * FROM scope_dwg  where dwgID ='$expand_id'");
      $row = mysql_fetch_array($result, MYSQL_ASSOC);
      $dwgTitle = $row['dwgList_Title'];
      $dwgProject = $row['dwgProject'];
      $dwgType = $row['dwgType'];
      $dwgcomplePercent = $row['dwgcomplePercent'];
      $designType = $row['dwg_type'];
      $dwgConsultant = $row['dwg_consultantID'];
      $date = $row['dwgDateCreated'];
      
      ?>
<table name="entryform" align="center" class="table3" width="80%" border="0" cellpadding="0">
    <tr>
      <td width="10%" align="left" valign="top"><strong>Project Code</strong></td>
      <td width="22%" align="left" valign="top"><input type="text" name="Project" value="<?php
          $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects where companySerial = '$id' AND projStatus=1 AND projectSerial='$dwgProject' ");
          if($rows = mysql_fetch_array($result, MYSQL_ASSOC)) {
                  echo $rows["projectCode"] . " - " . $rows["projectName"];

          } ?>" readonly style="background-color:gainsboro"></td>
      <td width="10%" align="left" valign="top"><strong>DWG Set Title</strong></td>
      <td width="22%" align="left" valign="top"><input type="text" name="Project" value="<?php echo $dwgTitle ?>" readonly style="background-color:gainsboro"></td>
      <td width="10%" align="left" valign="top"><strong>Related SOW</strong></td>
      <td width="23%" align="left" valign="top"><input type="text" name="handover" value="<?php
          $resultSW = mysql_query("SELECT sowName FROM scope_sow WHERE sowID='".$row['dwg_sowID']."'");
          if($rowSW = mysql_fetch_array($resultSW, MYSQL_ASSOC)){
                $SOW = $rowSW['sowName'];
                  echo $SOW;
          }
          ?>" readonly style="background-color:gainsboro"></td>
      <td width="3%" align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><strong>Phase</strong></td>
      <td align="left" valign="top"><input type="text" name="Project" value="<?php 								 
                $pID = null;
                $pID = $row['phaseID'];
                    $result21 = mysql_query("SELECT  Phase_id,Phase_name FROM projectphases where
                   projectphases.Phase_status=1 AND projectphases.Phase_id='$pID'
                     ");

                    while ($row21 = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                    $i = $row21['Phase_id'];
                    $n = $row21['Phase_name'];
                    echo $n;
                    }

                    ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top" class="table1"><strong>Zone</strong></td>
      <td align="left" valign="top" class="table1"><input type="text" name="Project" value="<?php
				$pID = null;
                $pID = $row['zoneID'];
                    $result21 = mysql_query("SELECT  Zone_id,Zone_name FROM projectzones where
                   projectzones.Zone_status=1 AND projectzones.Zone_id='$pID'
                     ");

                    while ($row21 = mysql_fetch_array($result21, MYSQL_ASSOC)) {
                    $i = $row21['Zone_id'];
                    $n = $row21['Zone_name'];
                    echo $n;
                    }

                    ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top"><strong>Contract</strong></td>
      <td align="left" valign="top"><input type="text" name="Project" value="<?php
           $pID = $row['contractID'];
          $result29 = mysql_query("SELECT  Contract_id,Contract_no,Contract_title FROM projectcontracts where
                   projectcontracts.Contract_status=1 AND projectcontracts.Contract_id='$pID'
                     ");

          if ($row29 = mysql_fetch_array($result29, MYSQL_ASSOC)) {
              //$i = $row29['Contract_no'];
              $n = $row29['Contract_no'];
              echo $n;
          } ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><strong>Type</strong></td>
      <td align="left" valign="top"><input type="text" name="Project" value="<?php echo $dwgType; ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top" class="table1"><strong>Stage</strong></td>
      <td align="left" valign="top" class="table1"><input type="text" name="plantitle" value="<?php echo $dwgcomplePercent; ?> Percent" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top"><strong>of</strong></td>
      <td align="left" valign="top"><input type="text" name="planid" value="<?php echo $designType = $row['dwg_type']; ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><strong>Consultant</strong></td>
      <td align="left" valign="top"><input type="text" name="Project" value="<?php
          $resultC = mysql_query("SELECT conSerial,conContactName,conDepartment,conDesignation FROM consultants WHERE companySerial = '$id' AND
                                          conStatus=1 AND conSerial = '$dwgConsultant'");

          if ($rowC = mysql_fetch_array($resultC, MYSQL_ASSOC)) {
              echo $rowC["conContactName"]." ";
          }
          ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top" class="table1"><strong>Date</strong></td>
      <td align="left" valign="top" class="table1"><input type="text" name="datetime" value="<?php echo $date; ?>" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top"><strong>Proponent</strong></td>
      <td align="left" valign="top"><input type="text" name="Proponent" value="Nothing to display" readonly style="background-color:gainsboro"></td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
</table>


<input id="edit_id" name="edit_id" type="hidden" value="<?php echo $_REQUEST['expand_id']; ?>">
  </fieldset>
  </div>
</div>
<table width="100%" border="0" cellpadding="0" align="center">
  <tbody>
    <tr>
      <td align="right"><a href="03-06Scope-02Drawings02-PV.php?expand_id=<?php echo $row['dwgID']; ?>"><img src="img/print.png" width="12" height="12" alt=""/></a>&nbsp;&nbsp;<a href="03-06Scope-01Drawings01.php"><img src="img/deletecb.png" width="12" height="12" alt=""/></a></td>
    </tr>
  </tbody>
</table>
<table width="90%" align="center">
  <tbody>
    <tr align="right">
      <td align="right"><select name="discipline" id="discipline" style="width:10% !important">
        <option value="">Sort by Discipline</option>
      </select>
        <select name="Sortaction" id="Sortaction" style="width:10% !important">
          <option value="">Sort by Action</option>
            <option>No Action Required</option>
            <option>Implement and Submit Now</option>
            <option>Implement before Next Stage</option>
            <option>Implement with Next Stage</option>
            <option>To be Discussed</option>
        </select>
        <select name="Sortreviewer" id="Sortreviewer" style="width:10% !important">
          <option value="">Sort by Reviewer</option>
      </select>
   <!--     <select name="Sortdiscipline4" id="Sortdiscipline4" style="width:10% !important">
          <option value="0">Sort by Organsiation</option>
      </select>-->
		<input id="search-text" type="text"  style="width:10% !important" placeholder="Search Text">
		
		</td>
    </tr>
  </tbody>
</table>
<table width="90%" border="0" align="center" class="table2" cellpadding="0">
  <tbody>
    <tr bgcolor="black">
      <td width="1%" ><span bgcolor="black" STYLE="color: gainsboro; font-size: 10pt" class="subTitle">+</span></td>
      <td width="3%" ><span bgcolor="black" STYLE="color: gainsboro; font-size: 10pt" class="subTitle">#</span></td>
      <td width="6%" ><span bgcolor="black" STYLE="color: gainsboro; font-size: 10pt" class="subTitle">ISSUED</span></td>
      <td width="10%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">Discipline</span></td>
      <td width="10%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">SUFFIX/DWG</span></td>
      <td width="11%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">SHEET/REV</span></td>
      <td width="17%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">DWG TITLE</span></td>
      <td width="17%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">DWG SUB-TITLE</span></td>
      <td width="15%" ><span STYLE="color: gainsboro; font-size: 10pt" class="subTitle">FILENAME</span></td>
     <!-- <td width="10%" ><span class="subTitle">ACTIONS</span></td>  -->
    </tr>
    <?php
    $DID = $expand_id;
    $disciplineDD = array();
    $reviewerDD = array();
    $reserved_sheets = array();
    $reserved_rev = array();
    $query = "SELECT * FROM scope_dwg_revisions WHERE dwg_id =$DID";
    $result = mysql_query($query);
	$range = mysql_num_rows($result);
    while ($rr = mysql_fetch_array($result)) {
        array_push($reserved_sheets, $rr['sheet_no']);
        array_push($reserved_rev, $rr['rev_no']);
    }

    //getting dynamic ranges of dwg doc
    $drawingRange = array();
    $rangeQ = "SELECT * FROM scope_dwg_range WHERE dwgID = '$DID' AND companyID = '$company_id' AND status = '1'";
    $rangeRes = mysql_query( $rangeQ );
    while( $rangeRow = mysql_fetch_assoc($rangeRes)){
        $dRange = range($rangeRow[range_from],$rangeRow[range_to]);
        $dRange = preg_filter('/^/', $rangeRow[dwg_suffix].'_', $dRange);  //appending prefix with dwg suffix
        $drawingRange = array_merge(  $drawingRange, $dRange );
    }


$serial =0;
//    for ($i = $row['range_from']; $i <= $row['range_to']; $i++) {
    foreach ($drawingRange as $range) {

    $rangeSuffix = explode( '_', $range);       //splitting range no and suffix
    $suffix = $rangeSuffix[0];
    $i = $rangeSuffix[1];
    $query = "SELECT * FROM scope_dwg_revisions WHERE dwg_id =$DID AND range_no=$i order by sheet_no, rev_no ";
    $result = mysql_query($query);
	$have_rows = mysql_num_rows($result);

    //$rew = mysql_fetch_object($result);

    if ($have_rows) {
		while($rew = mysql_fetch_object($result)){
			$dwgDiscipline = $rew->discipline;
    ?>
       
        <!-------------------------------------------------- Show DWG Row --------------------------------------------------->
    <tr bgcolor="#D4D4D4" class="rs tableData read_section<?php echo $rew->id ?>">
      <td valign="middle" bgcolor="#D4D4D4"><button id="divshownotesdiv" onclick="$('#divnotesdiv<?php echo $rew->id ?>').toggle();" class="button3"><img src="img/add.png" width="12" height="12" alt="Add Comments" title="Add Comments"/></button></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo ++$serial; ?></strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo $rew->dwg_idate ?></strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4">          <strong>
        <?php
          $resultD = mysql_query("SELECT discipline_name,discipline_code FROM discipline where discipline_company_id = '$id' 
                                          AND discipline_status=1 AND discipline_id='$dwgDiscipline' ");

          if ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) {
              echo $rowD['discipline_name'];
          }
          ?>
          
                                            </strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo $suffix .  " - ". $i; ?></strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo str_pad($rew->sheet_no, 3, '0', STR_PAD_LEFT) . "-" . str_pad($rew->rev_no, 3, '0', STR_PAD_LEFT); ?>
      </strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo $rew->dwg_title ?></strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4"><strong><?php echo $rew->dwg_title2 ?></strong></td>
      <td valign="middle" class="tdData"  bgcolor="#D4D4D4">
          <strong>
          <input type="hidden" name="old_filename"  value="<?php echo $rew->attachment ?>"/>
          <?php if ($rew->attachment != "") { ?>
              <a href="uploads/<?php echo $rew->attachment ?>" target="_blank" ><?php echo $rew->attachment ?></a> 
              <?php } ?>
      </strong></td>
      
      <!--
      <td valign="middle"><img width="14" height="14" onClick="ShowEditSection(<?php echo $rew->id ?>)" name="edit2" title="Edit" src="img/edit.png" style="cursor: pointer"  alt=""/>&nbsp; <img width="14" height="14" onClick="ShowSheetSection(<?php echo $rew->id; ?>)" title="Add Sheet" src="img/addSheets.png" style="cursor: pointer"  alt=""/>&nbsp; <img width="14" height="14" onClick="ShowRevSection(<?php echo $rew->id; ?>)" title="Add Revision" src="img/addRev.png" style="cursor: pointer"  alt=""/>&nbsp;
         <?php if(!($rew->rev_no=="000" && $rew->sheet_no =="001")) {?><a style="text-decoration:none" href="03-06Scope-02Drawings01DB.php?dwgID=<?php echo $DID ?>&del=<?php echo $rew->id ?>"><img onClick="return confirm('Are you sure you want to delete the record?');"
               height="14" style="cursor:pointer" width="14" name="delete2" title="Delete" src="img/delete.png"  alt=""/>&nbsp;</a><?php } ?>

      </td>
      
      -->
      </tr>
    <tr class="tableD">
      <td class="tdD" colspan="9" valign="middle">
		  
		  <!------------HIDDEN DIVS START-------------------------------------------------------------------------------------------------------------->

	    <!-- DIV FOR POSTING COMMENTS--><!-- TO BE MARKED DISPLAY:NONE -->
          <div id="divnotesdiv<?php echo $rew->id ?>" style="display:none; width:100%;"><br>
        <form id="postcomment<?php echo $rew->id ?>" method="post" action="03-06Scope-02Drawings02-DB.php?postComment=<?php echo $rew->id ?>">
            <input type="hidden" name="expand_id<?php echo $rew->id ?>" value="<?php echo $expand_id; ?>">

     
	<select name="commentType<?php echo $rew->id ?>" style="width:10% !important" required>
     <option value="">Select Comment Type*</option>
     <option>Design Clarification</option><option>Design Error - Major</option><option>Design Error - Minor</option><option>General Remarks</option><option>Missing Information</option><option>Typing Error</option><option>Suggestion</option>
     </select>
	
	<select name="discipline<?php echo $rew->id ?>" style="width:10% !important" >
    <option value="">Select a Discipline</option>

        <?php
          $resultD = mysql_query("SELECT discipline_id, discipline_name,discipline_code FROM discipline where discipline_company_id = '$id' 
                                          AND discipline_status=1 ORDER BY discipline_name,discipline_code ");

          while ($rowD = mysql_fetch_array($resultD, MYSQL_ASSOC)) {
              ?><option value="<?php echo $rowD['discipline_id'] ?>"><?php echo $rowD['discipline_name']; ?></option><?php
          }
          ?>
          </select>       
	
	<select name="actionType<?php echo $rew->id ?>" style="width:10% !important" required>
    <option value="">Select Action Type*</option><option>No Action Required</option><option>Implement and Submit Now</option><option>Implement before Next Stage</option><option>Implement with Next Stage</option><option>To be Discussed</option>
    </select>
	
	<input name="subject<?php echo $rew->id ?>" required style="width:10% !important" type="text" placeholder="Subject*">
		  <input name="details<?php echo $rew->id ?>" required style="width:58% !important" type="text" placeholder="Details*"><button id="divhidenotesdiv" type="submit" class="button3"><img src="img/add.png" width="12" height="12" alt=""/></button>

	</form>
          </div>

<?php
$commentQ = "SELECT * FROM scope_dwg_comments WHERE revision_id = '$rew->id' AND dwg_id = '$expand_id' AND status = '1' AND companyID = '$id'";
$commentRes = mysql_query( $commentQ );

if(mysql_num_rows($commentRes) == 0){ ?>
<!--  These elements are added if there exists no comments table of a issue so the filters work properly  -->
          <span class="actionType"></span>
          <span class="disciplineName"></span>
          <span class="reviewer"></span>
          <span class="commentsRow"></span>
        <?php }
$num_rows = mysql_num_rows($commentRes);
        if($num_rows > 0){?>
      <br>

          <table width="97.5%" class="table6" border="0" align="right">
              <tr>
                  <th width="5%" align="left">CommentID</th>
                  <th width="10%" align="left">CommentType</th>
                  <th width="10%" align="left">Discipline</th>
                  <th width="15%" align="left">ActionType</th>
                  <th width="15%" align="left">Subject</th>
                  <th width="20%" align="left">Details</th>
                  <th width="10%" align="left">PostedBy</th>
                  <th width="10%" align="left">PostedAt</th>
                  <th width="5%" align="left">Actions</th>

              </tr>
        <?php }
while( $commentRow = mysql_fetch_assoc( $commentRes )){

    $revisionID = $commentRow['revision_id'];
    $commentID = $commentRow['comment_id'];
    $commentType = $commentRow['comment_type'];

    $discipline = $commentRow['discipline'];
    $disQ = "SELECT discipline_name FROM discipline WHERE discipline_id = '$discipline'";
    $disRes = mysql_query( $disQ );
    $disRow = mysql_fetch_assoc( $disRes );
    $disciplineName = $disRow['discipline_name'];

    $actionType = $commentRow['action_type'];
    $subject = $commentRow['subject'];
    $details = $commentRow['details'];
    $createdBy = $commentRow['created_by'];
    $creationDateTime = $commentRow['creation_date'];
    ?>

    <tr class="commentsRow">
      <td align="left"><?php echo $commentID ; ?></td>
      <td  align="left"><?php echo $commentType; ?></td>
      <td align="left" ><span class="disciplineName"><?php echo $disciplineName;
          if(!in_array($disciplineName, $disciplineDD))
              array_push( $disciplineDD, $disciplineName);  ?></span></td>
        <td align="left"><span class="actionType"><?php echo $actionType; ?></span></td>
      <td align="left"><?php echo $subject; ?></td>
      <td align="left"><?php echo $details; ?></td>
      <td align="left"><span class="reviewer"> <?php echo $createdBy;
              if(!in_array($createdBy, $reviewerDD))
                  array_push( $reviewerDD, $createdBy);
      ?></span></td>
      <td align="left"><?php echo $creationDateTime; ?></td>
		<td align="left">
            <?php if($createdBy == $ipusername){?>
                <a href="03-06Scope-02Drawings02-DB.php?deleteComment=<?php echo $commentID; ?>&expand_id=<?php echo $expand_id; ?>" onclick="return confirm('Are you sure to delete this comment ?');">
                    <img src="img/delete.png" width="12" height="12" alt=""/></a>
          <?php  } ?>

        </td> <!-- only commentor can delete his own comment-->
    </tr>



    <?php
}

          if($num_rows > 0){?>
          </table>
          <?php }?>
          <br>


      </td>

        <?php
        }
        }
        }
        ?>
</table>
<br><br>



	
	
<script language="javascript">

    $(function () {
        var disp = <?php echo json_encode($disciplineDD); ?>;

        $.each(disp, function(val, text) {
            $('#discipline').append( $('<option></option>').html(text) )
        });

        var reviewer = <?php echo json_encode($reviewerDD); ?>;

        $.each(reviewer, function(val, text) {
            $('#Sortreviewer').append( $('<option></option>').html(text) )
        });



        $('#discipline').change(function(e) {

            $searchData = $(this).val().toLowerCase();
            $('.tableD').each(function(index, element) {
                $t = $(this);
                $status = false;
                $(this).find('td .disciplineName').each(function(index, element) {
                    $value = $(this).html();
                    if ($value.toLowerCase().indexOf($searchData) >= 0){
                        $status = true;
                        //console.log('find');
                    }
                });
                if($status){
                    $t.show();
                    $t.prev('tr').show();
                }else{
                    $t.hide();
                    $t.prev('tr').hide();
                }
            });
        });


        $('#Sortaction').change(function(e) {

            $searchData = $(this).val().toLowerCase();
            $('.tableD').each(function(index, element) {
                $t = $(this);
                $status = false;
                $(this).find('td .actionType').each(function(index, element) {
                    $value = $(this).html();
                    if ($value.toLowerCase().indexOf($searchData) >= 0){
                        $status = true;
                        //console.log('find');
                    }
                });
                if($status){
                    $t.show();
                    $t.prev('tr').show();
                }else{
                    $t.hide();
                    $t.prev('tr').hide();
                }
            });
        });

        $('#Sortreviewer').change(function(e) {

            $searchData = $(this).val().toLowerCase();
            $('.tableD').each(function(index, element) {
                $t = $(this);
                $status = false;
                $(this).find('td .reviewer').each(function(index, element) {
                    $value = $(this).html();
                    if ($value.toLowerCase().indexOf($searchData) >= 0){
                        $status = true;
                        //console.log('find');
                    }
                });
                if($status){
                    $t.show();
                    $t.prev('tr').show();
                }else{
                    $t.hide();
                    $t.prev('tr').hide();
                }
            });
        });


//search by text
        $('#search-text').keyup(function(e) {
            //console.log('keyup');
            $resultsFound = 0;
            $searchData = $(this).val().toLowerCase();
            $('.tableD').each(function(index, element) {
                $t = $(this);
                $status = false;
                $(this).find('.commentsRow').each(function(index, element) {
                    $value = $(this).html();
                    if ($value.toLowerCase().indexOf($searchData) >= 0){
                        $status = true;
                    }
                });
                if($status){
                    $resultsFound++;
                    $t.show();
                    $t.prev('tr').show();
                }else{
                    $t.hide();
                    $t.prev('tr').hide();
                }

            });
        });





    });








    function ShowEditSection(id) {
		 $(".rev_section" + id).hide();
		  $(".sheet_section" + id).hide();
        $(".read_section" + id).hide();
        $(".edit_section" + id).show();
    }
	
	function ShowRevSection(id) {
		$(".edit_section" + id).hide();
        $(".rev_section" + id).show();
		$(".sheet_section" + id).hide();
		document.getElementById("task" +id).value = "add";
		
    }
	
	function ShowSheetSection(id) {
		$(".edit_section" + id).hide();
		 $(".rev_section" + id).hide();
        $(".sheet_section" + id).show();
		document.getElementById("task" +id).value = "add";
		
    }
	
    function showreadsection(id) {
		
		$(".sheet_section" + id).hide();
		$(".rev_section" + id).hide();
        $(".edit_section" + id).hide();
        $(".read_section" + id).show();

    }
	
</script>
	
	
	<!-- DIVs for toggle fields -->
	
	                <!--Post Comments -->

	
	
	
	
	
	

</body>
</html>

<SCRIPT> // to show hide the forms and hidden tables
$(document).ready(function(){




    $("#hideformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#showformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#addformdiv").click(function(){
        $("#formdiv").toggle();
    });
	$("#showhiddendiv").click(function(){
        $("#hiddendiv").toggle();
    });
	$("#hidehiddendiv").click(function(){
        $("#hiddendiv").toggle();
    })
	/*$("#divshownotesdiv").click(function(){
        $("#divnotesdiv").toggle();
    })*/
	$("#diveditnotesdiv").click(function(){
        $("#divnotesdiv").toggle();
    })
	$("#divhidenotesdiv").click(function(){
        $("#divnotesdiv").toggle();
    })
	$("#divshowemailsdiv").click(function(){
        $("#divemailsdiv").toggle();
	})
	$("#divhideemailsdiv").click(function(){
        $("#divemailsdiv").toggle();		
    })
	$("#divshowfilesdiv").click(function(){
        $("#divfilesdiv").toggle();
	})
	$("#divhidefilesdiv").click(function(){
        $("#divfilesdiv").toggle();
    })
});	
</SCRIPT>

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