<?php $cookiearray = array();
$ses =array();
$ses = isset($_SESSION['acc_session'])?$_SESSION['acc_session']:"";
$string ="[0000],";
if(is_array($ses)){
foreach($ses as $k=>$v){
     
     $string .= '['.$v."],";
     $cookiearray[$v] =  $v;

}

}
?>
  <!--<input id="openAll" type="image" src="../images/close.png" width="16" height="16"  />&nbsp;-->
<!--<input id="closeAll" type="image" src="../images/open.png" width="16" height="16"  /> */-->
<style>
    .displayblock{display: block !important;}
.accordifth i{font-size:15px; font-weight:bold; cursor:pointer}
table th {
    font-size: 12px !important;
    padding: 7px 0;
    padding-right: 2px !important;
    color: #FFF !important;
    background: #3a70ab !important;
    background: -moz-linear-gradient(top, #5ba5cb 0%, #3a70ab 100%) !important;
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#5ba5cb), color-stop(100%, #3a70ab)) !important;
    background: -webkit-linear-gradient(top, #5ba5cb 0%, #3a70ab 100%) !important;
    background: -o-linear-gradient(top, #5ba5cb 0%, #3a70ab 100%) !important;
    background: -ms-linear-gradient(top, #5ba5cb 0%, #3a70ab 100%) !important;
    background: linear-gradient(to bottom, #5ba5cb 0%, #3a70ab 100%) !important;}
    /*.diplayblock.acc_container{display: block !important;}*/
</style>
<table style="width:100%">
  
<tr class="">
    <th width="4%" class="accordifth" style="padding-left:8px !important; text-align: center"><i id="openAll" class="fa fa-expand"></i>&nbsp;<br>
<i id="closeAll" class="fa fa-compress"></i></th>
    <th width="10%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Date Created<br />
      (yyyy.mm.dd)
      </th>
    <th width="8%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Sort <br />
      Code </th>
    <th width="10%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">WBS/ WPCode/<br />
      Item Code</th>
    <th width="30%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">MWBS/ WBS/ WP<br />
      ITEM/ S-ITEM</th>
    <th width="27%" align="left" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Notes<br />
        (IF ANY)</th>
    <th width="10%" colspan="2" align="right" valign="top" bgcolor="#E2E2E2" class="a1" scope="col">Edit/ <br />
    Del</th>
    </tr>
    
    <tr>
    <td colspan="7">
    
    
    <div class="bwl_acc_container" id="default_accordion">
            
            <div class="accordion_search_container">
                <input type="text" class="accordion_search_input_box " value="" placeholder="Search ..." style="width:98%"/><span style="width:2%; float:right; height:38px; cursor:pointer" class="acc_search_btn search_icon"></span>
            </div> <!-- end .bwl_acc_container -->
            
            <div class="search_result_container"></div> <!-- end .search_result_container -->
            
            
            
<?php
$parent =0;
$WID=$_REQUEST['WID'];
if(isset($_REQUEST['p']))
$id=$_REQUEST['p'];
include('../../includes/con2pma3.php');

//echo "df";	
		 $result1 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id' && parent=0 ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
		//echo"load";
   		while($row1 = mysql_fetch_array($result1 , MYSQL_ASSOC))
  		{
  		
			$WBSIDA = $row1["WBSIDA"];
	  		$WBSIDB = $row1["WBSIDB"];
	  		$WBSIDC = $row1["WBSIDC"];
	  		$WBSIDD = $row1["WBSIDD"];
	  		$WBSIDE = $row1["WBSIDE"];
			$WBSID1 = $row1["WBSID"];
			
			
			
			?> <!--First level-->
            <section>
                 <h2  onclick="setcookiefunc('<?php echo $row1["WBSID"]; ?>')" class="acc_title_bar <?php if(strpos($string,'['.$row1["WBSID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active";} ?>"><a class="ff" href="#" ></a> <table width="100%"><tr>
    <td align="left"  width="9%" scope="col"><?php echo $row1["creationDate"]; ?></td>
    <td align="left"  width="8%"><?php echo $row1["sortCode"]; ?></td>
    <td align="left"  width="9%"><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
    <td align="left"  width="34%" ><?php echo $row1["description"]; ?></td>
    <td align="left"  width="20%"><?php echo $row1["writeupwbs"]; ?></td>
    <td colspan="2" align="right"  width="10%">
    <input id="button" name="button" type="image" value="INSERT WBS" src="../images/icon-insert.jpg" onclick="LoadWBSG(<?php echo $row1["WBSID"]; ?>, <?php echo $WID ?>,<?php echo $parent?>); return false" />
    &nbsp;&nbsp;<input id="IIButton" name="IIButton" type="image" src="../images/icon-items.png" width="16px" height="16px" onclick="LoadIITEMForm(<?php echo $row1["WBSID"]; ?>, <?php echo $WID ?>);" />
    &nbsp;&nbsp;<input id="editButton" name="editButton" onclick="LoadWBSEditForm(<?php echo $row1["WBSID"]; ?>, <?php echo $WID ?>); return false; " type="image" src="../images/icon-edit.png">&nbsp;&nbsp;<input type="image" onclick="call_del_DB(<?php echo $row1["WBSID"]; ?>, <?php echo $WID ?>);" img src="../images/icon-del.png" width="16" height="16" border="0" /></td>
    </tr></table></h2>
                <div id="<?php echo 'd'.$row1['WBSID']?>" class="<?php if(strpos($string,'['.$row1["WBSID"].']')==true){echo "displayblock";} ?> acc_container " >
                    <div class="block">
                    <?php callWBSItem($WBSID1,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID);?>
                    <!--second level-->
                    <?php
					 $result2 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id' && parent=$WBSID1 ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
                    while($row2 = mysql_fetch_array($result2 , MYSQL_ASSOC))
  		{
  		 
			$WBSIDA = $row2["WBSIDA"];
	  		$WBSIDB = $row2["WBSIDB"];
	  		$WBSIDC = $row2["WBSIDC"];
	  		$WBSIDD = $row2["WBSIDD"];
	  		$WBSIDE = $row2["WBSIDE"];
			$WBSID2 = $row2["WBSID"];
			
			
			?>
            <section>
                <h2 onclick="setcookiefunc('<?php echo $row2["WBSID"]; ?>')" class="acc_title_bar <?php if(strpos($string,'['.$row2["WBSID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active ";} ?>"><a class="ff" href="#"></a> <table width="100%"><tr>
    <td align="left"  width="9%" scope="col"><?php echo $row2["creationDate"]; ?></td>
    <td align="left"  width="8%"><?php echo $row2["sortCode"]; ?></td>
    <td align="left"  width="9%"><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
    <td align="left"  width="34%" ><?php echo $row2["description"]; ?></td>
    <td align="left"  width="20%"><?php echo $row2["writeupwbs"]; ?></td>
    <td colspan="2" align="right"  width="10%">
    <input id="button" name="button" type="image" value="INSERT WBS" src="../images/icon-insert.jpg" onclick="LoadWBSG(<?php echo $row2["WBSID"]; ?>, <?php echo $WID ?>,<?php echo $WBSID1;?>); return false" />
    &nbsp;&nbsp;<input id="IIButton" name="IIButton" type="image" src="../images/icon-ITEMS.png" width="16px" height="16px" onclick="LoadIITEMForm(<?php echo $row2["WBSID"]; ?>, <?php echo $WID ?>); return false" />
    &nbsp;&nbsp;<input id="editButton" name="editButton" onclick="LoadWBSEditForm(<?php echo $row2["WBSID"]; ?>, <?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png">&nbsp;&nbsp;<input type="image" onclick="call_del_DB(<?php echo $row2["WBSID"]; ?>, <?php echo $WID ?>);" img src="../images/icon-del.png" width="16" height="16" border="0" /></td>
    </tr></table></h2>
                                            <div id="<?php echo 'd'.$row2['WBSID']?>" class="<?php if(strpos($string,'['.$row2["WBSID"].']')==true){echo "displayblock";} ?> acc_container " >


                    <div class="block">
                    <?php callWBSItem($WBSID2,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID);?>
                     <!--Third level-->
                    <?php
					 $result3 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id' && parent=$WBSID2 ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
                    while($row3 = mysql_fetch_array($result3 , MYSQL_ASSOC))
  		{
  		 
			$WBSIDA = $row3["WBSIDA"];
	  		$WBSIDB = $row3["WBSIDB"];
	  		$WBSIDC = $row3["WBSIDC"];
	  		$WBSIDD = $row3["WBSIDD"];
	  		$WBSIDE = $row3["WBSIDE"];
			$WBSID3 = $row3["WBSID"];
			
			
			?>
            <section>
               <h2 onclick="setcookiefunc('<?php echo $row3["WBSID"]; ?>')" class="acc_title_bar <?php if(strpos($string,'['.$row3["WBSID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active ";} ?>"><a class="ff" href="#"></a> <table width="100%"><tr>
                <!--<h2 onclick="setcookiefunc('<?php echo $row3["WBSID"]; ?>')" class="acc_title_bar"><a href="#"></a> <table width="100%"><tr>-->
    <td align="left"  width="9%" scope="col"><?php echo $row3["creationDate"]; ?></td>
    <td align="left"  width="8%"><?php echo $row3["sortCode"]; ?></td>
    <td align="left"  width="9%"><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
    <td align="left"  width="34%" ><?php echo $row3["description"]; ?></td>
    <td align="left"  width="20%"><?php echo $row3["writeupwbs"]; ?></td>
    <td colspan="2" align="right"  width="10%">
    <input id="button" name="button" type="image" value="INSERT WBS" src="../images/icon-insert.jpg" onclick="LoadWBSG(<?php echo $row3["WBSID"]; ?>, <?php echo $WID ?>,<?php echo $WBSID2;?>); return false" />
    &nbsp;&nbsp;<input id="IIButton" name="IIButton" type="image" src="../images/icon-ITEMS.png" width="16px" height="16px" onclick="LoadIITEMForm(<?php echo $row3["WBSID"]; ?>, <?php echo $WID ?>); return false" />
    &nbsp;&nbsp;<input id="editButton" name="editButton" onclick="LoadWBSEditForm(<?php echo $row3["WBSID"]; ?>, <?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png">&nbsp;&nbsp;<input type="image" onclick="call_del_DB(<?php echo $row3["WBSID"]; ?>, <?php echo $WID ?>);" img src="../images/icon-del.png" width="16" height="16" border="0" /></td>
    </tr></table></h2>
                                       <div id="<?php echo 'd'.$row3['WBSID']?>" class="<?php if(strpos($string,'['.$row3["WBSID"].']')==true){echo "displayblock";} ?> acc_container " >


                    <div class="block">
                    <?php callWBSItem($WBSID3,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID);?>
                    <!--Fourth level-->
                    <?php
					 $result4 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id' && parent=$WBSID3 ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
                    while($row4 = mysql_fetch_array($result4 , MYSQL_ASSOC))
  		{
  		 
			$WBSIDA = $row4["WBSIDA"];
	  		$WBSIDB = $row4["WBSIDB"];
	  		$WBSIDC = $row4["WBSIDC"];
	  		$WBSIDD = $row4["WBSIDD"];
	  		$WBSIDE = $row4["WBSIDE"];
			$WBSID4 = $row4["WBSID"];
			
			
			?>
            <section>
              <h2 onclick="setcookiefunc('<?php echo $row4["WBSID"]; ?>')" class="acc_title_bar <?php if(strpos($string,'['.$row4["WBSID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active ";} ?>"><a class="ff" href="#"></a> <table width="100%"><tr>
    <td align="left"  width="9%" scope="col"><?php echo $row4["creationDate"]; ?></td>
    <td align="left"  width="8%"><?php echo $row4["sortCode"]; ?></td>
    <td align="left"  width="9%"><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
    <td align="left"  width="34%" ><?php echo $row4["description"]; ?></td>
    <td align="left"  width="20%"><?php echo $row4["writeupwbs"]; ?></td>
    <td colspan="2" align="right"  width="10%">
    <input id="button" name="button" type="image" value="INSERT WBS" src="../images/icon-insert.jpg" onclick="LoadWBSG(<?php echo $row4["WBSID"]; ?>, <?php echo $WID ?>,<?php echo $WBSID3;?>); return false" />
    &nbsp;&nbsp;<input id="IIButton" name="IIButton" type="image" src="../images/icon-ITEMS.png" width="16px" height="16px" onclick="LoadIITEMForm(<?php echo $row4["WBSID"]; ?>, <?php echo $WID ?>); return false" />
    &nbsp;&nbsp;<input id="editButton" name="editButton" onclick="LoadWBSEditForm(<?php echo $row4["WBSID"]; ?>, <?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png">&nbsp;&nbsp;<input type="image" onclick="call_del_DB(<?php echo $row4["WBSID"]; ?>, <?php echo $WID ?>);" img src="../images/icon-del.png" width="16" height="16" border="0" /></td>
    </tr></table></h2>
            <div id="<?php echo 'd'.$row4['WBSID']?>" class="<?php if(strpos($string,'['.$row4["WBSID"].']')==true){echo "displayblock";} ?> acc_container " >
                    <div class="block">
                    <?php callWBSItem($WBSID4,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID);?>
                    <!--Fifth level-->
                    <?php
					 $result5 = mysql_query("SELECT * FROM globalwbs where gwbslist_id ='$WID' && companyID = '$id' && parent=$WBSID4 ORDER BY WBSIDA ASC,WBSIDA ASC,WBSIDB ASC,WBSIDC ASC,WBSIDD ASC,WBSIDE ASC");
                    while($row5 = mysql_fetch_array($result5 , MYSQL_ASSOC))
  		{
  		 
			$WBSIDA = $row5["WBSIDA"];
	  		$WBSIDB = $row5["WBSIDB"];
	  		$WBSIDC = $row5["WBSIDC"];
	  		$WBSIDD = $row5["WBSIDD"];
	  		$WBSIDE = $row5["WBSIDE"];
			$WBSID5 = $row5["WBSID"];
			
			
			?>
            <section>
               <h2 onclick="setcookiefunc('<?php echo $row5["WBSID"]; ?>')" class="acc_title_bar <?php if(strpos($string,'['.$row5["WBSID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active ";} ?>"><a class="ff" href="#"></a> <table width="100%"><tr>
    <td align="left"  width="9%" scope="col"><?php echo $row5["creationDate"]; ?></td>
    <td align="left"  width="8%"><?php echo $row5["sortCode"]; ?></td>
    <td align="left"  width="9%"><?php echo $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE; ?></td>
    <td align="left"  width="34%" ><?php echo $row5["description"]; ?></td>
    <td align="left"  width="20%"><?php echo $row5["writeupwbs"]; ?></td>
    <td colspan="2" align="right"  width="10%">
    <input id="button" name="button" type="image" value="INSERT WBS" src="../images/icon-insert.jpg" onclick="LoadWBSG(<?php echo $row5["WBSID"]; ?>, <?php echo $WID ?>,<?php echo $WBSID4;?>); return false" />
    &nbsp;&nbsp;<input id="IIButton" name="IIButton" type="image" src="../images/icon-ITEMS.png" width="16px" height="16px" onclick="LoadIITEMForm(<?php echo $row5["WBSID"]; ?>, <?php echo $WID ?>); return false" />
    &nbsp;&nbsp;<input id="editButton" name="editButton" onclick="LoadWBSEditForm(<?php echo $row5["WBSID"]; ?>, <?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png">&nbsp;&nbsp;<input type="image" onclick="call_del_DB(<?php echo $row5["WBSID"]; ?>, <?php echo $WID ?>);" img src="../images/icon-del.png" width="16" height="16" border="0" /></td>
    </tr></table></h2>
                <div id="<?php echo 'd'.$row5['WBSID']?>" class="<?php if(strpos($string,'['.$row5["WBSID"].']')==true){echo "displayblock";} ?> acc_container " >
                    <div class="block">
                    <?php callWBSItem($WBSID5,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID);?>
                    
                    
                    
                    </div>
                    </div>
             </section>
                    
                    <?php } // End of Fifth  level ?>
                    
                    
                    </div>
                    </div>
             </section>
                    
                    <?php } // End of Fourth  level ?>
                    
                    
                    
                    </div>
                    </div>
             </section>
                    
                    <?php } // End of third  level ?>
                    
                    
                    
                </div>
                    </div>
             </section>
                    
                    <?php } // End of second  level ?>
                   
                   
                  </div>
              </div>
             </section>
    
  
   <?php } // End of first level ?>
        
        </div></td>
    </tr>
    </table>
    <?php function callWBSItem($WBSID,$WBSIDA,$WBSIDB,$WBSIDC,$WBSIDD,$WBSIDE, $WID)
			{
			$cookiearrays = array();
$sess =array();
$sess = isset($_SESSION['acc_session'])?$_SESSION['acc_session']:"";
$strings ="[0000],";
if(is_array($sess)){
foreach($sess as $k=>$v){
     
     $strings .= '['.$v."],";
     $cookiearrays[$v] =  $v;

}
}

		 $result1 = mysql_query("SELECT * FROM globalitems where WBSID = '$WBSID' && itemParent = '0' ORDER BY itemID ASC");
		
   		while($row = mysql_fetch_array($result1 , MYSQL_ASSOC))
  		{
			?>
            <section>
               <h2 onclick="setcookiefunc('<?php echo $row["itemID"]; ?>')" class="acc_title_bar <?php if(strpos($strings,'['.$row["itemID"].']')==true){echo "theme-blue-title-bar theme-blue-title-active ";} ?>"><a class="ff" href="#"></a> <table width="100%"><tr >
    <td align="left" bgcolor="#F2F2FF" style="color:#000"  width="9%"><?php echo $row["dateCreated"]; ?></td>    
    
    <td align="left" bgcolor="#F2F2FF" style="color:#000"  width="8%">&nbsp;<?php echo $row["sortCode"]; ?></td>
    <td  width="9%" align="left" bgcolor="#F2F2FF" style="color:#000">
      <?php $items = $row["itemID"]; echo  $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE.".".$row["itemID"]; ?>
    </td>
    <td align="left" bgcolor="#F2F2FF" style="color:#000"  width="34%">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $row["description"]; ?></td>
    <td align="left"  width="30%" bgcolor="#F2F2FF" style="color:#000"><?php echo $row["writeupitem"]; ?></td>
    <td width="20%" align="right" bgcolor="#F2F2FF"><input id="IIButton" name="IIButton" type="image" src="../images/icon-ITEMS.png" width="16px" height="16px" onclick="LoadSIITEMForm(<?php echo $row["WBSID"]; ?>,<?php echo $row["itemID"]; ?>, <?php echo $WID ?>); return false" />&nbsp;&nbsp;<input name="editIButton" onclick="LoadITEMEditForm(<?php echo $row["itemID"]; ?>,<?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png"/>&nbsp;&nbsp;
    <input type="image" onclick="call_del_IDB(<?php echo $row["itemID"]; ?>,<?php echo $WID ?>);" src="../images/icon-del.png" /></td>
  </tr></table></h2>
                <div id="<?php echo 'd'.$row['itemID']?>" class="<?php if(strpos($strings,'['.$row["itemID"].']')==true){echo "displayblock";} ?> acc_container " >
                    <div class="block">
                    
<!--                    sub items 
-->                    
                    
           <?php
           
		   $result123 = mysql_query("SELECT * FROM globalitems where WBSID = '$WBSID' && itemParent = '$items' ORDER BY itemID ASC");
		
   		while($row1 = mysql_fetch_array($result123 , MYSQL_ASSOC))
  		{
		
  		?>
        
  <table width="100%"><tr class="a8">
    <td align="left" class="a8" scope="row"><?php echo $row1["dateCreated"]; ?></td>
    <td align="left" class="a8">&nbsp;&nbsp;<?php echo $row1["sortCode"]; ?></td>
    <td align="left" class="a8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo  $WBSIDA.".".$WBSIDB.".".$WBSIDC.".".$WBSIDD.".".$WBSIDE.".".$row1["itemID"];?></td>
    <td align="left" class="a8">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $row1["description"]; ?></td>
    <td align="left" class="a8"><?php echo $row1["writeupitem"]; ?></td>
    <td align="right" class="a8"><input name="editIButton" onclick="LoadITEMEditForm(<?php echo $row1["itemID"]; ?>,<?php echo $WID ?>); return false" type="image" src="../images/icon-edit.png"/></td>
    <td align="right" valign="top" class="a8"><input type="image" onclick="call_del_IDB(<?php echo $row1["itemID"]; ?>,<?php echo $WID ?>);" src="../images/icon-del.png" /></td>
  </tr></table>
  
  <?php }?>
                    
                    
                    
                    </div>
                    </div>
             </section>
		<?php }
			}
	?>