Skip to content

Commit

Permalink
Merge branch 'v2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshadhin committed Jul 21, 2019
2 parents 3fd70e1 + a0897a4 commit cb23e4e
Show file tree
Hide file tree
Showing 16 changed files with 690 additions and 520 deletions.
27 changes: 2 additions & 25 deletions app/Console/Commands/SeedEmployeeAttendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,31 +298,8 @@ public function handle()
try {
if ($pendingFile->send_notification) {
foreach ($absentIds as $attendance_date => $employeeIds) {
//todo: need uncomment these code on client deploy
// $sendNotification = AppHelper::getAppSettings('employee_attendance_notification');
// if ($sendNotification != "0") {
// if ($sendNotification == "1") {
// //then send sms notification
// //get sms gateway information
// $gateway = AppMeta::where('id', AppHelper::getAppSettings('employee_attendance_gateway'))->first();
// if (!$gateway) {
// Log::channel('employeeattendancelog')->error("SMS Gateway not setup!");
// }
//
// //get sms template information
// $template = Template::where('id', AppHelper::getAppSettings('employee_attendance_template'))->first();
// if (!$template) {
// Log::channel('employeeattendancelog')->error("Template not setup!");
// }
//
// $res = AppHelper::sendAbsentNotificationForEmployeeViaSMS($employeeIds, $attendance_date);
//
// }
// }

//push job to queue
//todo: need comment these code on client deploy
PushEmployeeAbsentJob::dispatch($employeeIds, $attendance_date);
PushEmployeeAbsentJob::dispatch($employeeIds, $attendance_date)
->onQueue('absent');
}
}
$pendingFile->is_imported = 1;
Expand Down
28 changes: 2 additions & 26 deletions app/Console/Commands/SeedStudentAttendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,32 +345,8 @@ public function handle()
try {
if ($pendingFile->send_notification) {
foreach ($absentStudentIdsByDate as $attendance_date => $absentIds) {

//todo: need uncomment these code on client deploy
// $sendNotification = AppHelper::getAppSettings('student_attendance_notification');
// if ($sendNotification != "0") {
// if ($sendNotification == "1") {
// //then send sms notification
// //get sms gateway information
// $gateway = AppMeta::where('id', AppHelper::getAppSettings('student_attendance_gateway'))->first();
// if (!$gateway) {
// Log::channel('studentabsentlog')->error("SMS Gateway not setup!");
// }
//
// //get sms template information
// $template = Template::where('id', AppHelper::getAppSettings('student_attendance_template'))->first();
// if (!$template) {
// Log::channel('studentabsentlog')->error("Template not setup!");
// }
//
// $res = AppHelper::sendAbsentNotificationForStudentViaSMS($absentIds, $attendance_date);
//
// }
// }

//push job to queue
//todo: need comment these code on client deploy
PushStudentAbsentJob::dispatch($absentIds, $attendance_date);
PushStudentAbsentJob::dispatch($absentIds, $attendance_date)
->onQueue('absent');
}
}
$pendingFile->is_imported = 1;
Expand Down
44 changes: 6 additions & 38 deletions app/Http/Controllers/Backend/EmployeeAttendanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Process\Process;


class EmployeeAttendanceController extends Controller
{
Expand Down Expand Up @@ -229,33 +228,9 @@ public function store(Request $request)

$message = "Attendance saved successfully.";
//check if notification need to send?
//todo: need uncomment these code on client deploy
// $sendNotification = AppHelper::getAppSettings('employee_attendance_notification');
// if($sendNotification != "0" && $request->has('is_send_notification')) {
// if($sendNotification == "1"){
// //then send sms notification
//
// //get sms gateway information
// $gateway = AppMeta::where('id', AppHelper::getAppSettings('employee_attendance_gateway'))->first();
// if(!$gateway){
// redirect()->route('employee_attendance.create')->with("warning",$message." But SMS Gateway not setup!");
// }
//
// //get sms template information
// $template = Template::where('id', AppHelper::getAppSettings('employee_attendance_template'))->first();
// if(!$template){
// redirect()->route('employee_attendance.create')->with("warning",$message." But SMS template not setup!");
// }
//
// $res = AppHelper::sendAbsentNotificationForEmployeeViaSMS($absentIds, $attendance_date);
//
// }
// }

//push job to queue
//todo: need comment these code on client deploy
if($request->has('is_send_notification')) {
PushEmployeeAbsentJob::dispatch($absentIds, $attendance_date);
PushEmployeeAbsentJob::dispatch($absentIds, $attendance_date)
->onQueue('absent');
}


Expand Down Expand Up @@ -358,16 +333,9 @@ public function createFromFile(Request $request)
'attendance_type' => 2,
]);


// now start the command to proccess data
$command = "php ".base_path()."/artisan attendance:seedEmployee";
$process = new Process($command);
$process->start();

// debug code
// $process->wait();
// echo $process->getOutput();
// echo $process->getErrorOutput();
//push command on queue
Artisan::queue('attendance:seedEmployee')
->onQueue('commands');

} catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use App\AboutContent;
Expand Down
44 changes: 6 additions & 38 deletions app/Http/Controllers/Backend/StudentAttendanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Process\Process;
use Exception;

class StudentAttendanceController extends Controller
Expand Down Expand Up @@ -395,33 +395,9 @@ public function store(Request $request)

$message = "Attendance saved successfully.";
//check if notification need to send?
//todo: need uncomment these code on client deploy
// $sendNotification = AppHelper::getAppSettings('student_attendance_notification');
// if($sendNotification != "0" && $request->has('is_send_notification')) {
// if($sendNotification == "1"){
// //then send sms notification
//
// //get sms gateway information
// $gateway = AppMeta::where('id', AppHelper::getAppSettings('student_attendance_gateway'))->first();
// if(!$gateway){
// redirect()->route('student_attendance.create')->with("warning",$message." But SMS Gateway not setup!");
// }
//
// //get sms template information
// $template = Template::where('id', AppHelper::getAppSettings('student_attendance_template'))->first();
// if(!$template){
// redirect()->route('student_attendance.create')->with("warning",$message." But SMS template not setup!");
// }
//
// $res = AppHelper::sendAbsentNotificationForStudentViaSMS($absentIds, $attendance_date);
//
// }
// }

//push job to queue
//todo: need comment these code on client deploy
if($request->has('is_send_notification')) {
PushStudentAbsentJob::dispatch($absentIds, $attendance_date);
PushStudentAbsentJob::dispatch($absentIds, $attendance_date)
->onQueue('absent');
}


Expand Down Expand Up @@ -523,17 +499,9 @@ public function createFromFile(Request $request)
'send_notification' => $request->has('is_send_notification') ? 1 : 0,
]);


// now start the command to proccess data
$command = "php ".base_path()."/artisan attendance:seedStudent";

$process = new Process($command);
$process->start();

// debug code
// $process->wait();
// echo $process->getOutput();
// echo $process->getErrorOutput();
//push command on queue
Artisan::queue('attendance:seedStudent')
->onQueue('commands');

} catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function profile(Request $request)
$user = User::where('id',auth()->user()->id)->with('role')->first();


$userRole = Role::findOrFail($user->role->role_id)->first();
$userRole = Role::where('id',$user->role->role_id)->first();


if ($request->isMethod('post')) {
Expand Down
11 changes: 9 additions & 2 deletions app/Http/Helpers/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public static function sendAbsentNotificationForStudentViaSMS($studentIds, $date
$message = str_replace('{{' . $key . '}}', $value, $message);
}

$cellNumber = AppHelper::validateBangladeshiCellNo($studentArray['student']['father_phone_no']);
$cellNumber = AppHelper::validateCellNo($studentArray['student']['father_phone_no']);

if($cellNumber){

Expand Down Expand Up @@ -624,7 +624,7 @@ public static function sendAbsentNotificationForEmployeeViaSMS($employeeIds, $da
$message = str_replace('{{' . $key . '}}', $value, $message);
}

$cellNumber = AppHelper::validateBangladeshiCellNo($employee->phone_no);
$cellNumber = AppHelper::validateCellNo($employee->phone_no);

if($cellNumber){

Expand Down Expand Up @@ -673,6 +673,13 @@ public static function validateBangladeshiCellNo($number) {


}
/**
* @param $number
* @return bool|mixed|string
*/
public static function validateCellNo($number) {
return $number;
}


public static function isLineValid($lineContent) {
Expand Down
10 changes: 10 additions & 0 deletions app/Http/Helpers/SmsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ function __construct($gateway)

public function sendSms($number, $message) {

//clean message for GSM extended character
// ~^{}[]\|
$message = str_replace('{', '(', $message);
$message = str_replace('}', ')', $message);
$message = str_replace('[', '(', $message);
$message = str_replace(']', ')', $message);
$message = preg_replace("/[^a-zA-Z0-9\s(),\/]/mi", "", $message);
$message = preg_replace("/\s{2,}/mi", " ", $message);


try {

if(!$this->gateway){
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/PushEmployeeAbsentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function makeNotificationJob($gateway=null) {
}

if($gateway) {
$cellNumber = AppHelper::validateBangladeshiCellNo($employee->phone_no);
$cellNumber = AppHelper::validateCellNo($employee->phone_no);
if ($cellNumber) {
//send to a job handler
ProcessSms::dispatch($gateway, $cellNumber, $message)->onQueue('sms');
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/PushStudentAbsentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function makeNotificationJob($gateway=null) {
}

if($gateway) {
$cellNumber = AppHelper::validateBangladeshiCellNo($studentData['student']['father_phone_no']);
$cellNumber = AppHelper::validateCellNo($studentData['student']['father_phone_no']);
if ($cellNumber) {
//send to a job handler
ProcessSms::dispatch($gateway, $cellNumber, $message)->onQueue('sms');
Expand Down
2 changes: 1 addition & 1 deletion bin/cloudschool-worker.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[program:cloudschool-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/hbot/www/public_html/sms/artisan queue:work --tries=3 --sleep=3 --queue=default,sms,email
command=php /home/hbot/www/public_html/sms/artisan queue:work --tries=3 --sleep=3 --queue=default,commands,absent,sms,email
autostart=true
autorestart=true
user=www-data
Expand Down
14 changes: 0 additions & 14 deletions database/seeds/PermissionTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,6 @@ public function run()
"group" => "Academic"
],
//subject end
// Holiday
[ "slug" => "academic.holiday",
"name" => "Holiday View",
"group" => "Academic"
],
[ "slug" => "academic.holiday",
"name" => "Holiday Create",
"group" => "Academic"
],
[ "slug" => "academic.holiday_destroy",
"name" => "Holiday Delete",
"group" => "Academic"
],
// Holiday
[ "slug" => "student.store",
"name" => "Student Create",
"group" => "Academic"
Expand Down
Loading

0 comments on commit cb23e4e

Please sign in to comment.