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

$order_type = "ASC";
$order_par = "projectCode";
if (isset($_REQUEST['otype'])) {
    $order_type = $_REQUEST['otype'];
}

if (isset($_REQUEST['opar'])) {
    $order_par = $_REQUEST['opar'];
}
?>

<style>
    .briefc-field{width:35%}
    .briefc-field .single-select{width:100%}
    .briefc-field .double-select, .briefc-field #briefCfrom{width:49%}
    .first{display:none}
    .formRow select#projname,.formRow select#clientname{width:100%}
    .bfc-datecreated{width:12%}
    .bfc-brieffrom{width:9%}
    .bfc-datename{width:17%}
    .bfc-developed{width:15%}
    .bfc-cycle{width:22%}
    .bfc-range{width:13%}
    .bfc-action{width:12%}
    .add-briefClient{display:none}
    .fixed{display:none}
    .bck{font-size:18px !important;}
    #add-descipline{padding:0 !important}
    #briefClist{float:right}
    th.bfc-actions{text-align: left}
    .label-notes,.label-prjcode,.label-descomp{width:10%}
    .col-sm-1-8.label-of {
        width: 3%;
        padding: 0;
    }
    .field-notes{width:85%}
    @media (max-width:480px){
        .bfc-datecreated{display:none}
        .bfc-brieffrom{width:14%}
        .bfc-datename{width:50%}
        .bfc-developed{display:none}
        .bfc-cycle{display:none}
        .bfc-actions{width:32%}
    }
</style>
<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") {
                    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" name="form2" id="form2" action="../../DB/03-scope/DWG1DB.php" onsubmit="return validatefield('discipline_id', 'dwgsuffix', 'noofdwg', 'rangeto', 'rangefrom', 'dwg_type', 'designtype', 'projname', 'complevel2')">
                                    <div class="formRow">

                                        <div class="col-md-4 label-assign" style="padding-right:0px;">

                                            <label>Project Name/Code*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="projname" class="" id="projname">
                                                 <option value="">Select</option>
                                                <?php
                                                $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects where companySerial = '$id' AND projStatus=1");


                                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                                    $projectSerial = $row['projectSerial'];
                                                    echo "<option value='$projectSerial'>" . $row["projectCode"] . " - " . $row["projectName"] . "</option>";
                                                }
                                                ?>  
                                            </select></div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Design Completion*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="complevel2" class="" id="complevel2">
                                                 <option value="">Select</option>
                                                <option value="30">30 percent</option>
                                                <option value="50">50 percent</option>
                                                <option value="90">90 percent</option>
                                                <option value="100">100 percent</option>
                                            </select>  </div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label style="text-align:center">    of </label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="designtype" class="" id="designtype">
                                                 <option value="">Select</option>
                                                <option value="Conceptual Design">Conceptual Design</option>
                                                <option value="Developed Design">Developed Design</option>
                                                <option value="Detailed Design">Detailed Design</option>
                                                <option value="Shop Drawings">Shop Drawings</option>
                                                <option value="As-Built">As-Built</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="formRow">
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>No of Dwgs:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="noofdwg" type="text" placeholder="Range From" class="" id="noofdwg" onchange="check_is_number(this, this.value)"/> </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Range*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="rangefrom" placeholder="Range To" type="text" class="" id="rangefrom" onchange="getLastValue(this, this.value)"/> </div>


                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label style="text-align:center">    to </label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="rangeto" type="text" class="" id="rangeto" readonly="readonly" /> </div>

                                    </div>
                                    <div class="formRow">

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>DWG Type:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="dwg_type" class="" id="dwg_type">
                                                <option value="">Select</option>
                                               <option value="3D Visualisation">3D Visualisation</option>
        <option value="Bid Package">Bid Package</option>
        <option value="Isometric">Isometric</option>
        <option value="Issue for Construction">Issue for Construction</option>
        <option value="Issue for Construction - Key Drawing">Issue for Construction - Key Drawing</option>
        <option value="Issue for Construction - Shop Drawing">Issue for Construction - Shop Drawing</option>
        <option value="Sketch">Sketch</option>
                                            </select>
                                        </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Dwgs Suffix:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="dwgsuffix" type="text" class="" id="dwgsuffix" size="100" /> </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Discipline:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">

                                            <select  name="discipline_id"  id="discipline_id">

                                                <option value="">Select</option>

                                                <?php
                                                $result = mysql_query("SELECT discipline_id,discipline_name FROM discipline where discipline_company_id = '$id' AND discipline_status=1 order by discipline_name");

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

                                                    $discipline = $row['discipline_id'];

                                                    echo "<option value='$discipline'>" . $row["discipline_name"] . "</option>";
                                                }
                                                ?>

                                            </select></div>

                                    </div>


                                    <div class="formRow">

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Notes (If Any):</label></div>
                                        <div class="col-sm-2-2 field-notes " style="padding-left:0px;">
                                            <input name="dwglistingnotes" type="text" class="" id="dwglistingnotes" size="100" /> </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 {

                        $dwgID = $_REQUEST['Edit'];
                        $result = mysql_query("SELECT * FROM scope_dwg where dwgID ='$dwgID'");

                        $row = mysql_fetch_array($result, MYSQL_ASSOC);

                        $dwgID = $row['dwgID'];
                        $dwgNotes = $row['dwgNotes'];
                        $dwgcomplePercent = $row['dwgcomplePercent'];
                        $dwgType = $row['dwgType'];
                        $dwgProject = $row['dwgProject'];
                        ?>
                        <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" name="form2" id="form2" action="../../DB/03-scope/DWG1DB.php?Edit=<?php echo $dwgID ?>" onsubmit="return validatefield('discipline_id', 'dwgsuffix', 'noofdwg', 'rangeto', 'rangefrom', 'dwg_type', 'designtype', 'projname', 'complevel2')">


                                    <div class="formRow">

                                        <div class="col-md-4 label-assign" style="padding-right:0px;">

                                            <label>Project Name/Code*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="projname" class="" id="projname">
                                                 <option value="">Select</option>
                                                <?php
                                                $result = mysql_query("SELECT projectSerial,projectCode, projectName FROM projects where companySerial = '$id' AND projStatus=1");


                                                while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                                    $projectSerial = $rows['projectSerial'];
                                                    if ($rows["projectSerial"] == $dwgProject)
                                                        echo "<option selected='selected' value='$projectSerial'>" . $rows["projectCode"] . " - " . $rows["projectName"] . "</option>";
                                                    else
                                                        echo "<option value='$projectSerial'>" . $rows["projectCode"] . " - " . $rows["projectName"] . "</option>";
                                                }
                                                ?>  
                                            </select>
                                        </div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Design Completion*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="complevel2" class="" id="complevel2">
                                                 <option value="">Select</option>
                                                <option value="30" <?php if ($dwgcomplePercent == 30) { ?> selected <?php } ?>>30 percent</option>
                                                <option value="50" <?php if ($dwgcomplePercent == 50) { ?> selected <?php } ?>>50 percent</option>
                                                <option value="90" <?php if ($dwgcomplePercent == 90) { ?> selected <?php } ?>>90 percent</option>
                                                <option value="100" <?php if ($dwgcomplePercent == 100) { ?> selected <?php } ?>>100 percent</option>
                                            </select>
                                        </div>
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label style="text-align:center">    of </label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="designtype" class="" id="designtype">
                                                 <option value="">Select</option>
                                                <option value="Conceptual Design" <?php if ($dwgType == "Conceptual Design") { ?> selected <?php } ?>>Conceptual Design</option>
                                                <option value="Developed Design" <?php if ($dwgType == "Developed Design") { ?> selected <?php } ?>>Developed Design</option>
                                                <option value="Detailed Design" <?php if ($dwgType == "Detailed Design") { ?> selected <?php } ?>>Detailed Design</option>
                                                <option value="Shop Drawings" <?php if ($dwgType == "Shop Drawings") { ?> selected <?php } ?>>Shop Drawings</option>
                                                <option value="As-Built" <?php if ($dwgType == "As-Built") { ?> selected <?php } ?>>As-Built</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="formRow">
                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>No of Dwgs:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input type="hidden" id="prenoofdwgs" value="<?php echo $row['no_of_dwgs'] ?>">
                                            <input name="noofdwg" type="text" class="" id="noofdwg" value="<?php echo $row['no_of_dwgs'] ?>" onchange="ConfirmNoOfDwgs(this, this.value)"/> </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Range*:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="rangefrom" type="text" class="" id="rangefrom"  value="<?php echo $row['range_from'] ?>" readonly/> </div>


                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label style="text-align:center">    to </label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="rangeto" type="text" class="" id="rangeto"  value="<?php echo $row['range_to'] ?>" readonly/> </div>

                                    </div>
                                    <div class="formRow">

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>DWG Type:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <select name="dwg_type" class="" id="dwg_type">
                                                   <option value="">Select</option>
                                                         <option <?php
                                                if ($row['dwg_type'] == "3D Visualisation") {
                                                    echo "selected";
                                                }
                                                ?>value="3D Visualisation">3D Visualisation</option>
        <option <?php
                                                if ($row['dwg_type'] == "Bid Package") {
                                                    echo "selected";
                                                }
                                                ?>value="Bid Package">Bid Package</option>
        <option <?php
                                                if ($row['dwg_type'] == "Isometric") {
                                                    echo "selected";
                                                }
                                                ?>value="Isometric">Isometric</option>
        <option <?php
                                                if ($row['dwg_type'] == "Issue for Construction") {
                                                    echo "selected";
                                                }
                                                ?>value="Issue for Construction">Issue for Construction</option>
        <option <?php
                                                if ($row['dwg_type'] == "Issue for Construction - Key Drawing") {
                                                    echo "selected";
                                                }
                                                ?>value="Issue for Construction - Key Drawing">Issue for Construction - Key Drawing</option>
        <option <?php
                                                if ($row['dwg_type'] == "Issue for Construction - Shop Drawing") {
                                                    echo "selected";
                                                }
                                                ?>value="Issue for Construction - Shop Drawing">Issue for Construction - Shop Drawing</option>
        <option <?php
                                                if ($row['dwg_type'] == "Sketch") {
                                                    echo "selected";
                                                }
                                                ?>value="Sketch">Sketch</option>
                                             
                                            </select>
                                        </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Dwgs Suffix:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">
                                            <input name="dwgsuffix" type="text" class="" id="dwgsuffix" value="<?php echo @$row['dwg_suffix'] ?>" /> </div>

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Discipline:</label></div>
                                        <div class="col-sm-2-2 field-assign " style="padding-left:0px;">

                                            <select  name="discipline_id"  id="discipline_id">

                                                <option value="">Select</option>

                                                <?php
                                                $result = mysql_query("SELECT discipline_id,discipline_name FROM discipline where discipline_company_id = '$id' AND discipline_status=1 order by discipline_name");

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

                                                    $discipline = $row['discipline_id'];
                                                    ?>
                                                    <option value='<?php echo $discipline ?>' <?php
                                                    if ($discipline == $row['discipline_id']) {
                                                        echo "selected";
                                                    }
                                                    ?>><?php echo $row["discipline_name"] ?></option>;

                                                <?php }
                                                ?>

                                            </select></div>

                                    </div>


                                    <div class="formRow">

                                        <div class="col-sm-1-8 label-assign" style="padding-right:0px;">

                                            <label>Notes (If Any):</label></div>
                                        <div class="col-sm-2-2 field-notes " style="padding-left:0px;">
                                            <input name="dwglistingnotes" type="text" class="" id="dwglistingnotes" size="100" value="<?php echo $dwgNotes; ?>" />



                                        </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-file-image-o"></i>                    
                                    Listing for Drawings
                                </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 class="first"></th>

                                    <th  class="bfc-datecreated"  align="left" bgcolor="#D6D6D6" scope="col">Date Created<br />
                                        (yyyy-mm-dd)</th>
                                    <th class="bfc-brieffrom" align="left" bgcolor="#D6D6D6" scope="col">Project<br />
                                        Code </th>
                                    <th  class="bfc-datename" align="left" bgcolor="#D6D6D6" scope="col">Design<br />
                                        Type</th>
                                    <th class="bfc-developed" align="left" bgcolor="#D6D6D6" scope="col">Design<br />
                                        Stage </th>
                                    <th  class="bfc-range" align="left" bgcolor="#D6D6D6" scope="col">No of Dwgs / Suffix<br />
                                        Range (from-to)</th>
                                    <th  class="bfc-cycle" align="left" bgcolor="#D6D6D6" scope="col">Notes<br />
                                        (If Any)</th>
                                    <th class="bfc-actions action-icons"  align="right" bgcolor="#D6D6D6" scope="col">Actions<br />
                                        Status
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $result = mysql_query("SELECT projects.projectName,projects.projectCode,scope_dwg.*
FROM projects,scope_dwg
WHERE scope_dwg.dwgProject = projects.projectSerial
AND scope_dwg.dwgCompany = '$id' AND scope_dwg.dwgStatus=1 ORDER BY $order_par $order_type");
                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                    ?>
                                    <tr>
                                        <td class="first"></td>
                                        <td class="bfc-datecreated" align="left" scope="row"><?php echo $row['dwgDateCreated']; ?></td>
                                        <td   class="bfc-brieffrom" align="left"><?php echo $row['projectCode']; ?></td>
                                        <td   class="bfc-datename" align="left"><?php echo $row['dwgType']; ?></td>
                                        <td  class="bfc-developed" align="left"><?php echo $row['dwgcomplePercent'] . " percent"; ?></td>
                                        <td  class="bfc-range"  align="left"><?php echo $row['no_of_dwgs'] . "/" . $row['dwg_suffix'] ?><br/> <?php echo $row['range_from'] . "-" . $row['range_to'] ?></td>
                                        <td  class="bfc-cycle"  align="left"><?php echo $row['dwgNotes']; ?></td>
                                        <td  class="bfc-actions action-icons"  align="right"><a href="DWG2.php?did=<?php echo $row['dwgID'] ?>"><img style="margin-top:3px" src="../images/icon-insert.jpg" width="15" height="15" border="0" /></a>

                                            <?php if ($uacc == "Full Control") { ?>

                                                <div class="close-icon"> <a href="javascript:void(0)" onclick="showConfirm('<?php echo $row["dwgID"]; ?>')">
                                                        <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="DWG1.php?Edit=<?php echo $row["dwgID"]; ?>">
                                                        <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") { ?>
                                        <a href="../../DB/03-scope/DWG1DB.php?InActive=<?php echo $row['dwgID']; ?>">
                                            <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>
                                        <?php
                                        $typid = $row["dwgID"];
                                        $path = "03-scope";
                                        $type = "DWG1";
                                        $attach = 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  class="bfc-datecreated"  align="left" bgcolor="#D6D6D6" scope="col">Date Created<br />
                                        (yyyy-mm-dd)</th>
                                    <th class="bfc-brieffrom" align="left" bgcolor="#D6D6D6" scope="col">Project<br />
                                        Code </th>
                                    <th  class="bfc-datename" align="left" bgcolor="#D6D6D6" scope="col">Design<br />
                                        Type</th>
                                    <th class="bfc-developed" align="left" bgcolor="#D6D6D6" scope="col">Design<br />
                                        Stage </th>
                                    <th  class="bfc-range" align="left" bgcolor="#D6D6D6" scope="col">No of Dwgs / Suffix<br />
                                        Range (from-to)</th>
                                    <th  class="bfc-cycle" align="left" bgcolor="#D6D6D6" scope="col">Notes<br />
                                        (If Any)</th>
                                    <th class="bfc-actions action-icons"  align="right" bgcolor="#D6D6D6" scope="col">Actions<br />
                                        Status
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $result = mysql_query("SELECT projects.projectName,projects.projectCode,scope_dwg.*
FROM projects,scope_dwg
WHERE scope_dwg.dwgProject = projects.projectSerial
AND scope_dwg.dwgCompany = '$id' AND scope_dwg.dwgStatus=0 ORDER BY $order_par $order_type");
                                while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                                    ?>
                                    <tr>
                                       
                                        <td class="bfc-datecreated" align="left" scope="row"><?php echo $row['dwgDateCreated']; ?></td>
                                        <td   class="bfc-brieffrom" align="left"><?php echo $row['projectCode']; ?></td>
                                        <td   class="bfc-datename" align="left"><?php echo $row['dwgType']; ?></td>
                                        <td  class="bfc-developed" align="left"><?php echo $row['dwgcomplePercent'] . " percent"; ?></td>
                                        <td  class="bfc-range"  align="left"><?php echo $row['no_of_dwgs'] . "/" . $row['dwg_suffix'] ?><br/> <?php echo $row['range_from'] . "-" . $row['range_to'] ?></td>
                                        <td  class="bfc-cycle"  align="left"><?php echo $row['dwgNotes']; ?></td>
                                        <td  class="bfc-actions action-icons"  align="right">
                                        
                                        <?php if ($uacc == "Full Control") { ?>
                                        <a href="../../DB/03-scope/DWG1DB.php?Active=<?php echo $row['dwgID']; ?>">
                                            <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>
                                      

                                <?php } ?>  
                            </tbody>
                </table>
            </div>
        </div>
    </div>

<script type="text/javascript">

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

    active_descipline_table = $('#active_descipline_tbl').DataTable({
        "bJQueryUI": false,
        "bAutoWidth": false,
        "columns": [
            {
                "className": 'details-control',
                "orderable": false,
                "defaultContent": '',
            },
            {"data": "bfc-datecreated"},
            {"data": "bfc-brieffrom"},
            {"data": "bfc-datename"},
            {"data": "bfc-developed"},
            {"data": "bfc-range"},
            {"data": "bfc-cycle"},
            {"data": "bfc-actions"},
            {"data": "details", "visible": false}
        ],
        "order": [[1, 'desc']],
        "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": [3]}]
    });

    $('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 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/DWG1DB.php?del=" + did;

            } else {
                return 0;
            }
        });
    }

    function check_is_number(th, value)
    {
        if (isNaN(value) || parseInt(value) < 1)
        {
            alert("Please insert numbers only and mut be reater than 0");
            $(th).val("");
        }
        else {
            var rangefrom = $("#rangefrom").val();
            var noofdwgs = $("#noofdwg").val();
            if (rangefrom && noofdwgs) {
                var rto = parseInt(rangefrom) + (parseInt(noofdwgs) - 1);
                $("#rangeto").val(rto);

            }
        }

    }
    function getLastValue(th, value) {
        if (isNaN(value) || parseInt(value) < 1)
        {
            alert("Please insert numbers only and mut be reater than 0");
            $(th).val("");
        } else {
            var rangefrom = $("#rangefrom").val();
            var noofdwgs = $("#noofdwg").val();

            if (noofdwgs == '') {
                alert("Please enter No of drawings first");
                $(th).val("");
            } else {

                var rto = parseInt(rangefrom) + (parseInt(noofdwgs) - 1);
                $("#rangeto").val(rto);
            }
        }

    }
    function ConfirmNoOfDwgs(th, value) {

        var pval = $("#prenoofdwgs").val();
       
        if (isNaN(value) || parseInt(value) < 1)
        {
            alert("Please insert numbers only and mut be reater than 0");
            $(th).val(pval);
        } else {
            if (parseInt(value) < parseInt(pval)) {
                alertify.confirm("You are entering number less than previous which will result in  losing some records records temporary! You wish to continue", function (e) {
              
                if (e) {
                     var rangefrom = $("#rangefrom").val();
                    var noofdwgs = $("#noofdwg").val();
                    if (rangefrom && noofdwgs) {
                        var rto = parseInt(rangefrom) + (parseInt(noofdwgs) - 1);
                        $("#rangeto").val(rto);

                    }
                  
                }
                else {
                     $(th).val(pval);
                }
            });
        }else {
                    var rangefrom = $("#rangefrom").val();
                    var noofdwgs = $("#noofdwg").val();
                    if (rangefrom && noofdwgs) {
                        var rto = parseInt(rangefrom) + (parseInt(noofdwgs) - 1);
                        $("#rangeto").val(rto);

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