<?php 
session_start();
// ============
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
$obj = new my_class();
// ============
$branchid = $_SESSION['LOGIN_BRANCH'];
extract($_GET);
//echo $id;
$project_info_list  = $obj->View_column_details_By_Cond("HYDROLOGY.LITHO_BORE_LOG_PRO_INFO@HYDRO10","*"," 1=1 and ID='$id'");
//print_r($project_info_list);

  $location_sketch_id = $project_info_list['LOCATION_SKETCH_ID'];

$id =  $project_info_list['ID'];
$district_id =  $project_info_list['UPZ_ID'];
$table_name  = 'HYDROLOGY.UPAZILA_TBL@HYDRO10 UPZ LEFT JOIN HYDROLOGY.DISTRICT_TBL@HYDRO10 DIST ON UPZ.DST_CODE=DIST.DISTRICT_NO';
$columns = 'UPZ.UPZL_CODE,UPZ.UPZL_NAME,DIST.DISTRICT_NAME';
$where_cond = "1=1 and UPZL_CODE='$district_id'";
$district= $obj->View_column_details_By_Cond( $table_name,$columns,$where_cond);
$district_data = $district['UPZL_NAME'] . ' (' . $district['DISTRICT_NAME'] . ')';
// exit();

// $district_name =  $district['DISTRICT_NAME'];

$sub_division_id =  $project_info_list['SUB_DIV_ID'];
$table_name = 'HYDROLOGY.GW_SUBDIVCODE_TBL@HYDRO10';
$columns = '*';
$where_cond = "HYDSUBDIVCODE='$sub_division_id'";
$division= $obj->View_column_details_By_Cond( $table_name,$columns,$where_cond);
$sub_division_name =  $division['SUBDIVISION_NAME'];


// echo $sub_division_name;
// exit();

$is_sampling_type="";
 if($project_info_list['SAMPLING_TYPE']=='undisturb'){
    $is_sampling_type="Soil Sampling Undisturb";
 }
 if($project_info_list['SAMPLING_TYPE']=='disturb'){
    $is_sampling_type="Soil Sampling Disturb";
 }
 $is_how_sampled="";
 
 if($project_info_list['HOW_SAMPLED']=='BG'){
    $is_how_sampled="Bags";
 }else if($project_info_list['HOW_SAMPLED']=='BX'){
    $is_how_sampled="Box";
 }else if($project_info_list['HOW_SAMPLED']=='C'){
    $is_how_sampled="Cans";
 }
 else if($project_info_list['HOW_SAMPLED']=='J'){
    $is_how_sampled="Jars";
 }
 else if($project_info_list['HOW_SAMPLED']=='W'){
    $is_how_sampled="Wooden";
 }


?>

<?php
// function get_image($image_url) {
//     $ch = curl_init();
//     curl_setopt($ch, CURLOPT_URL, $image_url);
//     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
//     // Execute cURL request
//     $image_content = curl_exec($ch);

//     // Check for cURL errors
//     if(curl_errno($ch)) {
//         // Handle cURL error (e.g., display an error message or log)
//         echo 'cURL error: ' . curl_error($ch);
//         return false;
//     }

//     curl_close($ch);

//     return $image_content;
// }

// Assuming $project_info_list is an array with LOCATION_SKETCH_ID
$location_sketch_id = $project_info_list['LOCATION_SKETCH_ID'];
$image_url = "http://103.141.9.234/hydro/module/common/view_file.php?file_id=" . $location_sketch_id;

// Fetch image content using cURL
// $image_content = get_image($image_url);

// if ($image_content === false) {
//     // Handle the case where cURL request failed
//     echo 'Failed to fetch image content';
// } else {
//     // Create a data URI for embedding in HTML
//     $data_uri = "data:image/jpg;base64," . $image_content;
//    // echo $data_uri;
//     // Output the HTML with the img tag
//     echo '<img src="' . $data_uri . '" style="width:300px; height:150px" alt="Image">';
// }
?>


<?php
// function get_signature($signature_url) {
//     $ch = curl_init();
//     curl_setopt($ch, CURLOPT_URL,$signature_url);
//     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
//     // Execute cURL request
//     $signature_content = curl_exec($ch);

//     // Check for cURL errors
//     if(curl_errno($ch)) {
//         // Handle cURL error (e.g., display an error message or log)
//         echo 'cURL error: ' . curl_error($ch);
//         return false;
//     }

//     curl_close($ch);

//     return  $signature_content ;
// }

// Assuming $project_info_list is an array with signature id
$signature_id  = $project_info_list['SIGNATURE_ID'];
// $signature_url = "http://103.141.9.234/hydro/module/common/view.php?img_name=" . $signature_id;
$signature_url = "http://103.141.9.234/hydro/module/common/view_file.php?file_id=" . $signature_id;

// Fetch image content using cURL
// $signature_content = get_signature($signature_url);

// if ($signature_content === false) {
//     // Handle the case where cURL request failed
//     echo 'Failed to fetch image content';
// } else {
//     // Create a data URI for embedding in HTML
//     $data_url = "data:image/jpg;base64," . $signature_content;
//    // echo $data_uri;
//     // Output the HTML with the img tag
//     echo '<img src="' . $data_url . '" style="width:300px; height:150px" alt="Image">';
// }
?>


<div class="row-fluid">
    <table style="width: 100%; border-collapse: collapse; padding-left: 5px;">

        <tr>
            <th style="text-align: right; width: 20%;">Site: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['SITE']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">P.S: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['POST_OFFICE']; ?></td>
            <th style="text-align: right; width: 20%;">&nbsp;&nbsp;&nbsp;</th>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Upzila(District): </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $district_data ; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Sub-Division: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $sub_division_name ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Client: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['CLIENT']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Drilled By: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['DRILLED_BY']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Unit: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['UNIT']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Sampling Type: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" .$is_sampling_type; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Sample Nos: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['SAMPLE_NO']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Dimensions: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['DIMENSIONS']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">No Taken: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['NO_TAKEN']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Type: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['TYPE']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Weight of Hammer: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" .$project_info_list['HAMMER_WEIGTH']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Avg. Drop: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['AVG_DROP']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">How Sampled: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $is_how_sampled; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Despatched On: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['DESPATCHED_ON']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Casing Size: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['CASING_SIZE']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Casing Length Used: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['CASING_LENGTH_USED']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Cashing Weight of Hammer: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['CASING_HAMMER_WT']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Cashing Avg. Drop: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['CASING_AVG_DROP']; ?></td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Remarks: </th>
            <td style="width: 28%; border-bottom: 1px dotted;"><?php echo "&nbsp;" . $project_info_list['REMARKS']; ?></td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6">&nbsp;&nbsp;&nbsp; </td>
        </tr>
        <tr>
            <th style="text-align: right; width: 20%;">Location Sketch: </th>
            <td>
                <?php
                    // if ($image_content === false) {
                    //     // Handle the case where cURL request failed
                    //     echo 'Failed to fetch image content';
                    // } else {
                    //     // Create a data URI for embedding in HTML
                    //     $data_uri = "data:image/jpg;base64," . $image_content;
                    // echo $data_uri;
                        // Output the HTML with the img tag
                        echo '<img src="' .$image_url. '" style="width:300px; height:150px" alt="Image">';
                   // }
                ?>

            </td>
            <td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
            <th style="text-align: right; width: 20%;">Signature: </th>
            <td>
            <?php
                // if ($signature_content === false) {
                //     // Handle the case where cURL request failed
                //     echo 'Failed to fetch image content';
                // } else {
                //     // Create a data URI for embedding in HTML
                //     $data_url = "data:image/jpg;base64," . $signature_content;
                // echo $data_uri;
                    // Output the HTML with the img tag
                    echo '<img src="' .$signature_url. '" style="width:300px; height:150px" alt="Image">';
                //}
                ?>
            </td>
            <td style="width: 28%;">&nbsp;&nbsp;&nbsp;</td>
        </tr>

    </table>
</div>


