<?

//echo "<br><br><br><br>";

/*
for($i=0; $i<sizeof($_GET); $i++) {
	list($key, $value) = each($_GET);
	$$key = $value;

	if(is_array($value))
	{
		$count = 10;
		for($i = 0; $i < $count; $i ++) {
			if ($value[$i]) echo "ARRAY[$key][$value[$i]]<br>";
		}
	}
	else 	echo "[$key][$value]<br>";
	//print_r($_POST);
}
for($i=0; $i<sizeof($_POST); $i++) {
	list($key, $value) = each($_POST);
	$$key = $value;

	if(is_array($value))
	{
		$count = 10;
		for($i = 0; $i < $count; $i ++) {
			if ($value[$i]) echo "ARRAY[$key][$value[$i]]<br>";
		}
	}
	else 	echo "[$key][$value]<br>";
	//print_r($_POST);
}
*/

// Level 9 이하만 사용 가능
$func->checkLevelModal(9);

// Delete 기능 제한 (Admin : 1, Staff : 5, Driver : 9 만 가능)
$permit = array("1", "5", "9");
if (in_array($_SESSION['ss_LEVEL'], $permit)) {
    $setTag = "ENABLED";
}
else $setTag = "DISABLED";	

$add_srchquery = "";
$add_query = "";


if ($d_orderdate) $orderdate = $func -> convertFormat ($d_orderdate, 3);
else if ($orderdate) $d_orderdate = str_replace("-", "", trim($orderdate));

if ($searchDriver) $d_driveruid = $searchDriver;

if ($_SESSION['ss_LEVEL'] == 9 && $_SESSION['ss_UID'] != $d_driveruid) {
				$msg = "Invalid data. Please try again. [Err - order driver data]";
				$func -> modalMsg ($msg, "/index_intranet.php?view=order_list");
				exit();
			exit();
}


// searching
if($key_word) {

	$key_wordStr = urldecode(trim($key_word));
	$add_srchquery .= " AND  ((m_userid LIKE '%$key_wordStr%') OR (m_firstname LIKE '%$key_wordStr%') OR (m_cell LIKE '%$key_wordStr%'))";
}

// sorting
if($switch) {
	$switched = $func -> switchOrder($switch, $switched);
	$add_query .= " ORDER BY $switch $switched ";
	$switched = $switch . "^" . $switched;
}else if($switched) {
	$switched1 = explode("^", $switched);
	$add_query .= " ORDER BY $switched1[0] $switched1[1] ";
} else {
	$add_query .= " ORDER BY d_ordertype DESC, d_name ASC";
}

$getSWHStr = $switched;


//total record
$query = "SELECT COUNT(d_uid) FROM tbl_daily
					WHERE d_orderdate = '$d_orderdate' AND d_driveruid = '$d_driveruid' " . $add_allquery . $add_srchquery . $add_query;

$total_count=$jdb->rQuery($query, "record query error");
//echo "<br><br><br><br><br>[$total_count][$query]<br>";

//페이징변수설정
/*
if(!$page) $page = 1;

if(!$list_count) $list_count = $INIT_PAGECNT; //출력리스트 갯수
if(!$page_count) $page_count = $INIT_PAGEVIEWCNT; //출력페이지 갯수

$list_number = $total_count - (($page-1)*$list_count);
$start_number = $list_count * ($page-1);

$add_query .= " LIMIT $start_number, $INIT_PAGECNT";
*/
$list_number = $total_count;

$d_quantitySUM = 0;

$query = "SELECT * FROM tbl_daily
					WHERE d_orderdate = '$d_orderdate' AND d_driveruid = '$d_driveruid' " . $add_allquery . $add_srchquery . $add_query;
//echo "<br><br><br><br>[$query]";

$result=$jdb->nQuery($query, "list error");

while($list=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	for($i=0; $i<sizeof($list); $i++) {
		//list($key, $value) = each($list);
		foreach ( (Array) $list as $key => $value )
		$$key = $value;
	}

	
	$d_nameSTR = str_replace("\\", "", $d_name);
	//$d_maincontainerSTR = $arrBin[$d_maincontainer];
	$d_containerSTR = str_replace("\\", "", $d_container);
	$d_locationSTR = str_replace("\\", "", $d_location);
	$d_paymenttypeSTR = $arrPaymenttype[$d_paymenttype];
	$d_addressSTR = str_replace("\\", "", $d_address);
	$d_citySTR = str_replace("\\", "", $d_city);	
	$d_lastpickupdateSTR = $func -> convertFormat ($d_lastpickupdate, 3);
	$d_lastpaiddateSTR = $func -> convertFormat ($d_lastpaiddate, 3);

	
	$d_visitdateSTR = $func -> convertFormat ($d_visitdate, 3);
		
	$d_paystatusSTR = $arrPaidStatus[$d_paystatus];
	if ($d_paystatus == "P") $d_paystatusSTR = $d_paystatusSTR." ($".$d_payamount.")";
	
	$d_estquantitySTR = number_format(floatval($d_estquantity));
	$d_quantitySTR = number_format(floatval($d_quantity));

	$d_quantitySUM = $d_quantitySUM + floatval($d_quantity);

	$qry_dvr = "SELECT m_initial FROM tbl_member WHERE m_uid = '".$d_driveruid."' ";
	$rt_dvr = $jdb->fQuery($qry_dvr, "fetch query error");

	
	//////////////////////////////////////////////////////////////////
	// 삭제 아이콘
	// d_orderdate 이 현재일 이후인 경우만 삭제 가능
	// 운영자는 예외
	//////////////////////////////////////////////////////////////////
	
	if (($d_orderdate >= date("Ymd") && $d_status != "F") || $_SESSION['ss_LEVEL'] == "1") {
		if ($setTag == "ENABLED") {
			if ($_SESSION['ss_LEVEL'] == 9 && $_SESSION['ss_UID'] != $d_createruid) {
					$OPTIONstr = "";
					//$OPTIONstr = "[".$_SESSION['ss_UID']."][".$d_createruid."]";
					//$OPTIONTITLEstr = "OPTION";
			} else {
					$OPTIONstr = "<button type=\"button\" class=\"historyOrder btn icon-history\"><a class=\"deleteClass btn-member\" data-toggle=\"modal\" data-target=\"#myModalDelete\" data-id=\"$d_uid\" data-orderdate=\"$d_orderdate\" data-accountno=\"$d_accountno\"><i class=\"bi bi-x-circle red-color icon-delete\"></i></a></button>";
			}
		}
		else {
			$OPTIONstr = "";
			//$OPTIONTITLEstr = "";
		}
	}

	// d_orderdate 이 현재일이고, Finished 안된 경우만 입력할수 있음
	// 운영자는 예외
	//if (($d_orderdate == date("Ymd") && $d_status != "F") || $_SESSION['ss_LEVEL'] == "1") {

	// d_orderdate 이 현재일이고, Finished 상관없이 입력할수 있음 (2023.08.31 request)
	// 운영자는 예외	

	// note 가 존재하면 색상 blue 로 (2023.11.09)
		$qry_note = "SELECT * FROM tbl_note WHERE n_dailyuid = '$d_uid' ORDER BY n_uid DESC LIMIT 1";
		$rt_note=$jdb->fQuery($qry_note, "fetch query error");
		$n_noteSTR = str_replace("\\", "", $rt_note['n_note']);
		if (strlen($n_noteSTR) >= 1) $iconColor = "icon-note";
		else $iconColor = "icon-edit";
		

	//////////////////////////////////////////////////////////////////
	// 트럭아이콘	
	// icon-edit / icon-note
	// 2024.02.12 요청에 의해 Accounting 도 트럭아이콘(오일량 입력) 가능하도록 추가
	///////////////////////////////////////////////////////////////////

	if (($d_orderdate == date("Ymd")) || $_SESSION['ss_LEVEL'] == "1" || $_SESSION['ss_LEVEL'] == "6") {
			$PICKUPstr = "<button type='button' class='pickupOrder btn icon-pickup' data-toggle='modal' data-target='#myModalpickupOrder' data-id=\"$d_uid\" style=\"cursor:pointer;cursor:hand;\"><i class='bi bi-truck $iconColor'></i></button>";
	}
	else $PICKUPstr = "";
	
	
	//$PICKUPstr = "<button type='button' class='pickupOrder btn icon-pickup' data-toggle='modal' data-target='#myModalpickupOrder' data-id=\"$d_uid\" style=\"cursor:pointer;cursor:hand;\"><i class='bi bi-truck icon-edit'></i></button>";


	///////////////////////
	// Get This/Last year Quantity
	///////////////////////
	$getThisYear = date("Y");
	$getLastYear = date("Y", strtotime('last year'));
	
	//echo "<br><br><br><br>[$get1Mon][$get2Mon][$get3Mon]";

	$qry_sum = "SELECT 
								SUM(CASE WHEN d_visitdate like '".$getThisYear."%' THEN d_quantity ELSE 0 END) AS THISYEAR, 
								SUM(CASE WHEN d_visitdate like '".$getLastYear."%' THEN d_quantity ELSE 0 END) AS LASTYEAR
							FROM  tbl_daily 
							WHERE d_customeruid = '".$d_customeruid."' AND d_status = 'F' ";
//echo "LIST_TOT[$qry_sum]<br>";							
	$rt_sum = $jdb->fQuery($qry_sum, "fetch query error");
	
	$getThisYearQ = number_format(floatval($rt_sum['THISYEAR']));
	$getLastYearQ = number_format(floatval($rt_sum['LASTYEAR']));
	
	if ($d_ordertype == "R") $d_ordertypeSTR = "class='bg-request'";
	else if ($d_ordertype == "S") $d_ordertypeSTR = "class='bg-will-call'";
	else if ($d_driveruid == $d_createruid) $d_ordertypeSTR = "class='bg-period'";
	else $d_ordertypeSTR = "";

	$c_uid = $d_customeruid;

	if ($d_fullcycleflag == 1) {
		$d_fullcycleSTR = $d_fullcycleforced;
		$d_fullcycleCSS = "style='color:red;'";
	}
	else {
		$d_fullcycleSTR = $d_fullcycle;
		$d_fullcycleCSS = "";
	}
	
	if ($d_ruid != "") {
			$qry_rnote = "SELECT r_note FROM tbl_request WHERE r_uid = '".$d_ruid."' ";
			$rt_rnote = $jdb->fQuery($qry_rnote, "fetch query error");

			$r_noteSTR = str_replace("\\", "", trim($rt_rnote[0]));
			if ($r_noteSTR != "") $putNotePopup = "&nbsp;&nbsp; <a data-toggle='modal' style='cursor:pointer;cursor:hand;' class='customerShortNote' data-target='#myModalcustomerShortNote' data-id=\"$d_uid\" data-history-type='standard-access'>&#128204;</a>";	
			else $putNotePopup = "";
	}
	else {
			$putNotePopup = "";
	}
	

	/*
	if ($d_ruid != "") {
			$qry_rnote = "SELECT r_note FROM tbl_request WHERE r_uid = '".$d_ruid."' ";
			$rt_rnote = $jdb->fQuery($qry_rnote, "fetch query error");

			$r_noteSTR = str_replace("\\", "", trim($rt_rnote[0]));
			if ($r_noteSTR != "") $putNotePopup = "&nbsp;&nbsp; <a data-toggle='modal' style='cursor:pointer;cursor:hand;' class='customerShortNote' data-target='#myModalcustomerShortNote' data-id=\"$d_uid\" data-history-type='standard-access'>&#128204;</a>";	
			else $putNotePopup = "";
	}
	else {
			$putNotePopup = "";
	}
	*/
	
	$driverPopup = "<a data-toggle='modal' style='cursor:pointer;cursor:hand;' class='customerShortInfo' data-target='#myModalcustomerShortInfo' data-id=\"$d_customeruid\" data-history-type='standard-access'>&#10067;</a>";

	if ($d_ordertype == "R" || $d_ordertype == "S") $list_numberSTR = $d_ordertype; 
	else $list_numberSTR = $list_number;
	
	$strList .= "

					<tr $d_ordertypeSTR>	
              <td>".$list_numberSTR."</td>
              <td class=\"td-icons-order\">$PICKUPstr
                <!--button type='button' class='pickupOrderClass btn icon-pickup' data-bs-toggle='modal' data-bs-target='#pickupOrderModal' data-id=\"$d_uid\" data-pickup-type='standard-access'><i class='bi bi-truck icon-edit'></i></button-->

                <button type='button' class='historyOrder btn icon-history' data-toggle='modal' data-target='#myModalHistory' data-id=\"$d_accountno\" data-history-type='standard-access'><i class='bi bi-folder2-open icon-delete'></i></button>
              	$OPTIONstr
              </td>              
              <td><b><a onclick=\"javascript:window.open('/index_intranet.php?view=customer_detail&mode=update&c_uid=$c_uid&page=$page&key_word=$key_word&column=$column&switched=$getSWHStr&sorting_type=$sorting_type&switch=$switch','_blank');\" style='cursor:pointer;cursor:hand;' class=\"link-name\" ><b>$d_nameSTR</a></b>&nbsp;&nbsp; $driverPopup $putNotePopup</td>
              <td>$d_accountno</td>
              <td>$d_maincontainer</td>
              <td>$d_paymenttype</td>
              <td>$d_rate</td>
              <td>$d_addressSTR</td>
              <td>$d_citySTR</td>
              <td style=\"text-align:right; padding-right:20px;\">$d_lastpickupquantity</td>
              <td style=\"text-align:right; padding-right:20px; color:#2A9B56\">$d_estquantitySTR</td>
              <td style=\"text-align:right; padding-right:20px; color:#FF8205\">$d_quantitySTR</td>
              <td>$d_lastpaiddateSTR</td>              
              <td style=\"text-align:right; padding-right:20px;\">$getLastYearQ </td>
              <td style=\"text-align:right; padding-right:20px;\">$getThisYearQ </td>";

	if ($_SESSION['ss_LEVEL'] == 9) {
			$strList .= "		
              <td style=\"text-align: right;margin-right: 20px;\">$d_fullcycleSTR</td>
              ";
	} else {     
			$strList .= "		
              <td style=\"text-align:right; padding-right:20px;\">

              		<input type='text' id=c_fullcycle_".$c_uid." name=c_fullcycle_".$c_uid." data-id=".$c_uid." ".$d_fullcycleCSS." class='updatecycle_form' required='required' value=".$d_fullcycleSTR." size=3 >


<script>

$('#c_fullcycle_".$c_uid."').on('change', function () { // changed
		var ii = $(this).data('id');
		var cc = document.getElementById('c_fullcycle_".$c_uid."').value;
		//alert(cc);exit;
		
    $.ajax({
        type: 'POST',
        url: '/lib/lib_updatecycle.php',
        data: { c_uid : ii, c_fullcycle : cc },
		    success: function(response){ 
					//alert(response);
					
          var rt = response.split('|');
          
					if (rt[0].trim().match('OK')) {
						//alert(rt[1]);

            document.getElementById('c_fullcycle_".$c_uid."').style.color = 'red';
						
						$('.myModalPopup-body').html('Successfully Updated');
						$('.myModalPopup-body').css('background-color', '#2A9B56');
            $('#myModalPopup').modal('show'); 

				    setTimeout(function () {
				        $('#myModalPopup').modal('hide'); 
				    }, 900);   
				    
						//showPopup();
						
						//setTimeout(function() {
					    	//$('.popup').fadeOut();
					  //  	hidePopup();
						//}, 2000);

					} else {
						if (rt[2] == 1) {
								document.getElementById('c_fullcycle_".$c_uid."').value = rt[1];
								document.getElementById('c_fullcycle_".$c_uid."').style.color = 'red';
						}
						else if (rt[2] == 0) {
								document.getElementById('c_fullcycle_".$c_uid."').value = rt[1];
						}

						$('.myModalPopup-body').html('Update Failed');
						$('.myModalPopup-body').css('background-color', '#F43700');
            $('#myModalPopup').modal('show'); 

				    setTimeout(function () {
				        $('#myModalPopup').modal('hide'); 
				    }, 1800);   						
					}

          //$('#myModalPopup').modal('show'); 
          					
		    }
    });
});

</script>
              
              </td>";


	}

              
	$strList .= "		              
              <td>$d_lastpickupdateSTR</td>
              <td>-</td>
              <td>$d_containerSTR</td>
					</tr>
	";

	$list_number--;
}


if( $total_count < 1 ) {
	$strList = "
		<tr><td colspan='20' align=center height='30'><B>No Data</B></td></tr>
		";
}

if ($_SESSION['ss_LEVEL'] == 9) $add_qry = " AND m_uid = '".$_SESSION['ss_UID']."' ";
else $add_qry = "";

// Get Driver Info
$qry_driver = "SELECT * FROM tbl_member WHERE m_level = 9 AND m_status = 'A' ".$add_qry." ORDER by m_initial ASC ";
$rt_driver = $jdb->nQuery($qry_driver, "list error"); 

while($lt_driver=mysqli_fetch_array($rt_driver, MYSQLI_ASSOC)) {

	if ($lt_driver['m_uid'] == $d_driveruid) $selectStr = "selected";
	else $selectStr = "";
	
	$c_driveruidSTR .= "
								<option value='".$lt_driver['m_uid']."' $selectStr>".$lt_driver['m_initial']."</option>";
								
}


addLog ("add", "ORDER DRIVER LIST", "VIEW", $lguserid, $query, $lgno);

?>


<script type="text/javascript">
$(document).ready(function(){

$(function () {
	$('#orderdate').datepicker({ 

					dateFormat: 'yy-mm-dd',
									//minDate: "+1D", 
									//maxDate: "+3D",
									//maxDate: "+1M +10D",
		              //showOn: "button",
		              //yearRange: '-50:+5',
		              buttonImage: "/images/cal_red.png",
		              //beforeShowDay: $.datepicker.noWeekends,
		              buttonImageOnly: true,
		              //showOn: "both",
		              changeMonth: true,
		              changeYear: true,
		              firstDay: 7              
	});
});
	
});
</script>




<SCRIPT TYPE="TEXT/JAVASCRIPT">
    $(function () {
        $(".deleteClass").click(function () {
            var my_id_value = $(this).data('id');
            var my_accountno_value = $(this).data('accountno');
            $(".modal-footer #d_uid").val(my_id_value);
            $(".modal-footer #d_accountno").val(my_accountno_value);
        })
    });

/*
    $(function () {
        $(".pickupOrderClass").click(function () {
            var my_id_value = $(this).data('id');
            $("#pickupOrderModal #d_uid").val(my_id_value);
        })
    });
*/
    
</SCRIPT>


<script>
$(document).ready(function(){

		$('.customerShortInfo').click(function(){
		 
		   var ccuid = $(this).data('id');

		   // AJAX request
		   $.ajax({
				    url: 'lib/shortInfo_lib.php',
				    type: 'post',
				    data: {c_uid: ccuid},
				    success: function(response){ 
				      // Add response in Modal body
				      $('.modal-content-modifycustomerShortInfo').html(response);

				      // Display Modal
				      //$('#myModalModify').modal('show'); 
				    }
			});
		});    
		
});

</script>


<script>
$(document).ready(function(){

		$('.customerShortNote').click(function(){
		 
		   var dduid = $(this).data('id');

		   // AJAX request
		   $.ajax({
				    url: 'lib/shortNote_lib.php',
				    type: 'post',
				    data: {d_uid: dduid},
				    success: function(response){ 
				      // Add response in Modal body
				      $('.modal-content-modifycustomerShortNote').html(response);

				      // Display Modal
				      //$('#myModalModify').modal('show'); 
				    }
			});
		});    
		
});

</script>


<script>
$(document).ready(function(){

		 $('.pickupOrder').click(function(){
		   
			   var dduid = $(this).data('id');

			   // AJAX request
			   $.ajax({
					    url: 'lib/order_lib.php',
					    type: 'post',
					    data: {d_uid: dduid},
					    success: function(response){ 
					      // Add response in Modal body
					      $('.modal-content-modifypickupOrder').html(response);

					      // Display Modal
					      //$('#myModalModify').modal('show'); 
					    }
		  	});
		 });
		 

		 $('.historyOrder').click(function(){
		   
			   var d_accountno = $(this).data('id');

			   // AJAX request
			   $.ajax({
					    url: 'lib/order_history.php',
					    type: 'post',
					    data: {d_accountno: d_accountno},
					    success: function(response){ 
					      // Add response in Modal body
					      $('.modal-content-historyOrder').html(response);

					      // Display Modal
					      //$('#myModalModify').modal('show'); 
					    }
		  	});
		 });
		 		 
});

function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>

<style type = "text/css">
   <!--
      @media print {
         .noprint {display:none;}
      }
   -->
</style>


  <main id="main" class="main">

    <!-- ======= Breadcrumbs ======= -->
    <div class="breadcrumbs">
      <div class="container">

        <div class="d-flex justify-content-between align-items-center">
          <h2>ORDER</h2>
          <ol>
            <li><a href="index.html">HOME</a></li>
            <li>ORDER</li>
          </ol>
        </div>

      </div>
    </div><!-- End Breadcrumbs -->

    <section class="page">


      <div class="container" data-aos="fade-up" id="printableArea">

        <div class="wrap-border form-search-inner">
            <table class="td-search">
              <tr>
                <td class="td-title"> <label for="Driver">Driver</label></td>
                <td>
											<FORM METHOD=POST NAME=form2 action='<?=$_SERVER["PHP_SELF"]?>'>
											<INPUT TYPE=HIDDEN NAME=view VALUE='order_driver'>
											<INPUT TYPE=HIDDEN NAME=searchtype VALUE='D'>
														<select name="searchDriver" id="searchDriver" class="custom-select" onChange="this.form.submit()">
														<!--option value=''>Select</option-->
														<?=$c_driveruidSTR?>
														</select>		
              	
                </td>
              </tr>
              <tr>
                <td class="td-title"><label for="Area">Date</label></td>
                <td><input type="text" id="orderdate" name="orderdate" value="<?=$orderdate?>" onChange="this.form.submit()"></td>
              </tr>
											</FORM>	  
            </table>
  
            <table class="td-search td-order">
              <tr>
                <td align="right" class="td-daily-report"><!--button type='button' class='btn-sub text-center width-300' data-bs-toggle='modal' data-bs-target='#pickup-modal' data-pickup-type='standard-access'>DAILY RECORD</button--></td>
                <!--td align="right" class="td-print"><button type='button' href="#" onclick="printDiv('printableArea')" class="btn-orange text-center">Print</button></td-->

<FORM NAME=exportorder id=exportorder METHOD=POST ACTION=/doc/export_process.php >
<input type=hidden name=mode value="export">
<input type=hidden name=actionStr value="ORDER">
<input type=hidden name="d_orderdate" value="<?=$orderdate?>">
<input type=hidden name="d_driveruid" value="<?=$d_driveruid?>">

                <td align="right" class="td-print"><button type='submit' href="#" class="btn-orange text-center">DOWNLOAD</button></td>
</FORM>

              </tr>
            </table>


        </div><!--wrap-border-->
  
        

        <div class="wrap-overflow order-2-info">
          <table class="tb-list">
            <tr>
                <th>No</th>
                <th>Option</th>
                <th class="td-order-restaurant"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_name">Restaurant Name</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_accountno">Account</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_maincontainer">Container</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_paymenttype">Payment</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_rate">Rate</a></th>
                <th class="td-order-address"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_address">Address</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_city">City</a></th>
                <th class="td-order-date"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_lastpickupquantity">Last Qty.</a></th>
                <th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_estquantity">Forecast(L)</a></th>
               	<th><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_quantity">Actual(L)</a></th>
                <th class="td-order-lastpu"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_lastpaiddate">Last Paid</a></th>               	
                <th><?=$getLastYear?></th>
                <th><?=$getThisYear?></th>
                <th class="td-order-cycle">Cycle</th>
                <th class="td-order-lastpu"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_lastpickupdate">Last PU</a></th>
                <th class="td-order-nextpu">Next PU</th>
                <th class="td-order-detail"><a href="/index_intranet.php?view=order_driver&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&d_orderdate=<?=$d_orderdate?>&d_driveruid=<?=$d_driveruid?>&switch=d_container">Detail</a></th>
            </tr>

<?=$strList?>

<!--
            <tr class="bg-request">
              <td>1</td>
              <td><a href="#" class="link-name">Restaurant Name</a></td>
              <td>GD221150</td>
              <td>400B </td>
              <td>Every summer I try to find the biggest tree around to climb. My mom always complains that my socks stink after I get home from camp.
              </td>
              <td>CHQ </td>
              <td>0.150 </td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>2,543 </td>
              <td>1,700 </td>
              <td>60 </td>
              <td>2022-12-11 </td>
              <td>2022-12-31 </td>
              <td>900</td>
              <td>350</td>
              <td>2022-12-11 </td>
              <td>        
                <button type="button" class="btn icon-pickup" data-bs-toggle="modal" data-bs-target="#pickup-modal" data-pickup-type="standard-access">
                      <i class="bi bi-truck icon-edit"></i>
                </button>
              </td>

              <td>    
                <button type="button" class="btn icon-history" data-bs-toggle="modal" data-bs-target="#history-modal" data-history-type="standard-access">
                   <i class="bi bi-folder2-open icon-delete"></i>
                </button>
              </td>

            </tr>
-->

          </table>
        </div>

        <div class="container-inner">
          <p class="estimate-wrap"><span class="txt-estimate">ACTUAL : <span id="estimatetotal"><?=number_format($d_quantitySUM)?></span> L</span></p>
        </div>
        <br><br>


        <!--div class="container-inner">
          <div class="pagination">
            <a href="#" ><i class="bi bi-arrow-left"></i></a>
            <a href="#"class="active">1</a>
            <a href="#">2</a>
            <a href="#">3</a>
            <a href="#">4</a>
            <a href="#">5</a>
            <a href="#">6</a>
            <a href="#"><i class="bi bi-arrow-right"></i></a>
          </div>
        </div-->

        <div class="col-lg-12">
                <a class="btn-sub text-center width-200" href="/index_intranet.php?view=order_list">BACK</a>
        </div>


      </div><!--container Ends-->
        

    </section>

  </main><!-- End #main -->


<!-- Modal modify Form -->
<div id="modify-modal" class="modal fade customer-info">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">DAILY RECORD</h4>
        <button type="button" class="btn" data-bs-dismiss="modal" aria-label="Close" style="color:#fff;"><i class="bi bi-x"></i></button>
      </div>
      <div class="modal-body">
        <form method="POST" action="#">
          <table class="tb-info-box">

            <tr>
              <td class="td-title-info">Departure Time</td>
              <td class="td-text-info">
                <input type="datetime-local" id="departureTime" name="departureTime">
              </td>
            </tr>

            <tr>
              <td class="td-title-info">Arrival Time</td>
              <td class="td-text-info">
                <input type="datetime-local" id="arrivalTime" name="arrivalTime">
              </td>
            </tr>

            <tr>
              <td class="td-title-info">Opening Balance</td>
              <td class="td-text-info">
                <input type="number" id="openingBalance" name="openingBalance" placeholder="500.45">
              </td>
            </tr>

            <tr>
              <td class="td-title-info">Cash In</td>
              <td class="td-text-info">
                <input type="number" id="cashIn" name="cashIn" placeholder="400.45">
              </td>
            </tr>

            <tr>
              <td class="td-title-info">Gas</td>
              <td class="td-text-info">
                <input type="number" id="gas" name="gas" placeholder="60.99">
              </td>
            </tr>


            <tr>
              <td class="td-title-info">Note</td>
              <td class="td-text-info">
                <textarea id="note" class="textarea" name="note" rows="4" cols="20">

                </textarea>
              </td>
            </tr>
          </table>
          <br>
          <div class="text-center grid-layout-col-2">
            <button type="submit" class="btn-sub">ADD</button>
            <button type="submit" class="btn-gray">CLOSE</button>
          </div>
        </form>
      </div>
    </div><!-- modal-content ends -->
  </div><!-- modal-dialog ends -->
</div>
<!-- Modal modify Form Ends -->



<!-- Modal History Form -->
<div id="myModalHistory" class="modal fade customer-info">
  <div class="modal-dialog" role="document">
    <div class="modal-content modal-content-historyOrder">
    	
    </div><!-- modal-content ends -->
  </div><!-- modal-dialog ends -->
</div>
<!-- Modal History Form Ends -->

            
<!-- Modal -->
<div class="modal fade" id="myModalDelete" data-backdrop="static" role="dialog">
  <div class="modal-dialog">
  
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
                  <h4 class="modal-title">MESSAGE</h4>
                  <button type="button" class="btn" data-dismiss="modal" aria-label="Close" style="color:#fff;"><i class="bi bi-x"></i></button>
      </div>
      <div class="modal-body">
        <p>Are you sure to delete?</p>
      </div>
      <div class="modal-footer">

	        <FORM NAME=newModalDeleteForm METHOD=POST ACTION="/lib/user_process.php" id="newModalDeleteForm">
						<input type=hidden name=d_uid id=d_uid value="">
						<input type=hidden name=d_accountno id=d_accountno value="">
						<input type=hidden name=d_orderdate id=d_orderdate value="<?=$d_orderdate?>">
						<input type=hidden name=mode value="delete">
	        	<input type=hidden name=actionStr value="ORDERINFO">

						<input type=hidden name=switched value="<?=$getSWHStr?>">
						<input type=hidden name=page value="<?=$page?>">
						<input type=hidden name=key_word value="<?=$key_word?>">
						<input type=hidden name=column value="<?=$column?>">
						<input type=hidden name=sorting_type value="<?=$sorting_type?>">
						<input type=hidden name=switch value="<?=$switch?>">
						<input type=hidden name=goSTRSTR value="d_driveruid=<?=$d_driveruid?>&d_orderdate=<?=$d_orderdate?>">

          <div class="text-center grid-layout-col-2">
            <button type="button" class="btn-gray" data-dismiss="modal">NO</button>
            <button type="submit" class="btn-sub">YES</button>
          </div>

					</FORM>    
			                              
      </div>
    </div>
    
  </div>
</div>


<div class="modal fade" id="myModalPopup" tabindex="-1" role="dialog" aria-labelledby="myModalPopup"  style="opacity: 0.5; padding-right: 0px !important;">
  <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
      <div class="modal-content" style="background-color:#F43700 !important; max-width:240px; margin: 0 auto;">
        <div class="myModalPopup-body" style="text-align: center; border-radius: 5px; max-height:60px;	font-size:18px; background-color:#F43700; color: #FFFFFF; font-weight: bold;padding:0.5em 1em; ">

        </div>     	
      </div>
  </div>
</div>


<!-- Start of Modal -->
<div class="container">

  <!-- Modal -->
  <div class="modal fade customer-info" id="myModalpickupOrder"  aria-labelledby="myModalpickupOrderLabel" aria-hidden="true">
    <div class="modal-dialog" role="document" >
    
      <!-- Modal content-->
      <div class="modal-content modal-content-modifypickupOrder" >

      </div>
      
    </div>
  </div>
  
</div>
<!-- End of Modal -->



<!-- Start of Modal -->

  <!-- Modal -->
  <div class="modal fade customer-info" id="myModalcustomerShortInfo"  aria-labelledby="myModalcustomerShortInfoLabel" aria-hidden="true">
    <div class="modal-dialog" role="document" >
    
      <!-- Modal content-->
      <div class="modal-content modal-content-modifycustomerShortInfo" >

      </div>
      
    </div>
  </div>
  
<!-- End of Modal -->

<!-- Start of Modal -->

  <!-- Modal -->
  <div class="modal fade customer-info" id="myModalcustomerShortNote"  aria-labelledby="myModalcustomerShortNoteLabel" aria-hidden="true">
    <div class="modal-dialog" role="document" >
    
      <!-- Modal content-->
      <div class="modal-content modal-content-modifycustomerShortNote" >

      </div>
      
    </div>
  </div>
  
<!-- End of Modal -->