<style>

#myTable thead th {

    position: sticky;

    top: 0;

    z-index: 1;

}

</style>

<table id="myTable" data-last-order-identifier="customers"

    class="table table-clients number-index-2 dataTable no-footer">

    <thead>

        <tr>

            <th class="sorting_disabled not-export" rowspan="2" colspan="1" aria-label=" - "><span class="hide"> -

                </span>

                <div class="checkbox mass_select_all_wrap"><input type="checkbox" id="mass_select_all"

                        data-to-table="clients"><label></label></div>

            </th>

            <th rowspan="2">Tên KH</th>

            <th rowspan="2">Ngày ghi sổ</th>

            <th rowspan="2">Số cont</th>

            <th rowspan="2">Điểm đi</th>

            <th rowspan="2">Điểm đến</th>

            <th rowspan="2">Loại Cont</th>

            <th rowspan="2">MOOC</th>

            <th rowspan="2">Lương Chuyến</th>

            <th colspan="6">Phí</th>

            <th rowspan="2">Số Xe</th>

            <th rowspan="2">Ứng</th>

            <th rowspan="2">Quyết Toán</th>

        </tr>

        <tr class="sticky_head">

            <th>Ngoài Tỉnh</th>

            <th>Cặp</th>

            <th>Neo</th>

            <th>Lạnh</th>

            <th>Điện Thoại</th>

            <th>khác</th>

        </tr>

    </thead>

 <tbody>

    <?php foreach ($paginated_data as $index => $row): ?>

    <tr data-id="<?php echo $row['id']; ?>" style="background-color: <?php echo $row['note_color']; ?>;">

        <td class="note_color">

            <?php

                foreach ($congno as $congno_row):

                    if ($row['id'] == $congno_row['id']):

                        echo '<div class="color_block" style="background-color: ' . $congno_row['note_color'] . '"></div>';

                    endif;

                endforeach;

            ?>

            <div class="checkbox"> 

                <input type="checkbox" class="rowselect" value="<?php echo $index; ?>">

                <label></label>

            </div>

        </td>

        <td class="truncate" data-truncate="<?php echo $row['Ten_KH']; ?>" style="text-align: left">

            <a href="/perfex_crm/admin/clients/client/<?php echo $row['MA_KH']; ?>"><?php echo $row['Ten_KH']; ?></a>

            <div class="row-options">

                <a href="#" class="edit-button" style="color:#e57909" data-id="<?php echo $row['id']; ?>">Chỉnh sửa </a>

                <?php if (empty($row['MA_KH'])): ?>

                    | <a href="<?php echo site_url('template_module/delete/' . $row['id']); ?>" 

                         class="text-danger _delete" 

                         onclick="return confirm('Bạn có chắc muốn xóa không?');">Xóa</a>

                <?php endif; ?>

            </div>

        </td>

        <td><?php echo date('d/m/Y', strtotime($row['Ngay_ghi_so'])); ?></td>

        <td><?php echo $row['So_cont']; ?></td>

        <td><?php echo $row['Diem_di']; ?></td>

        <td><?php echo $row['Diem_den']; ?></td>

        <td><?php echo $row['Loai_cont']; ?></td>

        <td><?php

            $MOOC = $row['MOOC'];

            if ($MOOC == '1-1') {

                echo "1";

            } elseif ($MOOC == '1.5-1') {

                echo "1.5";

            } elseif ($MOOC == '1-2') {

                echo "1";

            } elseif ($MOOC == '1.5-2') {

                echo "1.5";

            }
            
            else {

                echo $MOOC;

            }

        ?></td>

        <td style="color: rgb(37 99 235)">

            <?php

                $Luong_chuyen = $row['Luong_chuyen'];

                $MOOC = $row['MOOC'];

                if (!empty($Luong_chuyen)) {

                    echo number_format($Luong_chuyen);

                } else {

                    if ($MOOC == 1) {

                        echo number_format(850000);

                    } elseif ($MOOC == 1.5) {

                        echo number_format(1275000);

                    } elseif ($MOOC == '1-1') {

                        echo number_format(800000);

                    } elseif ($MOOC == '1.5-1') {

                        echo number_format(1200000);

                    } elseif ($MOOC == '1-2') {

                        echo number_format(900000);

                    }
                    elseif ($MOOC == '1-3') {

                        echo number_format(1000000);

                    }
                    elseif ($MOOC == '1.5-2') {

                        echo number_format(1350000);

                    }
                    elseif ($MOOC == '1.5-3') {

                        echo number_format(1500000);

                    }

                    else {

                        echo "0";

                    }

                }

            ?>

        </td>

        <td><?php echo number_format($row['Ngoai_tinh']); ?></td>

        <td><?php echo number_format($row['CAP']); ?></td>

        <td><?php echo number_format($row['NEO']); ?></td>

        <td><?php echo number_format($row['LANH']); ?></td>

        <td><?php echo number_format($row['D_THOAI']); ?></td>

        <td><?php echo number_format($row['Khac']); ?></td>

        <td>

            <?php

                foreach ($xenha as $xenha1) {

                    if ($xenha1['id'] == $row['bien_so_xe']) {

                        echo $xenha1['name'];

                    }

                }

            ?>

        </td>

        <td style="display: none">

            <?php

                foreach ($staff as $staffs) {

                    if ($staffs['staffid'] == $row['So_xe']) {

                        echo $staffs['staff_identifi'];

                    }

                }

            ?>

        </td>

        <td style="<?php echo empty($row['MA_KH']) ? 'color: red;' : ''; ?>">

            <?php echo number_format($row['UNG']); ?>

        </td>

        <td><?php echo number_format($row['QTOAN']); ?></td>

    </tr>

    <?php endforeach; ?>

</tbody>



</table>