public function fetchUserDetails($ident, $type) { $user_details = array(); $user_details['err_msg'] = ''; $user_details['own_profile'] = 'No'; $search_cond = "users.id = '" . addslashes($ident) . "'"; if ($type == 'code') { $search_cond = " users.user_code = '" . addslashes($ident) . "'"; } $udetails = User::whereRaw($search_cond)->first(array('users.first_name', 'users.user_code', 'users.id', 'users.last_name', 'users.email', 'users.activated', 'users.activated_at', 'users.last_login', 'users.about_me', 'users.user_status', 'users.user_access', 'users.phone')); if (count($udetails) > 0) { $user_details['user_code'] = $udetails['user_code']; $user_details['email'] = $udetails['email']; $user_details['user_id'] = $user_id = $udetails['id']; $user_details['first_name'] = $udetails['first_name']; $user_details['last_name'] = $udetails['last_name']; $user_display_name = $udetails['first_name'] . ' ' . substr($udetails['last_name'], 0, 1); $user_details['display_name'] = ucwords($user_display_name); $user_details['activated_at'] = $udetails['activated_at']; $user_details['last_login'] = $udetails['last_login']; $user_details['activated'] = $udetails['activated']; $user_details['phone'] = $udetails['phone']; $user_details['about_me'] = $udetails['about_me']; if ($udetails['activated'] == 0) { $user_details['user_status'] = "ToActivate"; } elseif ($udetails['user_status'] == "Deleted") { $user_details['user_status'] = "Locked"; } else { $user_details['user_status'] = $udetails['user_status']; } $user_details['user_access'] = $udetails['user_access']; $admin_profile_url = CUtil::getUserDetails($user_id, 'admin_profile_url', $user_details); $user_details['profile_url'] = $admin_profile_url; $user_groups = $this->fetchUserGroupNames($user_details['user_id']); $user_details['user_groups'] = $user_groups; } else { $user_details['err_msg'] = 'No such user found'; $user_details['profile_url'] = ''; } return $user_details; }
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); } }
public function postProductActions() { $action = \Input::get('action'); $p_id = \Input::get('product_id'); switch ($action) { case 'save_product_thumb_image_title': $title = \Input::get('product_image_title'); echo $this->productService->saveProductImageTitle($p_id, 'thumb', $title) ? 'success' : 'error'; $this->productService->updateProductStatus($p_id, 'Draft'); exit; break; case 'save_product_default_image_title': $title = \Input::get('product_image_title'); echo $this->productService->saveProductImageTitle($p_id, 'default', $title) ? 'success' : 'error'; $this->productService->updateProductStatus($p_id, 'Draft'); exit; break; case 'upload_product_thumb_image': $title = \Input::get('product_image_title'); $this->productAddService->product_media_type = 'image'; $this->productAddService->setAllowedUploadFormats('thumb'); $this->productAddService->setMaxUploadSize('thumb'); $file_info = array(); $file = \Input::file('uploadfile'); $upload_file_name = $file->getClientOriginalName(); $upload_status = $this->productAddService->uploadMediaFile('uploadfile', 'image', $file_info); if ($upload_status['status'] == 'success') { $this->productService->updateItemProductImage($p_id, $title, $file_info); $image_dim = CUtil::DISP_IMAGE(145, 145, $file_info['t_width'], $file_info['t_height'], true); echo json_encode(array('status' => 'success', 'server_url' => $file_info['server_url'], 'filename' => $file_info['filename_no_ext'] . 'T.' . $file_info['ext'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title'])); $this->productService->updateProductStatus($p_id, 'Draft'); } else { echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name)); } exit; break; case 'upload_item_default_image': $title = \Input::get('product_image_title'); $this->productAddService->product_media_type = 'image'; $this->productAddService->setAllowedUploadFormats('default'); $this->productAddService->setMaxUploadSize('default'); $file_info = array(); $file = \Input::file('uploadfile'); $upload_file_name = $file->getClientOriginalName(); $upload_status = $this->productAddService->uploadMediaFile('uploadfile', 'image', $file_info); if ($upload_status['status'] == 'success') { $this->productService->updateProductDefaultImage($p_id, $title, $file_info); $image_dim = CUtil::DISP_IMAGE(578, 385, $file_info['l_width'], $file_info['l_height'], true); echo json_encode(array('status' => 'success', 'server_url' => $file_info['server_url'], 'filename' => $file_info['filename_no_ext'] . 'L.' . $file_info['ext'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title'])); $this->productService->updateProductStatus($p_id, 'Draft'); } else { echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name)); } exit; break; case 'remove_default_thumb_image': echo $this->productService->removeProductThumbImage($p_id) ? 'success' : 'error'; $this->productService->updateProductStatus($p_id, 'Draft'); exit; break; case 'remove_default_image': echo $this->productService->removeProductDefaultImage($p_id) ? 'success' : 'error'; $this->productService->updateProductStatus($p_id, 'Draft'); exit; break; case 'upload_resource_preview': // images on the image tab $resource_type = \Input::get('resource_type'); $this->productAddService->setProductPreviewType($p_id); $this->productAddService->setAllowedUploadFormats('preview'); $this->productAddService->setMaxUploadSize('preview'); $resource_count = ProductResource::whereRaw('product_id = ? AND resource_type = ? ', array($p_id, $this->productAddService->product_media_type))->count(); if ($resource_count < \Config::get('webshoppack::preview_max')) { $file_info = array(); $file = \Input::file('uploadfile'); $upload_file_name = $file->getClientOriginalName(); $upload_status = $this->productAddService->uploadMediaFile('uploadfile', $this->productAddService->product_media_type, $file_info); if ($upload_status['status'] == 'success') { $resource_arr = array('product_id' => $p_id, 'resource_type' => $resource_type, 'filename' => $file_info['filename_no_ext'], 'ext' => $file_info['ext'], 'title' => $file_info['title'], 'width' => $file_info['width'], 'height' => $file_info['height'], 't_width' => $file_info['t_width'], 't_height' => $file_info['t_height'], 'l_width' => $file_info['l_width'], 'l_height' => $file_info['l_height'], 'server_url' => $file_info['server_url'], 'is_downloadable' => $file_info['is_downloadable']); $resource_id = $this->productService->insertResource($resource_arr); $image_dim = CUtil::DISP_IMAGE(74, 74, $file_info['t_width'], $file_info['t_height'], true); $this->productService->updateProductStatus($p_id, 'Draft'); echo json_encode(array('status' => 'success', 'resource_type' => ucwords($resource_type), 'server_url' => $file_info['server_url'], 'filename' => $file_info['file_thumb'], 't_width' => $image_dim['width'], 't_height' => $image_dim['height'], 'title' => $file_info['title'], 'resource_id' => $resource_id)); } else { echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name)); } } else { echo json_encode(array('status' => 'error', 'error_message' => trans('webshoppack::products_max_file'), 'filename' => '')); } exit; break; case 'save_resource_title': $row_id = \Input::get('row_id'); $resource_title = \Input::get('resource_title'); echo $this->productService->updateProductResourceImageTitle($row_id, $resource_title) ? 'success' : 'error'; $this->productService->updateProductStatus($p_id, 'Draft'); exit; break; case 'delete_resource': $row_id = \Input::get('row_id'); if ($this->productService->deleteProductResource($row_id)) { $this->productService->updateProductStatus($p_id, 'Draft'); echo json_encode(array('result' => 'success', 'row_id' => $row_id)); } else { echo json_encode(array('result' => 'failed', 'row_id' => $row_id)); } exit; break; case 'order_resource': $resourcednd_arr = \Input::get('resourcednd'); $this->productService->updateProductResourceImageDisplayOrder($resourcednd_arr); // set status is not called since only re-ordering exit; break; case 'upload_resource_file': // the download file in zip format $resource_type = 'Archive'; $this->productAddService->product_media_type = 'archive'; $this->productAddService->setAllowedUploadFormats('archive'); $this->productAddService->setMaxUploadSize('archive'); $resource_count = ProductResource::whereRaw('product_id = ? AND resource_type = ? ', array($p_id, $this->productAddService->product_media_type))->count(); if ($resource_count == 0) { $file_info = array(); $file = \Input::file('uploadfile'); $upload_file_name = $file->getClientOriginalName(); $upload_status = $this->productAddService->uploadMediaFile('uploadfile', $this->productAddService->product_media_type, $file_info, true); if ($upload_status['status'] == 'success') { $resource_arr = array('product_id' => $p_id, 'resource_type' => $resource_type, 'server_url' => $file_info['server_url'], 'filename' => $file_info['filename_no_ext'], 'ext' => $file_info['ext'], 'title' => $file_info['title'], 'width' => $file_info['width'], 'height' => $file_info['height'], 't_width' => $file_info['t_width'], 't_height' => $file_info['t_height'], 'l_width' => $file_info['l_width'], 'l_height' => $file_info['l_height'], 'is_downloadable' => $file_info['is_downloadable']); $resource_id = $this->productService->insertResource($resource_arr); if ($file_info['title'] != '') { $download_filename = preg_replace('/[^0-9a-z\\.\\_\\-)]/i', '', $file_info['title']) . '.' . $file_info['ext']; } else { $download_filename = md5($p_id) . '.' . $file_info['ext']; } echo json_encode(array('status' => 'success', 'server_url' => $file_info['server_url'], 'download_url' => \URL::action('Agriya\\Webshoppack\\AdminProductAddController@getProductActions') . '?action=download_file&product_id=' . $p_id, 'filename' => $download_filename, 't_width' => $file_info['t_width'], 't_height' => $file_info['t_height'], 'title' => $file_info['title'], 'resource_id' => $resource_id, 'is_downloadable' => $file_info['is_downloadable'])); $this->productService->updateProductStatus($p_id, 'Draft'); } else { echo json_encode(array('status' => 'error', 'error_message' => $upload_status['error_message'], 'filename' => $upload_file_name)); } } else { echo json_encode(array('status' => 'error', 'error_message' => trans('webshoppack::product.products_max_file'), 'filename' => '')); } exit; break; case 'check_user': $user_code = \Input::get('user_code'); $user_id = CUtil::getUserId($user_code); if ($user_id != "") { $user_details = CUtil::getUserDetails($user_id); if (count($user_details) > 0) { if (!$this->productAddService->checkIsShopOwner($user_id)) { echo json_encode(array('status' => 'error', 'message' => trans('webshoppack::product.invalid_seller_usercode'))); } else { $section_options = $this->productAddService->getProductUserSections($user_id); echo json_encode(array('status' => 'success', 'section_options' => $section_options)); } } else { echo json_encode(array('status' => 'error', 'message' => trans('webshoppack::product.invalid_user_code'))); } } else { echo json_encode(array('status' => 'error', 'message' => trans('webshoppack::product.invalid_user_code'))); } exit; break; } }
public function sendNotificationMailForAdmin($p_id, $arr) { $arr['product_details'] = isset($arr['product_details']) ? $arr['product_details'] : Product::where('id', $p_id)->first(); $arr['user_details'] = isset($arr['user_details']) ? $arr['user_details'] : CUtil::getUserDetails($arr['product_details']->product_user_id); $view_url = $this->getProductViewURL($p_id, $arr['product_details']); $arr['product_details']['view_url'] = $view_url; $arr['product_details']['product_status_lang'] = $this->getProductStatusLang($arr['product_details']['product_status']); $arr['product_details']['product_notes'] = $this->getUserLastProductNote($p_id); $category_list = $this->retriveSingleCategoryPath($arr['product_details']['product_category_id']); $category_arr = array(); foreach ($category_list as $cat) { $category_arr[] = $cat->category_name; } $category_arr = array_slice($category_arr, 1); //To remove root category $arr['product_details']['category'] = implode(' / ', $category_arr); $arr['product_details']['product_price'] = $arr['product_details']['product_price']; $arr['product_details']['product_discount_price'] = $arr['product_details']['product_discount_price']; $arr['product_details']['product_price_currency'] = $arr['product_details']['product_price_currency']; $subject = trans('webshoppack::product.product_created_published_admin'); if ($arr['product_details']['product_status'] == 'ToActivate') { $subject = trans('webshoppack::product.product_created_to_activate_admin'); } elseif ($arr['product_details']['product_status'] == 'NotApproved') { $subject = trans('webshoppack::product.product_created_disapprove_admin'); } $arr['subject'] = $subject; $arr['admin_email'] = \Config::get('webshoppack::admin_email'); \Mail::send('webshoppack::emails.productCreatedAdmin', $arr, function ($m) use($arr) { $m->to($arr['admin_email']); $m->subject($arr['subject']); }); }
@extends('layouts.base') @section('content') @if (isset($error_msg) && $error_msg != "") <div class="alert alert-danger">{{ $error_msg }}</div> @elseif (isset($success_msg) && $success_msg != "") <div class="alert alert-success">{{ $success_msg }}</div> @if(Sentry::check()) <?php $profile_url = CUtil::getUserDetails(Sentry::getUser()->user_id, 'profile_url'); ?> <a itemprop="url" href="{{ URL::to('users/my-account') }}"><strong>{{trans("myaccount/form.email-activation.my_settings")}}</strong></a> @else <a itemprop="url" href="{{ URL::to('users/login') }}"><strong>{{trans('index.login')}}</strong></a> @endif @endif @stop