update v1.0.5

This commit is contained in:
sujitprasad
2016-01-25 20:45:35 +05:30
parent 0b8ebb9c70
commit e7149e34e4
252 changed files with 9008 additions and 3152 deletions

View File

@@ -2,6 +2,7 @@
// controllers
use App\Http\Controllers\Controller;
// Model
use App\User;
use App\Model\helpdesk\Settings\Company;
@@ -10,8 +11,12 @@ use App\Model\helpdesk\Agent\Department;
use App\Model\helpdesk\Utility\Log_notification;
use App\Model\helpdesk\settings\Email;
// classes
use Exception;
/**
* UserController
* NotificationController
* This controller is used to send daily notifications
*
* @package Controllers
* @subpackage Controller
@@ -21,20 +26,27 @@ class NotificationController extends Controller {
/**
* This function is for sending daily report/notification about the system
* @return mail
**/
public function send_notification() {
//fetching email settings
$email = Email::where('id','=','1')->first();
// checking if the daily notification is enabled or not
if($email->notification_cron == 1){
// checking if current date is equal to the last entered daily notification log
$notification = Log_notification::where('log','=','NOT-1')->orderBy('id','DESC')->first();
$date = explode(" " , $notification->created_at);
if(Date('Y-m-d') == $date[0]){
} else {
// creating a daily notification log
Log_notification::create(['log'=>'NOT-1']);
$company = $this->company();
// Send notification details to admin
$this->send_notification_to_admin($company);
// Send notification details to team lead
$this->send_notification_to_team_lead($company);
// Send notification details to manager of a department
$this->send_notification_to_manager($company);
// Send notification details to all the agents
$this->send_notification_to_agent($company);
}
}
@@ -49,6 +61,7 @@ class NotificationController extends Controller {
// get all admin users
$users = User::where('role','=','admin')->get();
foreach ($users as $user) {
// Send notification details to admin
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.admin', ['company' => $company, 'name'=>$user_name], function ($message)use ($email, $user_name, $company) {
@@ -62,12 +75,14 @@ class NotificationController extends Controller {
* @return mail
**/
public function send_notification_to_manager($company) {
// get all department managers
$depts = Department::all();
foreach ($depts as $dept) {
if(isset($dept->manager)) {
$dept_name = $dept->name;
$users = User::where('id','=',$dept->manager)->get();
foreach ($users as $user) {
// Send notification details to manager of a department
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.manager', ['company' => $company, 'name'=>$user_name,'dept_id' => $dept->id, 'dept_name' => $dept->name], function ($message)use ($email, $user_name, $company, $dept_name) {
@@ -83,12 +98,14 @@ class NotificationController extends Controller {
* @return mail
**/
public function send_notification_to_team_lead($company) {
// get all Team leads
$teams = Teams::all();
foreach ($teams as $team) {
if(isset($team->team_lead)) {
$team_name = $team->name;
$users = User::where('id','=',$team->team_lead)->get();
foreach ($users as $user) {
// Send notification details to team lead
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.lead', ['company' => $company, 'name'=>$user_name,'team_id' => $team->id], function ($message)use ($email, $user_name, $company, $team_name) {
@@ -107,6 +124,7 @@ class NotificationController extends Controller {
// get all agents users
$users = User::where('role','=','agent')->get();
foreach ($users as $user) {
// Send notification details to all the agents
$email = $user->email;
$user_name = $user->first_name . " " . $user->last_name;
\Mail::send('emails.notifications.agent', ['company' => $company, 'name'=>$user_name, 'user_id' => 1], function ($message)use ($email, $user_name, $company) {
@@ -116,12 +134,13 @@ class NotificationController extends Controller {
}
/**
* company
* @return type
* Fetching company name
* @return type variable
*/
public function company()
{
public function company() {
// fetching comapny model
$company = Company::Where('id','=','1')->first();
// fetching company name
if($company->company_name == null){
$company = "Support Center";
}else{
@@ -130,12 +149,13 @@ class NotificationController extends Controller {
return $company;
}
public function test(){
$email = "sujit.prasad@ladybirdweb.com";
$user_name = "sujit prasad";
\Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
$message->to($email, $user_name)->subject('testing reporting');
});
}
// // testing
// public function test(){
// $email = "sujit.prasad@ladybirdweb.com";
// $user_name = "sujit prasad";
// \Mail::send('emails.notifications.test', ['user_id' => 1], function ($message) use($email, $user_name) {
// $message->to($email, $user_name)->subject('testing reporting');
// });
// }
}