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.
 
 
 
 
 
 

237 lines
9.3 KiB

<?php
require_once "../header.php";
// 載入db.php來連結資料庫
#錶
$table = 'hope_elevator_customer';
#可編輯的列
$editableColumn = [
'vol_no' => "卷號",
'customer' => "客戶名稱",
'case_name' => "案件名稱",
'manager' => "負責人",
'source' => "客戶來源",
'linkman' => "聯係人",
'lm_tel' => "市話/手機",
'salesman' => "營業員",
'num' => "臺數",
'pre_order_date' => "預定成交日",
'status' => "有望客戶狀態",
/*'next_visit_date' => "下次拜訪時間",
'quote_date' => "報價日期",*/
'is_renovation' => "產品屬性",
'creater' => "錄入人員",
'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_name like '$salesman'";
$sql_cmd = sql_myself($user_id, "salesman");
// max,許紓晴,林慧珊,鄭伊岑
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0107" || $user_id == "M0193" || $user_id == "M0149" || $user_id == "M0189" || $user_id == "TEST01" || $user_id == "TEST02" || $user_id == "TEST03" || $user_id == "TEST04") $sql_cmd = "";
if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd);
/*
$checkAll = ['p0044', 'M0007'];
if (!in_array($user_id, $checkAll)) {
$where .= " and salesman = '$user_id'";
}
//$where .= " and salesman = '$salesman'";
*/
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman'];
$where .= " and linkman like '$lm_name'";
$address = empty($_GET['address']) ? "%" : $_GET['address'];
$where .= " and address like '%$address%'";
$sql = "SELECT vol_no,customer,case_name,manager,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 ,
case when is_renovation='Y' then '汰改' when is_renovation='N' then '新梯' END 'is_renovation',
creater, created_at FROM $table where 1=1 $where ORDER BY vol_no";
//echo $sql;
$data = mysqli_query($link, $sql);
?>
<style>
#table_index2 {
table-layout: fixed;
width: 100%;
}
#table_index2_filter {
float: right;
}
#table_index2_paginate {
float: right;
}
div.dataTables_scrollHead table.dataTable {
margin-bottom: 0 !important;
border-bottom-width: 0;
}
div.dataTables_scrollBody table.dataTable {
border-top-width: 0;
}
/*
.col-sm-12 {
width: auto;
}
*/
</style>
<script>
$(function() {
$('#table_index2').DataTable({
"scrollX": true,
"pageLength": 10,
order: [
[13, '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' value='<?= (!empty($value)) ? $value : ""; ?>'></td>
<th>營業員</th>
<td><input type="text" class='form-control' name='salesman' value='<?= $salesman == '%' ? '' : $salesman ?>'></td>
<th>下單地區</th>
<td><input type="text" class='form-control' name='address' value='<?= $address == '%' ? '' : $address ?>'></td>
<th>聯係人姓名</th>
<td><input type="text" class='form-control' name='linkman' value='<?= $lm_name == '%' ? '' : $lm_name ?>'></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="8" style='text-align:center'>
<input type='hidden' name='token' value='<?= $token ?>' />
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button>
<a href="crmm03-edit.php?token=<?= $token ?>" class="btn btn-info btn-sm">新增</a>
</td>
</tr>
</tfoot>
</table>
<table id="table_index2" class="table table-striped table-bordered" style="width:100%">
<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>
<!-- <td>
<p>
<a href="crmm01-delete.php?vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td> -->
<?php
foreach ($editableColumn as $key => $val) {
echo "<td>" . $row[$key] . "</td>";
}
?>
<td>
<?php
$status = $pricereview_url = $fname = "";
$db_query = "select status from pricereview_main where contractno = '" . $row['vol_no'] . "' order by id desc limit 1";
$res_p = mysqli_query($link, $db_query);
if ($row_p = mysqli_fetch_row($res_p)) $status = $row_p[0];
mysqli_free_result($res_p);
if (empty($status) || $status == "YN" || $status == "D") {
if ($row['is_renovation'] == '汰改') {
$pricereview_url = "../mkt/pricereview_renovate-create.php";
$fname = "pricereview_renovate";
} else {
$pricereview_url = "../mkt/pricereview-create.php";
$fname = "pricereview";
}
}
?>
<p>
<a href="crmm04-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 (!empty($pricereview_url)) {
?>
<a href="<?= $pricereview_url ?>?vol_no=<?php echo $row['vol_no']; ?>&function_name=<?php echo $fname; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" style="margin-top:3px;">
填價審單
</a>
<?php
}
?>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代錶結束連線
mysqli_close($link);
include "../footer.php";
?>