<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../includes/header_in.php');

?>
<style type="text/css">
    .fixed{display:none !important}
    div.FixedHeader_Cloned th,
    div.FixedHeader_Cloned td {
        background-color: white !important;
    }
    .first{
        display: none;
    }
    /*    .fixed{
            width: auto !important;
        }*/
    .dataTable, .FixedHeader_Header {width:100% !important}
    .dataTable thead i{
        margin-top: -5px;
    }
</style>
<script src="../includes/js/fixedheader.js"></script>
<style>
    .addon-label{width:13%}
    .addon-field{width:20%}
    #import a{    float: left;
    margin-top: 4px;
    margin-right: 8px;}
    #import input,#import select{ width:160px; float:left}
    .fa-share-square-o{color: #68a341;
    font-size: 17px !important;
    margin-left: 4px;}
        .alertify-buttons{text-align:right !important}
    .alertify-dialog {
    padding: 16px 20px;
}
.label-td{padding-left:0px !important; padding-right:0px !important}
#alertify{width:375px}
</style>

<script type="text/javascript">

function ImportWBS(str)

{

	

if (str=="" || str=="3" || str=="-1")

  {

  document.getElementById("import").innerHTML="";

  return;

  } 

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {			

		document.getElementById("import").style.display='';

		document.getElementById("import").innerHTML=xmlhttp.responseText;

		

	}

  }
if (str=="1")

  {
xmlhttp.open("GET","importPMWBSfield.php",true);
  }
  else
  xmlhttp.open("GET","importWBSfield.php",true); 
xmlhttp.send();



}

</script>

<section class="content">
    <div class="container">
        <div class="row">
            <div class="main-content">
                <h5>
                    <?php if (isset($_REQUEST["msg"])) { ?>
                        <?php echo $_REQUEST["msg"]; ?>
                    <?php } ?>
                </h5>

                <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
                    <?php if (!isset($_REQUEST['Edit'])) { ?>
                        <div class="add-formpage">
                            <form action="../../DB/03-scope/UWBSListDB.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
                                <fieldset>
                                    <div class="widget">
                                        <div class="whead">
                                            <h6>
                                                <i class="fa fa-plus-circle"></i>
                                                Add </h6>
                                            <strong><a href="javascript:void(0)" onclick="hideform()" class="teamclose"><i class="fa fa-times"></i></a></strong>

                                        </div>
                                        <div class="formRow">
                                            <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                                <label>Assign a WBS Code*:</label></div>
                                            <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                                <input name="code" type="text" class="a1" id="code" size="30" required="required"  /> </div>
                                            <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                                <label>Choose a WBS Type*:</label></div>
                                            <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                                <select name="WBStype" class="a1" id="WBStype" onchange="ImportWBS(this.value)" required>
        <option value="" selected="selected">Select a WBS Type</option>
        <option value="1">Import from PManywhere</option>
        <option value="2">Import from my CSV file</option> 
        <option value="3">New WBS from scratch</option>
        </select> </div>
                                            <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                                <label>Choose Import File:</label></div>
                                            <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                                
                                                    <div id="import"></div> 
                                                </div>
                                                
                                                </div>
                                            <div class="formRow">
                                            <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                                <label>GWBS Title</label>
                                            </div>
                                            <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                                <input name="WBStitle" type="text" class="a1" id="WBStitle" size="30"/> 
                                            </div>
                                            <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                                <label>Remarks (if any):</label>
                                            </div>
                                            <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                                <input name="WBSR" type="text" class="a1" id="WBSR" size="30"/> 
                                            </div>
                                            <div class="grid2 submit-btn save-bottom"> 
                                                <button type="submit" class="btn btn-success"><i class="fa fa-check-square"></i> </button>
                                            </div>
                                        
                                    </div>
                                    <div class="clear"></div>
                                 
                                </fieldset>  
                            </form>
                        </div>


                        <?php
                    } else {

                        
		$WID = $_REQUEST['Edit'];
   		$result = mysql_query("SELECT WBSList_code, WBSList_remarks, WBSList_title FROM wbslist where WBSList_id='$WID'");
   		$row = mysql_fetch_array($result , MYSQL_ASSOC);
		$WBSList_code = $row["WBSList_code"];
		$WBSList_remarks = $row["WBSList_remarks"];
		$WBSList_title = $row["WBSList_title"];
	
                        ?>

                        <div class="edit-formpage">
                            <form action="../../DB/03-scope/UWBSListDB.php?Edit=<?php echo $WID;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
                                <div class="widget">
                                    <div class="whead">
                                        <h6>
                                            <i class="fa fa-pencil-square-o"></i>
                                            Edit</h6>
                                        <span style="float:right"><a href="javascript:void(0)" onclick="hideeform()" style="font-size:16px; padding:5px 24px; display:inline-block"><i class="fa fa-times"></i></a></span>

                                    </div>
                                    <div class="formRow">
                                        <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                            <label>Assign WBS Code*:</label></div>
                                        <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                            <input name="code" type="text" class="a1" id="code" size="30" required="required"  value="<?php echo $WBSList_code;?>" /> </div>
                                        </div>
                                        
                                        <div class="formRow">
                                        <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                            <label>GWBS Title</label></div>
                                        <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                            <input name="WBStitle" type="text" class="a1" id="WBStitle" size="60"  value="<?php echo $WBSList_title;?>"/> </div>
                                        <div class="col-sm-1-8 addon-label" style="padding-right:0px;">
                                            <label>Remarks (if any):</label></div>
                                        <div class="col-sm-2-2 addon-field" style="padding-left:0px;">
                                            <input name="WBSR" type="text" class="a1" id="WBSR" size="60"  value="<?php echo $WBSList_remarks;?>"/> </div>
                                            
                                        <div class="grid2 submit-btn save-bottom"> 
                                            <button type="submit" class="btn btn-success"><i class="fa fa-check-square"></i> </button>
                                        </div>
                                    </div>
                                </div>
                            </form><div class="divider"><span></span></div>

                        </div>

                        <?php
                    }
                }
                ?>
                <div class="table-subject">

                    <!--  -->

                    <div class="widget">
                        <div class="whead">
                            <h6 id="active-desciplines" >
                                <b>
                                    <i class="fa fa-pie-chart"></i>
                                    Add WBS Names
                                </b> 
                            </h6>
                     <span style="line-height: 35px;">
                        <a onclick="bottomfooterfunc()" href="#hidden-data" class="hidden-entry" >
                                    <!--                            Go to Hidden List-->
                                    <span class="icon-eye_box bck"></span>
                        </a>&nbsp;
                        <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
                        <?php if(!isset($_REQUEST['Edit'])) {?>
                        <a onclick="showaddform()" style="cursor:pointer"  class="addform-btn " id=""><span class="icon-plus_box  bck"></span></a>
                        <a onclick="hideform()" style="cursor:pointer" class="hideform-btn " id=""><span class="icon-minus_box  bck"></span></a>
                        
                             <?php } else {
                              ?>
                       <a onclick="showeditform()" style="cursor:pointer"  class="eform-btn " id=""><i class="fa fa-pencil-square-o green-icon"></i></a>
                       <a onclick="hideeform()" style="cursor:pointer" class="hideeform-btn " id=""><span class="icon-minus_box  bck"></span></a>
                        
                              <?php 
                          }?>
                        <?php } ?>
                   </div>
                        <div>
                            <!-- <div class="scroll"> -->
                            <table cellpadding="0" cellspacing="0" class="" style="width:100%; position:relative !important"  id="active_descipline_tbl">
                                <thead>
                                    <tr>
                                        <th class="first"></th>
                                        <th class="date-create WBSl-dcreated" >
                                            Date Created
                                            <br />
                                            (yyyy.mm.dd) <i class="fa fa-sort"></i>
                                        </th>
                                        <th  class="WBSl-ID" align="left" valign="top" scope="col">
                                            WBS <br />
      Code <i class="fa fa-sort"></i>
                                        </th>
                                        <th  class="WBSl-TITLE" align="left" valign="top" scope="col">
                                            WBS <br />
      Title<i class="fa fa-sort"></i>
                                        </th>
                                        <th  class="WBSl-TYPE"  align="left" valign="top" scope="col">
                                            WBS<br />
    Type<i class="fa fa-sort"></i>
                                        </th>
                                        <th class="WBSl-remarks">
                                            WBS
                                          Remarks
                                        <br />Import    Filename <i class="fa fa-sort"></i></th>
                                        
                                    <th class="WBSl-actions action-icon" style="text-align:right">
                                            Action<br />
       Status 
                                        </th>

                                        
                                        <!-- <th></th> -->
                                    </tr>
                                </thead>
                                <tbody>
                                   <?php
 $resultw = mysql_query("SELECT * FROM wbslist where WBSList_for=1 AND WBSList_companyid = '$id' AND WBSList_status='1'"); 
		while($row = mysql_fetch_array($resultw , MYSQL_ASSOC))
  		{
     ?>   

                                        <tr >
                                           <td class="first"></td>
                                            <td class="WBSl-dcreated" align="left" valign="middle" scope="col"></th><?php echo $row["WBSList_datecreation"]; ?></td>
                                            <td class="WBSl-ID" align="left" valign="middle" ><?php echo $row['WBSList_code']; ?></td>
                                            <td class="WBSl-ID" align="left" valign="middle" ><?php echo $row['WBSList_title']; ?></td>
                                            <td class="WBSl-TYPE"align="left" valign="middle" scope="col"><?php if($row['WBSList_type'] =='2') echo "Imported from CSV-File"; else if($row['WBSList_type'] =='3')  echo "New WBS"; else if($row['WBSList_type'] =='1') echo "Imported from PM-WBS"; ?></td>
                                            
                                            
                                            <td class="WBSl-remarks" align="left" valign="middle" scope="col"><?php echo $row['WBSList_remarks']; ?><br /><?php echo $row['WBSList_file_name']; ?></td>
                                            
                                            
                                            <td class="WBSl-actions action-icons" align="right" valign="middle">
<div  class="close-icon">   
       <a id="<?php echo $row["WBSList_id"]; ?>" class='confirm' href="" ><i class="fa fa-share-square-o " title="export">

                                        </i></a>
</div>
    <?php if ($uacc == "Full Control") { ?>
         <div class="close-icon"> 
         <a href="javascript:void(0)" onclick="deleteWBSl(<?php echo $row["WBSList_id"] ?>)">
           <div class="glyph">
              <div class="fs1 iconb" data-icon="" title="Delete"></div>
           </div>
         </a> 
         </div>
    <?php } else { ?> 						
    <div class="glyph">
        <div class="fs1 iconb" data-icon="" title="Delete"></div>
    </div> 
    <?php } ?>
    <?php if ($uacc == "Full Control" || $uacc == "Consolidate") { ?>
     <div class="edit-icon">
         <a href="WBSlist1.php?Edit=<?php echo $row["WBSList_id"]; ?>">
            <div class="glyph">
              <div class="fs1 iconb" data-icon="" title="Edit"></div>
              </div>
         </a> 
      </div>
    <?php } else { ?>
        <div class="glyph">
             <div class="fs1 iconb" data-icon="" title="Edit"></div>
         </div>
    <?php } ?>
    
    <?php if ($uacc == "Full Control") { ?>
         <div class="eye-icon">   
            <a href="../../DB/03-scope/UWBSListDB.php?InActive=<?php echo $row['WBSList_id']; ?>">
              <div class="glyph">
                <div class="fs1 iconb" data-icon="" title="Hide" ></div>
              </div>
            </a> 
         </div>
    <?php } else { ?>
           <div class="glyph">
               <div class="fs1 iconb" data-icon="" title="Hide" ></div>
           </div>

    <?php } ?>  
    
    
    <?php if ($uacc == "Full Control"  || $uacc == "Consolidate") { ?>
         <div style="font-size:14px">   
            <a href="WBS-ITEM-G.php?WID=<?php echo $row['WBSList_id']; ?>">
              <span class="icon-tree" style="margin-right:0px"></span>
            </a> 
         </div>
    <?php } else { ?>
          <div style="font-size:14px">   
            
              <span class="icon-tree" style="margin-right:0px"></span>
           
         </div>

    <?php } ?>   

                                            </td>

                                      <?php
                                        $typid = $row["WBSList_id"];
                                        $path = "03-scope";
                                        $type = "WBSlist1";
                                        $attach = 0;
                                        $note = 1;
                                        include('../includes/noterow2.php');
                                        ?>

                                        </tr>

<?php } ?>
                                </tbody>
                            </table>
                     
                        </div>
                    </div>
                </div>
            </div>
            <div class="divider"><span></span></div>
        </div>
    </div>

    <!--  -->


</div>
</div>
</div>
</div>
</section>
<footer>
    <div class="container">
        <div class="row">
            <div class="top-footer">
                <div class="instructions-cont">
                    <i class="fa fa-info-circle"></i>
                    <h6>Instructions </h6>
                    <span>
                        <a onclick="bottomfooterfunc()" href="#addonhidden-data" class="hidden-entry" >View The Hidden List</a>|
                        <a href="#active-desciplines">Go to Active List</a></span>
                </div>
                <div class="left-warning"> Deletion is permanent and can not be retrieved.  If a  parameter has been used at other places, deletion might cause problems.  A 
                    parameter can be deleted only after its usage is removed from other places.  
                    If you dont want to see an entry or a parameter, you can hide it instead of deleting it.  A Hidden entry or parameter will  show as &quot;HIDDEN&quot; at all places where it was used before.  
                    <!--Table of Hidden Values is given below--> 
                </div>
            </div>
            <div class="bottom-footer" id="addonhidden-data">
                <table cellpadding="0" cellspacing="0" width="100%" class="tDark" id="hidden-entry">
                    <thead>
                        <tr >
                            <th class="WBSl-dcreated" align="left" valign="top" bgcolor="#E2E2E2" scope="col">Date Created<br />
      (yyyy.mm.dd)</th>
                            <th class="WBSl-description" align="left" valign="top" bgcolor="#E2E2E2" scope="col">WBS <br />
Code</th>
                            <th class="WBSl-description" align="left" valign="top" bgcolor="#E2E2E2" scope="col"><span class="WBSl-percent">WBS Type</span></th>
                            <th class="WBSl-percent" align="left" valign="top" bgcolor="#E2E2E2" scope="col"><span class="WBSl-remarks">WBS
                                          Remarks <br />
                            Import    Filename</span></th>
                            <th class="WBSl-actions action-icons" align="right" valign="top" bgcolor="#E2E2E2" scope="col">Unhide</th>
                        </tr>
                    </thead>
                    <?php
                    $result2 = mysql_query("SELECT * FROM wbslist where WBSList_for=1 && WBSList_companyid = '$id' AND WBSList_status='0'");
                    while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
                        ?>  

                        <tr class="">
                            <td class="WBSl-dcreated" align="left" valign="top" scope="col"></th>
                            <?php echo $row2["WBSList_datecreation"]; ?></td>
                            <td class="WBSl-description" align="left" valign="top" ><span class="WBSl-ID"><?php echo $row2['WBSList_code']; ?></span></td>
                            <td class="WBSl-description" align="left" valign="top" ><span class="WBSl-ID">
                              <?php if($row2['WBSList_type'] =='2') echo "Imported from CSV-File"; else if($row2['WBSList_type'] =='3')  echo "New WBS"; else if($row2['WBSList_type'] =='1') echo "Imported from PM-WBS"; ?>
                            </span><br /></td>
                            <td class="WBSl-percent" align="left" valign="top" scope="col"><span class="WBSl-remarks"><?php echo $row2['WBSList_remarks']; ?><br />
                            <?php echo $row2['WBSList_file_name']; ?></span></td>
                            <td align="right" valign="top" class="WBSl-actions action-icons">
                                <div class="eye-icon"> 
    <?php if ($uacc == "Full Control") { ?>
         <a href="../../DB/03-scope/UWBSListDB.php?Active=<?php echo $row2['WBSList_id']; ?>">
           <div class="glyph">
             <div class="fs1 iconb" data-icon="" title="Unhide"></div>
           </div>
         </a>
    <?php } else { ?>
          <div class="glyph">
             <div class="fs1 iconb" data-icon="" title="Unhide"></div>
          </div>
    <?php } ?> </div></td>
                        </tr>


<?php } ?>
                </table>
            </div>
        </div>
    </div>
</footer>
<script type='text/javascript' src='../libraries/dialog/js/jquery.simplemodal.js'></script>
<script type='text/javascript' src='../libraries/dialog/js/confirm.js'></script>
<script>

   
    function deleteWBSl(id) {

        alertify.confirm("This record will be deleted and cannot be retrieved. Press OK to Delete.", function (e) {
            if (e) {
                window.location.href = "../../DB/03-scope/UWBSListDB.php?del=" + id;

            } else {
                return 0;
            }
        });
    }
</script>
<script type="text/javascript">
function format(d) {
        // `d` is the original data object for the row
        // console.log(d.details);
        return '<div >' + d.details + '</div>';
    }
// i = showing 1 of 2 pages
// f = filter or search
// p = pages buttons
// l = records per page drop down

    

    active_descipline_table = $('#active_descipline_tbl').DataTable({
        "bJQueryUI": false,
        "bAutoWidth": false,
        "columns": [
            {
                "className": 'details-control',
                "orderable": false,
                "defaultContent": '',
            },
			{"data": "WBSl-dcreated"},
            {"data": "WBSl-ID"},
            {"data": "WBSl-TITLE"},
			{"data": "WBSl-TYPE"},
            {"data": "WBSl-remarks"},
            {"data": "WBSl-actions"},
            {"data": "details", "visible": false}
        ],
        "order": [[1, 'asc']],
        "lengthMenu": [[-1, 10, 25, 50], ["All", 10, 25, 50]],
        "sPaginationType": "full_numbers",
        "sDom": '<"tOptions" f><"top">rt<"bottom" pil><"clear">',
        "oLanguage": {
            "sLengthMenu": "<span class='showentries'>Show entries:</span> _MENU_"
        },
		"aoColumnDefs": [{"bSortable": false, "aTargets": [7]}]
    });

    $('div.dataTables_filter input[type=search]').attr('placeholder', 'Type to Start Search');
    var active_descipline_table1 = $('#active_descipline_tbl').DataTable();
    new $.fn.dataTable.FixedHeader(active_descipline_table1, {
        bottom: true
    });
	
	$('.details-control').ready(function () {

        no_of_records = active_descipline_table.page.info().recordsTotal;
        for (var i = 0; i < no_of_records; i++) {
            active_descipline_table.row(i).child(format(active_descipline_table.row(i).data())).show();
        }
        ;


    });
	
	 function bottomfooterfunc() {
        $('#addonhidden-data').toggle('slow');
   }
    
</script>
<?php include('../includes/footer.php'); ?>