<?php
include('../../includes/checkSession.php');
include('../../includes/con2pma3.php');
include('../includes/header_in.php');
?>
<script type="text/javascript">
    function ImportMF(str)
    {
        if (str == "" || str == "4" || 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", "importPMProfield.php", true);
        }
        else if (str == "2")
        {
            xmlhttp.open("GET", "importPMMFfield.php", true);
        }
        else
            xmlhttp.open("GET", "importMFfield.php", true);
        xmlhttp.send();
    }
</script>
<style>
    
    select{
        width:100% !important;
    }
    .fixed{display:none}
    .action-icons .fa{float:right}
    .dataTables_length div.selector{width:35% !important}
    .dataTables_length label{width:250px !important}
    .dataTables_length{width:220px !important}
</style>
<link type='text/css' href='../libraries/dialog/css/confirm.css' rel='stylesheet' media='screen' />
<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 } ?>
                </h5>
<?php if (!isset($_REQUEST['Edit'])) { ?>
                    <div class="add-formpage">
                        <div class="widget">
                            <div class="whead">
                                <h6>
                                    <i class="fa fa-plus-circle"></i>
                                    Add 
                                </h6>
                            </div>
                            <form method="post"  enctype="multipart/form-data" action="MasterFormatDB.php" name="form1" id="form1" onsubmit="return validateMasterFormat1()">
                                <div class="formRow">
                                    <div class="col-sm-1-8 label-full" style="padding-right:0px;">
                                        <label>Masterformat Type*:</label></div>
                                    <div class="col-sm-2-2 field-full"  style="padding-left:0px;">
                                        <select name="importmasterformat"  id="importmasterformat" onchange="ImportMF(this.value)" style="float:left; margin-bottom:0;">
                                            <option value="" selected="selected">Select a Masterformat Type</option>
                                            <!--<option value="1">Import from Another Project</option>-->
                                            <option value="2">Import from pmAnywhere</option>
                                            <option value="3">Import from my CSV File</option>
                                            <option value="4">Create from Scratch</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="formRow">
                                    <div class="col-sm-1-8 label-full " style="padding-right:0px;">
                                        <label>Master Format Name*:</label></div>
                                    <div class="col-sm-2-2 field-full"  style="padding-left:0px;">
                                        <input name="masterformatname" type="text"  id="masterformatname" /> </div>
                                    <div class="grid2 submit-btn save-bottom"> 
                                                                                  <!--<input type="submit" class="buttonM formSubmit bGreen" value="Save">--> 
                                                                                  <!-- <input type="image" src="../includes/images/save-btn.png" title="Save" style="padding-top:4px;" />-->
                                        <button type="submit" class="btn btn-success"><i class="fa fa-check-square"></i> </button>
                                    </div>
                                </div>
                            </form>
                        </div></div>
                <?php
                } else {
                    $WID = $_REQUEST['Edit'];
                    $result = mysql_query("SELECT MFList_name FROM mflist where MFList_id='$WID'");
                    $row = mysql_fetch_array($result, MYSQL_ASSOC);
                    $MFList_name = $row["MFList_name"];
                    ?>
                    <div class="edit-formpage">
                        <div class="widget">
                            <div class="whead">
                                <h6>
                                    <i class="fa fa-plus-circle"></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="MasterFormatDB.php?Edit=<?php echo $WID; ?>" name="form1" id="form1" onsubmit="return validateMasterFormat12()">

                                <div class="formRow">
                                    <div class="col-sm-1-8 label-full" style="padding-right:0px;">
                                        <label>
                                            Master Format Name*: </label></div>
                                    <div class="col-sm-2-2 field-full"  style="padding-left:0px;">
                                        <input name="masterformatname" type="text"  id="masterformatname" value="<?php echo $MFList_name; ?>" /> 
                                    </div>
                                    <div class="grid2 submit-btn save-bottom"> 
                                                                                   <!--<input type="submit" class="buttonM formSubmit bGreen" value="Save">--> 
                                                                                   <!-- <input type="image" src="../includes/images/save-btn.png" title="Save" style="padding-top:4px;" />-->
                                        <button type="submit" class="btn btn-success"><i class="fa fa-check-square"></i> </button>
                                    </div>
                                </div>

                            </form>
                        </div> </div>

<?php } ?>
            </div>
            <div class="table-subject">
                <div class="widget">
                    <div class="whead">
                        <h6 id="active-docnature" > <b>
                                <i class="fa fa-file-o"></i>
                                MasterFormats </b> 
                            </h6>
 <span style="line-height: 35px;">
                       
                        <?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 class="dataTables_filter" id="DataTables_Table_0_filter">
                            <label class="search-select">
                                <div class="left-float"> <div class="search-select-label">Search:</div>
                                    <div class="selector search-select-select" id="uniform-undefined" >
                                        <select name="DataTables_Table_0_length" aria-controls="DataTables_Table_0" style="opacity:1">
                                            <option selected="" value="">Date</option>
                                            <option selected="" value="">First Name</option>
                                            <option selected="" value="">Last Name</option>
                                            <option selected="" value="">Access Type</option>
                                            <option selected="" value="">Contact</option>
                                            <option selected="" value="">Designation</option>
                                            <option selected="" value="">All</option>

                                        </select>
                                    </div>
                                </div>
                                <div class="search-select-input">
                                    <input type="text" aria-controls="DataTables_Table_0" placeholder="Search Active Entries">
                                </div>
                            </label>
                        </div></div>
                 
                        <table cellpadding="0" cellspacing="0"  style="width:100%;">
                            
                            <tbody>
                                <?php
                                $resultw = mysql_query("SELECT * FROM mflist where mflist.MFList_for=1 AND mflist.MFList_companyid = '$id'");
                                while ($row = mysql_fetch_array($resultw, MYSQL_ASSOC)) {
                                    ?>   
                                    <tr >
                                        <td class="mf-date" align="left" valign="top"  scope="col"><?php echo $row['MFList_datecreation']; ?></td>
                                        <td class="mf-id" align="left" valign="top" ><?php echo $row['MFList_id']; ?></td>
                                        <td class="mf-name" align="left" valign="top" ><?php echo $row['MFList_name']; ?></td>
                                        <td class="mf-type" align="left" valign="top" ><span ><?php if ($row['MFList_type'] == '1') echo "From Another Project";
                                    else if ($row['MFList_type'] == '2') echo "From pmAnywhere";
                                    else if ($row['MFList_type'] == '3') echo "From my CSV File";
                                    else if ($row['MFList_type'] == '4') echo "From Scratch"; ?></span></td>
                                        <td class="mf-status action-icons"  align="right" valign="top" >
                                            <a href="MasterFormat2.php?WID=<?php echo $row['MFList_id']; ?>">

                                                <i class="fa fa-level-down"></i>

                                            </a>
                                            <div class="edit-icon"><a href="MasterFormat1.php?Edit=<?php echo $row["MFList_id"]; ?>">
                                                    <div class="glyph">
                                                        <div class="fs1 iconb" data-icon="" title="Edit"></div>
                                                    </div>
                                                </a></div>
                                            <div class="close-icon"><a href="javascript:void(0)" onclick="deletemasterformat('<?php echo $row["MFList_id"]?>')">
                                                    <div class="glyph">
                                                            <div class="fs1 iconb" data-icon="" title="Delete"></div>
                                                        </div>
                                                </a></div>
                                            <a id="<?php echo $row["MFList_id"]; ?>" class='confirm' href=""></a>
                                            <i class="fa fa-share-square-o"></i>
                                        </td>
                                    </tr>
    <?php
    $typid = $row["MFList_id"];
    $path = "02-options";
    $type = "MasterFormat1";
    $attach = 0;
    $reminder = 0;
    $note = 1;
    include('../includes/noterow.php');
    ?>
<?php } ?>  
                            </tbody>
                        </table>
                    
                    <div class="filter-option">
                        <div class="tableFooter">
                            <div class="dataTables_info" id="dynamic_info">Showing 57 of 57 entries</div>
                            <div id="DataTables_Table_0_length" class="dataTables_length">
                                <label>
                                    <span class="showentries">Show entries:</span>
                                    <div class="selector" id="uniform-undefined"><span>All</span>
                                        <select name="DataTables_Table_0_length" aria-controls="DataTables_Table_0">
                                            <option selected="" value="">All</option>
                                            <option value="10">10</option>
                                        </select>
                                    </div>
                                </label>
                            </div>
                            <div class="dataTables_paginate paging_full_numbers" id="dynamic_paginate"><a tabindex="0" class="first paginate_button paginate_button_disabled" id="dynamic_first">First</a><a tabindex="0" class="previous paginate_button paginate_button_disabled" id="dynamic_previous">Previous</a><span><a tabindex="0" class="paginate_active">1</a><a tabindex="0" class="paginate_button">2</a><a tabindex="0" class="paginate_button">3</a><a tabindex="0" class="paginate_button">4</a><a tabindex="0" class="paginate_button">5</a></span><a tabindex="0" class="next paginate_button" id="dynamic_next">Next</a><a tabindex="0" class="last paginate_button" id="dynamic_last">Last</a></div>
                            <div class="clear"></div>
                        </div>
                    </div>  
                    <!-- modal content -->

                    <div id='confirm'>

                        <div class='header'><span>Confirm</span></div>

                        <div class='message'></div>

                        <div class='buttons'>

                            <div class='no simplemodal-close'>No</div><div class='yes'>Yes</div>

                        </div>

                    </div>
                </div>
            </div>
            </section>
            <!--dialog -->

            <script type='text/javascript' src='../libraries/dialog/js/jquery.simplemodal.js'></script>

            <script type='text/javascript' src='../libraries/dialog/js/confirmMaster.js'></script>
            <script>
              function deletemasterformat(id){
              alertify.confirm( "This record will be deleted and cannot be retrieved. Press OK to Delete.", function (e) {
    if (e) {
       window.location.href = "MasterFormatDB.php?del="+id;
       
    } else {
       return 0;
    }
});
              }
        
        </script>
<?php include('../includes/footer.php'); ?>
