Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Notifications extends EMongoDocument {
- /* Actions */
- CONST TYPE_LIKE = 'like';
- CONST TYPE_REPLY = 'reply';
- CONST TYPE_VOTE = 'vote';
- CONST TYPE_EVENT = 'event';
- CONST TYPE_REQUEST = 'request';
- CONST TYPE_REVOKE = 'revoke';
- CONST TYPE_NONE = 'none';
- CONST TYPE_UNLIKE = 'unlike';
- /* FILTER TYPE */
- CONST FILTER_UPDATE = 'update';
- CONST FILTER_LINK = 'link';
- CONST FILTER_QUESTION = 'question';
- CONST FILTER_POLL = 'poll';
- CONST FILTER_EVENT = 'event';
- CONST FILTER_LEAVE = 'leave';
- CONST FILTER_THUMBSUP = 'thumbsup';
- CONST FILTER_INVITE = 'invite';
- CONST FILTER_REQUEST = 'request';
- CONST FILTER_INVITE_GROUP = 'invite_group';
- CONST FILTER_SYSTEM_EVENT = 'system_event';
- CONST READ_STATUS_UNREAD = 0;
- CONST READ_STATUS_READ = 1;
- CONST NOTIFICATIONS = 'notifications';
- CONST REQUESTS = 'requests';
- CONST FILTER_SUB_NEWUSER = 'user';
- CONST FILTER_SUB_BIRTHDAY = 'birthday';
- CONST FILTER_SUB_ANNIVERSARY = 'anniversary';
- CONST FILTER_SUB_YEARS_SPENT = 'years_spent';
- CONST FILTER_ATTENDANCE = 'attendance';
- const FILTER_ATTEDANCE_REQUEST = 'attendance_request';
- CONST NOTIFICATION_REQUEST_LETTER = "request_letter";
- CONST NOTIFICATION_RESPONSE_LETTER = "response_letter";
- /* Notification categoires for sending emails */
- CONST NOTIFY_LEAVE_REQUEST = 'leave_request';
- CONST NOTIFY_LEAVE_RESPONSE = 'leave_response';
- CONST NOTIFY_REQUEST_OWNER = 'request_owner';
- CONST NOTIFY_REQUEST_USER = 'request_user';
- CONST NOTIFY_MESSAGE_LIKE = 'other_like_message';
- CONST NOTIFY_MESSAGE_REPLY = 'other_reply_message';
- CONST NOTIFY_MESSAGE_MENTION = 'other_mention';
- CONST NOTIFY_MESSAGE_PRIVATE = 'other_private_message';
- CONST NOTIFY_EVENT_SALARY = 'event_salary';
- CONST NOTIFY_EVENT_SPECIAL = 'special_event';
- CONST NOTIFY_REQUEST_EXPENSE = 'request_expense';
- CONST NOTIFY_RESPONSE_EXPENSE = 'response_expense';
- CONST NOTIFY_REQUEST_ATTENDANCE = 'request_attendance';
- CONST NOTIFY_RESPONSE_ATTENDANCE = 'response_attendance';
- CONST NOTIFY_RESET_PASSWORD = 'reset_password';
- CONST NOTIFY_CLOCKOUT_REMINDER = 'clockout_reminder';
- CONST NOTIFY_ASSIGN_SHIFT = 'assign_shift';
- CONST NOTIFY_LEAVE_ONBEHALF_REQUEST = 'leave_request_behalf';
- CONST NOTIFY_PAYROLL_SALARYSLIP = "payroll_salary_slip";
- CONST NOTIFICATION_ACTIVE = 1;
- CONST NOTIFICATION_INACTVE = 0;
- public $id; //uniqid()
- public $message_id;
- public $group_id;
- public $type;
- public $category; //Identifying what type of notification
- public $body;
- public $data = array();
- public $sender_id;
- public $recipient_id;
- public $isRequest = false;
- public $read_status;
- public $read_time;
- public $tenant_id;
- public $created;
- public $status = self::NOTIFICATION_ACTIVE;
- public $filter_type;
- public $is_for;
- /**
- * Returns the static model of the specified AR class.
- * @return UserPersonal the static model class
- */
- public static function model($className = __CLASS__) {
- return parent::model($className);
- }
- /**
- * @return string the associated collection name
- */
- public function getCollectionName() {
- return 'notifications';
- }
- public function primaryKey() {
- return 'id'; // Model field name, by default the _id field is used
- }
- /**
- * @return array validation rules for model attributes.
- */
- public function rules() {
- // NOTE: you should only define rules for those attributes that
- // will receive user inputs.
- return array(
- );
- }
- /**
- * @return array customized attribute labels (name=>label)
- */
- public function attributeLabels() {
- return array(
- );
- }
- /**
- * Populate default values for system fields
- */
- public function beforeSave() {
- if ($this->isNewRecord) {
- $this->id = uniqid();
- $this->tenant_id = ($this->tenant_id == null) ? Yii::app()->user->getTenantId() : $this->tenant_id;
- $this->created = new MongoDate(time());
- }
- return parent::beforeSave();
- }
- public function afterSave() {
- if ($this->isNewRecord) {
- $this->processSendEmails();
- }
- return parent::afterSave(); // parent::beforeSave();
- }
- public function processSendEmails() {
- $post_data = array();
- $attachment = array();
- $template_data_leaves_response = array();
- $template_data_attendace_update = array();
- $user = UserMongo::model()->tenant($this->tenant_id)->findByAttributes(array('user_id' => $this->recipient_id));
- $sender_user = UserMongo::model()->tenant($this->tenant_id)->findByAttributes(array('user_id' => $this->sender_id));
- $oldUser = null;
- if (!empty($user)) {
- $oldUser = $user->oldUser($this->tenant_id);
- }
- $tenant = Tenants::model()->findByPk($this->tenant_id);
- $subdomain = $tenant->tenant_subdomain;
- if ($user != null && $oldUser != null && ($this->sender_id == null || $user->isInSettingsNotify('notification', $this->category)) && $oldUser->isSelfService()) {
- //Data for sending email
- if ($this->sender_id == null) {
- $message_link = Yii::app()->createAbsoluteUrl('notifications/notifications');
- if ($this->category == Notifications::NOTIFY_EVENT_SALARY) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->data['month']);
- $message_data = $this->body;
- } else if ($this->category == Notifications::NOTIFY_RESPONSE_EXPENSE) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->data['status']);
- if(isset(Yii::app()->session['name_email']) && Yii::app()->session['name_email'] != "")
- {
- $subject_data = str_replace("Your",Yii::app()->session['name_email'],$subject_data);
- unset(Yii::app()->session['name_email']);
- }
- $message_data = $this->body;
- $message_link = Yii::app()->createAbsoluteUrl('notifications/requests');
- } else if ($this->category == Notifications::NOTIFY_CLOCKOUT_REMINDER) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), null);
- //$last_action = UserAttendance::getLastAction($user->id, $this->tenant_id);
- $today = strtotime(date('Y-m-d'));
- $last_log = UserAttendanceLog::getLastWorkingDayLog(($today - (24 * 3600)), $user->id, $this->tenant_id);
- if (!empty($last_log)) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), date('Y-m-d', $last_log->shift_date->sec));
- }
- $message_data = $this->body;
- $message_link = Yii::app()->createAbsoluteUrl('notifications/notifications');
- //reset link in case of cron
- if (Yii::app()->user->getTenantId() == null) {
- $tenants = Tenants::model()->findByPk($this->tenant_id);
- if (!empty($tenants)) {
- $subdomain = $tenants->tenant_subdomain;
- $domain_url = $subdomain . '.darwinbox.in';
- $message_link = str_replace('darwinbox.darwinbox.in', $domain_url, $message_link);
- }
- }
- } elseif ($this->category == Notifications::NOTIFY_ASSIGN_SHIFT) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), null);
- $message_data = Yii::app()->params['change_shift'];
- $message_link = Yii::app()->createAbsoluteUrl('notifications/notifications');
- }
- $template_data = array(
- 'tofullname' => $user->getFullname(),
- 'toemail' => $user->oldUser()->email,
- 'type' => $this->getType(),
- 'messagelink' => $message_link,
- 'messagedata' => $message_data,
- 'settingsurl' => null,
- 'created_date' => date("F d, Y", $this->created->sec),
- 'created_time' => date("h:i A", $this->created->sec),
- 'tenant' => $tenant->tenant_name,
- );
- } else {
- if ($this->category == self::NOTIFY_MESSAGE_REPLY || $this->category == self::NOTIFY_MESSAGE_LIKE) {
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender()->getFullname(), $this->getRootMessageType());
- } else {
- $messages = Messages::model()->findByPk($this->message_id);
- if (!empty($messages)) {
- /* leaves email changed as per new requirement */
- if ($messages->filter_type == "leave" && $this->isRequest == true) {
- /**/
- $from_date = strtotime($messages->attachments['items']['from_date']);
- $to_date = strtotime($messages->attachments['items']['to_date']);
- $datediff = $to_date - $from_date;
- $total_leaves_days_count = floor($datediff/(60*60*24)) + 1;
- /**/
- //$total_leaves_days_count = count($messages->attachments['items']['total_days']);
- //$total_working_days = count(RandomHelper::getWorkingDays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']),$sender_user->id,$sender_user->tenant_id));
- /**/
- $check_holiday = false;
- $check_weekly_off = false;
- $leave_type = $messages->attachments['items']['type'];
- $tenant_leaves_model = Leaves::model()->tenant()->findByPk($leave_type);
- if(isset($tenant_leaves_model) && !empty($tenant_leaves_model))
- {
- if($tenant_leaves_model->policy_count_intervening_holidays->status == Leaves::STATUS_ENABLE)
- {
- if(isset($tenant_leaves_model->policy_count_intervening_holidays->count_intervening_holidays['count_public_holiday']) && $tenant_leaves_model->policy_count_intervening_holidays->count_intervening_holidays['count_public_holiday'] == Leaves::STATUS_ENABLE)
- {
- $check_holiday = true;
- }
- if(isset($tenant_leaves_model->policy_count_intervening_holidays->count_intervening_holidays['count_weekly_off']) && $tenant_leaves_model->policy_count_intervening_holidays->count_intervening_holidays['count_weekly_off'] == Leaves::STATUS_ENABLE)
- {
- $check_weekly_off = true;
- }
- }
- }
- if($check_weekly_off && !$check_holiday)
- {
- $days_co = RandomHelper::getWorkingDaysIncludingWeeklyoff(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']),$sender_user->id,$sender_user->tenant_id);
- $holidays = RandomHelper::getHolidays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']), $this->tenant_id);
- $total_working_days = count(RandomHelper::excludeHolidays($days_co, $holidays));
- }
- /*else{
- $days_co = RandomHelper::getWorkingDays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']),$sender_user->id,$sender_user->tenant_id);
- }*/
- elseif($check_holiday && !$check_weekly_off)
- {
- $days_co = RandomHelper::getWorkingDays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']),$sender_user->id,$sender_user->tenant_id);
- $total_working_days = count($days_co);
- }
- elseif($check_holiday && $check_weekly_off)
- {
- $total_working_days = $total_leaves_days_count;
- }
- else
- {
- $days_co = RandomHelper::getWorkingDays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']),$sender_user->id,$sender_user->tenant_id);
- $holidays = RandomHelper::getHolidays(strtotime($messages->attachments['items']['from_date']),strtotime($messages->attachments['items']['to_date']), $this->tenant_id);
- $total_working_days = count(RandomHelper::excludeHolidays($days_co, $holidays));
- }
- /**/
- $total_non_working_days = $total_leaves_days_count - $total_working_days;
- if($total_leaves_days_count == 1)
- {
- $leave_id_for_user = $messages->attachments['items']['id'];
- $leave_object = UserLeaves::model()->findByPk($leave_id_for_user);
- if(isset($leave_object) && !empty($leave_object))
- {
- $is_half_day = $leave_object->is_half_day;
- if(isset($is_half_day) && $is_half_day == UserLeaves::HALF_DAY_YES)
- {
- $total_leaves_days_count = "Half Day";
- }
- }
- }
- $template_data_leaves = array(
- "leave_from_date" => $messages->attachments['items']['from_date'],
- "leave_to_date" => $messages->attachments['items']['to_date'],
- "leaves_total_days" => $total_leaves_days_count,
- "leaves_total_working_days" => $total_working_days,
- "leaves_total_non_working_days" => $total_non_working_days,
- "leaves_message_reason" => $messages->body_plain,
- "leaves_image_url" => "https://".$subdomain.".darwinbox.in" . Yii::app()->theme->baseUrl . "/images/leave.png",
- "leaves_leaves_name" => $messages->getLeaveType(),
- "leaves_user_image" => $messages->whosPhoto(),
- "url_approve" => "https://".$subdomain.".darwinbox.in/messages/LeaveActionEmailOrRequestPage/leave_id/" . $messages->attachments['items']['id'] . "/message_id/" . $messages->id . "/user_id/" . $user->user_id . "/action/approve",
- "url_decline" => "https://".$subdomain.".darwinbox.in/messages/LeaveActionEmailOrRequestPage/leave_id/" . $messages->attachments['items']['id'] . "/message_id/" . $messages->id . "/user_id/" . $user->user_id . "/action/decline",
- );
- } else {
- $template_data_leaves = array();
- }
- /* leaves email changed as per new requirement */
- /* attendance request email as per new requirement */
- if ($messages->filter_type == "attendance_request" && $this->isRequest == true) {
- /* getting location requested */
- if (isset($messages->attachments['items']['location']) && $messages->attachments['items']['location'] != "") {
- if ($messages->attachments['items']['location'] == UserAttendance::WORK_FROM_OFFICE) {
- $attendance_request_location = "Office";
- } elseif ($messages->attachments['items']['location'] == UserAttendance::WORK_FROM_HOME) {
- $attendance_request_location = "Home";
- } else {
- $attendance_request_location = "Field Duty";
- }
- } else {
- $attendance_request_location = "N.A.";
- }
- /* getting location requested */
- /*get logs for the same date previously stored*/
- if(isset($messages->attachments['items']['clock_in_timestamp']->sec) && $messages->attachments['items']['clock_in_timestamp']->sec != "")
- {
- $start = strtotime(date("Y-m-d", $messages->attachments['items']['clock_in_timestamp']->sec));
- $criteria = new EMongoCriteria();
- $criteria->user_id = $sender_user->id;
- $criteria->shift_date('==', new MongoDate($start));
- $user_attendance_log = UserAttendanceLog::model()->tenant($messages->tenant_id)->find($criteria);
- $attendance_request_punchin_time = (isset($user_attendance_log->punchin_time) && $user_attendance_log->punchin_time != "") ? $user_attendance_log->punchin_time : "N.A.";
- $attendance_request_punchout_time = (isset($user_attendance_log->punchout_time) && $user_attendance_log->punchout_time != "") ? $user_attendance_log->punchout_time : "N.A.";
- $attendance_request_previous_location = "Office";
- }
- else{
- $attendance_request_punchin_time = "N.A.";
- $attendance_request_punchout_time = "N.A.";
- $attendance_request_previous_location = "N.A.";
- }
- /*get logs for the same date previously stored*/
- $template_data_attendance_request = array(
- "attendance_request_user_image" => $messages->whosPhoto(),
- "attendance_request_clockin_time" => date("H:i:s, Y-m-d", $messages->attachments['items']['clock_in_timestamp']->sec),
- "attendance_request_clockout_time" => date("H:i:s, Y-m-d", $messages->attachments['items']['clock_out_timestamp']->sec),
- "attendance_request_location" => $attendance_request_location,
- "attendance_request_message_reason" => $messages->body_plain,
- "attendance_request_previous_clockin_time" => $attendance_request_punchin_time,
- "attendance_request_previous_clockout_time" => $attendance_request_punchout_time,
- "attendance_request_previous_location" => $attendance_request_previous_location,
- "attendance_request_image_url" => "https://".$subdomain.".darwinbox.in" . Yii::app()->baseUrl . "/images/icons/attendanceClock.png",
- //"attendance_request_leaves_name" => $messages->getLeaveType(),
- "attendance_request_url_approve" => "https://".$subdomain.".darwinbox.in/request/process/id/" . $messages->id ."/action/accept",
- "attendance_request_url_decline" => "https://".$subdomain.".darwinbox.in/request/process/id/" . $messages->id ."/action/reject",
- );
- } else {
- $template_data_attendance_request = array();
- }
- /* attendance request email as per new requirement */
- /* attendance clock in request email as per new requirement */
- if ($messages->filter_type == "attendance" && $this->isRequest == true) {
- /* getting location requested */
- if (isset($messages->attachments['items']['location']) && $messages->attachments['items']['location'] != "") {
- if ($messages->attachments['items']['location'] == UserAttendance::WORK_FROM_OFFICE) {
- $attendance_request_location = "Office";
- } elseif ($messages->attachments['items']['location'] == UserAttendance::WORK_FROM_HOME) {
- $attendance_request_location = "Home";
- } else {
- $attendance_request_location = "Field Duty";
- }
- } else {
- $attendance_request_location = "N.A.";
- }
- /* getting location requested */
- /*get logs for the same date previously stored*/
- if(isset($messages->attachments['items']['clock_in_timestamp']->sec) && $messages->attachments['items']['clock_in_timestamp']->sec != "")
- {
- $start = strtotime(date("Y-m-d", $messages->attachments['items']['clock_in_timestamp']->sec));
- $criteria = new EMongoCriteria();
- $criteria->user_id = $sender_user->id;
- $criteria->shift_date('==', new MongoDate($start));
- $user_attendance_log = UserAttendanceLog::model()->tenant($messages->tenant_id)->find($criteria);
- $attendance_request_punchin_time = (isset($user_attendance_log->punchin_time) && $user_attendance_log->punchin_time != "") ? $user_attendance_log->punchin_time : "N.A.";
- //$attendance_request_punchout_time = (isset($user_attendance_log->punchout_time) && $user_attendance_log->punchout_time != "") ? $user_attendance_log->punchout_time : "N.A.";
- if(isset($attendance_request_punchin_time) && $attendance_request_punchin_time != "N.A.")
- {
- $attendance_request_previous_location = "Office";
- }
- else{
- $attendance_request_previous_location = "N.A.";
- }
- }
- else{
- $attendance_request_punchin_time = "N.A.";
- //$attendance_request_punchout_time = "N.A.";
- $attendance_request_previous_location = "N.A.";
- }
- /*get logs for the same date previously stored*/
- $template_data_attendance_request_clock_in = array(
- "attendance_request_user_image" => $messages->whosPhoto(),
- "attendance_request_clockin_time" => date("H:i:s, Y-m-d", $messages->attachments['items']['clock_in_timestamp']->sec),
- //"attendance_request_clockout_time" => date("H:i:s, Y-m-d", $messages->attachments['items']['clock_out_timestamp']->sec),
- "attendance_request_location" => $attendance_request_location,
- "attendance_request_message_reason" => $messages->body_plain,
- "attendance_request_previous_clockin_time" => $attendance_request_punchin_time,
- //"attendance_request_previous_clockout_time" => $attendance_request_punchout_time,
- "attendance_request_previous_location" => $attendance_request_previous_location,
- "attendance_request_image_url" => "https://".$subdomain.".darwinbox.in" . Yii::app()->baseUrl . "/images/icons/attendanceClock.png",
- //"attendance_request_leaves_name" => $messages->getLeaveType(),
- "attendance_request_url_approve" => "https://".$subdomain.".darwinbox.in/request/process/id/" . $messages->id ."/action/accept",
- "attendance_request_url_decline" => "https://".$subdomain.".darwinbox.in/request/process/id/" . $messages->id ."/action/reject",
- );
- } else {
- $template_data_attendance_request_clock_in = array();
- }
- /* attendance clock in request email as per new requirement */
- /* Admin or Manager Responded on Leave Request*/
- if(isset($this->message_id) && $this->message_id!=''){
- $leave_attn_status = "responded to";
- // $messages = Messages::model()->findByPk($this->message_id);
- if($messages->filter_type == "leave" && $this->isRequest == FALSE){
- if(isset($messages->attachments['items']['status']) && $messages->attachments['items']['status'] == UserLeaves::STATUS_APPROVED){
- $leave_attn_status = "Approved";
- }else{
- $leave_attn_status = "Rejected";
- }
- $template_data_leaves_response = array(
- "leave_from_date" => $messages->attachments['items']['from_date'],
- "leave_to_date" => $messages->attachments['items']['to_date'],
- "leaves_message_reason" => $messages->body_plain,
- "leaves_image_url" => "https://".$subdomain.".darwinbox.in" . Yii::app()->theme->baseUrl . "/images/leave.png",
- "leaves_leaves_name" => $messages->getLeaveType(),
- "status"=>$leave_attn_status
- );
- }
- if(($messages->filter_type == "attendance" || $messages->filter_type =="attendance_request") && ($messages->message_type == "update" && $this->isRequest == FALSE) ){
- if(isset($messages->attachments['items']['status']) && $messages->attachments['items']['status'] == UserLeaves::STATUS_APPROVED){
- $leave_attn_status = "Approved";
- }else{
- $leave_attn_status = "Rejected";
- }
- if($messages->filter_type == "attendance"){
- $update_type ="Clock In";
- }else{
- $update_type ="Attendance Update";
- }
- $template_data_attendace_update = array(
- "clock_in_timestamp" => $messages->attachments['items']['clock_in_timestamp'],
- "clock_out_timestamp" => $messages->attachments['items']['clock_out_timestamp'],
- "status"=>$leave_attn_status,
- "update_type" => $update_type
- );
- }
- }
- /* EOF Admin or Manager Responded on Leave Request*/
- if (Yii::app()->user->id == $messages->sender_id) {
- if($this->category == self::NOTIFY_LEAVE_RESPONSE || $this->category == self::NOTIFY_RESPONSE_ATTENDANCE){
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender($this->tenant_id)->getFullname(),$leave_attn_status);
- }else{
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender($this->tenant_id)->getFullname());
- }
- } else {
- if ($messages->last_action == null) { //!= Notifications::TYPE_REQUEST && $messages->last_action != Notifications::TYPE_LIKE) {
- $applying_user = UserMongo::model()->findByAttributes(array('user_id' => Yii::app()->user->id));
- $appling_user_name = null;
- if (!empty($applying_user)) {
- $appling_user_name = $applying_user->getFullname();
- }
- $messageSenderUser = UserMongo::model()->findByAttributes(array("user_id" => $messages->sender_id));
- $message_sender_user = "";
- if (!empty($messageSenderUser)) {
- $message_sender_user = $messageSenderUser->getFullname();
- }
- $subject_data = sprintf(self::itemAlias('category', self::NOTIFY_LEAVE_ONBEHALF_REQUEST), $appling_user_name, $message_sender_user);
- } else {
- if($this->category == self::NOTIFY_LEAVE_RESPONSE || $this->category == self::NOTIFY_RESPONSE_ATTENDANCE){
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender($this->tenant_id)->getFullname(),$leave_attn_status);
- }else{
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender($this->tenant_id)->getFullname());
- }
- }
- }
- } else {
- $subject_data = sprintf(self::itemAlias('category', $this->category), $this->sender($this->tenant_id)->getFullname());
- }
- }
- //reset link in case of cron
- if ($this->category == self::NOTIFY_RESET_PASSWORD || $this->category == self::NOTIFY_ASSIGN_SHIFT) {
- $email_message_link = Yii::app()->createAbsoluteUrl('notifications/notifications');
- $subject_data = Yii::app()->params['change_shift'];
- } else {
- $email_message_link = ($this->message_id != null) ? Yii::app()->createAbsoluteUrl('messages/thread', array('id' => $this->message_id)) : Yii::app()->createAbsoluteUrl('notifications/requests');
- }
- $email_setting_url = Yii::app()->createAbsoluteUrl('employee/settings');
- if (Yii::app()->user->getTenantId() == null) {
- $tenants = Tenants::model()->findByPk($this->tenant_id);
- if (!empty($tenants)) {
- $subdomain = $tenants->tenant_subdomain;
- $domain_url = $subdomain . '.darwinbox.in';
- $email_message_link = str_replace('darwinbox.darwinbox.in', $domain_url, $email_message_link);
- $email_setting_url = str_replace('darwinbox.darwinbox.in', $domain_url, $email_message_link);
- }
- }
- $template_data = array(
- 'tofullname' => $user->getFullname(),
- 'toemail' => $user->oldUser()->email,
- 'type' => $this->getType(),
- 'messagelink' => $email_message_link, //($this->message_id != null) ? Yii::app()->createAbsoluteUrl('messages/thread', array('id' => $this->message_id)) : Yii::app()->createAbsoluteUrl('notifications/requests'),
- 'messagedata' => ($this->category == self::NOTIFY_RESET_PASSWORD ) ? $this->body : $subject_data,
- 'settingsurl' => $email_setting_url, //Yii::app()->createAbsoluteUrl('employee/settings'),
- 'created_date' => date("F d, Y", $this->created->sec),
- 'created_time' => date("h:i A", $this->created->sec),
- 'tenant' => (isset($tenant->tenant_name) && $tenant->tenant_name != "") ? $tenant->tenant_name : $tenant->tenant_subdomain,
- 'darwinbox_logo' => "https://".$subdomain.".darwinbox.in" . Yii::app()->baseUrl . "/images/darwinbox/darwinbox_logo.png",
- );
- }
- /*Check manager if not manager then dont send new emails which contains approve and decline button*/
- if(isset($template_data_leaves) && !empty($template_data_leaves))
- {
- $managers = $sender_user->getAllManagers();
- if(!in_array($this->recipient_id, $managers))
- {
- $template_data_leaves = array();
- }
- }
- /*Check manager if not manager then dont send new emails which contains approve and decline button*/
- if(!isset($template_data_leaves))
- {
- $template_data_leaves = array();
- }
- if(!isset($template_data_attendance_request))
- {
- $template_data_attendance_request = array();
- }
- if(!isset($template_data_attendance_request_clock_in))
- {
- $template_data_attendance_request_clock_in = array();
- }
- $_view = Yii::app()->controller->renderPartial("//emailTemplates/notification", array('data' => $template_data,'date_leaves_response'=>$template_data_leaves_response,'update_clockin_response'=>$template_data_attendace_update, 'data_leaves' => $template_data_leaves, 'data_attendance_request' => $template_data_attendance_request, 'template_data_attendance_request_clock_in' => $template_data_attendance_request_clock_in, 'tenant_id' => Yii::app()->user->getTenantId()), true);
- $tenant_name_email = (isset($tenant->tenant_name) && $tenant->tenant_name != "") ? $tenant->tenant_name : $tenant->tenant_subdomain;
- /*from email changing according to new email sending email ids*/
- if(isset($this->is_for) && ($this->is_for == Messages::MESSAGE_LIKE_DONE || $this->is_for == Messages::MESSAGE_SALARY_DONE || $this->is_for == Messages::MESSAGE_PRIVATE_EMAIL))
- {
- $from_email_final = $tenant_name_email." <alerts@darwinbox.in>";
- }
- else{
- $from_email_final = $tenant_name_email." <requests@darwinbox.in>";
- }
- /*from email changing according to new email sending email ids*/
- // making a check for reset password request
- $subject_data = ($this->category == self::NOTIFY_RESET_PASSWORD ) ? strip_tags($this->body) : $subject_data;
- // making a check for reset password request
- $emails = array(
- 'tofullname' => $user->getFullname(),
- 'toemail' => $user->oldUser()->email,
- 'fromemail' => $from_email_final,
- 'subject' => $subject_data,
- 'html' => $_view,
- );
- $encode_json = array("data" => json_encode($emails));
- $post_result = PostRequest::post_request("http://localhost/sendNotificationEmail", $encode_json, $attachment);
- if (isset($post_result['status']) && $post_result['status'] == 'ok') {
- EmailLogs::log(EmailLogs::TYPE_NOTIFICATION, $emails['toemail'], $emails['tofullname'], $emails['subject'], $_view, null, "sent", $this->message_id);
- } else {
- EmailLogs::log(EmailLogs::TYPE_NOTIFICATION, $emails['toemail'], $emails['tofullname'], $emails['subject'], $_view, null, "pending", $this->message_id);
- }
- }
- }
- public static function itemAlias($type, $code = NULL) {
- $_items = array(
- 'type' => array(
- self::TYPE_LIKE => 'likes',
- self::TYPE_REPLY => 'replied',
- self::TYPE_VOTE => 'voted',
- self::TYPE_EVENT => 'responded',
- self::TYPE_REQUEST => 'requested',
- ),
- 'filter' => array(
- self::FILTER_UPDATE => 'Update',
- self::FILTER_QUESTION => 'Question',
- self::FILTER_POLL => 'Poll',
- self::FILTER_EVENT => 'Event',
- self::FILTER_LEAVE => 'Leave',
- self::FILTER_INVITE => 'Invitation',
- self::FILTER_SYSTEM_EVENT => 'System',
- self::FILTER_ATTEDANCE_REQUEST => 'Attendance Request',
- self::FILTER_ATTENDANCE => 'Attendance Request'
- ),
- 'category' => array(
- self::NOTIFY_MESSAGE_MENTION => "You have been Mentioned by %s",
- self::NOTIFY_LEAVE_REQUEST => "Leave requested by %s",
- self::NOTIFY_LEAVE_RESPONSE => "%s has %s your Leave Request",
- self::NOTIFY_MESSAGE_LIKE => "%s likes your %s",
- self::NOTIFY_MESSAGE_PRIVATE => "%s has sent you a Private Message",
- self::NOTIFY_MESSAGE_REPLY => "%s has replied to your %s",
- self::NOTIFY_REQUEST_OWNER => "%s has invited you to join a Group",
- self::NOTIFY_REQUEST_USER => "%s has requested to join a Group",
- self::NOTIFY_EVENT_SALARY => "Your salary for the month of %s has been processed.",
- self::NOTIFY_REQUEST_EXPENSE => "%s has requested a reimbursement",
- self::NOTIFY_RESPONSE_EXPENSE => "Your expense request has been %s",
- self::NOTIFY_REQUEST_ATTENDANCE => "Attendance update requested By %s",
- self::NOTIFY_RESPONSE_ATTENDANCE => "%s has %s your Attendance Request",
- self::NOTIFY_RESET_PASSWORD => "%s has reset your password.",
- self::NOTIFY_CLOCKOUT_REMINDER => "You are marked absent for %s",
- self::NOTIFY_ASSIGN_SHIFT => "Assigned New Shift.",
- self::NOTIFY_LEAVE_ONBEHALF_REQUEST => "%s has applied for leave on behalf of %s",
- )
- );
- if (isset($code))
- return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
- else
- return isset($_items[$type]) ? $_items[$type] : false;
- }
- public function weekly() {
- $today = new MongoDate(strtotime(date('Y-m-d')));
- $last_week = new MongoDate(strtotime(date('Y-m-d', strtotime('-1 Week'))));
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'created' => array('<=' => $today),
- 'created' => array('>' => $last_week),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function daily() {
- $start = new MongoDate(strtotime(date('Y-m-d 00:00:00')));
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'created' => array('>=' => $start),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function tenant($tenant_id = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'tenant_id' => array('==' => ($tenant_id == null) ? Yii::app()->user->getTenantId() : $tenant_id),
- ),
- ));
- return $this;
- }
- public function getAll($type = null) {
- //$when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'isRequest' => array('==' => ($type == null) ? false : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'type'=> array('==' => self::FILTER_INVITE_GROUP),
- //'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllSender($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllArchieved($type = null) {
- $when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllArchievedSender($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessed($type = null) {
- $when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllProcessedSender($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllPending($type = null) {
- //$when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllPendingSender($type = null) {
- //$when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllPendingatt($type = null, $request_type = self::FILTER_ATTENDANCE, $user_id = null) {
- if ($user_id == null) {
- $user_id = Yii::app()->user->id;
- }
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'type'=> array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- //'type'=> array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- // 'type'=> array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- // 'type'=> array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllPendingattSender($type = null, $request_type = self::FILTER_ATTENDANCE, $user_id = null) {
- if ($user_id == null) {
- $user_id = Yii::app()->user->id;
- }
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllProcessedatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllProcessedattSender($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllArchievedatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- if ($request_type == self::FILTER_ATTENDANCE) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- } else {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- }
- return $this;
- }
- public function getAllPendingleav($type = null, $user_id = null) {
- if ($user_id == null) {
- $user_id = Yii::app()->user->id;
- }
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllPendingleavSender($type = null, $user_id = null) {
- if ($user_id == null) {
- $user_id = Yii::app()->user->id;
- }
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => $user_id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllProcessedleav($type = null) {
- $when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllProcessedleavSender($type = null) {
- $when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllArchievedleav($type = null) {
- $when = strtotime('-3 months');
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllleav($type = null) {
- if(Yii::app()->cache->executeCommand("hget", array(Yii::app()->user->getTenantId().":".Yii::app()->user->id,"Owner")))
- {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- else{
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- /* others filter */
- public function getAllPendingother($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllPendingotheratt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllPendingotherleav($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllPendingmeatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllPendingmeleav($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessedother($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessedotheratt($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessedotherleav($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessedmeatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllProcessedmeleav($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllArchievedother($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllArchievedotheratt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllArchievedotherleav($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllArchievedmeatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- $when = strtotime('-3 months');
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllArchievedmeleav($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllother($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllotheratt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllotherleav($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'sender_id' => array('!=' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllmeatt($type = null, $request_type = self::FILTER_ATTENDANCE) {
- if ($request_type == self::FILTER_ATTENDANCE) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTENDANCE),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- } else {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_ATTEDANCE_REQUEST),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- }
- return $this;
- }
- public function getAllmeleav($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'type' => array('==' => self::FILTER_LEAVE),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- /* others filter */
- /* ME filter */
- public function getAllPendingme($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllProcessedme($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'created' => array('>=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllArchievedme($type = null) {
- $when = strtotime('-3 months');
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'sender_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'created' => array('<=' => new MongoDate($when)),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getAllme($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- //'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- 'sender_id' => array('==' => Yii::app()->user->id),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- /* ME filter */
- public function getUnread($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_UNREAD),
- 'isRequest' => array('==' => ($type == null) ? FALSE : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function getRead($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'read_status' => array('==' => self::READ_STATUS_READ),
- 'isRequest' => array('==' => ($type == null) ? FALSE : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- public function isReceiver($user_id = null) {
- $user_id = ($user_id == null) ? Yii::app()->user->id : $user_id;
- //$user = User::model()->findByPk($user_id);
- $user = UserMongoView::model()->findByAttributes(array('user_id'=>$user_id));
- return ($user->id == $this->recipient_id) ? true : false;
- }
- public function isActive() {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'status' => array('==' => self::NOTIFICATION_ACTIVE),
- ),
- ));
- return $this;
- }
- public function isPending($status = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => ($status == null) ? self::READ_STATUS_UNREAD : self::READ_STATUS_READ),
- ),
- ));
- return $this;
- }
- public function isRequest($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'isRequest' => array('==' => ($type == null) ? false : true),
- ),
- ));
- return $this;
- }
- public function sortCreated($sort = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'sort' => array('created' => ($sort == null) ? EMongoCriteria::SORT_DESC : EMongoCriteria::SORT_ASC),
- ));
- return $this;
- }
- public static function getUnreadNotificationsCount() {
- $notifications = Notifications::model()->tenant()->getUnread()->isActive()->findAll();
- /* code below is not required as we can directly do count($notifications) */
- /* $unread = array();
- foreach ($notifications as $notification) {
- $unread[] = $notification;
- } */
- return count($notifications);
- }
- public static function displayNotifications($unreadCount = 0) {
- //$unreadCount = Notifications::getUnreadNotificationsCount();
- $unread = Notifications::model()->tenant()->getUnread()->isActive()->findAll();
- if ($unreadCount < 5) {
- $readCount = 5 - $unreadCount;
- $read = array();
- $readNotifications = Notifications::model()->tenant()->getRead()->isActive()->findAll();
- foreach ($readNotifications as $notification) {
- $read[] = $notification;
- $readCount--;
- if ($readCount == 0)
- break;
- }
- $unread = array_merge($unread, $read);
- } else {
- $temp = array();
- foreach ($unread as $n) {
- if (count($temp) < 5) {
- $temp[] = $n;
- }
- }
- $unread = $temp;
- }
- return $unread;
- }
- public static function getUnreadRequestsCount() {
- /* chnaging the complete logic as this is showing wrong count
- requests = Notifications::model()->tenant()->getUnread(Notifications::REQUESTS)->isActive()->findAll();
- return count($requests);*/
- /*for leaves*/
- /*$leave_data = array();
- $att_count = array();
- $reim_count = array();
- $grp_invite_count = array();*/
- // new comment
- // $requests = 0;
- // $criteria = new EMongoCriteria();
- // $criteria->tenant_id('==', Yii::app()->user->getTenantId());
- // $criteria->filter_type('==', Notifications::FILTER_LEAVE);
- // $criteria->attachments->items->status('==', UserLeaves::STATUS_PENDING);
- // $leave_data = Messages::model()->findAll($criteria);
- // foreach ($leave_data as $key => $value) {
- // if(!in_array(Yii::app()->user->id, $value->receiver_id))
- // unset($leave_data[$key]);
- // }
- // $leaves_count = count($leave_data);
- // /*for leaves*/
- // /*for attendance*/
- // $criteria = new EMongoCriteria();
- // $criteria->tenant_id('==', Yii::app()->user->getTenantId());
- // $criteria->addCond('filter_type','or', Notifications::FILTER_ATTENDANCE);
- // $criteria->addCond('filter_type','or', Notifications::FILTER_ATTEDANCE_REQUEST);
- // $criteria->attachments->items->status('==', Request::STATUS_PENDING);
- // $attendance_data = Messages::model()->findAll($criteria);
- // foreach ($attendance_data as $key => $value) {
- // if(!in_array(Yii::app()->user->id, $value->receiver_id))
- // unset($attendance_data[$key]);
- // }
- // $att_count = count($attendance_data);
- // /*for attendance*/
- // /*for reimbursement*/
- // $criteria = new EMongoCriteria();
- // $criteria->tenant_id('==', Yii::app()->user->getTenantId());
- // $criteria->status('==', UserExpenses::STATUS_PENDING);
- // $reimbursement_data = UserExpenses::model()->findAll($criteria);
- // foreach ($reimbursement_data as $key => $value) {
- // if(!in_array(Yii::app()->user->id, $value->recipients))
- // unset($reimbursement_data[$key]);
- // }
- // $reim_count = count($reimbursement_data);
- // /*for reimbursement*/
- // /**/
- // $criteria = new EMongoCriteria();
- // $criteria->tenant_id('==', Yii::app()->user->getTenantId());
- // $criteria->addCond('type','or', Notifications::FILTER_INVITE);
- // $criteria->addCond('type','or', Notifications::FILTER_INVITE_GROUP);
- // $criteria->recipient_id('==', Yii::app()->user->id);
- // $criteria->read_status('==', Notifications::READ_STATUS_UNREAD);
- // $group_invite_data = Notifications::model()->findAll($criteria);
- // $grp_invite_count = count($group_invite_data);
- // /**/
- // $requests = $leaves_count + $att_count + $reim_count + $grp_invite_count;
- $requests = 0 ;
- return $requests;
- }
- public static function displayRequests($unreadCount = 0) {
- //$unreadCount = Notifications::getUnreadRequestsCount();
- $unread = Notifications::model()->tenant()->getUnread(Notifications::REQUESTS)->isActive()->findAll();
- if ($unreadCount < 5) {
- $readCount = 5 - $unreadCount;
- $read = array();
- $readRequests = Notifications::model()->tenant()->getRead(Notifications::REQUESTS)->isActive()->findAll();
- foreach ($readRequests as $request) {
- $read[] = $request;
- $readCount--;
- if ($readCount == 0)
- break;
- }
- $unread = array_merge($unread, $read);
- } else {
- $temp = array();
- foreach ($unread as $n) {
- if (count($temp) < 5) {
- $temp[] = $n;
- }
- }
- $unread = $temp;
- }
- return $unread;
- }
- public function whosPhoto() {
- $user = UserMongo::model()->tenant()->findByAttributes(array('user_id' => $this->sender_id));
- return $user->getAvatarWithFullname();
- }
- public function getHumanTime() {
- if(isset($this->message_id) && $this->message_id != null && $this->category != "request_expense")
- {
- $message_data = Messages::model()->findByPk($this->message_id);
- if(isset($message_data) && !empty($message_data)){
- $to_return = $message_data->getHumanTime();
- return $to_return;
- }
- return RandomHelper::humanTiming($this->created->sec);
- }
- return RandomHelper::humanTiming($this->created->sec);
- }
- //Invitation
- public function generateInviteNotification($group_id, $user_id, $fromUser = false, $message_id = null) {
- $group = Groups::model()->tenant()->findByPk($group_id);
- //$user = User::model()->tenant()->findByPk($user_id);
- $notify = new Notifications;
- $notify->group_id = $group->id;
- $notify->isRequest = true;
- if (!$fromUser) {
- //Group Owner -> User
- $notify->category = Notifications::NOTIFY_REQUEST_OWNER;
- $notify->type = self::FILTER_INVITE;
- $notify->body = Yii::t('notifications', Yii::app()->params['groupinvite'], array('{username}' => $group->owner()->getUserLink(), '{groupname}' => $group->getURL()));
- $notify->sender_id = $group->getGroupOwner();
- $notify->recipient_id = $user_id;
- } else {
- //User -> Group Owner
- $notify->category = Notifications::NOTIFY_REQUEST_USER;
- $notify->type = self::FILTER_INVITE_GROUP;
- $notify->body = Yii::t('notifications', Yii::app()->params['groupjoinrequest'], array('{username}' => $user->mongo()->getUserLink(), '{groupname}' => $group->getURL()));
- $notify->sender_id = $user_id;
- $notify->recipient_id = $group->getGroupOwner();
- }
- $notify->read_status = Notifications::READ_STATUS_UNREAD;
- if ($notify->validate()) {
- $notify->save();
- }
- }
- //Special Events
- public function generateSpecialNotification($type, $user_id, $salary = null, $expense = null) {
- //$user = User::model()->tenant()->findByPk($user_id);
- $user_mongo = UserMongo::model()->tenant()->findByAttributes(array('user_id' => $user_id));
- $notify = new Notifications;
- $notify->isRequest = false;
- if ($type == Notifications::NOTIFY_EVENT_SALARY) {
- //Salary Paid Notification
- $salary = UserSalary::model()->findByPk($salary);
- if ($salary != null) {
- $notify->type = Notifications::FILTER_SYSTEM_EVENT;
- $notify->category = Notifications::NOTIFY_EVENT_SALARY;
- $notify->body = Yii::t('notifications', Yii::app()->params['event_salary'], array('{month}' => $salary->getPayMonth(), '{link}' => $salary->getPDFLink('here')));
- $notify->data = array('month' => $salary->getPayMonth(), 'amount' => $salary->total_net, 'link' => $salary->getPDFLink('here'));
- $notify->sender_id = null;
- $notify->recipient_id = $user_mongo->user_id;
- }
- } else if ($type == Notifications::NOTIFY_RESPONSE_EXPENSE) {
- $expense = UserExpenses::model()->tenant()->findByPk($expense);
- if ($expense != null) {
- $notify->type = Notifications::FILTER_SYSTEM_EVENT;
- $notify->category = Notifications::NOTIFY_RESPONSE_EXPENSE;
- if($expense->user_id == $user_mongo->id)
- {
- $name_email = 'Your';
- $notify->body = Yii::t('notifications', Yii::app()->params['expense_response'], array('{reimbursement}' => $expense->link(), '{status}' => UserExpenses::itemAlias('status', $expense->status)));
- }
- else
- {
- $requested_user = UserMongo::model()->tenant()->findByPk($expense->user_id);
- $requested_users_name = $requested_user->getFullname() . "'s";
- $body = Yii::t('notifications', Yii::app()->params['expense_response'], array('{reimbursement}' => $expense->link(), '{status}' => UserExpenses::itemAlias('status', $expense->status)));
- $new_body = str_replace("Your",$requested_users_name,$body);
- $notify->body = $new_body;
- $name_email = $requested_users_name;
- }
- $notify->data = array('approver' => Yii::app()->user->id, 'status' => UserExpenses::itemAlias('status', $expense->status));
- $notify->sender_id = null;
- $notify->recipient_id = $user_mongo->user_id;
- }
- }
- $notify->read_status = Notifications::READ_STATUS_UNREAD;
- if ($notify->validate()) {
- if(isset($name_email) && $name_email != "")
- {
- Yii::app()->session['name_email'] = $name_email;
- }
- $notify->save();
- }
- }
- //Expenses Request
- public function generateExpenseRequest($expense_id, $user_id, $manager_id) {
- $expense = UserExpenses::model()->tenant()->findByPk($expense_id);
- $user = UserMongo::model()->tenant()->findByPk($user_id);
- $notify = new Notifications;
- $notify->isRequest = true;
- $notify->category = Notifications::NOTIFY_REQUEST_EXPENSE;
- $notify->type = Notifications::FILTER_REQUEST;
- $notify->body = Yii::t('notifications', Yii::app()->params['expense_request'], array('{username}' => $user->getUserLink(), '{reimbursement}' => $expense->link(), '{expensename}' => $expense->title));
- $notify->sender_id = $user->user_id;
- $notify->recipient_id = $manager_id;
- $notify->data = array('expense' => $expense->id);
- $notify->read_status = Notifications::READ_STATUS_UNREAD;
- if ($notify->validate()) {
- $notify->save();
- }
- }
- //Announcement notification
- /**
- * @todo Remove if not in use
- */
- public function generateAnnouncementNotification() {
- $notify = new Notifications;
- $notify->isRequest = false;
- $notify->type = Notifications::FILTER_SYSTEM_EVENT;
- $notify->category = Notifications::NOTIFY_RESPONSE_EXPENSE;
- $notify->body = Yii::t('notifications', Yii::app()->params['expense_response'], array('{reimbursement}' => $expense->link(), '{status}' => UserExpenses::itemAlias('status', $expense->status)));
- $notify->data = array('approver' => Yii::app()->user->id, 'status' => UserExpenses::itemAlias('status', $expense->status));
- $notify->sender_id = null;
- $notify->recipient_id = $user->id;
- }
- public function fromTenant($user_id) {
- //$user = User::model()->findByPk($user_id);
- $user = UserMongoView::model()->tenant()->findByAttributes(array('user_id'=>$user_id));
- if ($this->tenant_id == $user->tenant->id) {
- return true;
- }
- return false;
- }
- public function getURL() {
- return Yii::app()->createUrl('messages/thread', array('id' => $this->message_id));
- }
- public function sender($tenant_id = null) {
- return UserMongo::model()->tenant($tenant_id)->findByAttributes(array('user_id' => $this->sender_id));
- }
- public function receiver() {
- return UserMongo::model()->tenant()->findByAttributes(array('user_id' => $this->recipient_id));
- }
- public function receiverLink() {
- $user = UserMongo::model()->tenant()->findByAttributes(array('user_id' => $this->recipient_id));
- return (!empty($user)) ? CHtml::link($user->getFullname(), Yii::app()->createUrl('employee/view', array('id' => $user->user_id))) : null;
- }
- public function getType() {
- return ($this->isRequest) ? "Request" : "Notification";
- }
- public function getRootMessageType() {
- $mes = Messages::model()->tenant()->findByPk($this->message_id)->getRootThread();
- return $mes->filter_type;
- }
- public function message() {
- $message = null;
- if ($this->message_id != null) {
- $message = Messages::model()->tenant()->findByPk($this->message_id);
- }
- return $message;
- }
- public function senderPhoto() {
- if ($this->sender_id == null) {
- $tenant = Tenants::model()->findByPk(Yii::app()->user->getTenantId());
- $baseUrl = Yii::app()->request->baseUrl;
- if ($tenant->logo != null) {
- $imgUrl = Yii::app()->createUrl('messages/showimage', array(
- 'filename' => urlencode($tenant->logo),
- 'adaptive' => 'true',
- 'width' => '25',
- 'height' => '25'
- )
- );
- } else {
- $imgUrl = Yii::app()->theme->baseUrl . '/images/darwinbox-25x25.png';
- }
- $photo = CHtml::image($imgUrl, 'Image', array('class' => 'profile'));
- } else {
- $photo = $this->sender()->getAvatarWithFullname();
- }
- return $photo;
- }
- /**
- * function to get cached notification object for the give tenant
- * @param number $tenant_id sql id
- * @param constant $read_status
- * @return object otification object
- */
- public static function getCachedNotifications($tenant_id, $read_status = Notifications::READ_STATUS_READ, $is_request = null) {
- if ($read_status == self::READ_STATUS_READ) {
- $cache_key = ($is_request == null) ? 'READ_NOTIFICATIONS_' . $tenant_id : 'REQUEST_READ_NOTIFICATIONS_' . $tenant_id;
- } else {
- $cache_key = ($is_request == null) ? 'UNREAD_NOTIFICATIONS_' . $tenant_id : 'REQUEST_UNREAD_NOTIFICATIONS_' . $tenant_id;
- }
- if (($cache = Yii::app()->cache) !== null) {
- if (($notifications = $cache->get($cache_key)) !== false) {
- return $notifications;
- } else {
- $notifications = ($read_status == Notifications::READ_STATUS_READ) ? Notifications::model()->tenant($tenant_id)->getRead($is_request)->isActive()->findAll() : Notifications::model()->tenant($tenant_id)->getUnread($is_request)->isActive()->findAll();
- if (!empty($notifications)) {
- //set cache
- $cache->set($cache_key, $notifications, 60);
- return $notifications;
- }
- }
- }
- $notifications = ($read_status == Notifications::READ_STATUS_READ) ? Notifications::model()->tenant($tenant_id)->getRead($is_request)->isActive()->findAll() : Notifications::model()->tenant($tenant_id)->getUnread($is_request)->isActive()->findAll();
- return $notifications;
- }
- /**
- * Genearate salary slip notification and send mail to user (salary slip link)
- * @param type $type constant
- * @param type $salary Id
- */
- public static function generateSalarySlipNotification($type, $salary_id = null) {
- $notify = new Notifications;
- $notify->isRequest = false;
- $salary = UserSalarySlip::model()->findByPk($salary_id);
- $user = UserMongo::model()->findByPk($salary->user_id);
- if (isset($user) && $type == Notifications::NOTIFY_EVENT_SALARY) {
- //Salary Paid Notification
- if ($salary != null) {
- $notify->type = Notifications::FILTER_SYSTEM_EVENT;
- $notify->category = Notifications::NOTIFY_EVENT_SALARY;
- $notify->body = Yii::t('notifications', Yii::app()->params['event_salary'], array('{month}' => $salary->for_month, '{link}' => $salary->getPDFLink('here')));
- $notify->data = array('month' => $salary->for_month, 'amount' => $salary->total_net, 'link' => $salary->getPDFLink('here'));
- $notify->sender_id = null;
- $notify->recipient_id = $user->user_id;
- $notify->is_for = Messages::MESSAGE_SALARY_DONE;
- }
- $notify->read_status = Notifications::READ_STATUS_UNREAD;
- if ($notify->validate()) {
- $notify->save();
- }
- }
- }
- public function getSender($sender_id) {
- $this->getDbCriteria()->mergeWith(
- array(
- 'conditions' => array(
- 'sender_id' => array('==' => $sender_id)
- )
- )
- );
- return $this;
- }
- public static function FilterAcctoReportees($requests) {
- $list_of_reportees = UserMongo::getReporteesUserId();
- if(isset($list_of_reportees) && !empty($list_of_reportees)){
- foreach ($requests as $key => $value) {
- if(isset($value->sender_id) && !in_array($value->sender_id, $list_of_reportees))
- {
- unset($requests[$key]);
- }
- }
- $requests = array_values($requests);
- return $requests;
- }
- else{
- $requests = array();
- return $requests;
- }
- }
- public function type($type) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'type' => array('==' => $type),
- ),
- ));
- return $this;
- }
- public function readStatus($read_status = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'read_status' => array('==' => ($read_status == null) ? self::READ_STATUS_UNREAD : $read_status),
- ),
- ));
- return $this;
- }
- public function getAllOnlyNotifications($type = null) {
- $this->getDbCriteria()->mergeWith(array(
- 'conditions' => array(
- 'recipient_id' => array('==' => Yii::app()->user->id),
- 'isRequest' => array('==' => ($type == null) ? false : true),
- ),
- 'sort' => array('created' => EMongoCriteria::SORT_DESC),
- ));
- return $this;
- }
- //Hr Letter Request
- public function generateLetterRequest($request_id, $user_id, $manager_id) {
- $user = UserMongo::model()->tenant()->findByPk($user_id);
- $notify = new Notifications;
- $notify->isRequest = true;
- $notify->category = Notifications::NOTIFICATION_REQUEST_LETTER;
- $notify->type = Notifications::FILTER_REQUEST;
- $notify->body = Yii::t('notifications', Yii::app()->params['letter_request'], array('{username}' => $user->getUserLink(), '{hrletter}' => $request_id->link(), '{lettername}' => $request_id->name));
- $notify->sender_id = $user->user_id;
- $notify->recipient_id = $manager_id;
- $notify->data = array('hrletter' => $request_id->id);
- $notify->read_status = Notifications::READ_STATUS_UNREAD;
- if ($notify->validate()) {
- $notify->save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement