public function sendProductActionMail($p_id, $action, $input_arr) { $product_details = Product::whereRaw('id = ?', array($p_id))->first(); $user_details = CUtil::getUserDetails($product_details->product_user_id); $product_code = $product_details->product_code; $url_slug = $product_details->url_slug; $view_url = $this->getProductViewURL($product_details->id, $product_details); $user_type = CUtil::isSuperAdmin() ? 'Admin' : 'Staff'; $logged_user_id = isLoggedin() ? getAuthUser()->user_id : 0; $staff_details = CUtil::getUserDetails($logged_user_id); $data = array('product_code' => $product_details['product_code'], 'product_name' => $product_details['product_name'], 'display_name' => $user_details['display_name'], 'user_email' => $user_details['email'], 'action' => $action, 'view_url' => $view_url, 'admin_notes' => isset($input_arr['comment']) ? $input_arr['comment'] : '', 'user_type' => $user_type); $data['product_details'] = $product_details; $data['user_details'] = $user_details; $data['staff_details'] = $staff_details; //Mail to User Mail::send('emails.mp_product.productStatusUpdate', $data, function ($m) use($data) { $m->to($data['user_email']); $subject = str_replace('VAR_PRODUCT_CODE', $data['product_code'], trans('email.productStatusUpdate')); $m->subject($subject); }); //Send mail to admin $mailer = new AgMailer(); $data['subject'] = str_replace('VAR_PRODUCT_CODE', $data['product_code'], trans('email.productStatusUpdateAdmin')); $mailer->sendAlertMail('mp_product_status_update', 'emails.mp_product.productStatusUpdateAdmin', $data); }
public function sendProductConversationMail($product_details = array(), $thread_id = 0, $key = 'NewComment', $message_id = 0, $reference_id = 0) { $thread_details_arr = MpProductComments::whereRaw("id = ?", array($thread_id))->first(); if (count($product_details) == 0 || count($thread_details_arr) == 0) { return ''; } $email_template = 'emails.mp_product.productCommentAddedNotify'; /* switch($key) { case 'NewComment': $email_template .= 'requestNewMessage'; break; case 'MessageOwnerReply': $email_template .= 'requestMessageOwnerReply'; break; case 'MessageUserReply': $email_template .= 'requestMessageUserReply'; break; case 'deleteThread': $email_template .= 'requestDeleteThread'; break; case 'deleteThreadReply': $email_template .= 'requestDeleteThreadReply'; break; default: return ''; } */ $view_product_link = $this->getProductViewURL($product_details->id, $product_details); $thread_link = $view_product_link . '?thread=' . $thread_id; $message_details_arr = array(); //To get user information $from_id = $this->logged_user_id; $to_id = $product_details['product_user_id'] == $from_id ? $thread_details_arr['user_id'] : $thread_details_arr['seller_id']; $from_user_details = CUtil::getUserDetails($from_id, 'all'); $to_user_details = CUtil::getUserDetails($to_id, 'all'); //To get seller details $owner_details = array(); if ($from_id == $product_details['product_user_id']) { $owner_details = $from_user_details; } elseif ($to_id == $product_details['product_user_id']) { $owner_details = $to_user_details; } else { $owner_details = CUtil::getUserDetails($product_details['product_user_id'], 'all'); } //To get commenter details $commenter_details = array(); if ($from_id == $thread_details_arr['user_id']) { $commenter_details = $from_user_details; } elseif ($to_id == $thread_details_arr['user_id']) { $commenter_details = $to_user_details; } else { $commenter_details = CUtil::getUserDetails($thread_details_arr['user_id'], 'all'); } $visibility_text = $thread_details_arr['visibility'] == "Public" ? "Public" : "Private"; //Get replied message details $notes = $thread_details_arr['message']; if ($message_id > 0) { //To get message details if already not fetched.. if (count($message_details_arr) == 0) { $message_details_arr = MpProductCommentReplies::whereRaw("id = ?", array($message_id))->first(); if (count($message_details_arr) > 0) { $notes = $message_details_arr['notes']; if ($message_details_arr['visibility_status'] == 'Private') { $visibility_text = trans('mp_product/viewProduct.private_msg_for'); $visibility_text .= $to_user_details['display_name']; $visibility_text .= " By." . $from_user_details['display_name']; } } } } //To assign mail data's.. $mail_subject_lang = 'email.product_' . snake_case($key); $user_mail_sub = trans($mail_subject_lang . '_notify_user'); $admin_mail_sub = trans($mail_subject_lang . '_notify_admin'); // $ack_mail_sub = trans($mail_subject_lang.'NotifyACK'); $data_arr = array('product_title' => $product_details['product_name'], 'from_user_name' => $from_user_details['display_name'], 'to_user_name' => $to_user_details['display_name'], 'from_profile_url' => $from_user_details['profile_url'], 'to_profile_url' => $to_user_details['profile_url'], 'view_product_link' => $view_product_link, 'thread_link' => $thread_link, 'notes' => $notes, 'visibility' => $visibility_text, 'product_details' => $product_details, 'owner_details' => $owner_details, 'commenter_details' => $commenter_details, 'user_subject' => str_replace('VAR_PRODUCT_TITLE', $product_details['product_name'], $user_mail_sub), 'to_user_mail' => $to_user_details['email'], 'admin_subject' => str_replace('VAR_PRODUCT_TITLE', $product_details['product_name'], $admin_mail_sub), 'admin_email_template' => $email_template . 'ForAdmin', 'user_email_template' => $email_template . 'ForUser', 'key' => $key); //Mail to admin $mailer = new AgMailer(); $data_arr['subject'] = $data_arr['admin_subject']; $mailer->sendAlertMail('product_comment', $data_arr['admin_email_template'], $data_arr); if (isset($to_user_details['email']) && $to_user_details['email'] != "" && $from_id != $to_id) { $data_arr['subject'] = $data_arr['user_subject']; $data_arr['to_email'] = $to_user_details['email']; $mailer->sendUserMail('product_comment', $data_arr['user_email_template'], $data_arr); } }