<?

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

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

if ($cstatus == 'T')
   $status_query = " AND (tbl_customer.c_status = 'A' OR tbl_customer.c_status = 'I') ";
else if ($cstatus == 'I')
   $status_query = " AND (tbl_customer.c_status = 'I') ";
else {
	$cstatus = 'A';
	$status_query = " AND (tbl_customer.c_status = 'A') ";
}

if ($cistop == 'A') {
    $cistop_query = " AND tbl_customer.c_is_top = 'A' ";
} else if ($cistop == 'G') {
    $cistop_query = " AND tbl_customer.c_is_top = 'G' ";
} else {
    $cistop = 'T';
    $cistop_query = "";
}

if ($_SESSION['ss_LEVEL'] == 9) {
    $add_allquery = $status_query . $cistop_query . " AND c_driveruid = '".$_SESSION['ss_UID']."' ";
} else {
    $add_allquery = $status_query . $cistop_query;
}

//$add_query .= "tbl_groups   INNER JOIN naloxca_bbs.tbl_customer ON (tbl_groups.g_uid = tbl_customer.m_gid) ";
$add_srchquery = "";
$add_query = "";

// searching
if($key_word) {

	$key_wordStr = urldecode(trim($key_word));
	
	// single quote, double quote 문제 해결 위해 사용
	$key_wordStr = addslashes($key_wordStr);
	
	$add_srchquery .= " AND  ((c_accountno LIKE '%$key_wordStr%') OR (c_name LIKE '%$key_wordStr%') OR (c_address LIKE '%$key_wordStr%') 
											OR (c_phone LIKE '%$key_wordStr%') OR (c_cell LIKE '%$key_wordStr%') OR (c_email LIKE '%$key_wordStr%') 
											OR (c_payableto LIKE '%$key_wordStr%') OR (c_rate LIKE '%$key_wordStr%')
											OR (c_location LIKE '%$key_wordStr%') OR (c_city LIKE '%$key_wordStr%')
											OR (c_postal LIKE '%$key_wordStr%') OR (c_contractby LIKE '%$key_wordStr%')
											OR (c_salesperson LIKE '%$key_wordStr%') OR (c_salesmethod LIKE '%$key_wordStr%')
											OR (c_paymenttype LIKE '%$key_wordStr%')) ";
}

// sorting
if($switch) {
	$switched = $func -> switchOrder($switch, $switched);
	if ($switch == "c_address") {
			$add_query .= " ORDER BY TRIM(SUBSTRING(c_address,LOCATE(' ',c_address)+1)) $switched, 
											CAST(TRIM(LEFT(c_address,LOCATE(' ',c_address) - 1)) AS SIGNED) $switched";
	} else {
			$add_query .= " ORDER BY $switch $switched ";
	}
	$switched = $switch . "^" . $switched;

}else if($switched) {
	$switched1 = explode("^", $switched);
	$add_query .= " ORDER BY $switched1[0] $switched1[1] ";
} else {
	if ($cstatus == 'I') $add_query .= " ORDER BY c_inactivedate DESC, c_name ASC";
	else $add_query .= " ORDER BY c_uid DESC";
}

$getSWHStr = $switched;

// $query = "SELECT * FROM tbl_sampletypes 
// INNER JOIN tbl_members ON (tbl_sampletypes.t_uid = tbl_members.m_gid) 
// where tbl_members.m_uid != ''  
// ORDER BY tbl_members.m_uid DESC ";

//total record
$query = "SELECT COUNT(c_uid) FROM tbl_customer
					INNER JOIN tbl_member ON (tbl_customer.c_driveruid = tbl_member.m_uid) 
					where tbl_customer.c_uid <> ''  " . $add_allquery . $add_srchquery . $add_query;

$total_count=$jdb->rQuery($query, "record query error");
//echo "<br><br><br><br><br>[$key_word][$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";
$query = "SELECT *
					FROM tbl_customer
					INNER JOIN tbl_member ON (tbl_customer.c_driveruid = tbl_member.m_uid) 
					where tbl_customer.c_uid <> ''  " . $add_allquery . $add_srchquery . $add_query;
//echo "<br><br><br><br>[$query]";

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

// container
$rows = [];
$customer_uids = [];
while ($r = mysqli_fetch_assoc($result)) {
    $rows[] = $r;
    $customer_uids[] = (int)$r['c_uid'];
}
$customerContainerMap = [];
$customer_uids = array_values(array_unique($customer_uids));
if ($customer_uids) {
    $in = implode(',', $customer_uids);
    $sql_cc = "
      SELECT cc_customer_uid, cc_type, cc_owner_type, cc_is_used, cc_has_lock, cc_has_wheel, cc_has_woodframe
      FROM tbl_customer_container
      WHERE cc_status = 'A'
        AND cc_customer_uid IN ($in)
      ORDER BY cc_customer_uid, cc_type, cc_uid
    ";

    $rc = $jdb->nQuery($sql_cc, "Load customer containers error");

    while ($c = mysqli_fetch_assoc($rc)) {
        $cu = (int)$c['cc_customer_uid'];
        if (!isset($customerContainerMap[$cu])) $customerContainerMap[$cu] = [];
        $customerContainerMap[$cu][] = $c;
    }
}

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

	//$logindateStr = $func -> convertFormat ($MLOGINDATE, 1);
	//$signupdateStr = $func -> convertFormat ($MSIGNUPDATE, 1);
		
	//$qry = "SELECT CNAME  FROM tbl_company WHERE CUID = '$MCOMPANY' ";
	//$rtd=$jdb->fQuery($qry, "fetch query error"); 
	//if ($MCOMPANY == "0" || $MCOMPANY == "") $companyStr = "-";
	//else $companyStr = $rtd[CNAME];
  $c_uid = (int)$list['c_uid'];
	
	$c_phone = preg_replace('/[^A-Za-z0-9\-]/', '', $c_phone);
	$c_phoneSTR = substr ($c_phone, 0, 3)."-".substr ($c_phone, 3, 3)."-".substr ($c_phone, 6, 4);
	
	$c_nameSTR = str_replace("\\", "", $c_name);
	$c_addressSTR = str_replace("\\", "", $c_address);
  $customerContainers = $customerContainerMap[$c_uid] ?? [];
  ob_start();
  include $_SERVER['DOCUMENT_ROOT'].'/lib/customer_container_chips.php';
  $containerChipsHtml = ob_get_clean();
	// $c_containerSTR = str_replace("\\", "", $c_container);
	$c_statusSTR = $arrStatus[$c_status];
  $c_istopSTR = ($c_is_top === 'A') ? 'A Rank' : (($c_is_top === 'G') ? 'Ghost' : '');

	$todayQty = number_format(round(floatval($c_fullquantity - $c_fullquantitydaily)));
	//$qry_driver = "SELECT m_firstname, m_lastname FROM tbl_member WHERE m_uid = '$c_driveruid' ";
	//$rt_driver = $jdb->fQuery($qry_driver, "fetch query error");

	if ($setTag == "ENABLED") {
		$OPTIONstr = "&nbsp;&nbsp;&nbsp;<a class=\"deleteClass btn-member\" data-toggle=\"modal\" data-target=\"#myModalDelete\" data-id=\"$c_uid\"><i class=\"bi bi-x-circle icon-delete\"></i></a>";
		//$OPTIONTITLEstr = "OPTION";
	}
	else {
		$OPTIONstr = "";
		//$OPTIONTITLEstr = "";
	}
	
	$driverPopup = "<a data-toggle='modal' class='customerShortInfo' data-target='#myModalcustomerShortInfo' data-id=\"$c_uid\" data-history-type='standard-access'>&#10067;</a>";

	$strList .= "

            <tr>
              <td>$list_number</td>
              <td><a onclick=\"location.href='/index_intranet.php?view=customer_detail&mode=update&c_uid=$c_uid&page=$page&key_word=$key_wordStr&column=$column&switched=$getSWHStr&sorting_type=$sorting_type&switch=$switch&cstatus=$cstatus'\" style='cursor:pointer;cursor:hand;'><i class=\"bi bi-pencil-square icon-edit\"></i></a>
              <!--$OPTIONstr-->
              </td>
              <td style=\"text-align:right; padding-right:20px;\">".$todayQty." </td>
              <td><a onclick=\"location.href='/index_intranet.php?view=customer_detail&mode=update&c_uid=$c_uid&page=$page&key_word=$key_wordStr&column=$column&switched=$getSWHStr&sorting_type=$sorting_type&switch=$switch&cstatus=$cstatus'\" style='cursor:pointer;cursor:hand;'><b class='customer-info-detail'>$c_nameSTR</b>&nbsp;&nbsp; $driverPopup</td>
              <td onclick=\"location.href='/index_intranet.php?view=customer_detail&mode=update&c_uid=$c_uid&page=$page&key_word=$key_wordStr&column=$column&switched=$getSWHStr&sorting_type=$sorting_type&switch=$switch&cstatus=$cstatus'\" style='cursor:pointer;cursor:hand;'>$c_accountno</td>
              <td>$c_addressSTR </td>
              <td>$c_city </td>
              <td>$c_postal</td>
              <td>$c_paymenttype </td>
              <td>$c_rate </td>
              <td>$containerChipsHtml </td>
              <td>$m_initial </td>
              <td>$c_phoneSTR </td>
              <td>$c_statusSTR </td>
              <td style=\"min-width:70px;\">$c_istopSTR </td>
            </tr>

	";

	$list_number--;
}


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


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

?>


<SCRIPT LANGUAGE=JAVASCRIPT>
<!--
function goSearch(f){
    var f = document.form1;
    if(trim(f.key_word.value).length < 1){
        alert('Enter keyword.');
        f.key_word.focus();
        return false;
    }
}
//-->
</SCRIPT>
    


<SCRIPT TYPE="TEXT/JAVASCRIPT">
$(document).ready(function(){


    // $("#cstatus").change(function(){
    //     //$(this).css("background-color", "#FFD2A6");
    //     $('#customerFilterForm').submit();
    // });
    
    $("input[name='cstatus']").change(function () {
        $('#customerFilterForm').submit();
    });

    $("input[name='cistop']").change(function () {
        $('#customerFilterForm').submit();
    });

		$('.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 TYPE="TEXT/JAVASCRIPT">
    $(function () {
        $(".deleteClass").click(function () {
            var my_id_value = $(this).data('id');
            $(".modal-footer #c_uid").val(my_id_value);
        })
    });
</SCRIPT>


<div class="container">
            
  <!-- 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=c_uid id=c_uid value="">
							<input type=hidden name=mode value="delete">
		        	<input type=hidden name=actionStr value="CUSTOMERINFO">

							<input type=hidden name=switched value="<?=$getSWHStr?>">
							<input type=hidden name=page value="<?=$page?>">
							<input type=hidden name=key_word value="<?=$key_wordStr?>">
							<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=cstatus value="<?=$cstatus?>">
							

            <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>


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

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

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

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

    <section class="page">


      <div class="container" data-aos="fade-up">
        <div class="wrap-border">
          <form method="post" name="customerFilterForm" id="customerFilterForm" action="<?=$_SERVER['PHP_SELF']?>" class="form-customer">
            <input type="hidden" name="view" value="customer_list">
            <input type="hidden" name="switched" value="<?=$getSWHStr?>">
            <input type="hidden" name="page" value="<?=$page?>">
            <input type="hidden" name="column" value="<?=$column?>">
            <input type="hidden" name="sorting_type" value="<?=$sorting_type?>">
            <input type="hidden" name="switch" value="<?=$switch?>">

            <table class="table-search-customer">
              <tr>
                <!--td class="td-title">
                  <select name="name" id="name" class="custom-select">
                    <option value="jk">J.K.</option>
                    <option value="hs">H.S.</option>
                    <option value="Hold">Hold</option>
                  </select>
                </td-->
                <td class="td-title">
                  <div class="search-container">
                        <input class="" type="text" placeholder="Search.." name="key_word" value='<?=htmlspecialchars($key_word, ENT_QUOTES)?>'>
                        <button type="submit" style="padding:0px"><i class="bi-search"></i></button>
                  </div>
                </td>

                <td style="text-align:right;">
                  <div class="cstatus-segment">
                    <label>
                        <input type="radio" name="cstatus" value="A" <?=($cstatus == "A")?"checked":"";?>>
                        <span>&nbsp;Active&nbsp;</span>
                    </label>

                    <label>
                        <input type="radio" name="cstatus" value="I" <?=($cstatus == "I")?"checked":"";?>>
                        <span>Inactive</span>
                    </label>

                    <label>
                        <input type="radio" name="cstatus" value="T" <?=($cstatus == "T")?"checked":"";?>>
                        <span>&nbsp;All&nbsp;</span>
                    </label>
                  </div>
                </td>

                <td style="text-align:left; padding-left:10px;">
                  <div class="cistop-segment">
                    <label>
                        <input type="radio" name="cistop" value="A" <?=($cistop == "A")?"checked":"";?>>
                        <span>&nbsp;Top&nbsp;</span>
                    </label>

                    <label>
                        <input type="radio" name="cistop" value="G" <?=($cistop == "G")?"checked":"";?>>
                        <span>&nbsp;Ghost&nbsp;</span>
                    </label>

                    <label>
                        <input type="radio" name="cistop" value="T" <?=($cistop == "T")?"checked":"";?>>
                        <span>&nbsp;All&nbsp;</span>
                    </label>
                </div>
              </td>

                <td align="right">
                  <? if ($setTag == "ENABLED") { ?>                	
                    <a href="/index_intranet.php?view=customer_detail&mode=create&page=<?=$page?>&key_word=<?=$key_wordStr?>&column=<?=$column?>&switched=<?=$getSWHStr?>&sorting_type=<?=$sorting_type?>&switch=<?=$switch?>&cstatus=<?=$cstatus?>" class="btn-add">ADD</a>
                  <? } ?>  	
                </td>
              </tr>
            </table>
          </form>
        </div><!--wrap-border-->
  

        <div class="wrap-overflow customer-info">
          <table class="tb-list">
            <tr>
                <th>No</th>
                <th class="col-rate">Option</th>
                <th class="col-liter">Liter</th>
                <th class="td-restaurant"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_name">Restaurant Name</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_accountno">Account</a></th>
                <th class="col-address"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_address">Address</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_word?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_city">City</a></th>
                <th class="col-postal-code"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_postal">Postal Code</a></th>
                <th class="col-payment"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_paymenttype">Payment</a></th>
                <th class="col-rate"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_rate">Rate</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_maincontainer">Container</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=m_initial">Driver</a></th>
                <th class="th-width-phone"><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_phone">Phone</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_status">Status</a></th>
                <th><a href="/index_intranet.php?view=customer_list&switched=<?=$getSWHStr?>&page=<?=$page?>&key_word=<?=$key_wordStr?>&sorting_type=<?=$sorting_type?>&cstatus=<?=$cstatus?>&cistop=<?=$cistop?>&switch=c_is_top">Rank</a></th>
            </tr>

<?=$strList?>

<!--
            <tr class="bg-request">
              <td>1</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr class="bg-request">
              <td>2</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr class="bg-period">
              <td>3</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr class="bg-period">
              <td>4</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr class="bg-will-call">
              <td>5</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr class="bg-will-call">
              <td>6</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr>
              <td>7</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr>
              <td>8</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr>
              <td>9</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>

            <tr>
              <td>10</td>
              <td>Restaurant Name</td>
              <td>GD221150</td>
              <td>145 Kingston Rd. Nork Yorth, ON M1K 7Y8</td>
              <td>Toronto</td>
              <td>CHQ </td>
              <td>0.150 </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>D.S </td>
              <td>647-123-1234</td>
              <td>Active </td>
              <td><i class="bi bi-pencil-square icon-edit"></i></td>
              <td><i class="bi bi-x-circle icon-delete"></i></td>
            </tr>
-->

          </table>
        </div>


        <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-->
					<?

					$page_string = "view=$view&key_word=$key_wordStr&key_CTGSEQ=$key_CTGSEQ&column=$column&mode=$mode&cstatus=$cstatus&cistop=$cistop&switched=$getSWHStr";
					$paging = new PAGE('page',$total_count,$list_count,$page_count,$page,$page_string,'#c71930','','','#c71930','');

					?>
            
          </div>
        </div>


        <!--div class="row text-center">
          <div class="col-sm-4 item-inner">
          <a class="btn-sub" href="#">LIST</a>
         </div>
        </div-->


      </div>

        

    </section>

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



<!-- 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 -->

<style>
.cstatus-segment,
.cistop-segment {
    display: flex;              /* inline-flex 말고 flex 로 */
    border: 1px solid #ccc;
    border-radius: 10px;
    overflow: hidden;
}

/* 라벨 전체가 버튼처럼 동작 + 같은 너비 */
.cstatus-segment label,
.cistop-segment label {
    margin: 0;
    cursor: pointer;
    flex: 1 1 0;                /* 3개 버튼을 동일 너비로 나눔 */
}

.cstatus-segment input[type="radio"],
.cistop-segment input[type="radio"] {
    display: none;
}

.cstatus-segment span,
.cistop-segment span {
    display: block;
    text-align: center;
    padding: 8px 0;             /* 좌우 padding 빼고, 너비는 flex가 담당 */
    background: #e7e7e7;
    color: #333;
    font-weight: 500;
}

.cstatus-segment input[type="radio"]:checked + span,
.cistop-segment input[type="radio"]:checked + span {
    background: #ffca1a;
    color: #333;
}

/* 가로일 때 border-radius (좌우) */
.cstatus-segment label:first-child span,
.cistop-segment label:first-child span {
    border-radius: 5px 0 0 5px;
}

.cstatus-segment label:last-child span,
.cistop-segment label:last-child span {
    border-radius: 0 5px 5px 0;
}

/* 모바일. 너비는 나중에 조절 */
@media (max-width: 768px) {  
  .cstatus-segment,
  .cistop-segment {
      flex-direction: column;  /* 세로로 쌓기 */
      width: 100%;             /* td 안에서 꽉 차게 */
  }

  .cstatus-segment label,
  .cistop-segment label {
      flex: 1 0 auto;
      width: 100%;             /* 각 버튼이 컨테이너 전체 너비 사용 */
  }

  /* 세로일 때 border-radius (위/아래) 다시 정의 */
  .cstatus-segment label:first-child span,
  .cistop-segment label:first-child span {
      border-radius: 5px 5px 0 0;
  }

  .cstatus-segment label:last-child span,
  .cistop-segment label:last-child span {
      border-radius: 0 0 5px 5px;
  }
}


</style>