diff --git a/ajax/getClientLogForEventsNew.php b/ajax/getClientLogForEventsNew.php index 305f083..7176bf9 100644 --- a/ajax/getClientLogForEventsNew.php +++ b/ajax/getClientLogForEventsNew.php @@ -11,7 +11,7 @@ if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET[ $gmtmsk = get_time_zone_user(); - + $time_zone = ''; $time_zone_sql = 'INTERVAL 0 HOUR'; @@ -90,7 +90,7 @@ if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET[ } } else { - if($client->deleted > 0){ + if($client->deleted > 0){ $client_id = $client->id; $sql_del = "SELECT date_update FROM `events_clients` WHERE client_id=$client_id and event='delete' order by id desc limit 1"; @@ -138,7 +138,7 @@ if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET[ $usersIds = array_unique($usersIds); $sql_users2 = "SELECT id, user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name) as user_fio FROM users WHERE id in (".implode(',',$usersIds).")"; - + $q_users2 = mysql_query($sql_users2); while($r_users2 = mysql_fetch_assoc($q_users2)){ $users[$r_users2['id']] = $r_users2; @@ -153,20 +153,20 @@ if ($_SESSION['id'] && ((isset($_GET['id']) && is_numeric($_GET['id']) && $_GET[ $usersCanEdit = $req->getIdsUsers($user_access); // если смотрит руководитель - показываем все - // if ($_SESSION['agency'] || $_SESSION['manager'] || $_SESSION['users_admin']) { + // 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.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 " - . "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`, 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' + $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 " + . "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.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 " . "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`, 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 from events_clients as ev WHERE ev.req_id = $get[req_id] and event = 'transmitted_parallel' ORDER BY date_sort ASC"; - + $arrSin = array(); $sql_obj_sin = "SELECT object_id FROM object_req_synchronization WHERE req_id = {$get['req_id']}"; $q_obj_sin = $pdo->query($sql_obj_sin); @@ -174,20 +174,20 @@ 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.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 " - . "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`, 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' + $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 " + . "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' union -SELECT e.id, e.comment, '' as name, e.create_date, e.create_date as date_sort, '0' as checklist, 'show_object' as type, 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' +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' ORDER BY date_sort ASC"; //echo $sql; } } - /* if($get['req_id'] == 560779){ - echo $sql; - }*/ + /* if($get['req_id'] == 560779){ + echo $sql; + }*/ $rez = mysql_query($sql); $date = null; @@ -213,9 +213,9 @@ ORDER BY date_sort ASC"; } $sql_user = "SELECT user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name) as user_fio FROM users WHERE id = {$from_id} UNION SELECT user_logo, CONCAT(last_name, ' ', first_name, ' ', middle_name, ' (удален)') as user_fio FROM users_delete WHERE user_id = {$from_id}"; - // echo $sql_user."
"; + // echo $sql_user."
"; $from_user = mysql_fetch_assoc(mysql_query($sql_user)); - + $event['user_logo'] = $from_user['user_logo']; $event['user_fio'] = $from_user['user_fio']; @@ -247,30 +247,30 @@ ORDER BY date_sort ASC"; ?>
-
+
- - -
+ ?> +
-
+
-
+
Примечание - от партнёра + от партнёра
@@ -278,51 +278,51 @@ ORDER BY date_sort ASC"; - 0){?>
Примечание добавлено автоматически при переходе на этап - - 0){?>
Из заявки ID: - - -
+
- - - -
+ + + +
-
-
+
+
- @@ -353,20 +353,20 @@ ORDER BY date_sort ASC";
'; - - } + + } } $docs_q = mysql_query("SELECT * FROM clients_files WHERE event_id = '".$event['id']."'"); $name_files = ''; while ($file = mysql_fetch_assoc($docs_q)) { if($file['name_id'] > 0 && $name_files == ''){ - $sql_n = "SELECT * FROM names_client_files WHERE id={$file['name_id']}"; - $q_n = mysql_query($sql_n); - if(mysql_num_rows($q_n) > 0){ - $r_n = mysql_fetch_assoc($q_n); - $name_files = $r_n['name']; - } + $sql_n = "SELECT * FROM names_client_files WHERE id={$file['name_id']}"; + $q_n = mysql_query($sql_n); + if(mysql_num_rows($q_n) > 0){ + $r_n = mysql_fetch_assoc($q_n); + $name_files = $r_n['name']; + } } $name_doc = $_SERVER['DOCUMENT_ROOT'].'/upload/clients/'.$file['client_id'].'/'.$file['guid'].'.'.$file['type']; if ($file['req_id'] > 0) { @@ -403,74 +403,74 @@ ORDER BY date_sort ASC"; } if (!empty($file_list)) { ?> -
-
-
- - - - - -
-
-
-
-
-
Файл
-
    ' . $file_list . '
' : ''; ?>
- - 0){?> -
Файл добавлен автоматически при переходе на этап - - 0){?> -
Из заявки ID: - - - -
- - - - - - +
+
+
+ + + + + +
-
+
+
+
Файл
+
    ' . $file_list . '
' : ''; ?>
+ + 0){?> +
Файл добавлен автоматически при переходе на этап + + 0){?> +
Из заявки ID: + + + + + +
+
+
-
-
+ ?>
-
+
- - + ?>
-
+
@@ -487,255 +487,276 @@ ORDER BY date_sort ASC";
-
- + + +
-
+
Звонок - от партнёра + от партнёра
Позвонить - - c
по - - в - + + c
по + + в +
- ссылка', $event['comment']); + + if(!empty($event['type_call'])){ + switch($event['type_call']){ + case 1:{ + $comment = ''.$comment.''; + break; + } + case 2:{ + $comment = ''.$comment.''; + break; + } + case 3:{ + $comment = ''.$comment.''; + break; + } + case 4:{ + $comment = ''.$comment.''; + break; + } + } + } ?> -
Комментарий:
+
Комментарий:
- - 0 || $event['megafon']>0 || $event['telphin']>0 || $event['beeline']>0 || $event['mts']>0 || $event['tele2']>0 || $event['allo']>0){ ?> 0 && isset($users[$event['user_id']])){?>
- - - 0){?>
Задача добавлена автоматически при переходе на этап - - 0){?>
Из заявки ID: - - + if(!empty($event['record'])){ + if($event['megafon'] == 1){?>
- - - + +
- -
- agencyId."/"; - if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){ - $href = 'https://voice.joywork.ru/mts/'.$user->agencyId.'/'; - - $Headers = @get_headers($href.$rec.'.mp3'); - - if(strpos($Headers[0],'200')) { - - $path = $href; - } else { - $path = ''; - } - } - - //echo $pach; - } else if($event['tele2'] == 1) { - $date_patch = date('Ymd', strtotime($event['create_date'])); - $path = '/server/tele2/'.$user->agencyId.'/'.$date_patch.'/'; - if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){ - $href = 'https://voice.joywork.ru/tele2/'.$user->agencyId.'/'.$date_patch.'/'; - - $Headers = @get_headers($href.$rec.'.mp3'); - - if(strpos($Headers[0],'200')) { - - $path = $href; - } else { - $path = ''; - } - } - - //echo $pach; - } else if($event['allo'] == 1) { - $date_patch = date('Ymd', strtotime($event['create_date'])); - $path = '/server/allo/'.$user->agencyId.'/'; - if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){ - $href = 'https://voice.joywork.ru/allo/'.$user->agencyId.'/'; - - $Headers = @get_headers($href.$rec.'.mp3'); - - if(strpos($Headers[0],'200')) { - - $path = $href; - } else { - $path = ''; - } - } - - //echo $pach; - }else { - $path = '/server/mango/'; - - if(!file_exists($_SERVER['DOCUMENT_ROOT'].$path.$rec.'.mp3')){ - $href = 'https://voice.joywork.ru/mango/'; - $Headers = @get_headers($href.$rec.'.mp3'); - if(strpos($Headers[0],'200')) { - $path = $href; - } else { - $path = ''; - } - } - } - if(!empty($path)){ ?> -
-
-
+
+
- + ?>
-
+
- - -
+ ?> +
-
+
@@ -760,84 +781,84 @@ ORDER BY date_sort ASC";
-
+
Встреча - от партнёра + от партнёра
Встреча будет в
-
Адрес:
- Адрес:
+ ссылка', $event['comment']);?> -
Комментарий:
+
Комментарий:
- 0 && isset($users[$event['user_id']])){?>
- - - 0){?>
Задача добавлена автоматически при переходе на этап - - 0){?>
Из заявки ID: - - -
-
-
+
+
- + ?>
-
+
- - -
+ ?> +
-
+
@@ -862,60 +883,60 @@ ORDER BY date_sort ASC";
-
+
Показ - от партнёра + от партнёра
Показ будет в
-
Адрес:
- Адрес:
+ ссылка', $event['comment']); ?> -
Комментарий:
+
Комментарий:
- 0 && isset($users[$event['user_id']])){?>
- - - 0){?>
Задача добавлена автоматически при переходе на этап - - 0){?>
Из заявки ID: - - -
-
-
+
+
- 0, ( SELECT CONCAT(u.last_name, ' ', u.first_name, ' ', u.middle_name) FROM users as u WHERE u.id = s.created_by @@ -941,34 +962,34 @@ ORDER BY date_sort ASC"; ) AND s.section_id = 1 AND s.req_id = '$event[req_id]' LIMIT 1"; - //echo ""; + //echo ""; - if ($query = mysql_query($sql)) { - $row = mysql_fetch_assoc($query); - if (!empty($row['sub_comment']) && !empty($row['sub_comment_author'])) { - $event['sub_comment'] = $row['sub_comment']; - $event['sub_comment_author'] = $row['sub_comment_author']; - } - } - ?> + if ($query = mysql_query($sql)) { + $row = mysql_fetch_assoc($query); + if (!empty($row['sub_comment']) && !empty($row['sub_comment_author'])) { + $event['sub_comment'] = $row['sub_comment']; + $event['sub_comment_author'] = $row['sub_comment_author']; + } + } + ?>
-
+
- - -
+ ?> +
-
+
-
Показ из объекта
+
Показ из объекта
Показ будет в
-
Адрес:
- Адрес:
+ ссылка', $event['comment']); ?> @@ -1007,36 +1028,36 @@ ORDER BY date_sort ASC";
Комментарий к задаче: ()
- 0 && isset($users[$event['user_id']])){?>
- - - 0){?>
Задача добавлена автоматически при переходе на этап - - 0){?>
Из заявки ID: - -
-
-
+
+
- + ?>
-
+
- - -
+ ?> +
-
+
@@ -1086,7 +1107,7 @@ ORDER BY date_sort ASC";
-
+
Сделка + ?> - от партнёра + от партнёра
Запланирована сделка на в
@@ -1203,10 +1224,10 @@ ORDER BY date_sort ASC";
-
Сумма сделки: p
+
Сумма сделки: p
- ссылка', $event['comment']); ?> @@ -1223,7 +1244,7 @@ ORDER BY date_sort ASC"; if (isset($params['client_ids'])) { //var_dump($params['client_ids']); $client_ids = json_decode(html_entity_decode($params['client_ids'])); - + $sql_cls = "SELECT id, fio, phone, email FROM `clients` WHERE `id` in (".implode(',', $client_ids).")"; $rez_cls = mysql_query($sql_cls); while($doc_cls = mysql_fetch_assoc($rez_cls)) { @@ -1256,7 +1277,7 @@ ORDER BY date_sort ASC"; $doc_parties .= '
  • Клиент: '.$doc_cl['fio'] . ((!empty($cl_contacts)) ? ' (' . implode(', ', $cl_contacts) . ')' : '') . '
  • '; } } - + if (isset($params['object_id'])) { $sql_obj = "SELECT id, nazv, adres FROM `objects` WHERE `id` = '$params[object_id]' LIMIT 1"; @@ -1300,71 +1321,71 @@ ORDER BY date_sort ASC"; - 0 && isset($users[$event['user_id']])){?>
    - - - 0){?>
    Задача добавлена автоматически при переходе на этап - - 0){?>
    Из заявки ID: - - -
  • -
    -
    +
    +
    - + ?>
    -
    +
    - - -
    + ?> +
    -
    +
    @@ -1389,98 +1410,98 @@ ORDER BY date_sort ASC";
    -
    +
    - от партнёра + от партнёра
    Мероприятие состоится в
    -
    Сумма сделки: p
    +
    Сумма сделки: p
    ссылка', $event['comment']); + $pattern = '/(https?:\/\/\S+)/i'; + $comment = preg_replace($pattern, 'ссылка', $event['comment']); ?> -
    Комментарий:
    +
    Комментарий:
    - 0 && isset($users[$event['user_id']])){?>
    - - - 0){?>
    Задача добавлена автоматически при переходе на этап - - 0){?>
    Из заявки ID: - - -
    -
    -
    +
    +
    - + ?>
    -
    +
    - - + ?>
    -
    +
    -
    Этап «»
    +
    Этап «»
    -
    Закрыт со следующими событиями:
    + ?> +
    Закрыт со следующими событиями:
    -
    Добавлено событие по чек листу:
    +
    Добавлено событие по чек листу:
    -
    +
    - 0 && isset($users[$event['user_id']])){?>
    - - - 0){?>
    Задача добавлена автоматически при переходе на этап - - 0){?>
    Из заявки ID: - -
    -
    -
    +
    +
    - + ?>
    -
    +
    - - + ?>
    -
    +
    @@ -1583,57 +1604,57 @@ ORDER BY date_sort ASC";
    -
    -
    - Партнер - от партнёра -
    -
    Добавлен к совместной работе
    - - - "> +
    + Партнер + от партнёра +
    +
    Добавлен к совместной работе
    + + + 0 && isset($users[$event['user_id']])){?>
    - - - 0){?> -
    Задача добавлена автоматически при переходе на этап + 0){?> +
    Задача добавлена автоматически при переходе на этап - 0){?> -
    Из заявки ID: - - + if($event['old_req_id'] > 0){?> +
    Из заявки ID: + +
    -
    -
    +
    +
    '.$date_del.''; - $text2 = 'Клиент закрыт'; - if($is_req){ - $text2 = 'Заявка закрыта'; - } - echo '
    '.$text2; - if(isset($reason) && !empty($reason)){ + if($date_del != ''){ + echo '
    '.$date_del.'
    '; + $text2 = 'Клиент закрыт'; + if($is_req){ + $text2 = 'Заявка закрыта'; + } + echo '
    '.$text2; + if(isset($reason) && !empty($reason)){ echo " - ".$reason; - } - echo '
    '; - } + } + echo '
    '; + } }