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


<style>
    .fixed{display:none !important}
    div.FixedHeader_Cloned th,
    div.FixedHeader_Cloned td {
        background-color: white !important;
    }
	.rs-code
	{
		width:54% !important;}
    .first{
        display: none;
    }
    .dataTable, .FixedHeader_Header {width:100% !important}
    .dataTable thead i{
        margin-top: -5px;
    }
       .imgview{
        height: 16px;
    width: 16px;
    margin-left: 4px;
    margin-top: 3px;
}
.notesDIV .col-attachment{float:left}
</style>
<script src="../includes/js/fixedheader.js"></script>
<section class="content">

    <div class="container">

        <div class="row">

            <div class="main-content">

                <!--<h5>-->

                <h5>

                    <?php if (isset($_REQUEST["msg"])) { ?>

                        <?php echo $_REQUEST["msg"]; ?>

                    <?php } ?>
                    <?php if (isset($_REQUEST["msg1"])) { ?>

                        <?php echo $_REQUEST["msg1"]; ?>

                    <?php } ?>

                </h5>
                <?php
                if ($uacc == "Full Control") {
                    if (!isset($_REQUEST['Edit'])) {
                        ?>

                        <div class="add-formpage">
                            <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>
                                <form method="post" enctype="multipart/form-data" action="../../DB/03-scope/StandardsDB.php" name="form1" id="form1" >
                                    <div class="formRow">
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Standard Prefix:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select  name="stdprefix"  id="stdprefix">
                                                <option value="ACI">ACI</option>
                                                <option value="AISI">AISI</option>
                                                <option value="AISC">AISC</option>
                                                <option value="AISI">AISI</option>
                                                <option value="ANSI">ANSI</option>
                                                <option value="ASHRAE">ASHRAE</option>
                                                <option value="ASCE">ASCE</option>
                                                <option value="ASTM">ASTM</option>
                                                <option value="AWS">AWS</option>
                                                <option value="BICSI">BICSI</option>
                                                <option value="BS">BS</option>
                                                <option value="EIA">EIA</option>
                                                <option value="EN">EN</option>
                                                <option value="IBC">IBC</option>
                                                <option value="ISO">ISO</option>
                                                <option value="ITU">ITU</option>
                                                <option value="NEC">NEC</option>
                                                <option value="NEMA">NEMA</option>
                                                <option value="PCI">PCI</option>
                                                <option value="TIA">TIA</option>
                                                <option value="UBC">UBC</option>
                                                <option value="UL">UL</option>
                                            </select>
                                        </div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Standard Code/ No.:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="stdcode" type="text"  id="stdcode" /></div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px; width:53px !important">
                                            <label>Title:</label></div>
                                        <div class="col-sm-2-2 field-assign" style="padding-left:0px;">
                                            <input name="stdname" type="text"  id="stdname" style="width:300px !important" /></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>

                                </form>
                            </div>

                        </div>
                    <?php
                    } else {

                        $SID = $_REQUEST['Edit'];
                        $result = mysql_query("SELECT * FROM scope_std where stdId ='$SID'");

                        $row = mysql_fetch_array($result, MYSQL_ASSOC);

                        $stdID = $row['stdId'];
                        $stdName = $row['stdName'];
                        $stdPrefix = $row['stdPrefix'];
                        $stdCode = $row['stdCode'];
                        $stdNotes = $row['stdNotes'];
                        $stdFiles = $row['stdFile'];
                        ?>
                         <div class="edit-formpage">
                                
                            <div class="widget">

                                <div class="whead">

                                    <h6>

                                        <i class="fa fa-pencil-square-o"></i>

                                        Edit

                                    </h6>

                                    <strong><a href="javascript:void(0)" onclick="hideeform()" class="teamclose"><i class="fa fa-times"></i></a></strong> </div>
                                 
                        <form method="post" enctype="multipart/form-data" action="../../DB/03-scope/StandardsDB.php?Edit=<?php echo $stdID; ?>" name="form1" id="form1" >
                           
                             <div class="formRow">
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Standard Prefix:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                              <select name="stdprefix"  id="stdprefix">
                                            <option <?php if ($stdPrefix == "ACI") { ?> selected="selected" <?php } ?>value="ACI">ACI</option>
                                            <option  <?php if ($stdPrefix == "AISI") { ?> selected="selected" <?php } ?>value="AISI">AISI</option>
                                            <option  <?php if ($stdPrefix == "AISC") { ?> selected="selected" <?php } ?>value="AISC">AISC</option>
                                            <option  <?php if ($stdPrefix == "AISI") { ?> selected="selected" <?php } ?>value="AISI">AISI</option>
                                            <option  <?php if ($stdPrefix == "ANSI") { ?> selected="selected" <?php } ?>value="ANSI">ANSI</option>
                                            <option  <?php if ($stdPrefix == "ASHRAE") { ?> selected="selected" <?php } ?>value="ASHRAE">ASHRAE</option>
                                            <option  <?php if ($stdPrefix == "ASCE") { ?> selected="selected" <?php } ?>value="ASCE">ASCE</option>
                                            <option  <?php if ($stdPrefix == "ASTM") { ?> selected="selected" <?php } ?>value="ASTM">ASTM</option>
                                            <option  <?php if ($stdPrefix == "AWS") { ?> selected="selected" <?php } ?>value="AWS">AWS</option>
                                            <option  <?php if ($stdPrefix == "BICSI") { ?> selected="selected" <?php } ?>value="BICSI">BICSI</option>
                                            <option  <?php if ($stdPrefix == "BS") { ?> selected="selected" <?php } ?>value="BS">BS</option>
                                            <option  <?php if ($stdPrefix == "EIA") { ?> selected="selected" <?php } ?>value="EIA">EIA</option>
                                            <option  <?php if ($stdPrefix == "BCI") { ?> selected="selected" <?php } ?>value="IBC">IBC</option>
                                            <option  <?php if ($stdPrefix == "ICS") { ?> selected="selected" <?php } ?>value="ICS">ICS</option>
                                            <option  <?php if ($stdPrefix == "ISO") { ?> selected="selected" <?php } ?>value="ISO">ISO</option>
                                            <option  <?php if ($stdPrefix == "ITU") { ?> selected="selected" <?php } ?>value="ITU">ITU</option>
                                            <option  <?php if ($stdPrefix == "NEC") { ?> selected="selected" <?php } ?>value="NEC">NEC</option>
                                            <option  <?php if ($stdPrefix == "NEMA") { ?> selected="selected" <?php } ?>value="NEMA">NEMA</option>
                                            <option  <?php if ($stdPrefix == "PCI") { ?> selected="selected" <?php } ?>value="PCI">PCI</option>
                                            <option  <?php if ($stdPrefix == "TIA") { ?> selected="selected" <?php } ?>value="TIA">TIA</option>
                                            <option  <?php if ($stdPrefix == "UBC") { ?> selected="selected" <?php } ?>value="UBC">UBC</option>
                                            <option  <?php if ($stdPrefix == "UL") { ?> selected="selected" <?php } ?>value="UL">UL</option>
                                            
                                        </select>
                                        </div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Standard Code/ No.:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                          <input value="<?php echo $stdCode; ?>"name="stdcode" type="text"  id="stdcode" /></div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px; width:53px !important">

                                            <label>Title:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                              <input name="stdname" value="<?php echo $stdName; ?>" type="text"  id="stdname" style="width:300px !important" /></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>
                       
                        </form>
                        
                        </div>
            </div>
                    <?php }
                } ?>

<div class="table-subject">

            <!--  -->

            <div class="widget">
                <div class="whead">
                    <h6 id="active-desciplines" >
                        <b>
                            <i class="fa fa-certificate"></i>                    
                            List of Standards
                        </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>
                        <?php if ($uacc == "Full Control") { ?>
                        <?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 } ?>
                    </span>

                                    </div>
              
                 <table cellpadding="0" cellspacing="0" class="" style="width:100%;position:relative !important"  id="active_descipline_tbl">
<thead>
                    <tr >
                        <th width="1%" class="first"></th>
                        <th width="15%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-datecreation " scope="col">Date Created<br />
                            (yyyy.mm.dd)
                            </th>
                        <th width="11%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-cat" scope="col">Standard<br />
                            Code</th>
                        <th width="54%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-code" scope="col">Standard <br />
                            Name</th>
                        <th width="19%" align="right" valign="top" bgcolor="#E2E2E2" class="rs-actions action-icons" scope="col">  Actions<br />
                            Status</th>
                    </tr>
                   
</thead>
<tbody>
                    <?php
                    $result = mysql_query("SELECT * FROM scope_std
WHERE scope_std.stdCompany = '$id'
AND scope_std.stdStatus=1");

                    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        ?> 

                        <tr >
                            <td class="first"></td>
                            <td  class="rs-datecreation " align="left" valign="top"  scope="col"><?php echo $row['stdDateCreated']; ?></td>
                            <td  class="rs-cat" align="left" valign="top"><?php echo $row['stdPrefix'] . " - " . $row['stdCode']; ?></td>
                            <td  class="rs-code" align="left" valign="top" ><?php echo $row['stdName']; ?></td>
                            <td  class="rs-actions action-icons" align="right" valign="top" >
                              
                                
                        <?php if ($uacc == "Full Control") { ?>
                                 <div class="close-icon"> <a href="javascript:void(0)" onclick="showConfirm('<?php echo $row["stdId"]; ?>')">
                                                        <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") { ?>
                                <div class="edit-icon"> <a href="Standards1.php?Edit=<?php echo $row["stdId"]; ?>">
                                                        <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/StandardsDB.php?InActive=<?php echo $row['stdId']; ?>">
                                                        <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 } ?> 

                            </td>
                            <?php
                       $typid = $row["stdId"];
                        $path = "03-scope";
                        $type = "Standards1";
                        $attach = 1;
                        $reminder = 0;
                        $note = 1;
                        include('../includes/noterow2.php');
                        ?>
                        </tr>
                        
<?php } ?>
</tbody>
                        </table>
                    </div>
                </div>



            </div>

            <div class="divider"><span></span></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="#hidden-data" class="hidden-entry" >View The Hidden List</a> &nbsp; | 
                        <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="hidden-data">
                <table cellpadding="0" cellspacing="0" width="100%" class="tDark" id="hidden-entry">
                    <thead>
                        <tr >
                        
                        <th width="15%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-datecreation " scope="col">Date Created<br />
                            (yyyy.mm.dd)
                            </th>
                        <th width="11%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-cat" scope="col">Standard<br />
                            Code</th>
                        <th width="54%" align="left" valign="top" bgcolor="#E2E2E2" class="rs-code" scope="col">Standard <br />
                            Name</th>
                        <th width="19%" align="right" valign="top" bgcolor="#E2E2E2" class="rs-actions action-icons" scope="col">  Actions<br />
                            Status</th>
                    </tr>
                   
                    </thead>
                    <tbody>
                        <?php
                        $result = mysql_query("SELECT * FROM scope_std
WHERE scope_std.stdCompany = '$id'
AND scope_std.stdStatus=0  ORDER BY stdDateCreated DESC, stdName ASC");
                        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                          
                                    ?>

                            <tr >
                                <td class="bfc-datecreated" align="left" valign="top"  scope="col"><span class="rs-datecreation "><?php echo $row['stdDateCreated']; ?></span></td>
                                <td class="bfc-developed " align="left" valign="top" ><span class="rs-cat"><?php echo $row['stdPrefix'] . " - " . $row['stdCode']; ?></span></td>
                                <td class="bfc-cycle" align="left" valign="top" ><span class="rs-code"><?php echo $row['stdName']; ?></span></td>
                                <td class="bfc-actions action-icons" valign="top"><?php if ($uacc == "Full Control") { ?>
                                        <a href="../../DB/03-scope/StandardsDB.php?Active=<?php echo $row['stdId']; ?>">
                                            <div class="glyph">
                                                <div class="fs1 iconb" data-icon="" title="Hide" ></div>
                                            </div>
                                        </a>
    <?php } else { ?>
                                        <div class="glyph">
                                            <div class="fs1 iconb" data-icon="" title="Hide" ></div>
                                        </div>
                            <?php } ?></td>
                            </tr>
<?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<script>
    function togglefunction() {
        $(".add-project").toggle("slow");
    }
   
</script>
<script type="text/javascript">

    function format(d) {
        // `d` is the original data object for the row
//        console.log(d.details);
        return '<div class="notesDIV">' + d.details + '</div>';
    }

    active_units_table = $('#active_descipline_tbl').DataTable({
        "columns": [
            {
                "className": 'details-control',
                "orderable": false,
                "defaultContent": '',
            },
            {"data": "rs-datecreation"},
            {"data": "rs-cat"},
            {"data": "rs-code"},
            {"data": "rs-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": [5]}]
    });

    $('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_units_table.page.info().recordsTotal;
        for (var i = 0; i < no_of_records; i++) {
            active_units_table.row(i).child(format(active_units_table.row(i).data())).show();
        }
        ;


    });


function showConfirm(did) {
        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/StandardsDB.php?del=" + did;

            } else {
                return 0;
            }
        });
    }

</script>