<?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>
<link type='text/css' href='../libraries/dialog/css/confirm.css' rel='stylesheet' media='screen' />
<table width="100%" border="0">
  <tr class="ablks5">
    <th width="50%" align="left" scope="row"><span class="lbrownlll1" style="background-color: #E2E2E2;">&nbsp;*&nbsp;</span><span class="kgraylll7" style="background-color: #930;"> Master Formats </span> <span class="ablks1"> &nbsp;</span></th>
    <td width="50%" align="right"><span class="a11">
      <?php
  if (isset($_REQUEST["msg"])){  ?>
      <span class="fbrownl1"> <?php echo $_REQUEST["msg"];?></span>
      <?php }?>
    </span></td>
  </tr>
</table>
  <?php if(!isset($_REQUEST['Edit'])){?>
<form method="post" class="bootstrap-frm" enctype="multipart/form-data" action="MasterFormatDB.php" name="form1" id="form1" onsubmit="return validateMasterFormat1()">
  <table width="100%" border="0">
  <tr class="ablks5">
      <th width="10%" align="left" valign="top" class="ablks5" scope="col">Masterformat Type*:</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col"><label for="importmasterformat"></label>
        <select name="importmasterformat" class="ablks1" 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><span id="import"></span>
        </th>
      <th width="5%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="10%" align="left" valign="top" class="ablks5" scope="col">Master Format Name*:</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col"><label for="masterformatname"></label>
        <input name="masterformatname" type="text" class="ablks1" id="masterformatname" />
        <input type="image" src="../images/icon-save.png"  width="12" height="12"  border="0"/></th>
      <th width="5%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="10%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
    </tr>
  </table>
</form>
<?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"];		
	?>
<form method="post" class="bootstrap-frm" enctype="multipart/form-data" action="MasterFormatDB.php?Edit=<?php echo $WID;?>" name="form1" id="form1" onsubmit="return validateMasterFormat12()">
  <table width="100%" border="0">
  <tr class="ablks5">
      <th width="10%" align="left" valign="top" class="ablks5" scope="col">Master Format Name*:</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col"><label for="masterformatname"></label>
      <input name="masterformatname" type="text" class="ablks1" id="masterformatname" value="<?php echo $MFList_name;?>" /> <input type="image" src="../images/icon-save.png"  width="13" height="13" border="0" /></th>
      <th width="5%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="10%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="5%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="10%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
      <th width="20%" align="left" valign="top" class="a11" scope="col">&nbsp;</th>
    </tr>
    </table>
</form>
    <?php } ?>
<br />
<img src="../images/icon-heading.gif" width="12" height="13" border="0" /><span class="lbrownlll7"> List of Masterformats</span><span class="ablks1"><br />
<br />
</span>
<table width="100%" border="0" class="table1">
  <tr class="fbrownl7">
    <td width="9%"  align="left" valign="top" bgcolor="#E2E2E2" scope="col">Date Created<br />
      (yyyy.mm.dd)
      </th>
    <td width="31%" align="left" valign="top" bgcolor="#E2E2E2" scope="col">Master Format<br />
      ID</td>
    <td width="27%" align="left" valign="top" bgcolor="#E2E2E2" scope="col">Master Format <br />
    Name</td>
    <td width="25%" align="left" valign="top" bgcolor="#E2E2E2" scope="col">Master Format<br />
      Type</td>
    <td width="8%" align="right" valign="top" bgcolor="#E2E2E2" scope="col"> Start/ Edit<br />
Del/Export</td>
  </tr>  
   <?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 class="ablks1">
    <td align="left" valign="top" class="ablks1" scope="col"><?php echo $row['MFList_datecreation']; ?></td>
    <td align="left" valign="top" class="ablks1"><?php echo $row['MFList_id']; ?></td>
    <td align="left" valign="top" class="ablks1"><?php echo $row['MFList_name']; ?></td>
    <td align="left" valign="top" class="ablks1"><span class="ablks1"><?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 align="right" valign="top" class="ablks1">&nbsp;<a href="MasterFormat2.php?WID=<?php echo $row['MFList_id']; ?>"><img src="../images/icon-insert.jpg" width="15" height="15" border="0" /></a>
    <a href="MasterFormat1.php?Edit=<?php echo $row["MFList_id"]; ?>"><img src="../images/icon-edit1.png" width="15" height="15" border="0"/></a>&nbsp;<a href="MasterFormatDB.php?del=<?php echo $row["MFList_id"]; ?>" onClick="return confirm('This deleted information cannot be retrieved. Press OK to Delete.')"><img src="../images/icon-del1.png" width="16" height="16" border="0"/></a><a id="<?php echo $row["MFList_id"]; ?>" class='confirm' href=""></a> <img src="../images/icon-export.jpg" width="15" height="15" border="0"/></td>
  </tr>
  <?php $typid = $row["MFList_id"]; $path = "02-options"; $type = "MasterFormat1"; $attach=0; $reminder=0; $note=1;
   include('../includes/noterow.php');
   ?>
   <?php }?>  
</table>
<!-- 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>

<!--dialog -->

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

<script type='text/javascript' src='../libraries/dialog/js/confirmMaster.js'></script>
<?php include('../includes/footer.php'); ?>
