diff --git a/ajax/ajax_vue_clients.php b/ajax/ajax_vue_clients.php index e19f4f8..fafaf98 100644 --- a/ajax/ajax_vue_clients.php +++ b/ajax/ajax_vue_clients.php @@ -2321,8 +2321,12 @@ if($request == 'saveOpenPrevStep'){ if (!empty($linkedReqs)) { mysql_query("UPDATE requisitions SET deal_id = NULL WHERE id IN (" . implode(',', $linkedReqs) . ")"); } - // Запись в историю - //mysql_query("INSERT INTO user_client_events (user_id, req_id, deal_id, type, name, comment, create_date) VALUES ({$userId}, {$reqId}, {$dealId}, 'deal', 'Отмена сделки', 'Сделка отменена при возврате на предыдущий этап', NOW())"); + // Ставим cancel = 1 на все события сделки + if ($dealId > 0) { + mysql_query("UPDATE user_client_events SET cancel = 1 WHERE deal_id = {$dealId}"); + } + // Запись в историю об отмене + mysql_query("INSERT INTO user_client_events (user_id, req_id, deal_id, type, name, comment, create_date) VALUES ({$userId}, {$reqId}, {$dealId}, 'deal', 'Отмена сделки', 'Сделка отменена при возврате на предыдущий этап', NOW())"); } } diff --git a/ajax/getClientLogForEventsNew.php b/ajax/getClientLogForEventsNew.php index d8481d2..40f6601 100644 --- a/ajax/getClientLogForEventsNew.php +++ b/ajax/getClientLogForEventsNew.php @@ -155,15 +155,15 @@ if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET[ // если смотрит руководитель - показываем все // if ($_SESSION['agency'] || $_SESSION['manager'] || $_SESSION['users_admin']) { - $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step " + $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id " . "FROM user_client_events as e WHERE e.client_id = $get[id] union SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step from events_clients as ev WHERE ev.client_id = $get[id] and event = 'transmitted_parallel' ORDER BY date_sort ASC"; if(isset($get['req_id']) && $get['req_id'] > 0){ - $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step " + $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id " . "FROM user_client_events as e WHERE e.req_id = $get[req_id] union - SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step + SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step, 0 as deal_id from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel' ORDER BY date_sort ASC"; @@ -174,9 +174,9 @@ ORDER BY date_sort ASC"; $arrSin[] = $r_obj_sin['object_id']; } if(!empty($arrSin)){ - $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step " + $sql = "SELECT e.id, e.comment, e.name, e.create_date, IF ((mango<>1 AND megafon<>1 AND telphin<>1 AND beeline<>1 AND mts<>1 AND tele2<>1 AND allo<>1), DATE_ADD(create_date, {$time_zone_sql}), create_date) as date_sort, e.checklist, e.type, e.type_call, e.user_id, e.partner_id, e.record, e.client_id, e.document_id, e.req_id, e.old_req_id, e.schedule_date, e.schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, `e`.`mango`, `e`.`megafon`, e.telphin,e.beeline, e.mts, e.tele2, e.allo, e.tracking, e.cancel, e.open_step, e.deal_id " . "FROM user_client_events as e WHERE e.req_id = $get[req_id] union -SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel' +SELECT ev.id, '' as comment, '' as name, ev.date as create_date, ev.date as date_sort, 0 as checklist, 'partner' as `type`, NULL as type_call, ev.user_id, 0 AS partner_id, '' as record, ev.client_id, '' as document_id, ev.req_id, 0 as old_req_id, ev.date as schedule_date, '' as schedule_date_to, '' as address, '' as `sum`, ev.from_id, '' as calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, 0 as cancel, 0 as open_step, 0 as deal_id from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel' union SELECT e.id, e.comment, '' as name, e.create_date, e.create_date as date_sort, '0' as checklist, 'show_object' as type, NULL as type_call, e.user_id, '' as record, e.object_id, 0 as client_id, e.document_id, e.req_id, 0 as old_req_id, e.schedule_date, '' as schedule_date_to, e.address, e.sum, e.from_id, e.calendar_view, '' as `mango`, '' as `megafon`, '' as telphin, '' as beeline, '' as mts, '' as tele2, '' as allo, '' as tracking, e.cancel, 0 as open_step " . "FROM user_object_events as e WHERE e.req_id={$get['req_id']} AND e.object_id in (".implode(',', $arrSin).") AND e.type='show' @@ -1085,29 +1085,9 @@ ORDER BY date_sort ASC";
0) { - $row_deal = mysql_fetch_assoc($rez_deal); - $deal_id_for_edit = $row_deal['id']; - } - } - if (!$deal_id_for_edit && !empty($event['client_id'])) { - $sql_deal_client = "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 = " . intval($event['client_id']) . " AND d.status != 2 LIMIT 1"; - $rez_deal_client = mysql_query($sql_deal_client); - if ($rez_deal_client && mysql_num_rows($rez_deal_client) > 0) { - $row_deal_client = mysql_fetch_assoc($rez_deal_client); - $deal_id_for_edit = $row_deal_client['id']; - } - } - $isNewDeal = !empty($deal_id_for_edit); + $deal_id_for_edit = !empty($event['deal_id']) ? intval($event['deal_id']) : null; ?> - +
@@ -1135,7 +1115,7 @@ ORDER BY date_sort ASC";
Сделка '; } ?> +
Подробнее →
+
Сумма сделки: p