You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

196 lines
7.2 KiB

<?php
require_once "../header.php";
// 載入db.php來連結資料庫
#錶
$table = 'hope_contract_customer';
#可編輯的列
$editableColumn = [
'vol_no' => "卷號",
'customer_no' => "客戶編號",
'customer' => "客戶名稱",
'manager' => "負責人",
'source' => "客戶來源",
'linkman' => "聯係人",
'lm_tel' => "手機",
'salesman' => "營業員",
'num' => "数量",
'pre_order_date' => "預定成交日",
'status' => "有望客戶狀態",
'next_visit_date' => "下次拜訪時間",
'brand' => "廠牌",
'quote_date' => "報價日期",
'created_at' => "建立時間",
];
// 可瀏覽全部資料的部門
$depart_arr = ["501"];
$sql = "SELECT department_id FROM account WHERE accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no'];
$where = " and vol_no like '$vol_no'";
$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman'];
$where .= " and salesman like '$salesman'";
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman'];
$where .= " and linkman like '$lm_name'";
$sql_cmd = sql_myself($user_id, "salesman");
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0061" || $user_id == "M0149" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $sql_cmd = ""; // M0060:Max,鄭伊岑
if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd);
$sql = "SELECT vol_no,customer,manager,salesman,f_return_content('customer_source',source ) source,
linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date,
f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand ,
date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no";
$data = mysqli_query($link, $sql);
// echo '<pre>';
// print_r($sql);
// echo '</pre>';
// echo '<pre>';
// print_r($data);
// echo '</pre>';
// $sql = "SELECT * FROM hope_contract_customer WHERE 1=1 $where";
// $result = mysqli_query($link, $sql);
// echo '<pre>';
// print_r($result);
// echo '</pre>';
// echo $data['salesman'];
?>
<style>
#table_index2 {
table-layout: fixed;
/*width: 100%;*/
display: inline-block;
}
.col-sm-12 {
width: auto;
}
.pagination {
margin: 0;
}
</style>
<script>
$(function() {
$('#table_index2').DataTable({
order: [
[14, 'desc']
]
});
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋";
});
</script>
<?php
if ($data) :
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) {
echo "<p class='error'>Please fill up the required field!</p>";
} else {
header("Location:repair-index.php");
}
}
?>
<link rel="stylesheet" href="common.css">
<div style="overflow-x:auto; white-space:nowrap;">
<form method='get' action='#'>
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>有望客戶(契約)資料維護</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th style='width:50px'>卷號</th>
<td><input type="text" class='form-control' name='vol_no'></td>
<th>營業員</th>
<td><input type="text" class='form-control' name='salesman'></td>
<th>下單地區</th>
<td><input type="text" class='form-control' name='order_province'></td>
<th>聯係人姓名</th>
<td><input type="text" class='form-control' name='lm_name'></td>
<input type="hidden" name="token" value='<?= $_GET['token'] ?>'>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="8" style='text-align:center'>
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button>
<a href="crmm06-edit.php?<?= $token_link ?>" class="btn btn-info btn-sm">新增</a>
</td>
</tr>
</tfoot>
</table>
<table id="table_index" class="table table-striped table-bordered">
<thead>
<?php
echo "<tr>";
foreach ($editableColumn as $key => $val) {
echo "<th>$val</th>";
}
echo "<th>編輯</th>";
// echo "<th>刪除</th>";
echo "</tr>";
?>
</thead>
<tbody>
<?php foreach ($data as $row) : ?>
<tr>
<?php
foreach ($editableColumn as $key => $val) {
// echo '<pre>';
// print_r($row['salesman']);
// echo '</pre>';
echo "<td>" . (!empty($row[$key]) ? $row[$key] : '') . "</td>";
}
?>
<td>
<p>
<a href="crmm05-edit.php?function_name=customer&<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<?php if ($user_name === $row['salesman'] || $user_id = 'M0225') : ?>
<a href="../cont/pricereviewCheck.php?function_name=sign_list&<?= $token_link ?>&vol_no=<?= $row['vol_no'] ?>" class="btn btn-info btn-sm">
轉價審
</a>
<?php endif ?>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代錶結束連線
mysqli_close($link);
include "../footer.php";
?>