<?php
ini_set('display_errors',1);
session_start();
include('script/condb.php');

/* ---------- Resolve project ID ---------- */
$PID = $_GET['project_ref'] ?? $_POST['pid'] ?? $_SESSION['pid'] ?? '';
if (!empty($PID)) {
    $_SESSION['pid'] = $PID;
}

$sql = "SELECT walltype, blocktype, walllength, wallheight, course FROM wall_calculation WHERE PID = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("s", $PID);
$stmt->execute();
$result = $stmt->get_result();
?>


<!doctype html>

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link href="css/styles.css" rel="stylesheet" type="text/css">
  <title>Project Details - <?php echo htmlspecialchars($row['project_ref']); ?></title>
  <meta name="viewport" content="width=device-width,initial-scale=1">
   <script type="text/javascript">
	

	
	
	<!--<script src="js/fetchemp.js"></script>equipke
	<script src="js/jquery-3.6.0.js"></script>-->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<style>
.form-row {
  display: flex;
  align-items: center;
  gap: 10px; /* space between inputs */
  margin-bottom: 10px; /* space between rows */
}

.form-row input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  flex: 1;
  min-width: 100px;
}

.form-row input::placeholder {
  color: #888;
}
</style>
</head>
<body>
    <div class="flex justify-end mt-4">
    <!--  <a href="javascript:history.back()" class="bg-blue-600 text-white px-3 py-2 rounded hover:bg-blue-700">
    ← Go Back
</a> -->
  </div>
  <div class="dashboardpagewrap">

	
<div class="right-frame-modal">
<!-- <div class="page-tag"><img src="images/settings-ico2.png" width="128" height="128" alt=""/>Stages of Project</div> -->
<div class="accordion-wrapper-mpdal">
<div class="worko-tabs">
  
    <input class="state" type="radio" title="tab-one" name="tabs-state" id="tab-one" checked />
  <!--  <input class="state" type="radio" title="tab-two" name="tabs-state" id="tab-two" />
    <input class="state" type="radio" title="tab-three" name="tabs-state" id="tab-three" />
    <input class="state" type="radio" title="tab-four" name="tabs-state" id="tab-four" />
	<input class="state" type="radio" title="tab-five" name="tabs-state" id="tab-five" />-->

    <div class="tabs flex-tabs">
        <label for="tab-one" id="tab-one-label" class="tab">Foundation</label>
      <!--  <label for="tab-two" id="tab-two-label" class="tab">Floor Stages</label>
        <label for="tab-three" id="tab-three-label" class="tab">Roofing Work</label>
        <label for="tab-four" id="tab-four-label" class="tab">Other Works</label>
		<label for="tab-five" id="tab-five-label" class="tab">Finishing</label>-->


        <div id="tab-one-panel" class="panel active">
            <div>Block Setting</div>
          <form method="post" action="save_wall_calculation.php">
  <input type="hidden" name="pid" value="<?php echo htmlspecialchars($PID ?? '', ENT_QUOTES); ?>">

  <?php
  if ($result && $result->num_rows > 0) {
      while ($row = $result->fetch_assoc()) {
          // Safely extract values — prevent "undefined" or "null" warnings
          $id = isset($row['ID']) ? $row['ID'] : '';
          $walltype = isset($row['walltype']) ? $row['walltype'] : '';
          $blocktype = isset($row['blocktype']) ? $row['blocktype'] : '';
          $walllength = isset($row['walllength']) ? $row['walllength'] : '';
          $wallheight = isset($row['wallheight']) ? $row['wallheight'] : '';
          $course = isset($row['course']) ? $row['course'] : '';

          echo '<div class="form-row">';
          echo '<input type="hidden" name="id[]" value="' . htmlspecialchars($id, ENT_QUOTES) . '">';
          echo '<input type="text" class="text-input-box-float2" name="walltype[]" placeholder="Wall Type" value="' . htmlspecialchars($walltype, ENT_QUOTES) . '">';
          echo '<input type="text" class="text-input-box-float2" name="blocktype[]" placeholder="Block Type" value="' . htmlspecialchars($blocktype, ENT_QUOTES) . '">';
          echo '<input type="text" class="text-input-box-float" name="walllength[]" placeholder="Length" value="' . htmlspecialchars($walllength, ENT_QUOTES) . '">';
          echo '<input type="text" class="text-input-box-float" name="course[]" placeholder="Course" value="' . htmlspecialchars($course, ENT_QUOTES) . '">';
          echo '<input type="text" class="text-input-box-float" name="wallheight[]" placeholder="Height" value="' . htmlspecialchars($wallheight, ENT_QUOTES) . '">';
          echo '</div>';
      }
  } else {
      echo "<p>No wall records found for this project.</p>";
  }
  ?>
  
  <button type="submit" name="save">💾 Save Changes</button>
</form>

			  
			  <form class="left-form2" id="fcolnm" action="column-calculate.php?zd=<?php echo $PID;
?>" name="fcolnm" method="post">
			  	<div class="inputidentifier">Starter Columns & Base</div>

	
            <div class="inputidentifier">Columns</div>	
            <form class="form-container"  > 

			  <div class="tagchecked"><input type="checkbox" name="check5" id="check5" onChange="$('#fcolnm').submit();">Calculate Columns</div>
			  <input type="text" class="text-input-box-float" placeholder="16" name="I8" id="I8"><div class="tagchecked3">How many columns are inside the entire building?</div>
				
			 <div class="nextline"><div class="tagchecked3">Height</div> <input type="text" class="text-input-box-float" placeholder="1.25" name="A_15" id="A_15"> <input type="reset" class="sub_btn3" value="Refresh"></div>
			
			<div class="tagchecked3"><input type="checkbox" name="check10" id="check10" onChange="$('#fcolnm').submit();">Column Type-1</div>
			  <input type="text" class="text-input-box-float" placeholder="Number" name="A_21" id="A_21">
			  <input type="text" class="text-input-box-float" placeholder="Length" name="A_17" id="A_17">
			  <input type="text" class="text-input-box-float" placeholder="Width" name="A_19" id="A_19">
			  <input type="text" class="text-input-box-float" placeholder="bartype" name="bartype" id="bartype">
			  <input type="text" class="text-input-box-float" placeholder="Bar Numbers" name="banum" id="banum">
			  <input type="text" class="text-input-box-float" placeholder="Cut Steel into" name="cutsteel" id="cutsteel">
			  <input type="text" class="text-input-box-float" placeholder="Stairups" name="stairups" id="stairups">
			  <input type="text" class="text-input-box-float" placeholder="stairuptype" name="stairuptype" id="stairuptype">
 
         
			<div class="partition_left">
			<div class="inputidentifier">Column Bases</div>	
            <form class="form-container" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post" name="fcolnm" id="fcolnm"> 
			  <div class="tagchecked2"><input type="checkbox" name="check11" id="check11" onChange="$('#fcolnm').submit();">Calculate Columns Bases</div>
			<div class="tagchecked2"><input type="checkbox">Include Binding</div>
			<div class="checkbox-arranger">
  <input type="text" class="text-input-box-float" placeholder="16" name="A_30" id="A_30"><div class="tagchecked3">How many column base are inside the entire building?</div>
				
			 <div class="nextline">
				
			<div class="tagchecked3"><input type="checkbox" >Base Type-1</div>
			  <input type="text" class="text-input-box-float" placeholder="Number" name="A_28" id="A_28">
			  <input type="text" class="text-input-box-float" placeholder="Width" name="A_26" id="A_26">
			  <input type="text" class="text-input-box-float" placeholder="Height" name="A_18" id="A_18">
			  <input type="text" class="text-input-box-float" placeholder="bartype" name="bartype" id="bartype">
			  <input type="text" class="text-input-box-float" placeholder="Bar Numbers" name="barnums" id="barnums">
			  <input type="text" class="text-input-box-float" placeholder="mattype" name="mattype" id="mattype">
			<input type="text" class="text-input-box-float" placeholder="Bending Heights" name="bendit" id="bendit"></div>
				</div>
                
                <input class="form-input"
                       placeholder="Enter Your Email"
                       id="email" 
                       name="email" required> 
  
 
            </form> 
			</div>
        </div> 
    </div> 
			  </form>
			  
			  <div class="inputidentifier3">Properties</div>
			  
		    <div class="partition_left">
			<form id="pattrench" name="pattrench" action="partition-calculate.php?pd=<?php echo $PID;
?>"  method="post">
			<div class="inputidentifier">Partition in Trench</div>	
			  <div class="tagchecked"><input type="checkbox" id="trench" name="trench" onchange="$('#pattrench').submit();">Calculate Partitions</div>
			  <input type="text" class="text-input-box-float3" placeholder="Length" name="somelabourer_1B" id="somelabourer_1B">
			  <input type="text" class="text-input-box-float3" placeholder="Width" name="somelabourer_1C" id="somelabourer_1C">
			  <input type="text" class="text-input-box-float3" placeholder="Depth" name="somelabourer_1D" id="somelabourer_1D">				  
				</form></div>
			
			<div class="partition_left">
			<form id="fmorta" name="fmorta" action="cement-mortal-calculation.php?ced=<?php echo $PID;
?>" method="post">
			 <div class="inputidentifier">Blocks & Mortar</div>
			  <div class="tagchecked"><input type="checkbox" id="check3" name="check3" onchange="$('#fmorta').submit();">Calculate Blocks & Mortar</div>
			  <input type="text" class="text-input-box-float3" placeholder="Cement" name="A_37" id="A_37">
			  <input type="text" class="text-input-box-float3" placeholder="Sand" name="A_38" id="A_38">				  
			  </form></div>
			  
			<div class="partition_left">
			  <form name="fplank"  id="fplank" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">
			  <div class="inputidentifier">Planks</div>
			 <div class="checkbox-arranger">
			 <!--<div class="tagchecked2"><input type="checkbox" checked="checked">Calculate Planks</div>-->
			    <div class="tagchecked2"><input type="checkbox" name="check12" id="check12" onChange="$('#fplank').submit();">Planks for Columns</div>
				 <div class="tagchecked2"><input type="checkbox"  name="check13" id="check13" onChange="$('#fplank').submit();">Planks for Column Bases</div>
			</div>
			  <select class="list-input-box3" name="plakname" id="plakname">
			  <option>Select Plank</option>
				  <?php
						$prod30= "SELECT plankothers_name FROM upline_app_plankothers where plankothers_type='plank'";
		$que30 =mysqli_query($con, $prod30);
		while($rec30 =mysqli_fetch_array($que30)){
			?> 
			<option <?php echo $rec30['plankothers_name'] ?>><?php echo $rec30['plankothers_name'] ?></option>
						
	<?php	}
					?>
			  
            </select>
			 
			   <select class="list-input-box3" name="planktype2" id="planktype2">
			  <option>Select Plank</option>
			  <?php
						$prod30= "SELECT plankothers_name FROM upline_app_plankothers where plankothers_type='plank' ";
		$que30 =mysqli_query($con, $prod30);
		while($rec30 =mysqli_fetch_array($que30)){
			?> 
			<option <?php echo $rec30['plankothers_name']?>><?php echo $rec30['plankothers_name'] ?></option>
						
	<?php	}
					?>
            </select>				
				</form></div>
			  
<form id="fwood" name="fwood" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">
			  <div class="inputidentifier">Woods</div>	
			<div class="checkbox-arranger">
			 <!--<div class="tagchecked2"><input type="checkbox">Calculate Woods</div>-->
	</div>
				<div class="tagchecked3"><input type="checkbox" name="check45" id="check45" onChange="$('#fwood').submit();">Calculate Wood For Bracing column</div>
			  <input type="text" class="text-input-box-float" placeholder="Length" name="A_53" id="A_53">
			  <input type="text" class="text-input-box-float" placeholder="Numbers" name="A_47" id="A_47">
			  <select class="list-input-box" name="woodtype" id="woodtype">
			  <option>Select Wood</option>
			  <?php
						$prod30= "SELECT plankothers_name FROM upline_app_plankothers where plankothers_type='wood'";
		$que30 =mysqli_query($con, $prod30);
		while($rec30 =mysqli_fetch_array($que30)){
			?> 
			<option <?php echo $rec30['plankothers_name'] ?>><?php echo $rec30['plankothers_name'] ?></option>
						
	<?php	}
					?>
            </select>
			  
			<div class="checkbox-arranger">
			 <div class="tagchecked3"><input type="checkbox" name="wood2" id="wood2" onChange="$('#fwood').submit();">Calculate Wood for Forming Column</div>
			<input type="text" class="text-input-box-float" placeholder="Spacing" name="spacing" id="spacing">
			  <select class="list-input-box" name="woodtype1">
			  <option>Select Wood</option>
			  <?php
						$prod30= "SELECT plankothers_name FROM upline_app_plankothers where plankothers_type='wood'";
		$que30 =mysqli_query($con, $prod30);
		while($rec30 =mysqli_fetch_array($que30)){
			?> 
			<option <?php echo $rec30['plankothers_name'] ?>><?php echo $rec30['plankothers_name'] ?></option>
						<?php	}
					?>
            </select> 
			  </div>				
</form>			  
			  
		      <div class="partition_left">
<form id="fstir" name="fstir" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">
			  <div class="inputidentifier">Stairups</div>
			  <div class="tagchecked"><input type="checkbox" name="stirup" id="stirup" onChange="$('#fstir').submit();">Calculate Stairups</div>				  
</form>
				  
<form id="fbar" name="fbar" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">
			 <div class="inputidentifier">Bars</div>
<div class="checkbox-arranger">
				  <!--<div class="tagchecked3"><input type="checkbox" checked="checked">Calculate Bars</div>-->	
			    <div class="tagchecked3"><input type="checkbox"  name="bar1" id="bar1" onChange="$('#fbar').submit();">Bars for Column Bases</div>
			    <div class="tagchecked3"><input type="checkbox" name="bar2" id="bar2" onChange="$('#fbar').submit();">Bars for Entire Column</div>
	</div>				  
</form>
			  
<form id="fconcrete" name="fconcrete" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">
			  <div class="inputidentifier">Concrete</div>
	<div class="checkbox-arranger">
				  <div class="tagchecked3"><input type="checkbox" >Calculate Concrete</div>
			   <div class="tagchecked3"><input type="checkbox" name="concreteB" id="concreteB" onChange="$('#fconcrete').submit();">Concrete for Blinding</div>
			   <div class="tagchecked3"><input type="checkbox" name="entbase" id="entbase" onChange="$('#fconcrete').submit();">Concrete for Columns Bases</div>
			   <div class="tagchecked3"><input type="checkbox" name="entbase2" id="entbase2" onChange="$('#fconcrete').submit();">Concrete for Columns</div>
	</div>
				  
			 
			   <input type="text" class="text-input-box-float" placeholder="Thickness" name="A_106" id="A_106">
				  
			   <select class="list-input-box-small" name="concretegrade" id="concretegrade">
			  <option>Concrete Grade</option>
			  <?php
						$prod03= "SELECT Mixed_Ratio_Name FROM upline_app_concretework ";
		$que03 =mysqli_query($con, $prod03);
		while($rec03 =mysqli_fetch_array($que03)){
			?> 
			<option <?php echo $rec03['Mixed_Ratio_Name'] ?>><?php echo $rec03['Mixed_Ratio_Name'] ?></option>
						
	<?php	}
					?>
            </select>
				  
			  <input type="text" class="text-input-box-float" placeholder="Cement" name="cement" id="cement">
			  
			   <input type="text" class="text-input-box-float" placeholder="Sand" name="sand" id="sand">  
				  
			   <input type="text" class="text-input-box-float" placeholder="Gravel" name="gravel2" id="gravel2"> 
				  
	<div class="checkbox-arranger-header">
	Concrete for columns
	</div>
			 
			   <select class="list-input-box-small" name="concretegrade2" id="concretegrade2">
			  <option>Concrete Grade</option>
			  <?php
						$prod03= "SELECT Mixed_Ratio_Name FROM upline_app_concretework ";
		$que03 =mysqli_query($con, $prod03);
		while($rec03 =mysqli_fetch_array($que03)){
			?> 
			<option <?php echo $rec03['Mixed_Ratio_Name'] ?>><?php echo $rec03['Mixed_Ratio_Name'] ?></option>
						
	<?php	}
					?>
            </select>
				 
			  <input type="text" class="text-input-box-float" placeholder="Cement" name="cement2" id="cement2">
			  
			   <input type="text" class="text-input-box-float" placeholder="Sand" name="sand2" id="sand2">  
				  
			   <input type="text" class="text-input-box-float" placeholder="Gravel" name="gravel" id="gravel"> 
				  				  
</form>
			  
			<div class="partition_left">
<form id="9">
			 <div class="inputidentifier">Imported Bars</div>
			  <div class="tagchecked"><input type="checkbox" checked="checked">Calculate Bars</div>
	
<div class="checkbox-arranger">
				   <select class="list-input-box-small">
			  <option>8mm Steel</option>
            </select>
			  <input type="text" class="text-input-box-float" placeholder="Total Length">
			  <input type="text" class="text-input-box-float" placeholder="Bar Quantity">
	</div>
				
			<div class="checkbox-arranger">
				<select class="list-input-box-small">
			  <option>12mm Steel</option>
            </select>	
			  <input type="text" class="text-input-box-float" placeholder="Length">
			  <input type="text" class="text-input-box-float" placeholder="Bar Quantity">
	</div>   

				
<div class="checkbox-arranger">
				   <select class="list-input-box-small">
			  <option>16mm Steel</option>
            </select>	
			  <input type="text" class="text-input-box-float" placeholder="Length">
			  <input type="text" class="text-input-box-float" placeholder="Bar Quantity">
	</div>
				
<div class="checkbox-arranger">
				   <select class="list-input-box-small">
			  <option>20mm Steel</option>
            </select>	
			  <input type="text" class="text-input-box-float" placeholder="Length">
			  <input type="text" class="text-input-box-float" placeholder="Bar Quantity">
	</div>
				
<div class="checkbox-arranger">
				   <select class="list-input-box-small">
			  <option>25mm Steel</option>
            </select>	
			  <input type="text" class="text-input-box-float" placeholder="Length">
			  <input type="text" class="text-input-box-float" placeholder="Bar Quantity">
	</div>			
				</form>
				  </div>
				

				  <div class="partition_left">
				  <form id="10">
			<div class="inputidentifier">Plumbering</div>
			  <div class="tagchecked"><input type="checkbox">Plumbing Piping</div>
			  <input type="text" class="text-input-box-float-right" placeholder="Materials">
			  <input type="text" class="text-input-box-float-right" placeholder="Labour">				
				    </form></div>
				
<div class="partition_left">
				  <form id="11">
			  <div class="inputidentifier">Electrical</div>
			  <div class="tagchecked"><input type="checkbox">Electrical Piping</div>
			  <input type="text" class="text-input-box-float-right" placeholder="Materials">
			  <input type="text" class="text-input-box-float-right" placeholder="Labour">		
</form></div>
				
<div class="partition_left">
		<form id="equipke" name="equipke" action="column-calculate.php?zd=<?php echo $PID;
?>" method="post">	  
			<div class="inputidentifier">Equipments to be used</div>
			  <div class="tagchecked"><input type="checkbox" name="equip" id="equip" onChange="$('#equipke').submit();" >Equipments</div>
			
			<div class="checkbox-arranger">
			<input type="text" class="text-input-box-float-right" placeholder="Quantity" name="equipqty" id="equipqty">
				  <div class="tagchecked4"><!--<input type="checkbox">--></div>
				<select class="list-input-box-small" name="equipment" id="equipment">
			  <option>Select equipment</option>
			  <?php
						$prod09= "SELECT construction_equipmentName FROM upline_app_construction_equipment ";
		$que09 =mysqli_query($con, $prod09);
		while($rec09 =mysqli_fetch_array($que09)){
			?> 
			<option value="<?php echo $rec09['construction_equipmentName'] ?>"><?php echo $rec09['construction_equipmentName'] ?></option>
						
	<?php	}
					?>
            </select>
			  <!--<input type="text" class="text-input-box-float-right2" placeholder="Swamp Buggy">-->
			</div>
			
			<!--<div class="checkbox-arranger">
			<input type="text" class="text-input-box-float-right" placeholder="Numbers">
				  <div class="tagchecked4"><input type="checkbox"></div>
			  <input type="text" class="text-input-box-float-right2" placeholder="Dozer">
			</div>-->
			
			<!--<div class="checkbox-arranger">
			<input type="text" class="text-input-box-float-right" placeholder="Numbers">
				  <div class="tagchecked4"><input type="checkbox" checked="checked"></div>
			  <input type="text" class="text-input-box-float-right2" placeholder="Leveling Instrument">
			</div>-->
			
			<!--<div class="checkbox-arranger">
			<input type="text" class="text-input-box-float-right" placeholder="Numbers">
				  <div class="tagchecked4"><input type="checkbox"></div>
			  <input type="text" class="text-input-box-float-right2" placeholder="Excavator">
			</div>-->
</form></div>
		
        <div id="tab-two-panel" class="panel">
                <form class="left-form">
				  <input type="text" class="text-input-box" placeholder="From D.P.C to First Floor Slab">
	
			  <div class="form-input-title">First Floor Slap</div>
				  <input type="text" class="text-input-box" placeholder="First Floor to Second Floor Slab">
					
			  <div class="form-input-title">Second Floor Slab</div>
				  <input type="text" class="text-input-box" placeholder="Second Floor to Parapet Level">
					
			  <div class="form-input-title">Third Floor Slab</div>
				  <input type="text" class="text-input-box" placeholder="Third Floor to Roofing Level">
					
			  <div class="form-input-title">Other Works on Floor Stages</div>
				  <input type="text" class="text-input-box" placeholder="Parapet">
				  <input type="text" class="text-input-box" placeholder="Kitchen Slab">
				  <input type="text" class="text-input-box" placeholder="Gable Walls">
			</form>
        </div>
        <div id="tab-three-panel" class="panel">
                <form class="left-form">
				  <input type="text" class="text-input-box" placeholder="Wood Work & Properties">
	
			  <div class="form-input-title">Roofing Sheet Work & Properties</div>
				  <input type="text" class="text-input-box" placeholder="Fencing">
					
				  <input type="text" class="text-input-box" placeholder="Suckaway Pit & Septic Tank ">
					
			</form>
        </div>
		
        <div id="tab-four-panel" class="panel">
                <form class="left-form">
				  <input type="text" class="text-input-box" placeholder="Electrical Piping">
	
				  <input type="text" class="text-input-box" placeholder="Home Automation Piping">
					
				  <input type="text" class="text-input-box" placeholder="CCTV Piping">
					
				  <input type="text" class="text-input-box" placeholder="Plumbing Piping">
					
				  <input type="text" class="text-input-box" placeholder="AC Line Piping">
			</form>
        </div>
		
        <div id="tab-five-panel" class="panel">
                <form class="left-form">
				  <input type="text" class="text-input-box" placeholder="Plastering">
	
				  <input type="text" class="text-input-box" placeholder="Windows & Doors">
					
				  <input type="text" class="text-input-box" placeholder="Black POP Works for windows, Beams & Others">
					
				  <input type="text" class="text-input-box" placeholder="Electrical Wiring">
					
				  <input type="text" class="text-input-box" placeholder="Home Automation Wiring">
				  <input type="text" class="text-input-box" placeholder="CCTV Wiring">
				  <input type="text" class="text-input-box" placeholder="Ceiling POP">
				  <input type="text" class="text-input-box" placeholder="Screeding">
				  <input type="text" class="text-input-box" placeholder="Tiling Work">
				  <input type="text" class="text-input-box" placeholder="Painting">
			</form>
        </div>
    </div>
</div>




    
    </body>
    </html>
    