Actual prod
This commit is contained in:
parent
7ee214b7ff
commit
253d016ff0
@ -23,7 +23,9 @@ if ($_SESSION['id']) {
|
||||
$where = "calendar_view = 0";
|
||||
}
|
||||
|
||||
$sql = "SELECT e.*, o.nazv from user_object_events e, objects o WHERE user_id = $_SESSION[id] and o.id=e.object_id and schedule_date is not null and $where and $startDateWhere and $endDateWhere";
|
||||
// Явные колонки (НЕ e.*): user_object_events получил 19-ю колонку moved_on_copy → e.* стал 20, а вторая ветка
|
||||
// UNION = 19 → запрос падал с «different number of columns» → задачи по своим объектам пропадали из календаря.
|
||||
$sql = "SELECT e.id, e.user_id, e.from_id, e.object_id, e.req_id, e.create_date, e.type, e.address, e.sum, e.document_id, e.schedule_date, e.comment, e.platforms_advert, e.calendar_view, e.cancel, e.tel, e.max, e.name, o.nazv from user_object_events e, objects o WHERE user_id = $_SESSION[id] and o.id=e.object_id and schedule_date is not null and $where and $startDateWhere and $endDateWhere";
|
||||
$sql .= "union
|
||||
SELECT s.id, s.user_for as user_id, 0 as from_id, e.object_id as object_id, 0 as req_id, created_at as create_date, 'sub_moderation' as type,
|
||||
'' as address,null as sum, null as document_id, created_at as schedule_date, sub_comment as comment, '' as platforms_advert, e.calendar_view,e.cancel, 0 as tel, 0 as max, '' as name,
|
||||
@ -120,6 +122,54 @@ if ($_SESSION['id']) {
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Найденные листинги парсера: задачи пользователя из своей таблицы. Offset-free: object_id = РЕАЛЬНЫЙ el.id
|
||||
// (реальный el.id коллизит с objects.id), листинг различаем по флагу is_external=1.
|
||||
// table_id = реальный id события — завершение адресует конкретную задачу. LEFT JOIN: листинг мог уйти по TTL,
|
||||
// задача остаётся (адрес тогда пустой). Комментарии — не задачи, пропускаем. deal/moderation у листингов нет.
|
||||
$sqlListing = "SELECT e.*, IFNULL(el.address_text, '') AS adres
|
||||
FROM external_listing_events e
|
||||
LEFT JOIN external_listings el ON el.id = e.external_listing_id
|
||||
WHERE e.user_id = $_SESSION[id] AND e.schedule_date IS NOT NULL AND $where AND $startDateWhere AND $endDateWhere";
|
||||
$rezListing = mysql_query($sqlListing);
|
||||
while ($rezListing && ($event = mysql_fetch_assoc($rezListing))) {
|
||||
if ($event['type'] == 'comment') {
|
||||
continue;
|
||||
}
|
||||
$label = trim($event['adres']) !== '' ? $event['adres'] : ('EXT-' . $event['external_listing_id']);
|
||||
$label = str_replace(array('"', '\\', "\r", "\n", '"'), array("'", '/', ' ', ' ', "'"), $label);
|
||||
$evName = str_replace(array('"', '\\', "\r", "\n", '"'), array("'", '/', ' ', ' ', "'"), (string)$event['name']);
|
||||
|
||||
if ($i > 0) {
|
||||
echo ',{';
|
||||
} else {
|
||||
echo '{';
|
||||
}
|
||||
echo '"id" : "'.$i.'", ';
|
||||
echo '"table_id" : "'.$event['id'].'", '; // РЕАЛЬНЫЙ id события: завершение адресует конкретную задачу
|
||||
echo '"from" : "listing", '; // сигнал для setEventViewed-гарда: завершать в external_listing_events
|
||||
echo '"is_external" : "1", '; // явный маркер листинга: openEventsWindow откроет окно с &src=ext (id-диапазон больше не различает)
|
||||
echo '"start" : "'.date(DateTime::ATOM, strtotime($event['schedule_date'])).'", ';
|
||||
echo '"object_id" : "'.(int)$event['external_listing_id'].'",'; // реальный el.id: клик открывает окно задач листинга (openEventsWindow)
|
||||
|
||||
$className = ($event['type'] == 'meet') ? 'meet' : (($event['type'] == 'show') ? 'showing' : (($event['type'] == 'even') ? 'even' : 'call'));
|
||||
if ($event['calendar_view'] != 0) {
|
||||
$className .= ' viewed';
|
||||
}
|
||||
|
||||
if ($event['type'] == 'meet') {
|
||||
echo '"title": "Встреча '.$label.'","className" : "'.$className.'"';
|
||||
} else if ($event['type'] == 'show') {
|
||||
echo '"title": "Показ '.$label.'","className" : "'.$className.'"';
|
||||
} else if ($event['type'] == 'even') {
|
||||
echo '"title": "'.$evName.' '.$label.'","className" : "'.$className.'"';
|
||||
} else {
|
||||
echo '"title": "Звонок '.$label.'","className" : "'.$className.'"';
|
||||
}
|
||||
|
||||
echo "}";
|
||||
$i++;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM user_client_events WHERE user_id = $_SESSION[id] and schedule_date is not null and cancel=0 and $where and $startDateWhere and $endDateWhere";
|
||||
//echo $sql;
|
||||
$agencyId = User::getUserAgencyID();
|
||||
@ -141,7 +191,7 @@ if ($_SESSION['id']) {
|
||||
$fio = str_replace("\\","/", mysql_fetch_assoc($q_cl)['fio']);
|
||||
} else if($event['req_id'] > 0) {
|
||||
$sql_cl = "SELECT name from requisitions WHERE id=$event[req_id]";
|
||||
|
||||
|
||||
$q_cl = mysql_query($sql_cl);
|
||||
$fio = mysql_fetch_assoc($q_cl)['name'];
|
||||
}
|
||||
@ -227,28 +277,28 @@ if ($_SESSION['id']) {
|
||||
}
|
||||
|
||||
//if($_SESSION['id'] == 5238){
|
||||
if (isset($post['start'])) {
|
||||
// echo $post['start'];
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') >='".date('1930-m-d', strtotime($post['start']))."'";
|
||||
/*if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') >='01-01'";
|
||||
}*/
|
||||
}
|
||||
if (isset($post['start'])) {
|
||||
// echo $post['start'];
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') >='".date('1930-m-d', strtotime($post['start']))."'";
|
||||
/*if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') >='01-01'";
|
||||
}*/
|
||||
}
|
||||
|
||||
if (isset($post['end'])) {
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') < '".date('Y-m-d', strtotime($post['end']))."'";
|
||||
//echo date('m', strtotime($post['end']))."\n";
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') <='12-31'";
|
||||
}*/
|
||||
|
||||
}
|
||||
$sql = "SELECT id, fio, birthday FROM clients WHERE cancel=0 AND who_work = ".$_SESSION['id']." AND ".$startDateWhereBirthday." AND ".$endDateWhereBirthday;
|
||||
/* if($_SESSION['id'] == 5238){
|
||||
echo $sql;
|
||||
}*/
|
||||
$q = mysql_query($sql);
|
||||
while ($b = mysql_fetch_assoc($q)) {
|
||||
if (isset($post['end'])) {
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') < '".date('Y-m-d', strtotime($post['end']))."'";
|
||||
//echo date('m', strtotime($post['end']))."\n";
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') <='12-31'";
|
||||
}*/
|
||||
|
||||
}
|
||||
$sql = "SELECT id, fio, birthday FROM clients WHERE cancel=0 AND who_work = ".$_SESSION['id']." AND ".$startDateWhereBirthday." AND ".$endDateWhereBirthday;
|
||||
/* if($_SESSION['id'] == 5238){
|
||||
echo $sql;
|
||||
}*/
|
||||
$q = mysql_query($sql);
|
||||
while ($b = mysql_fetch_assoc($q)) {
|
||||
if ($i > 0) {
|
||||
echo ',{';
|
||||
} else {
|
||||
@ -265,62 +315,62 @@ if ($_SESSION['id']) {
|
||||
|
||||
echo '"client_id" : "'.$b['id'].'",';
|
||||
|
||||
//if ($event['type'] == 'call') {
|
||||
//if ($event['type'] == 'call') {
|
||||
|
||||
$className = "birthday";
|
||||
/* if ($event['calendar_view'] != 0) {
|
||||
$className .= " viewed";
|
||||
}*/
|
||||
$className = "birthday";
|
||||
/* if ($event['calendar_view'] != 0) {
|
||||
$className .= " viewed";
|
||||
}*/
|
||||
|
||||
echo '"title": "День рождения «'.$fio.'»","className" : "'.$className.'"';
|
||||
// }
|
||||
echo '"title": "День рождения «'.$fio.'»","className" : "'.$className.'"';
|
||||
// }
|
||||
echo "}";
|
||||
$i++;
|
||||
if(date('Y-', strtotime($post['start'])) != date('Y-', strtotime($post['end']))){
|
||||
if ($i > 0) {
|
||||
echo ',{';
|
||||
} else {
|
||||
echo '{';
|
||||
}
|
||||
$fio = $b['fio'];
|
||||
echo '"id" : "'.$i.'", ';
|
||||
echo '"table_id" : "'.$b['id'].'", ';
|
||||
echo '"start" : "'.date('Y-', strtotime($post['end'])).date('m-d', strtotime($b['birthday'])).'", ';
|
||||
if(date('Y-', strtotime($post['start'])) != date('Y-', strtotime($post['end']))){
|
||||
if ($i > 0) {
|
||||
echo ',{';
|
||||
} else {
|
||||
echo '{';
|
||||
}
|
||||
$fio = $b['fio'];
|
||||
echo '"id" : "'.$i.'", ';
|
||||
echo '"table_id" : "'.$b['id'].'", ';
|
||||
echo '"start" : "'.date('Y-', strtotime($post['end'])).date('m-d', strtotime($b['birthday'])).'", ';
|
||||
|
||||
echo '"client_id" : "'.$b['id'].'",';
|
||||
echo '"client_id" : "'.$b['id'].'",';
|
||||
|
||||
//if ($event['type'] == 'call') {
|
||||
|
||||
$className = "birthday";
|
||||
/* if ($event['calendar_view'] != 0) {
|
||||
$className .= " viewed";
|
||||
}*/
|
||||
$className = "birthday";
|
||||
/* if ($event['calendar_view'] != 0) {
|
||||
$className .= " viewed";
|
||||
}*/
|
||||
|
||||
echo '"title": "День рождения «'.$fio.'»","className" : "'.$className.'"';
|
||||
echo '"title": "День рождения «'.$fio.'»","className" : "'.$className.'"';
|
||||
// }
|
||||
echo "}";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// }
|
||||
echo "}";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
if (isset($post['start'])){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%Y-%m-%d') >= '".date('1930-m-d', strtotime($post['start']))."'";
|
||||
/* if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%m-%d') >= '01-01'";
|
||||
}*/
|
||||
/* if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%m-%d') >= '01-01'";
|
||||
}*/
|
||||
}
|
||||
|
||||
if (isset($post['end'])){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%Y-%m-%d') < '".date('Y-m-d', strtotime($post['end']))."'";
|
||||
|
||||
//echo date('m', strtotime($post['end']))."\n";
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%m-%d') <= '12-31'";
|
||||
}*/
|
||||
|
||||
//echo date('m', strtotime($post['end']))."\n";
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(employees.birthday, '%m-%d') <= '12-31'";
|
||||
}*/
|
||||
}
|
||||
|
||||
$userId = $_SESSION['id'];
|
||||
@ -398,16 +448,16 @@ if ($_SESSION['id']) {
|
||||
|
||||
if (isset($post['start'])){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') >='".date('1930-m-d', strtotime($post['start']))."'";
|
||||
/* if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') >='01-01'";
|
||||
}*/
|
||||
/* if (date('m', strtotime($post['start']))=='12' && (date('m', strtotime($post['end']))=='01' || date('m', strtotime($post['end']))=='02')){
|
||||
$startDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') >='01-01'";
|
||||
}*/
|
||||
}
|
||||
|
||||
if (isset($post['end'])){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%Y-%m-%d') < '".date('Y-m-d', strtotime($post['end']))."'";
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') <= '12-31'";
|
||||
}*/
|
||||
/* if (date('m', strtotime($post['end']))=='01' && (date('m', strtotime($post['start']))=='12' || date('m', strtotime($post['start']))=='11')){
|
||||
$endDateWhereBirthday = "DATE_FORMAT(birthday, '%m-%d') <= '12-31'";
|
||||
}*/
|
||||
}
|
||||
|
||||
$usersIds = User::getAllAgencyUsers($agencyId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user