add deal icon in clients
This commit is contained in:
parent
c4658b0835
commit
9a28c36296
@ -2310,4 +2310,55 @@ if($request == 'get_deal_by_req'){
|
||||
exit();
|
||||
}
|
||||
|
||||
if($request == 'get_deal_by_client'){
|
||||
$client_id = intval($data->client_id);
|
||||
$sql = "SELECT d.id FROM deals d JOIN requisitions r ON (r.id = d.side_one_requisition_id OR r.id = d.side_two_requisition_id) WHERE r.client_id = $client_id AND d.status != 2 GROUP BY d.id LIMIT 10";
|
||||
$q = $pdo->query($sql);
|
||||
$deals = [];
|
||||
if($q && $pdo->num_rows($q) > 0){
|
||||
while($r = $pdo->fetch_assoc($q)){
|
||||
$deals[] = (int)$r['id'];
|
||||
}
|
||||
}
|
||||
echo json_encode(['deals' => $deals, 'total' => count($deals)]);
|
||||
exit();
|
||||
}
|
||||
|
||||
if($request == 'get_deal_by_object'){
|
||||
$object_id = intval($data->object_id);
|
||||
$sql = "SELECT id FROM deals WHERE status != 2 AND (side_one_object_id = $object_id OR side_two_object_id = $object_id) LIMIT 10";
|
||||
$q = $pdo->query($sql);
|
||||
$deals = [];
|
||||
if($q && $pdo->num_rows($q) > 0){
|
||||
while($r = $pdo->fetch_assoc($q)){
|
||||
$deals[] = (int)$r['id'];
|
||||
}
|
||||
}
|
||||
echo json_encode(['deals' => $deals, 'total' => count($deals)]);
|
||||
exit();
|
||||
}
|
||||
|
||||
if($request == 'get_deals_by_objects'){
|
||||
$object_ids = isset($data->object_ids) ? $data->object_ids : [];
|
||||
$object_ids = array_map('intval', $object_ids);
|
||||
$deals_by_object = [];
|
||||
if (count($object_ids) > 0) {
|
||||
$ids_str = implode(',', $object_ids);
|
||||
$sql = "SELECT side_one_object_id, side_two_object_id, id FROM deals WHERE status != 2 AND (side_one_object_id IN ($ids_str) OR side_two_object_id IN ($ids_str))";
|
||||
$q = $pdo->query($sql);
|
||||
if($q && $pdo->num_rows($q) > 0){
|
||||
while($r = $pdo->fetch_assoc($q)){
|
||||
if(in_array((int)$r['side_one_object_id'], $object_ids)){
|
||||
$deals_by_object[$r['side_one_object_id']] = 1;
|
||||
}
|
||||
if(in_array((int)$r['side_two_object_id'], $object_ids)){
|
||||
$deals_by_object[$r['side_two_object_id']] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(['deals_by_object' => $deals_by_object]);
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -2070,6 +2070,17 @@ if (isset($_POST['get_list'])) {
|
||||
}
|
||||
}
|
||||
|
||||
//формируем список сделок клиентов
|
||||
$clientDealsArray = [];
|
||||
if (count($clientIds) > 0) {
|
||||
$clientDealsRes = mysql_query("SELECT r.client_id, d.id as deal_id FROM deals d JOIN requisitions r ON (r.id = d.side_one_requisition_id OR r.id = d.side_two_requisition_id) WHERE r.client_id IN (" . implode(", ", $clientIds) . ") AND d.status != 2 GROUP BY r.client_id, d.id");
|
||||
if ($clientDealsRes && mysql_num_rows($clientDealsRes) > 0) {
|
||||
while ($dealRow = mysql_fetch_assoc($clientDealsRes)) {
|
||||
$clientDealsArray[$dealRow['client_id']][] = (int)$dealRow['deal_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$contractsArray = [];
|
||||
|
||||
$sqlContracts = "SELECT * FROM contracts_client WHERE client_id in (" . implode(", ", $clientIds) .")";
|
||||
@ -2599,6 +2610,13 @@ if (isset($_POST['get_list'])) {
|
||||
|
||||
?>
|
||||
<div class="actions">
|
||||
<?php if (!empty($clientDealsArray[$client['id']])) : ?>
|
||||
<a href="javascript:{};" class="no-border" title="Сделка"
|
||||
onclick="var cid=this.closest('.client').id.replace('client__',''); openClientDeal(cid)">
|
||||
<span style="color: #43A047 !important;" class="simple-button settings"><i class="fas fa-handshake"></i></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="javascript:{};" data-id="<?= $client['id'] ?>"
|
||||
class="client_info no-border" title="Подробно...">
|
||||
<span class="simple-button settings"><i class="far fa-eye"></i>
|
||||
|
||||
22
clients.php
22
clients.php
@ -1080,10 +1080,32 @@ else
|
||||
get_list(page, this.value);
|
||||
});
|
||||
});
|
||||
|
||||
function openClientDeal(clientId) {
|
||||
$.ajax({
|
||||
url: '/ajax/ajax_vue_requisitions.php',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ request: 'get_deal_by_client', client_id: clientId }),
|
||||
success: function(response) {
|
||||
var res = typeof response === 'string' ? JSON.parse(response) : response;
|
||||
if (res.deals && res.deals.length > 0) {
|
||||
window.editDeal(0, res.deals[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php require($_SERVER['DOCUMENT_ROOT']."/templates/footer.php"); ?>
|
||||
<?php require($_SERVER['DOCUMENT_ROOT']."/templates/modals/req_info.php"); ?>
|
||||
<?php
|
||||
$allowed_users_deal = [18388];
|
||||
if (in_array((int)$_SESSION['id'], $allowed_users_deal)) {
|
||||
echo '<script type="module" src="/deal/assets/app.js"></script>';
|
||||
echo '<link rel="stylesheet" href="/deal/assets/app.css">';
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="/js/crm_vue.js?v=<?=filemtime($_SERVER['DOCUMENT_ROOT'].'/js/crm_vue.js')?>"></script>
|
||||
|
||||
<script type="text/javascript" src="/js/clients_vue.js?v=<?=filemtime($_SERVER['DOCUMENT_ROOT'].'/js/clients_vue.js')?>"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user