get($_SESSION['id']); if($user->agency == 0 && $user->manager == 0 && $user->id_manager == 0) { $user->agency = 1; } // hide_client_contacts: прячем кнопки WhatsApp/Telegram в карточках клиентов через CSS. // Классы: // .whatsappBtn_mini / .whatsappBtn_mini_pad — иконки на карточках в канбане/списке // .whatsappBtn — иконки рядом с чат-инпутом (внизу модалки карточки) // .wazzapBtn — внешний интегратор Wazzap (тоже идёт через wa.me/t.me) if (function_exists('should_hide_contacts_for_current_user') && should_hide_contacts_for_current_user()) { echo ''; } $cl = new Clients; if(isset($_POST['page'])) $page = $_POST['page']; if(!isset($page) || $page < 1) $page = 1; $clients = $cl->getAllClients($_SESSION['id']); // Маскируем контактные данные клиентов в массиве (право проверяется внутри helper'а). // $clients['clients'] может быть либо плоским массивом клиентов (табличный вид), // либо двумерным с группировкой по stage/step_id (канбан). if (isset($clients['clients']) && is_array($clients['clients'])) { foreach ($clients['clients'] as $stageKey => &$stageBucket) { if (!is_array($stageBucket)) { continue; } if (isset($stageBucket['id']) || isset($stageBucket['phone']) || isset($stageBucket['email']) || isset($stageBucket['fio'])) { // Плоский элемент: это сам клиент mask_client_contacts_inplace($stageBucket); } else { // Вложенная корзина клиентов по стадии воронки foreach ($stageBucket as &$clientItem) { if (is_array($clientItem)) { mask_client_contacts_inplace($clientItem); } } unset($clientItem); } } unset($stageBucket); } $all_pages = $clients['all_pages']; $total = $clients['total']; $role_arr = ['арендатор', 'арендодатель', 'покупатель', 'продавец']; $arrActivities = []; $sql_adv = "SELECT * FROM `activities` WHERE `user_id` = '".$user->id."' OR `manager_id` = '".$user->id."'"; if ($user->id_manager) $sql_adv .= " OR `manager_id` = '".$user->id_manager."' OR `user_id` = '".$user->id_manager."'"; if ($user->agencyId) $sql_adv .= " OR `manager_id` = '".$user->agencyId."' OR `user_id` = '".$user->agencyId."'"; $sql_adv .= ' ORDER BY `name`'; $q_adv = mysql_query($sql_adv); $rows_adv = mysql_num_rows($q_adv); if ($rows_adv > 0) { while ($r_adv = mysql_fetch_assoc($q_adv)) { $arrActivities[$r_adv['id']] = $r_adv; } } $post = clearInputData($_POST); $funnel_id = 0; if($post['funnel']){ $funnel_id = $post['funnel']; } if(isset($post['filter_etap'])) { $arr_etap = json_decode(html_entity_decode($post['filter_etap']), ENT_QUOTES); } $htmlFilter = ''; //загружаем этапы воронки $htmlFilter = $htmlFilter . ''; ?>
Новые
В работе
Презентация
Показ
Бронь
Подаем на ипотеку
Сделка
Завершённые
style="border-color: " >
style="background-color: " >
  • style="width: 134px">
    0){ ?>
    0) {?>
    10) : ?>

    p
    Объект:
    Ответственный:
    $tag) { if($tags_visible < 2){ ?>
    и ещё шт.
    $tag) { ?>
    Закрыт успешно"; echo "
    Статус:
    $status
    "; } else if ($client['deleted'] == "1") { $status = "Закрыт"; echo "
    Статус:
    $status
    "; } ?>
    Статус:
    ID:

$clients) { if (!isset($result[$stages_class[$key - 1]])) $result[$stages_class[$key - 1]] = array(); foreach ($clients as $client) { $clientEv = ''; if ($client['events_res'] > 0) { $clientEv = '' . $client['events_res'] . ''; } else if ($client['events_res1'] > 0) { $clientEv = '' . $client['events_res1'] . ''; } else if ($client['events_res2'] > 0) { $clientEv = '' . $client['events_res2'] . ''; } $htmlli = '
  • ' . '
    '; $htmlli.=''; } else { $htmlli.= ''; $htmlli.=''; } if ($client['hot'] > 0) { $htmlli .= '
    '; } if ($client['priority'] > 0) { $htmlli .= '
    '; } if ($client['deleted'] && intval($client['confirm']) <> 10) { $htmlli .= '
    '; } $htmlli .= '

    '.$client['fio'].''. $client['add_date'] .'
    '; if (!empty($client['budget'])) { $htmlli .= '
    ' . $client['budget']; $htmlli .= 'p'; $htmlli .= '
    '; } if($client['deleted'] == "1" && $client['confirm'] == "10"){ $status = "Закрыт успешно"; $htmlli .= "
    Статус:
    $status
    "; }else if($client['deleted'] == "1"){ $status = "Закрыт"; $htmlli .= "
    Статус:
    $status
    "; } if ($client['objects'] != 'null' and !empty($client['objects'])) $htmlli .= '
  • '; $result[$stages_class[$key - 1]][] = $htmlli; } } } else { $funnelStepsData = mysql_query("select * from funnel_steps WHERE funnel_id = $funnel_id and deleted=0 order by order_number, branch"); $i=1; while($funnelStep = mysql_fetch_assoc($funnelStepsData)) { if(isset($clientsStages[$funnelStep['id']])) { foreach ($clientsStages[$funnelStep['id']] as $client) { $clientEv = ''; if ($client['events_res'] > 0) { $clientEv = '' . $client['events_res'] . ''; } else if ($client['events_res1'] > 0) { $clientEv = '' . $client['events_res1'] . ''; } else if ($client['events_res2'] > 0) { $clientEv = '' . $client['events_res2'] . ''; } $htmlli = '
  • ' . '
    '; $htmlli.=''; } else { $htmlli.= ''; $htmlli.=''; } if ($client['hot'] > 0) { $htmlli .= '
    '; } if ($client['priority'] > 0) { $htmlli .= '
    '; } $htmlli .= '

    '.$client['fio'].''. $client['add_date'] .'
    '; if (!empty($client['budget'])) { $htmlli .= '
    ' . $client['budget']; $htmlli .= 'p'; $htmlli .= '
    '; } if($client['deleted'] == "1" && $client['confirm'] == "10"){ $status = "Закрыт успешно"; $htmlli .= "
    Статус:
    $status
    "; }else if($client['deleted'] == "1"){ $status = "Закрыт"; $htmlli .= "
    Статус:
    $status
    "; } if ($client['objects'] != 'null' and !empty($client['objects'])) $htmlli .= '
  • '; $result['stage-step-' . $funnelStep['id']][] = $htmlli; } } } } if(!empty($result)){ $result['html'] = $result; $result['source'] = 'done'; } else { $result['source'] = 'none'; } $result['scriptToExec'] = ''; echo json_encode($result); } } else { ?> getDepartments(); $isStage = true; //архив типов договоров $contract = new Contract(); $contract->setAgencyId($user->agencyId); $typesContracs = $contract->getTypesName(); $sqlCastom = "SELECT id, is_client, is_stage FROM funnel_default WHERE agency_id = {$user->agencyId}"; $qCastom = mysql_query($sqlCastom); if(mysql_num_rows($qCastom) > 0){ $rCastom = mysql_fetch_assoc($qCastom); if($rCastom['is_stage'] == 0) $isStage = false; if($rCastom['is_client'] == 0) $useCustomFunnel = false; } ?>
    = 1) { $stage = "Новый"; } if ($stages >= 2) { $stage = "В работе"; } if ($stages >= 3) { $stage = "Презентация"; } if ($stages >= 4) { $stage = "Показ"; } if ($stages >= 5) { $stage = "Бронь"; } if ($stages >= 6) { $stage = "Подаем на ипотеку"; } if ($stages >= 7) { $stage = "Сделка"; } if ($stages >= 8) { $stage = "Закрыт"; } } else if ($client['funnel_id']) { $change_step_query = mysql_query("SELECT * FROM clients_funnel_step WHERE client_id = " . $client['id']); $next_id = 0; $change_step = array('step_id' => 0); $lostDate = $client['date_create']; if (mysql_num_rows($change_step_query) > 0) { $change_step = mysql_fetch_assoc($change_step_query); $next_id = $change_step['next_id']; $lostDate = $change_step['date_update']; } $next_steps = array(); $funnel_step = mysql_query("SELECT * FROM funnel_steps WHERE funnel_id = " . $client['funnel_id'] . " and deleted=0 order by order_number, branch"); $isActive = true; $classF = ' active'; $stage = ''; if ((int)$change_step['step_id'] == 0) { $isActive = false; } $arr_steps = array(); $countStep = mysql_num_rows($funnel_step); while ($step = mysql_fetch_assoc($funnel_step)) { $step['isActive'] = (int)$isActive; $step['nextStep'] = false; if ($step['main'] == 1 && !$isActive) { $next_steps[] = $step['id']; } if ($step['id'] == (int)$change_step['step_id']) { //$stage = $step['name']; $next_steps = json_decode(htmlspecialchars_decode($step['next_step'])); if ($next_id == 0) { //$stage = $step['name']; //$next_steps = json_decode( htmlspecialchars_decode($step['next_step'])); //if($step['branch'] < $branch){ $isActive = false; // } } } else if ($step['id'] == (int)$next_id) { $isActive = false; } $arr_steps[$step['id']] = $step; } if ($next_id != 0 && !empty($next_steps)) { foreach ($next_steps as $key => $st) { if ($st != $next_id) { unset($next_steps[$key]); } } } foreach ($arr_steps as $idstep => $step) { $arr_steps[$idstep]['isNext'] = 0; if (in_array($idstep, $next_steps)) { $stage = $step['name']; $arr_steps[$idstep]['isNext'] = 1; } } if ($stage == '') { foreach ($arr_steps as $idstep => $step) { if ($step['stage'] == 'Закрыт') { $stage = $step['name']; } } } if($client['funnel_id'] == 0){ $name_funnel = "Обычные"; } else { $sql_fun = "SELECT name FROM funnel WHERE id = ".$client['funnel_id']; $name_funnel = mysql_fetch_assoc(mysql_query($sql_fun))['name']; } } ?>
      ФИО Телефон Почта Бюджет Ответственный Воронка Этап Ближайшая задача Горячий
    1) { if ($mas_url_add) $str_url_add = implode("&", $mas_url_add); echo "
      "; num_of_pages_for_ajax($page, $all_pages, $str_url_add); echo "
    "; echo 'перейти на '; echo "
    "; } ?>
    get($id); //var_dump($client); $data_add = date('d', strtotime($client['date_add'])); $mounth = $mounthArr[((int)date('m', strtotime($client['date_add'])) - 1)]; $data_add .= ' '.$mounth.' '.date('Y', strtotime($client['date_add'])); $client['add_date'] = $data_add; $phone = $client['phone']; // Не форматируем уже замаскированный номер — иначе маска покрошится substr-ом. if (strpos($phone, '+7') !== false && strpos($phone, '*') === false) { $phone = substr($phone, 0, 2)."(".substr($phone, 2, 3).")".substr($phone, 5, 3)."-".substr($phone, 8, 2)."-".substr($phone, 10, 2); } $client['phone'] = $phone; $client_id = (int)$client['id']; $tasks_sql = "SELECT schedule_date, comment, user_id, name , type FROM user_client_events WHERE client_id = $client_id AND type IN ('even', 'call', 'deal', 'show', 'meet') AND calendar_view = 0 ORDER BY schedule_date ASC"; $tasks_result = mysql_query($tasks_sql); if ($tasks_result) { while ($row = mysql_fetch_assoc($tasks_result)) { // var_dump($row); $sql_user = "SELECT CONCAT(last_name, ' ', first_name, ' ', middle_name) as user_fio FROM users WHERE id = {$row['user_id']}"; $responsible = mysql_fetch_assoc(mysql_query($sql_user))['user_fio']; $client['tasks_data'][] = [ 'schedule_date' => $row['schedule_date'], 'comment' => $row['comment'], 'name' => $row['name'], 'type' => $row['type'], 'responsible' => $responsible, ]; } } $events = "SELECT count(id) as res FROM user_client_events WHERE calendar_view = 0 and schedule_date is not null and client_id=" . $client['id'] . " and schedule_date < '" . date("Y-m-d H:i:s") . "'"; $events1 = "SELECT count(id) as res FROM user_client_events WHERE calendar_view = 0 and schedule_date is not null and client_id=" . $client['id'] . " and DATE_FORMAT(schedule_date, '%Y-%m-%d') = '" . date("Y-m-d") . "'"; $events2 = "SELECT count(id) as res FROM user_client_events WHERE calendar_view = 0 and schedule_date is not null and client_id=" . $client['id'] . " and DATE_FORMAT(schedule_date, '%Y-%m-%d') > '" . date("Y-m-d") . "'"; $q_events = mysql_query($events); $events_res = (int)mysql_fetch_assoc($q_events)['res']; $client['events_res'] = $events_res; $q_events1 = mysql_query($events1); $events_res1 = (int)mysql_fetch_assoc($q_events1)['res']; $client['events_res1'] = $events_res1; $q_events2 = mysql_query($events2); $events_res2 = (int)mysql_fetch_assoc($q_events2)['res']; $client['events_res2'] = $events_res2; $activities = []; $sqlAddInfo = "SELECT `activity_id` FROM `clients_activities` WHERE `client_id` = '$id'"; if ($rezAddInfo = mysql_query($sqlAddInfo)) { if (mysql_num_rows($rezAddInfo) > 0) { while ($row = mysql_fetch_array($rezAddInfo)) { $sql_a_name = "SELECT * FROM activities WHERE id = {$row['activity_id']}"; $q_a_name = mysql_query($sql_a_name); $r_a_name = mysql_fetch_assoc($q_a_name); $activities[] = $r_a_name; } } } ?>
    style="width: 134px">
    ">
    ">
    ">
    ">
    0){ ?>
    0) {?>
    10) : ?>

    p
    Объект:
    Ответственный:
    $tag) { if($tags_visible < 2){ ?>
    и ещё шт.
    $tag) { ?>
    Закрыт успешно"; echo "
    Статус:
    $status
    "; } else if ($client['deleted'] == "1") { $status = "Закрыт"; echo "
    Статус:
    $status
    "; } ?>
    ID:

    get($_SESSION['id']); if($user->agency == 0 && $user->manager == 0 && $user->id_manager == 0){ $user->agency = 1; } $sqlCastom = "SELECT id, is_client, is_stage FROM funnel_default WHERE agency_id = {$user->agencyId}"; $qCastom = mysql_query($sqlCastom); if(mysql_num_rows($qCastom) > 0){ $rCastom = mysql_fetch_assoc($qCastom); if($rCastom['is_stage'] == 0) $isStage = false; if($rCastom['is_client'] == 0) $useCustomFunnel = false; } $sql="SELECT * FROM clients WHERE id=$id"; if(isset($_POST['req_id'])){ $req_id = $_POST['req_id']; } if(isset($_POST['adjacent_id']) && (int)$_POST['adjacent_id'] > 0){ $adjacent_id = (int)$_POST['adjacent_id']; } $see_client = true; if($req_id > 0){ $sql="SELECT *, created_at as date_add, name as fio, description as opis FROM requisitions WHERE id=$req_id"; } $toSend = $_POST['to_send']; $rez=mysql_query($sql); $client = mysql_fetch_assoc($rez); if (is_array($client)) { mask_client_contacts_inplace($client); } if($req_id > 0){ if(($user->agencyId == 8826 || $user->agencyId == 19895) && $client['who_work'] == 0 && $client['confirm'] == 0){ $see_client = false; } } $data_add = date('d', strtotime($client['date_add'])); $mounth = $mounthArr[((int)date('m', strtotime($client['date_add'])) - 1)]; $data_add .= ' '.$mounth.' '.date('Y', strtotime($client['date_add'])); if(isset($client['role'])){ $role .= $role_client; }else if($client['type_id']){ if($client['type_id'] == 1){ $role = "Подбор объекта"; } else if($client['type_id'] == 2){ $role = "Реализация объекта"; } else if($client['type_id'] == 3){ $role = "Другие услуги"; } } if($req_id > 0){ if($client['client_id'] > 0){ $sql_cl="SELECT id, phone, email, fio, phone2 FROM clients WHERE id=$client[client_id]"; $r_cl = mysql_fetch_assoc(mysql_query($sql_cl)); $client['phone'] = $r_cl['phone']; $client['email'] = $r_cl['email']; $client['fio_cl'] = $r_cl['fio']; $client['id_cl'] = $r_cl['id']; $client['phone2'] = $r_cl['phone2']; // Контакты были перезаписаны из дополнительного запроса — маскируем повторно. // fio_cl — дополнительное ФИО клиента из связанной заявки; helper его не покрывает, // поэтому прогоняем через mask_fio_if_contains_phone отдельно. mask_client_contacts_inplace($client); if (isset($client['fio_cl'])) { $client['fio_cl'] = mask_fio_if_contains_phone($client['fio_cl']); } } } $work_type = ""; $work_type_client = json_decode(html_entity_decode($client['work_type']), true); foreach($work_type_client as $work_client){ if($work_type != '') { $work_type .= ' / '; } $work_type .= $work_client; } $stages = (int)$client['stage']; if((int)$client['deleted'] == 1) $stages = 8; $stage = "Новый"; $phone = $client['phone']; // Не форматируем уже замаскированный номер — иначе маска покрошится substr-ом. if (strpos($phone, '+7') !== false && strpos($phone, '*') === false) { $phone = substr($phone, 0, 2)."(".substr($phone, 2, 3).")".substr($phone, 5, 3)."-".substr($phone, 8, 2)."-".substr($phone, 10, 2); } $source = ""; if($client['source'] == 10000){ $source = "Объекты нашей компании"; } else { $sql_source = "SELECT * FROM `advertising_sources` WHERE `id` = '{$client['source']}'"; $q_source = mysql_query($sql_source); $r_source = mysql_fetch_assoc($q_source); if(is_see($r_source['is_no_see'], $r_source['users_no_see'])) $source = $r_source['source']; } $client_objects = json_decode(html_entity_decode($client['objects']), true); $fields = "SELECT count(id) as ids FROM `inner_docs_fields` WHERE `section_id` = '2' AND `source_id` = '" . $client['id'] . "'"; $fields_count = (int)mysql_fetch_assoc(mysql_query($fields))['ids']; // Обновление инфо о том, что клиент/заявка были просмотрены пользователем if ($req_id > 0) { $sql = "UPDATE `events_clients` SET `viewed` = 1 WHERE `viewed` = 0 AND `read` = 1 AND `user_id` = '$_SESSION[id]' AND `req_id` = '$req_id' AND `from_id` = '$_SESSION[id]' AND (`event` = 'accepted' OR `event` = 'accepted_doer')"; mysql_query($sql); } else { $sql = "UPDATE `events_clients` SET `viewed` = 1 WHERE `viewed` = 0 AND `read` = 1 AND `user_id` = '$_SESSION[id]' AND `client_id` = '$client[id]' AND `from_id` = '$_SESSION[id]' AND (`event` = 'accepted' OR `event` = 'accepted_doer')"; mysql_query($sql); } ?>
    года
    = 1){ $classSt=' active'; $stage = "Новый"; } ?> = 2){ $classSt=' active'; $stage = "В работе"; } ?> = 3){ $classSt=' active'; $stage = "Презентация"; } ?> = 4){ $classSt=' active'; $stage = "Показ"; } ?> = 5){ $classSt=' active'; $stage = "Бронь"; } ?> = 6){ $classSt=' active'; $stage = "Подаем на ипотеку"; } ?> = 7){ $classSt=' active'; $stage = "Сделка"; } ?> = 8){ $classSt=' active'; $stage = "Закрыт"; } ?> 0){ ?> 0){ $change_step_query = mysql_query("SELECT * FROM adjacent_funnels WHERE id = ".$adjacent_id); } else { $change_step_query = mysql_query("SELECT * FROM clients_funnel_step WHERE client_id = ".$client['id']); if($req_id > 0){ $change_step_query = mysql_query("SELECT * FROM clients_funnel_step WHERE req_id = ".$client['id']); } } $next_id = 0; $change_step = array('step_id' => 0); $lostDate = $client['date_add']; if(mysql_num_rows($change_step_query) > 0){ $change_step = mysql_fetch_assoc($change_step_query); if(isset($change_step['funnel_id'])){ $client['funnel_id'] = $change_step['funnel_id']; } $next_id = $change_step['next_id']; if(isset($change_step['date_update']) && !empty($change_step['date_update'])){ $lostDate = $change_step['date_update']; } else if(isset($change_step['updated_at']) && !empty($change_step['updated_at'])){ $lostDate = $change_step['updated_at']; } } $next_steps = array(); $funnel_step = mysql_query("SELECT * FROM funnel_steps WHERE funnel_id = ".$client['funnel_id']." and deleted=0 order by order_number, branch"); $isActive = true; $classF=' active'; $stage = ''; if((int)$change_step['step_id'] == 0){ $isActive = false; } $arr_steps = array(); $countStep = mysql_num_rows($funnel_step); while ($step = mysql_fetch_assoc($funnel_step)) { $step['isActive'] = (int)$isActive; $step['nextStep'] = false; if ($step['main'] == 1 && !$isActive) { $next_steps[] = $step['id']; } if ($step['id'] == (int)$change_step['step_id']) { //$stage = $step['name']; $next_steps = json_decode(htmlspecialchars_decode($step['next_step'])); if ($next_id == 0) { //$stage = $step['name']; //$next_steps = json_decode( htmlspecialchars_decode($step['next_step'])); //if($step['branch'] < $branch){ $isActive = false; // } } } else if ($step['id'] == (int)$next_id) { $isActive = false; } $arr_steps[$step['id']] = $step; } if ($next_id != 0 && !empty($next_steps)) { foreach ($next_steps as $key => $st) { if ($st != $next_id) { unset($next_steps[$key]); } } } foreach ($arr_steps as $idstep => $step) { $arr_steps[$idstep]['isNext'] = 0; if (in_array($idstep, $next_steps)) { $stage = $step['name']; $arr_steps[$idstep]['isNext'] = 1; } } // var_dump($arr_steps); $isActive = true; foreach ($arr_steps as $idstep => $step) { $classF = ''; if ($isActive) $classF = ' active'; if ($step['isNext'] == 1) { $classF = ' nextStep'; $isActive = false; } // Покажет сколько мне дней $interval = date_diff(new DateTime(), new DateTime($lostDate))->days; if ($interval >= $step['days_step']) { $classF .= ' expired'; } ?>
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Новый
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    В работе
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Презентация
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Показ
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Бронь
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Подаем на ипотеку
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    Сделка
    0) ? 'data-req="'.$req_id.'"' : ''?> class="crm__small-stage">
    0) ? 'data-req="'.$req_id.'"' : 'data-client="'.$client['id'].'"'?> data-main="" 0) ? 'data-adjacent="'.$adjacent_id.'"' : ''?> class="crm__small-step">
    0){ $stage .= ' (закрыт)'; } ?>
    0){ $sql_adjacent_funnels = "SELECT * FROM adjacent_funnels WHERE req_id = {$req_id}"; $q_adjacent_funnels = mysql_query($sql_adjacent_funnels); while($r_adjacent_funnels = mysql_fetch_assoc($q_adjacent_funnels)){ $funnels_adjacent[] = $r_adjacent_funnels; /*$steps = $this->get_class_etap($r_adjacent_funnels); $html .= $this->get_stagebar($steps);*/ } } if(count($funnels_adjacent) > 0){ $funnels_adjacent_text = ''; $new_total = count($funnels_adjacent); if(count($funnels_adjacent) > 0){ $new_text = 'Ещё '.$new_total; if($new_total == 1){ $new_text .= ' воронка'; } else if($new_total > 1 && $new_total < 5){ $new_text .= ' воронки'; } else if($new_total > 4){ $new_text .= ' воронок'; } $funnels_adjacent_text = $new_text; } $funnelClass = new Funnel(); ?>
    funnel
    0){ $pole = 'req_id'; $type_list = "req"; } $sql_f = "SELECT * FROM clients_files WHERE {$pole} = {$client['id']} AND event_id > 0"; $q_f = mysql_query($sql_f); $filesTotal += mysql_num_rows($q_f); $sql_f = "SELECT * FROM `funnel_files` WHERE {$pole} = {$client['id']}"; $q_f = mysql_query($sql_f); $filesTotal += mysql_num_rows($q_f); ?> 0){ $typeCheckList = 'client'; if ($req_id > 0) $typeCheckList = 'req'; ?>
    0 && $client['deleted'] && intval($client['confirm']) <> 10) : ?> 10) : ?> getDepartments(); $dep_user = $depClass->getDepartment((int)$_SESSION['id']); $sql_check_manager = "SELECT `id_manager`, `department_id` FROM `users` WHERE `id` = ".$client['who_work']; $result_check_manager = mysql_query($sql_check_manager); $client_id_manager = mysql_fetch_assoc($result_check_manager); $r_check_permissions = $user->checkMenuPermissions(); if ($user->agency == 1 || $user->users_admin == 1 || $_SESSION['id'] === $client['who_work'] || ($r_check_permissions['menu_all_clients_edit'] == 1 && $_SERVER['HTTP_REFERER'] == 'https://joywork.ru/clients.php') || ($r_check_permissions['menu_all_submissions_edit'] == 1 && $_SERVER['HTTP_REFERER'] == 'https://joywork.ru/requisitions.php')) { $user_allow_edit = 1; } elseif (($dep_user['role'] == 'admin_department' || $dep_user['role'] == 'manager_office') && $client_id_manager['department_id'] == $user->department_id) { $user_allow_edit = 1; } elseif ($dep_user['role'] == 'manager' && ($_SESSION['id'] == $client_id_manager['id_manager'])) { $user_allow_edit = 1; } elseif ($dep_user['role'] == 'manager_office_menager' && ($_SESSION['id'] == $client_id_manager['id_manager'] || $_SESSION['id_manager'] === $client_id_manager['id_manager'] || $_SESSION['id_manager'] === $client['who_work'])) { $user_allow_edit = 1; } elseif (!($dep_user['role']) && ($_SESSION['manager'] && ($_SESSION['id'] == $client_id_manager['id_manager']))) { $user_allow_edit = 1; } $see_modal_client = 1; if ($req_id > 0 && $user->agencyId == 19895){ $see_modal_client = 0; if($user->agency == 1 || $user->users_admin == 1 || $r_check_permissions['menu_all_submissions_edit'] == 1) { $see_modal_client = 1; } elseif (($dep_user['role'] == 'admin_department' || $dep_user['role'] == 'manager_office') && $client_id_manager['department_id'] == $user->department_id) { $see_modal_client = 1; } elseif ($dep_user['role'] == 'manager' && ($_SESSION['id'] == $client_id_manager['id_manager'])) { $see_modal_client = 1; } elseif ($dep_user['role'] == 'manager_office_menager' && ($_SESSION['id'] == $client_id_manager['id_manager'] || $_SESSION['id_manager'] === $client_id_manager['id_manager'] || $_SESSION['id_manager'] === $client['who_work'])) { $see_modal_client = 1; } elseif (!($dep_user['role']) && ($_SESSION['manager'] && ($_SESSION['id'] == $client_id_manager['id_manager']))) { $see_modal_client = 1; } } ?> 0) ? 'data-req="'.$req_id.'"' : ''?> title="Редактировать"> 0 && $client['who_work'] > 0) && !$adjacent_id) { ?> 0) ? 'data-req="'.$req_id.'"' : ''?> class="delClientAgent no-border" title="Закрыть"> 0) { ?>

    '

    Имя

    Имя

    Телефон

    Почта

    0){ if($client['object_id'] > 0){ $sql_obj = "SELECT id, nazv FROM `objects` WHERE `id`= ".$client['object_id']; $q_obj = mysql_query($sql_obj); $count_obj = mysql_num_rows($q_obj); if($count_obj > 0){ ?>

    Объект

    1"; $q_obj = mysql_query($sql_obj); $count_obj = mysql_num_rows($q_obj); if($count_obj > 0){ ?>

    Объект

    Бюджет

    Сумма сделки

    0){ $phoneStr = ''; foreach($phone2 as $ph){ if($phoneStr != '') $phoneStr .= '; '; // Применяем маскирование (helper сам решает по праву пользователя). $ph = mask_phone_value_if_needed($ph); // Маскированный номер ("+7 *** *** ** **") не форматируем substr-ом. if (strpos($ph, '*') !== false) { $phoneStr .= $ph; } else { $phoneStr .= substr($ph, 0, 2)."(".substr($ph, 2, 3).")".substr($ph, 5, 3)."-".substr($ph, 8, 2)."-".substr($ph, 10, 2); } } ?>

    Дополнительные телефоны

    0){ ?>

    Комментарий

    0){ $urlParam = 'reqId'; $urlId = $req_id; $sql_wazz = "SELECT * FROM requisition_data_wazzap WHERE requisition_id = " . $req_id; } $q_wazz = mysql_query($sql_wazz); if (mysql_num_rows($q_wazz) > 0) { $objAddedToWazzap = true; } if (!$objAddedToWazzap && $user->agencyEnableWazzap && $user->added_to_wazzap) { ?> agencyEnableWazzap && $user->added_to_wazzap) { ?>
    "> ">
    Предложенные варианты

    История
    = 0){ $time_zone = '+'.$gmtmsk.' hour'; } else { $time_zone = '-'.$gmtmsk.' hour'; } $array_ev = array('add'=>'Добавлен', 'transmitted' => 'Передан', 'parallel_del' => 'Удален из совместной работы', 'transmitted_parallel' => 'Приглашен к совместной работе', 'accepted' => 'Принят', 'accepted_doer'=>'Добавлен к совместной работе', 'notadopted' => 'Не принят','notadopted_doer' => 'Приглашение не принято', 'stageedit' => 'Изменен этап', 'delete' => 'Закрыт', 'double_client' => 'Повторное обращение', 'sub_comment' => 'Добавлен комментарий к задаче: '); $k = 1000; $date_ev = ""; $sql_ev = "(SELECT id, client_id, user_id, from_id, `event`, `date`, `dop_text`, 0 as `of_objects` FROM events_clients where client_id = $client[id] AND funnel_type != 'adjacent' AND is_not_show = 0) union (SELECT id, id as client_id, id_agent as user_id, 0 as from_id, 'add' as `event`, `date_add` as `date`, '' as `dop_text`, `of_objects` FROM clients WHERE id = $client[id]) order by `date` DESC"; if($req_id > 0){ $sql_ev = "(SELECT id, id as client_id, user_id, from_id, `event`, `date`, `dop_text`, 0 as `of_objects` FROM events_clients where req_id = $req_id AND funnel_type != 'adjacent' AND is_not_show = 0) union (SELECT id, id as client_id, user_id, 0 as from_id, 'add' as `event`, `created_at` as `date`, '' as `dop_text`, '' as `of_objects` FROM requisitions WHERE id = $req_id) order by `date` DESC"; } $q_ev = mysql_query($sql_ev); $insertedData = []; while($r_ev = mysql_fetch_assoc($q_ev)){ if ( strpos($r_ev['event'], 'extension_reservation_') !== false || strpos($r_ev['event'], 'ext_confirming_res_') !== false || strpos($r_ev['event'], 'ext_unconfirming_res_') !== false ) { foreach ($insertedData as $item) { if ($item['event'] == $r_ev['event'] && $item['user_id'] == $r_ev['user_id'] && $item['req_id'] == $r_ev['req_id'] && $item['date'] == $r_ev['date'] ) { continue 2; } } $insertedData[] = $r_ev; } $master = ""; $mstr = mysql_fetch_assoc(mysql_query("SELECT agency, manager, agency_name, first_name, last_name, middle_name, 0 as del FROM users WHERE id=".$r_ev['user_id'] . " UNION SELECT agency, manager, agency_name, first_name, last_name, middle_name, 1 as del FROM users_delete WHERE user_id={$r_ev['user_id']}")); if($mstr['agency']) $master = "Агентство $mstr[agency_name]"; elseif($mstr['manager']) $master = "Менеджер " . trim($mstr['last_name'] . ' ' . $mstr['first_name'] . ' ' . $mstr['middle_name']); else $master = "Агент " . trim($mstr['last_name'] . ' ' . $mstr['first_name'] . ' ' . $mstr['middle_name']); if($mstr['del'] == 1) $master .= " (удален)"; $from_master = ""; if($r_ev['from_id'] != 0){ $mstr = mysql_fetch_assoc(mysql_query("SELECT agency, manager, agency_name, first_name, last_name, middle_name, 0 as del FROM users WHERE id=".$r_ev['from_id'] . " UNION SELECT agency, manager, agency_name, first_name, last_name, middle_name, 1 as del FROM users_delete WHERE user_id=".$r_ev['from_id'])); if($mstr['agency']) $from_master = "агентство $mstr[agency_name]"; elseif($mstr['manager']) $from_master = "менеджер " . trim($mstr['last_name'] . ' ' . $mstr['first_name'] . ' ' . $mstr['middle_name']); else $from_master = "агент " . trim($mstr['last_name'] . ' ' . $mstr['first_name'] . ' ' . $mstr['middle_name']); if($mstr['del'] == 1) $from_master .= " (удален)"; } $udate = strtotime($time_zone, strtotime($r_ev['date'])); $date_row = date('d', $udate) . ' ' .getRusMonth(date('m', $udate)) . ' ' . date('Y', $udate); $dop_text = ''; if($r_ev['event'] == 'add' && $r_ev['of_objects'] > 1){ $name = ''; $sql_o = "SELECT nazv, adres FROM objects WHERE id = ".$r_ev['of_objects']; $q_o = mysql_query($sql_o); $r_o = mysql_fetch_assoc($q_o); if(!empty($r['nazv'])) $name .= $r_o['nazv']; if(!empty($r_o['adres'])) { if($name != '') $name .= ' '; $name .= $r_o['adres']; } if($name != '') $dop_text .= ' по звонку по объекту '.$name; } if($date_row != $date_ev){ $date_ev = $date_row; if($k != 1000){ ?>

    1 AND objects.moder <> 1 AND 1 AND objects.use_in_advert = 0 AND archive <> 1 AND id_add_user = 10 AND objects.operation_type = 0 GROUP BY objects.id ORDER BY UNIX_TIMESTAMP(objects.date_add) DESC LIMIT 0, 20 $q_obj = mysql_query($sql_obj); if(mysql_num_rows($q_obj) > 0) { while($obj = mysql_fetch_assoc($q_obj)) { //$use_advert_budget = ($_SESSION['use_advert_budget']); //include($_SERVER['DOCUMENT_ROOT']."/templates/system__object_new.php"); $sqlPhotoInfo = "SELECT oop.sort_order, p.photo FROM objects_object_photo oop, object_photo p WHERE p.id = oop.object_photo_id AND oop.object_id = $obj[id] ORDER BY oop.sort_order"; $rezPhotoInfo = mysql_query($sqlPhotoInfo); if (mysql_num_rows($rezPhotoInfo) > 0) { while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) { $obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo']; } } ?>
    ","\n",$obj['opis']); // $photo = ""; for($num=1;$num<=50;$num++) if($obj['photo'.$num]) { $photo = $obj['photo'.$num]; break; } // and is_file($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) and filesize($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) > 0 if(empty($photo)) { ?>
    '; // and is_file($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) and filesize($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) > 0 } ?>
    Агент JW
    '; else echo '
    Собственник JW
    ' ?>
    Сдается   Уже в работе'; } } else { if ($obj['operation_type'] == 1) { ?> Продается ID 

    " id="to_send_button" data-id=""> pdf
    p

    Объектов не найдено

    1 AND objects.moder <> 1 AND 1 AND objects.use_in_advert = 0 AND archive <> 1 AND id_add_user = 10 AND objects.operation_type = 0 GROUP BY objects.id ORDER BY UNIX_TIMESTAMP(objects.date_add) DESC LIMIT 0, 20 $q_obj = mysql_query($sql_obj); if(mysql_num_rows($q_obj) > 0) { while($obj = mysql_fetch_assoc($q_obj)) { //$use_advert_budget = ($_SESSION['use_advert_budget']); //include($_SERVER['DOCUMENT_ROOT']."/templates/system__object_new.php"); $sqlPhotoInfo = "SELECT oop.sort_order, p.photo FROM objects_object_photo oop, object_photo p WHERE p.id = oop.object_photo_id AND oop.object_id = $obj[id] ORDER BY oop.sort_order"; $rezPhotoInfo = mysql_query($sqlPhotoInfo); if (mysql_num_rows($rezPhotoInfo) > 0) { while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) { $obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo']; } } ?>
    ","\n",$obj['opis']); // $photo = ""; for($num=1;$num<=20;$num++) if($obj['photo'.$num]) { $photo = $obj['photo'.$num]; break; } // and is_file($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) and filesize($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) > 0 if(empty($photo)) { ?>
    '; // and is_file($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) and filesize($_SERVER['DOCUMENT_ROOT']."/photos/".$obj['photo'.$num]) > 0 } ?>
    Агент JW
    '; else echo '
    Собственник JW
    ' ?>
    Сдается   Уже в работе'; } } else { if ($obj['operation_type'] == 1) { ?> Продается

    Площадь: кв. м
    0) { ?>
    Жилая: кв. м
    0) { ?>
    Кухни: кв. м
    этаж из
    " id="to_send_button" data-id=""> pdf
    p

    Объектов не найдено

    0){ $activeRent = ""; $activeSell = ""; $archiveRent = ""; $archiveSell = ""; while($obj = mysql_fetch_assoc($q_obj)) { if ($obj['archive'] == 1) { if ($obj['operation_type'] == 1) { $archiveSell = $archiveSell . ''; } else { $archiveRent = $archiveRent . ''; } } else { if ($obj['operation_type'] == 1) { $activeSell = $activeSell . ''; } else { $activeRent = $activeRent . ''; } } } if ($activeRent) { echo ""; echo $activeRent; echo ""; } if ($activeSell) { echo ""; echo $activeSell; echo ""; } if ($archiveRent) { echo ""; echo $archiveRent; echo ""; } if ($archiveSell) { echo ""; echo $archiveSell; echo ""; } } else { echo '0'; } } if (isset($_POST['get_list_count'])) { require_once($_SERVER['DOCUMENT_ROOT']."/config.php"); $user = new User; $user->get($_SESSION['id']); if($user->agency == 0 && $user->manager == 0 && $user->id_manager == 0) { $user->agency = 1; } $cl = new Clients; if(isset($_POST['page'])) $page = $_POST['page']; if(!isset($page) || $page < 1) $page = 1; $clients = $cl->getAllClients($_SESSION['id']); echo json_encode($clients['count']); } ?>