getTimestamp())."'"; $who_work = 0; if(isset($_POST['who_work']) && (int)$_POST['who_work'] > 0){ $who_work = (int)$_POST['who_work']; } $req_id = 0; if(isset($_POST['req_id']) && $_POST['req_id'] > 0){ $req_id = (int)$_POST['req_id']; } $sql="SELECT * FROM clients WHERE id=$post[client_id]"; if($req_id > 0){ $sql="SELECT * FROM requisitions WHERE id=$req_id"; } $rez=mysql_query($sql); $client = mysql_fetch_assoc($rez); $idUser = $_SESSION['id']; if ($client['who_work'] > 0 && $client['doer_clients'] == 0) { // тому событие, чей клиент $idUser = $client['who_work']; } if($post['from_id']){ $idUser = $post['from_id']; if($post['from_id'] == 'not') $idUser = $_SESSION['id']; } if($who_work > 0){ $idUser = $who_work; } $from_id = $_SESSION['id']; $calendar_view = 0; if($post[noEvent]) $calendar_view = 1; $funnel_id = 0; $step_id = 0; if($client['funnel_id']) $funnel_id = (int)$client['funnel_id']; if($client['step_id']) $step_id = (int)$client['step_id']; $sql = "INSERT INTO user_client_events(user_id, client_id, type, comment, address, schedule_date, from_id, calendar_view, funnel_id, step_id) "; $sql .= " VALUES($idUser, $post[client_id], 'meet', '$post[comment]', '$post[address]', $scheduleDate, $from_id, $calendar_view, $funnel_id, $step_id)"; if($req_id > 0){ $sql = "INSERT INTO user_client_events(user_id, req_id, type, comment, address, schedule_date, from_id, calendar_view, funnel_id, step_id) "; $sql .= " VALUES($idUser, $req_id, 'meet', '$post[comment]', '$post[address]', $scheduleDate, $from_id, $calendar_view, $funnel_id, $step_id)"; } mysql_query($sql); }