<?php
/**
 * 제품 데이터 배열을 생성하는 함수
 *
 * @param string $model_name 제품 모델 (예: 'KSS01', 'KWE01' 등)
 * @param string $finishing_type 마감 형태 (예: 'SUS마감' 등)
 * @param float|int $rail_length 레일 가로(너비)
 * @param float|int $rail_width  레일 세로(폭)
 * @param string $check_type 체크 타입 ('벽면형' 또는 '측면형') - 기본값은 '벽면형'
 * @return array 제품 데이터 배열
 */
function getProductData($model_name, $finishing_type, $rail_length, $rail_width, $check_type = '벽면형') {
    $productData = [];

    // 벽면형에 대한 처리
    if ($check_type === '벽면형') {
        if ($model_name === 'KSS01') {
            // 1번
            $proditem1 = [
                'label' => '1번(마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 2,
                'inputValues' => [10, 11 + ($rail_width/2 - 35), $rail_length - 10, $rail_width/2 - 5, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, $rail_width/2 - 5 - 4, $rail_length - 40, $rail_width - 3, $rail_length - 40, $rail_width/2 - 5 - 4, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 3번 (벽면형-C)
            $proditem3 = [
                'label' => '3번(벽면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [30, 45, 30],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 4번 (벽면형-D)
            $proditem4 = [
                'label' => '4번(벽면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 23, 40 + ($rail_width - 70), 23, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4];

        } 
		if ($model_name === 'KDSS01') {  // 신제품 더블셔터
            // 1번
            $proditem1 = [
                'label' => '1번(마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 2,
                'inputValues' => [15, 13, 16,25,140,11,10],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false, false]
            ];
            // 2번 마감제
            $proditem2 = [
                'label' => '2번(마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [15,13,16,60,16,13,15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false, false]
            ];
            // 3번 (본체)
            $proditem3 = [
                'label' => '3번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 2,
                'inputValues' => [10, 28, 98,73,98,20,10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, false, false, false, false]
            ];
            // 4번 (벽면형-C각도)
            $proditem4 = [
                'label' => '4번(벽면형-C각도)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [20,35,123,35,20],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4];
		} 
		if ($model_name === 'KSS02') {
            // 1번
            $proditem1 = [
                'label' => '1번(마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 2,
                'inputValues' => [10, 11 + ($rail_width/2 - 35), $rail_length - 10, $rail_width/2 - 5, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, $rail_width/2 - 5 - 4, $rail_length - 40, $rail_width - 3, $rail_length - 40, $rail_width/2 - 5 - 4, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 3번 (벽면형-C)
            $proditem3 = [
                'label' => '3번(벽면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [30, 45, 30],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];          
            $productData = [$proditem1, $proditem2, $proditem3];
        } 
		if ($model_name === 'KWE01' || $model_name === 'KSE01') {
            // 1번
            $proditem1 = [
                'label' => '1번(마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 2,
                'inputValues' => [10, 11 + ($rail_width/2 - 35), $rail_length - 10, $rail_width/2 - 5, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, $rail_width/2 - 5 - 4, $rail_length - 40, $rail_width - 3, $rail_length - 40, $rail_width/2 - 5 - 4, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 3번 (벽면형-C)
            $proditem3 = [
                'label' => '3번(벽면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [30, 45, 30],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 4번 (벽면형-D)
            $proditem4 = [
                'label' => '4번(벽면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 23, 40, 23, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];			
		if ($finishing_type == 'SUS마감') {
                // 5번 별도마감재
                $proditem5 = [
                    'label' => '5번(별도마감)',
                    'material' => 'SUS 1.2T',
					'surang' => 2,
                    'inputValues' => [9, $rail_length - 6, $rail_width/2 - 1, 10],
                    'bendingRates' => [0, -1, -1, 0],
                    'sums' => [],
                    'colors' => [false, false, false, false],
                    'aAngles' => [false, false, false, false]
                ];
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5];
            } else {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4];
            }
        } 
		
		if ($model_name == 'KQTS01') {
            // 1번
            $proditem1 = [
                'label' => '1번(A마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 13 + ($rail_width/2 - 37.5), $rail_length - 10, ($rail_width/2 - 37.5 + 25), 15],
                'bendingRates' => [0, 0, -1, -1, -1],
                'sums' => [],
                'colors' => [true, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(B마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 13 + ($rail_width/2 - 37.5), $rail_length - 10, ($rail_width/2 - 37.5 + 25), 19, 14, 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 3번 (본체)
            $proditem3 = [
                'label' => '3번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 60 + ($rail_width - 75), $rail_length - 40, 21 + ($rail_width/2 - 37.5), 15, 15, 20, 15, 43, 30, 78, 21 + ($rail_width/2 - 37.5), $rail_length - 40, 12, 10],
                'bendingRates' => [0, -1, -1, -1, -1, 0, 1, 0, 0, 1, 0, -1, -1, -2, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, true, true, false, true, true, false, false, false, false, false],
                'aAngles' => [false, false, -1, false, false, false, false, false, false, false, false, -1, false, false, false]
            ];
            // 4번 (벽면형-C)
            $proditem4 = [
                'label' => '4번(벽면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [30, 45, 30],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4];
        } 
		
		if ($model_name === 'KTE01') {
            // 1번
            $proditem1 = [
                'label' => '1번(A마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 13 + ($rail_width/2 - 37.5), $rail_length - 10, ($rail_width/2 - 37.5 + 25), 15],
                'bendingRates' => [0, 0, -1, -1, -1],
                'sums' => [],
                'colors' => [true, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 13 + ($rail_width/2 - 37.5), $rail_length - 10, ($rail_width/2 - 37.5 + 25), 19, 14, 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 3번 (본체)
            $proditem3 = [
                'label' => '3번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 60 + ($rail_width - 75), $rail_length - 40, 21 + ($rail_width/2 - 37.5), 15, 15, 20, 15, 43, 30, 78, 21 + ($rail_width/2 - 37.5), $rail_length - 40, 12, 10],
                'bendingRates' => [0, -1, -1, -1, -1, 0, 1, 0, 0, 1, 0, -1, -1, -2, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, true, true, false, true, true, false, false, false, false, false],
                'aAngles' => [false, -1, false, false, false, false, false, false, false, false, -1, false, false, false, false]
            ];
            // 4번 (벽면형-D)
            $proditem4 = [
                'label' => '4번(벽면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 23, 40, 23, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 5번 (벽면형-C)
            $proditem5 = [
                'label' => '5번(벽면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [30, 45, 30],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 6번 (마감재덧방)
            $proditem6 = [
                'label' => '6번(별도마감)',
                'material' => 'SUS 1.2T',
				'surang' => 2,
                'inputValues' => [10, $rail_length -10 + 3, 28, 10],
                'bendingRates' => [0, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false],
                'aAngles' => [false, false, false, false]
            ];
            if ($finishing_type == 'SUS마감') {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5, $proditem6];
            } else {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5];
            }
        }    
    } 
	// 측면형에 대한 처리
	if ($check_type === '측면형') {
        if ($model_name === 'KSS01' ) {
            // 1번
            $proditem1 = [
                'label' => '1번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 10, $rail_length, 30, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 50, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false]
            ];
            // 3번 (측면형본체)
            $proditem3 = [
                'label' => '3번(측면형본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 26, $rail_length - 40, 70 - 3, $rail_length - 40, 26, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 4번 (측면형별도마감)
            $proditem4 = [
                'label' => '4번(측면형별도마감)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, $rail_length - 80 - 5, 70 - 3, $rail_length - 80 - 5, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 5번 (측면형-C)
            $proditem5 = [
                'label' => '5번(측면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [43, 95, 43],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 6번 (측면형-D)
            $proditem6 = [
                'label' => '6번(측면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 36, 90, 36, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5, $proditem6];
        } 
		
		if ($model_name === 'KDSS01' ) { // 측면형 신제품 더블 개발
            // 1번
            $proditem1 = [
                'label' => '1번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [15,13,16,25,150,190,11,10],
                'bendingRates' => [0, 0, -1, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [15,13,16,60,16,13,15],
                'bendingRates' => [0, 0, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false, false]
            ];
            // 3번 (측면마감제)
            $proditem3 = [
                'label' => '3번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [15,13,16,65,11,10],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false]
            ];
            // 4번 (측면형본체)
            $proditem4 = [
                'label' => '4번(측면형본체)',
                'material' => 'EGI 1.55T',
				'surang' => 2,
                'inputValues' => [19,28,146,73,146,20,9],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, false, false, false, false]
            ];
            // 5번 (측면형-D각도)
            $proditem5 = [
                'label' => '5번(측면형-D각도)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [20,37,123,37,20],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];          
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5];

        }
		if ($model_name === 'KSS02' ) {
            // 1번
            $proditem1 = [
                'label' => '1번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 10, $rail_length, 30, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(측면마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 50, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false]
            ];
            // 3번 (측면형본체)
            $proditem3 = [
                'label' => '3번(측면형본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 26, $rail_length - 40, 70 - 3, $rail_length - 40, 26, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 4번 (측면형별도마감)
            $proditem4 = [
                'label' => '4번(측면형별도마감)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, $rail_length - 80 - 5, 70 - 3, $rail_length - 80 - 5, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 5번 (측면형-C)
            $proditem5 = [
                'label' => '5번(측면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [43, 95, 43],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
			
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5];
        } 
		if ($model_name === 'KWE01' || $model_name === 'KSE01') {
            // 1번
            $proditem1 = [
                'label' => '1번(측면마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 10, $rail_length, 30, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false, true, false],
                'aAngles' => [false, false, false, false, true, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(측면마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_length/2 - 60), $rail_width - 50, 15, 15, 15],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, true, false, false]
            ];
            // 3번 (측면형본체)
            $proditem3 = [
                'label' => '3번(측면형본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 26, $rail_length - 40, 70 - 3, $rail_length - 40, 26, 10],
                'bendingRates' => [0, -1, -1, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false, false, false],
                'aAngles' => [false, false, false, true, false, false, false]
            ];
            // 4번 (측면형별도마감)
            $proditem4 = [
                'label' => '4번(측면형별도마감)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, $rail_length - 80 - 5, 70 - 3, $rail_length - 80 - 5, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 5번 (측면형-C)
            $proditem5 = [
                'label' => '5번(측면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,				
                'inputValues' => [43, 95, 43],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 6번 (측면형-D)
            $proditem6 = [
                'label' => '6번(측면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 36, 90, 36, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 7번 (측면형-별도마감A)
            $proditem7 = [
                'label' => '7번(측면형-별도마감A)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [9 + ($rail_length/2 - 60), $rail_width - 10 + 4, $rail_length + 4, 34, 10],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 8번 (측면형-별도마감B)
            $proditem8 = [
                'label' => '8번(측면형-별도마감B)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, $rail_width - 50 + 4, 9],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            if ($finishing_type == 'SUS마감') {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5, $proditem6, $proditem7, $proditem8];
            } else {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5, $proditem6];
            }

        } 
		if ($model_name === 'KTE01') {
            // 1번
            $proditem1 = [
                'label' => '1번(A마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_width/2 - 62.5), $rail_width - 10, $rail_length, ($rail_width/2 - 62.5 + 25), 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false],
                'aAngles' => [false, false, false, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(마감제)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_width/2 - 62.5), $rail_width - 60, 19, 14, 15],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false]
            ];
            // 3번 (본체)
            $proditem3 = [
                'label' => '3번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, $rail_length - 16, 21 + ($rail_width/2 - 62.5), 15, 15, 20, 15, 43, 30, 78, 21 + ($rail_width/2 - 62.5), $rail_length - 4, $rail_width - 53, 12, 10],
                'bendingRates' => [0, -1, -1, -1, 0, 1, 0, 0, 1, 0, -1, -1, -1, -2, 0],
                'sums' => [],
                'colors' => [false, false, false, false, true, true, false, true, true, false, false, false, false, false, false],
                'aAngles' => [false, -1, false, false, false, false, false, false, false, false, -1, false, false, false, false]
            ];
            // 4번 (측면형-D)
            $proditem4 = [
                'label' => '4번(측면형-D)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [11, 36, 100 + ($rail_length - 130), 36, 11],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 5번 (측면형-C)
            $proditem5 = [
                'label' => '5번(측면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [43, 105 + ($rail_length - 130), 43],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            // 6번 (마감재덧방)
            $proditem6 = [
                'label' => '6번(별도마감)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [9, $rail_width - 7, $rail_length + 3, 28, 10],
                'bendingRates' => [0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [false, false, false, false, false],
                'aAngles' => [false, false, false, false, false]
            ];
            // 7번 (마감재덧방)
            $proditem7 = [
                'label' => '7번(별도마감)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [9, $rail_width - 60 + 3, 9],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            if ($finishing_type == 'SUS마감') {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5, $proditem6, $proditem7];
            } else {
                $productData = [$proditem1, $proditem2, $proditem3, $proditem4, $proditem5];
            }
        }    		
		if ($model_name === 'KQTS01') {
            // 1번
            $proditem1 = [
                'label' => '1번(A마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_width/2 - 62.5), $rail_width - 10, $rail_length, ($rail_width/2 - 62.5 + 25), 15],
                'bendingRates' => [0, 0, -1, -1, -1, 0],
                'sums' => [],
                'colors' => [true, false, false, false, false, false],
                'aAngles' => [false, false, false, false, false, false]
            ];
            // 2번
            $proditem2 = [
                'label' => '2번(B마감제)',
                'material' => 'SUS 1.2T',
				'surang' => 1,
                'inputValues' => [10, 11 + ($rail_width/2 - 62.5), $rail_width - 60, 19, 14, 15],
                'bendingRates' => [0, 0, -1, -1, 0, 0],
                'sums' => [],
                'colors' => [true, false, false, false, true, false],
                'aAngles' => [false, false, false, false, false, false]
            ];
            // 3번 (본체)
            $proditem3 = [
                'label' => '3번(본체)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [10, $rail_length - 16, 21 + ($rail_width/2 - 62.5), 15, 15, 20, 15, 43, 30, 78, 21 + ($rail_width/2 - 62.5), $rail_length - 4, $rail_width - 53, 12, 10],
                'bendingRates' => [0, -1, -1, -1, 0, 1, 0, 0, 1, 0, -1, -1, -1, -2, 0],
                'sums' => [],
                'colors' => [false, false, false, false, true, true, false, true, true, false, false, false, false, false, false],
                'aAngles' => [false, -1, false, false, false, false, false, false, false, false, -1, false, false, false, false]
            ]; 
            // 4번 (측면형-C)
            $proditem4 = [
                'label' => '4번(측면형-C)',
                'material' => 'EGI 1.55T',
				'surang' => 1,
                'inputValues' => [43, 105 + ($rail_length - 130), 43],
                'bendingRates' => [0, -1, 0],
                'sums' => [],
                'colors' => [false, false, false],
                'aAngles' => [false, false, false]
            ];
            $productData = [$proditem1, $proditem2, $proditem3, $proditem4];

        } 

	}

    // 합계(sums) 계산 함수 (내부 클로저 사용) 연신율 음수표시로 변경 (2025.06.24 두진호 책임요청)
    $calculateSums = function($product) {
        $accumulatedSum = 0;
        $sums = [];
        foreach ($product['inputValues'] as $index => $inputVal) {
            $result = $inputVal + $product['bendingRates'][$index];
            $accumulatedSum += $result;
            $sums[] = $accumulatedSum;
        }
        return $sums;
    };

    // 각 제품에 대해 sums 계산 후 업데이트
    foreach ($productData as &$product) {
        $product['sums'] = $calculateSums($product);
    }
    unset($product);
    return $productData;
}
?>