<?php
// 철재 스라트
function generateTableSection_slat($id, $title, $badgeClass = 'bg-success', $user_idtem= '', $process=null, $mode ) {   
    // 합계가 필요한 열 번호 (0-based index)
	$sumColumns = range(0, 78);
	
    // echo $user_idtem . '</br>';
    echo " <div class='table-responsive mb-5'>             
        <div class='d-flex  align-items-center p-1 mt-1 mb-2'>
			<button  type='button' id='estimateslat_view' class='btn btn-success btn-sm ms-2 me-3 mt-1'> <i class='bi bi-chevron-down'></i> </button> 
            <span class='badge $badgeClass fs-6 me-3'>$title</span>
            <span class='text-primary fs-4 viewNoBtn add-row-slat me-4' data-table='{$id}Table' style='margin-right: 5px;'>+</span> ";
	if($process =='견적서')
	{
      echo "		
            <button type='button' id='viewEstimateSlatUnit' class='btn btn-secondary btn-sm me-2' data-table='{$id}Table' > <i class='bi bi-grid-3x3'></i> 단가표 </button> ";
		if($mode === 'view') {
      echo "<button type='button' id='viewEstimateSlat' class='btn btn-dark btn-sm ' data-table='{$id}Table' > <i class='bi bi-card-heading'></i> 견적서 </button>
            <button type='button' id='viewEstimateSlatDetail' class='btn btn-danger btn-sm ms-2' data-table='{$id}Table' > <i class='bi bi-card-heading'></i> 산출내역서 </button> 
			";
		}
	}
    echo "	 
        </div>
        <div id='estimate_slatDiv' >
        <div class='d-flex row'> &nbsp;&nbsp;
            <table class='table table-bordered' id='{$id}Table'> 
                <thead id='thead_{$id}'>
                    <tr>
                        <th rowspan='6'>행추가<br>삭제</th>
                        <th rowspan='6'>일련<br>번호</th>
                        <th rowspan='6'>층수</th>
                        <th rowspan='6'>부호</th>
                        <th rowspan='6'>제품명</th>
                        <th rowspan='6'>투시창선택</th>
                        <th rowspan='6'>종류</th>
                        <th rowspan='4' colspan='2'>가이드레일</th>
                        <th rowspan='4' colspan='2'>①오픈사이즈</th>
                        <th rowspan='4' colspan='2'>②-1제작사이즈 <br> <span class='text-primary'> (철재)</span></th>
                        <th rowspan='4' colspan='2'>②-2제작사이즈 <br> <span class='text-danger'> (부자재)</span></th>
                        <th rowspan='6'>③면적</th>
                        <th rowspan='6'>④중량</th>
                        <th rowspan='6'>투시창<br>수량</th>
                        <th rowspan='6'>셔터<br>수량</th>
                        <th rowspan='4' colspan='3' >연동제어기</th>
                        <th rowspan='2' colspan='7'>⑤모터</th>
                        <th rowspan='1' colspan='36'>절곡</th>
                        <th rowspan='1' colspan='21'>부자재</th>                                                                                                
                    </tr>
					<tr>
						<th rowspan='2' colspan='8'>⑥가이드레일(한쌍)</th>
						<th rowspan='2' colspan='18'>⑦케이스(셔터박스)</th>
						<th rowspan='2' colspan='10'>⑧하단마감재</th>
						<th rowspan='2' colspan='13'>⑨감기샤프트</th>
						<th rowspan='2' colspan='4'>⑩각파이프</th>
                        <th rowspan='4'>조인트바</th>                        
                        <th rowspan='4'>앵글</th>						
					</tr>
                    <tr>
                        <th rowspan='4'> <span class='text-primary'> 모터 견적가 포함</span> </th>						
						<th rowspan='4'> 전원 </th>						
						<th rowspan='4'> 유/무선 </th>						
						<th rowspan='4'> 용량 </th>						
						<th rowspan='2' colspan='3'> 브라케트 </th>					
					</tr>
					<tr>                        
                        <th rowspan='1' colspan='6'>가이드레일 마감/보강재</th>
                        <th rowspan='3'>하부base1</th>
                        <th rowspan='3'>하부base2</th>
                        <th colspan='5' > 레일용 연기차단재 <br> W50</th>
                        <th colspan='12'> 케이스 </th>                        
                        <th> 케이스용<br>연기차단재</th>
                        <th colspan='3'>하장바</th>
                        <th colspan='7'>x</th>
                        <th rowspan='3'>인치</th>
                        <th colspan='12'>원형파이프</th>
                        <th rowspan='2' colspan='4'> 50*30*1.4T </th>
                    </tr>
					<tr>
						<th rowspan='2'> 설치유형 </th>					
						<th rowspan='2'> 마감유형 </th>					
						<th rowspan='2'> 가로 </th>					
						<th rowspan='2'> 높이 </th>					
						<th rowspan='2'> 가로 </th>					
						<th rowspan='2'> 높이 </th>					
						<th rowspan='2'> 가로 </th>					
						<th rowspan='2'> 높이 </th>			
						<th rowspan='2'> 매립 </th>					
						<th rowspan='2'> 노출 </th>						
						<th rowspan='2'> 매립형 <br> 뒷박스 </th>	
						<th rowspan='2'>가로*세로</th>
                        <th rowspan='2'>사이즈</th>
                        <th rowspan='2'>받침용<br>앵글</th>
                        <th rowspan='2'>size</th>
                        <th rowspan='2'>2438</th>
                        <th rowspan='2'>3000</th>
                        <th rowspan='2'>3500</th>
                        <th rowspan='2'>4000</th>
                        <th rowspan='2'>4300</th>    
                        <th rowspan='2'>2438</th>
                        <th rowspan='2'>3000</th>
                        <th rowspan='2'>3500</th>
                        <th rowspan='2'>4000</th>
                        <th rowspan='2'>4300</th>    
                        <th colspan='8'>셔터박스</th>
                        <th rowspan='1'>상부덮개</th>
                        <th colspan='3'>마구리</th>                        
                        <th colspan='1'>W80</th>                        
                        <th colspan='3'>60*40</th>                        
                        <th colspan='7'>x</th>                        
                        <th colspan='1'>x</th>                        
                        <th colspan='3'>4</th>                        
                        <th colspan='3'>5</th>    
                        <th colspan='4'>6</th>    
                        <th colspan='1'>8</th>    
                    </tr>
                    <tr>                    
						<th>규격 <br> (사이즈,전면밑,레일폭,점검구방향) </th>
                        <th>size</th>
                        <th>1219</th>
                        <th>2438</th>
                        <th>3000</th>
                        <th>3500</th>
                        <th>4000</th>
                        <th>4150</th>
                        <th>1219*@</th>
                        <th>size</th>
                        <th>날개</th>
                        <th>수량</th>
                        <th>3000</th>
						<th>size</th>
						<th>3000</th>
                        <th>4000</th>
						<th colspan='7'>x</th>
                        <th>철재x</th>
                        <th>3000</th>
                        <th>4500</th>
                        <th>6000</th>
                        <th>6000</th>
                        <th>7000</th>
                        <th>8200</th>
                        <th>3000</th>
                        <th>6000</th>
                        <th>7000</th>
                        <th>8000</th>
                        <th>8200</th>
                        <th>보강개수환산</th>
                        <th>size</th>
                        <th>3000</th>
                        <th>6000</th>
                        <th>300</th>
                        <th>2500</th>
                    </tr> " ;
					
    // $user_id가 'pro'일 경우 열 번호를 표시하는 th 행 추가
    if ($user_idtem === 'pro') {        
        echo "<tr class='text-primary'><th></th>";
        
        // 1) 기본 col1~col4
        for ($i = 1; $i <= 4; $i++) {
            echo "<th class='text-primary'>col{$i}</th>";
        }
        
        // 2) col4 다음에 col4_quartz
        echo "<th class='text-primary'>col4_quartz</th>";
        
        // 3) col5~col18
        for ($i = 5; $i <= 18; $i++) {
			if($i==10) 
            {
                $j = 'col10_SW'; // 스크린제작치수 가로
                echo "<th class='text-primary'>$j</th>";
                $j = 'col11_SH'; // 스크린제작치수 높이
                echo "<th class='text-primary'>$j</th>";
                echo "<th class='text-primary'>col{$i}</th>";
            }
            else {            
                echo "<th class='text-primary'>col{$i}</th>";
            }
        }
        
        // 4) col19 이전에 추가할 3개
        echo "<th class='text-primary'>col19_brand</th>";
        echo "<th class='text-primary'>col19</th>";
        echo "<th class='text-primary'>col19_wireless</th>";
        
        // 5) 나머지 col20~col46
        for ($i = 20; $i <= 46; $i++) {
            echo "<th class='text-primary'>col{$i}</th>";
        }
        echo "<th class='text-primary'>col46_wing</th>";        

        for ($i = 47; $i <= 77; $i++) {
            echo "<th class='text-primary'>col{$i}</th>";
        }
        echo "</tr>";       
        echo "<tr> <th>idx </th> ";	     
        for ($i = 0; $i <= 82; $i++) {			
            echo "<th  class='text-success'>$i</th>";
        }
        echo "</tr>";

     }						
                echo "</thead>
                <tbody id='{$id}Group'>
                    <!-- 자동생성 -->
                </tbody>
				 <tfoot class='table-secondary'>
					<tr>
						<th class='text-end' colspan='15'> 합계 &nbsp; </th>";
						
						for ($i = 16; $i <= 84; $i++) {											
								echo "<th class='text-center' id='estimateSlattotalCol{$i}'></th>";											
						}
			echo "          </tr> ";				
		echo "	</tfoot>				
            </table>
			 <div class='d-flex row mt-3 mb-5'> &nbsp;&nbsp;
        </div>            
        </div>            
      </div>
    </div>
    ";     
}

?>
