all
This commit is contained in:
commit
05f1559a8b
|
|
@ -0,0 +1,15 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_size = 2
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_DRIVER=smtp
|
||||||
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
* text=auto
|
||||||
|
*.css linguist-vendored
|
||||||
|
*.scss linguist-vendored
|
||||||
|
*.js linguist-vendored
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/node_modules
|
||||||
|
/public/my-files
|
||||||
|
/public/uploads
|
||||||
|
/public/documents
|
||||||
|
/public/storage
|
||||||
|
/public/logs
|
||||||
|
/storage/*.key
|
||||||
|
/storage/logs
|
||||||
|
/storage/*/.gitignore
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
*.meta.*
|
||||||
|
_ide_*
|
||||||
|
resources/views/remote_transfers/index.blade.php
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -d [OR]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -f
|
||||||
|
RewriteRule ^ ^$1 [N]
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
|
||||||
|
RewriteRule ^(.*)$ public/$1
|
||||||
|
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ server.php
|
||||||
|
|
||||||
|
</IfModule>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- unused_use
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
- server.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Absent extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'absents';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id', 'start_date', 'end_date',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class Admin extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'email', 'password', 'username',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password', 'remember_token',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AssignAbsence extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'assign_absences';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id', 'absent_id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Comment extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'comments';
|
||||||
|
|
||||||
|
protected $fillable = ['workflow_document_id', 'user_id', 'comment', 'parent_id'];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function document()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(WorkflowDocument::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Log;
|
||||||
|
use File;
|
||||||
|
|
||||||
|
class DBBackup extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'db:backup';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Backup DB';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->backupLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function backupLocal()
|
||||||
|
{
|
||||||
|
Artisan::call('down');
|
||||||
|
Log::warning(['dbbackup-start' => now()]);
|
||||||
|
$path = storage_path() . "/app/backup/" . now()->year . "/";
|
||||||
|
File::isDirectory($path) or File::makeDirectory($path, 0777, true, true);
|
||||||
|
|
||||||
|
$filename = "backup_" . now()->format('Y-m-d_H:i:m') . ".gz";
|
||||||
|
$command = "mysqldump --user=" . env('DB_USERNAME') ." --password=" . env('DB_PASSWORD') . " --host=" . env('DB_HOST') . " " . env('DB_DATABASE') . " --complete-insert " . " | gzip > " . $path . $filename;
|
||||||
|
$returnVar = NULL;
|
||||||
|
$output = NULL;
|
||||||
|
|
||||||
|
exec($command, $output, $returnVar);
|
||||||
|
sleep(10);
|
||||||
|
Log::warning(['dbbackup-stop' => now()]);
|
||||||
|
Artisan::call('up');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function backupRemote()
|
||||||
|
{
|
||||||
|
Artisan::call('down');
|
||||||
|
Log::warning(['dbbackup-start' => now()->format('Y-m-d H:i:m')]);
|
||||||
|
|
||||||
|
$filename = "ags_billing_" . now()->format('Y-m-d_H:i') . ".gz";
|
||||||
|
$filename_withpath = storage_path() . "/app/public/" . $filename;
|
||||||
|
$command = "mysqldump --user=" . \config('backup.db_username') ." --password=" . \config('backup.db_password') . " --host=" . \config('backup.db_host') . " " . \config('backup.db_database') . " --complete-insert " . " | gzip > " . $filename_withpath;
|
||||||
|
|
||||||
|
$returnVar = NULL;
|
||||||
|
$output = NULL;
|
||||||
|
|
||||||
|
exec($command, $output, $returnVar);
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
Log::warning(['dbbackup-stop' => now()->format('Y-m-d H:i:m')]);
|
||||||
|
Artisan::call('up');
|
||||||
|
|
||||||
|
$remote_serv = 'user@ip-address';
|
||||||
|
$remote_path = ':/var/sql_data/ags_billing/' . now()->year . "/" . now()->month . "/";
|
||||||
|
$remote_pass = 'remote_pass';
|
||||||
|
|
||||||
|
Log::warning(['start: db backup cp to remote server' => now()->format('Y-m-d H:i:m')]);
|
||||||
|
|
||||||
|
$command = "sshpass -p " . $remote_pass . " scp " . $filename_withpath . " " . $remote_serv . $remote_path;
|
||||||
|
// apt-get install sshpass;
|
||||||
|
|
||||||
|
exec($command, $output, $returnVar);
|
||||||
|
|
||||||
|
Log::warning(['end: db backup cp to remote server' => now()->format('Y-m-d H:i:m')]);
|
||||||
|
|
||||||
|
// remote file
|
||||||
|
if($returnVar == 0)
|
||||||
|
File::delete($filename_withpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Artisan commands provided by your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $commands = [
|
||||||
|
'App\Console\Commands\DBBackup'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
// $schedule->command('inspire')->hourly();
|
||||||
|
// * * * * * cd /var/www/html/org && php artisan schedule:run >> /dev/null 2>&1
|
||||||
|
$schedule->command('db:backup')->cron('30 1 * * *');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Contact extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'contacts';
|
||||||
|
protected $fillable = [
|
||||||
|
'organization_name', 'alternative_name', 'address', 'telephone_number', 'notes', 'status', 'is_approved',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DeliveryType extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'delivery_types';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'description',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Department extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'departments';
|
||||||
|
protected $fillable = [
|
||||||
|
'parent_id', 'name', 'status', 'responsible_user_id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Directory extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'directories';
|
||||||
|
protected $fillable = [
|
||||||
|
'parent_id', 'name', 'year', 'user_id', 'title', 'description', 'by_admin'
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getPath($did)
|
||||||
|
{
|
||||||
|
if(!isset($did) || $did==null)
|
||||||
|
return '';
|
||||||
|
|
||||||
|
$directory = Directory::find($did);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->parent_id == 0)
|
||||||
|
return $directory->name;
|
||||||
|
else
|
||||||
|
return Directory::getPath($directory->parent_id) . ' / ' . $directory->name;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPathArray($did)
|
||||||
|
{
|
||||||
|
if(!isset($did) || $did==null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
$directory = Directory::find($did);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->parent_id == 0)
|
||||||
|
return [$directory->id => $directory->name];
|
||||||
|
else
|
||||||
|
return Directory::getPathArray($directory->parent_id) + [$directory->id => $directory->name];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPathToRoot($did, $show_itself=false)
|
||||||
|
{
|
||||||
|
if(!isset($did) || $did==null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
$directory = Directory::find($did);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
$directory =($show_itself) ? $directory : Directory::find($directory->parent_id);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->parent_id == 0)
|
||||||
|
return [$directory->id];
|
||||||
|
else
|
||||||
|
return array_merge([$directory->id], Directory::getPathToRoot($directory->parent_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DocumentType extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'document_types';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'description', 'status', 'incoming', 'outgoing', 'internal'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Event extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'events';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'title',
|
||||||
|
'text',
|
||||||
|
'link',
|
||||||
|
'start_date_time',
|
||||||
|
'end_date_time',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function report(Exception $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function render($request, Exception $exception)
|
||||||
|
{
|
||||||
|
if ($exception instanceof \Illuminate\Session\TokenMismatchException) {
|
||||||
|
return redirect()->route('login');
|
||||||
|
}
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
|
||||||
|
|
||||||
|
class ListingExport implements FromView, ShouldAutoSize, WithStrictNullComparison
|
||||||
|
{
|
||||||
|
public function __construct($row)
|
||||||
|
{
|
||||||
|
$this->workflowtypes= $row[0];
|
||||||
|
$this->input = $row[1];
|
||||||
|
$this->documents = $row[2];
|
||||||
|
$this->dashboard = isset($row[3]) ? 'dashboard' : 'listing';
|
||||||
|
$this->export = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
if($this->dashboard == 'listing')
|
||||||
|
return view('listings.index-table', [
|
||||||
|
'workflowtypes'=>$this->workflowtypes,
|
||||||
|
'input'=>$this->input,
|
||||||
|
'documents'=>$this->documents,
|
||||||
|
'exp' => true,
|
||||||
|
]);
|
||||||
|
else if($this->dashboard == 'dashboard')
|
||||||
|
return view('dashboard.list-table', [
|
||||||
|
'workflowtypes'=>$this->workflowtypes,
|
||||||
|
'input'=>$this->input,
|
||||||
|
'documents'=>$this->documents,
|
||||||
|
'exp' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,245 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Absent;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
class AbsentsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function reset(Request $request)
|
||||||
|
{
|
||||||
|
if($request->session()->has('search_options')):
|
||||||
|
$request->session()->forget('search_options');
|
||||||
|
endif;
|
||||||
|
return redirect()->route('absents');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$condition=$search_options=[];
|
||||||
|
$input = $request->all();
|
||||||
|
if(!empty($input)):
|
||||||
|
$request->session()->put('search_options', $input);
|
||||||
|
endif;
|
||||||
|
if($request->session()->has('search_options')):
|
||||||
|
$search_options=$request->session()->get('search_options');
|
||||||
|
if($search_options['user_id'] != ""):
|
||||||
|
array_push($condition, ['absents.user_id', '=', $search_options['user_id']]);
|
||||||
|
endif;
|
||||||
|
if($search_options['absent_date'] != ""):
|
||||||
|
$search_options['absent_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $search_options['absent_date'])->format('Y-m-d');
|
||||||
|
array_push($condition, ['absents.start_date', '<=', $search_options['absent_date']]);
|
||||||
|
array_push($condition, ['absents.end_date', '>=', $search_options['absent_date']]);
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if(!empty($condition))
|
||||||
|
{
|
||||||
|
$absents = DB::table('absents')
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'absents.user_id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'absents.*')
|
||||||
|
->orderBy('absents.id', 'desc')
|
||||||
|
->where($condition)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$absents = DB::table('absents')
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'absents.user_id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'absents.*', 'roles.name as role_name')
|
||||||
|
->orderBy('absents.id', 'desc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.absents.index', compact('absents', 'user_lists', 'search_options'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.absents.create', compact('user_lists'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'user_id' => 'required',
|
||||||
|
'start_date' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if($input['start_date'] != "")
|
||||||
|
$input['start_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['start_date'])->format('Y-m-d');
|
||||||
|
if($input['end_date'] != ""):
|
||||||
|
$input['end_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['end_date'])->format('Y-m-d');
|
||||||
|
else:
|
||||||
|
$input['end_date']=$input['start_date'];
|
||||||
|
endif;
|
||||||
|
$saved_data=Absent::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Absent has been added successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-absent');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get();
|
||||||
|
$absent = Absent::where('id', '=', $id)->first();
|
||||||
|
if($absent):
|
||||||
|
return view('admin.absents.edit', compact('absent', 'user_lists'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid Absent id.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$absent = Absent::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'user_id' => 'required',
|
||||||
|
'start_date' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if($input['start_date'] != "")
|
||||||
|
$input['start_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['start_date'])->format('Y-m-d');
|
||||||
|
if($input['end_date'] != ""):
|
||||||
|
$input['end_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['end_date'])->format('Y-m-d');
|
||||||
|
else:
|
||||||
|
$input['end_date']=$input['start_date'];
|
||||||
|
endif;
|
||||||
|
$saved_data=$absent->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Absent has been updated successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-absent');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = Absent::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Absent has been deleted successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = Absent::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Absent has been updated successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Admin;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
|
||||||
|
class AdminsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function editprofile()
|
||||||
|
{
|
||||||
|
$id=\Auth::guard('admin')->user()->id;
|
||||||
|
$user = Admin::where('id', '=', $id)->first();
|
||||||
|
return view('admin.admins.editprofile', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \App\Admin $user
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function updateprofile(Request $request)
|
||||||
|
{
|
||||||
|
$id=\Auth::guard('admin')->user()->id;
|
||||||
|
$user = Admin::findOrFail($id);
|
||||||
|
if($user)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|max:255',
|
||||||
|
'username' => 'required|max:255',
|
||||||
|
'email' => 'required|unique:admins,email,'.$id.'|email|max:255',
|
||||||
|
'password' => 'nullable|min:6|confirmed',
|
||||||
|
]);
|
||||||
|
$input = [
|
||||||
|
'name' => $request['name'],
|
||||||
|
'username' => $request['username'],
|
||||||
|
'email' => $request['email']
|
||||||
|
];
|
||||||
|
if($request['password']!="")
|
||||||
|
$input['password']=bcrypt($request['password']);
|
||||||
|
$saved_data=$user->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Profile has been updated successfully');
|
||||||
|
return redirect()->route('edit-profile');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-profile');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'Invalid user id.');
|
||||||
|
return redirect()->route('edit-profile');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,246 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\AssignAbsence;
|
||||||
|
use App\Absent;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
class AssignAbsencesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$condition=$search_options=[];
|
||||||
|
$input = $request->all();
|
||||||
|
if(!empty($input)):
|
||||||
|
$request->session()->put('search_options', $input);
|
||||||
|
endif;
|
||||||
|
if($request->session()->has('search_options')):
|
||||||
|
$search_options=$request->session()->get('search_options');
|
||||||
|
if($search_options['user_id'] != ""):
|
||||||
|
array_push($condition, ['absents.user_id', '=', $search_options['user_id']]);
|
||||||
|
endif;
|
||||||
|
if($search_options['absent_date'] != ""):
|
||||||
|
$search_options['absent_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $search_options['absent_date'])->format('Y-m-d');
|
||||||
|
array_push($condition, ['absents.start_date', '<=', $search_options['absent_date']]);
|
||||||
|
array_push($condition, ['absents.end_date', '>=', $search_options['absent_date']]);
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if(!empty($condition))
|
||||||
|
{
|
||||||
|
$absents = DB::table('absents')
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'absents.user_id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name, ' (', roles.name, ')') AS user_details"), 'absents.*')
|
||||||
|
->orderBy('absents.id', 'desc')
|
||||||
|
->where($condition)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$absents = DB::table('absents')
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'absents.user_id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name, ' (', roles.name, ')') AS user_details"), 'absents.*')
|
||||||
|
->orderBy('absents.id', 'desc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
return view('admin.absents.index', compact('absents', 'user_lists', 'search_options'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create($absentId)
|
||||||
|
{
|
||||||
|
$absent_id=base64_decode($absentId);
|
||||||
|
$absent = Absent::where('absents.id',$absent_id)
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'absents.*', 'roles.name as role_name')
|
||||||
|
->first();
|
||||||
|
$assign_absence = AssignAbsence::where('absent_id',$absent_id)->first();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '<>', $absent->user_id)
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
if($assign_absence):
|
||||||
|
return redirect()->route('edit-assign-absence', $absentId);
|
||||||
|
else:
|
||||||
|
return view('admin.assign-absences.create', compact('user_lists', 'absent'));
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request, $absentId)
|
||||||
|
{
|
||||||
|
$absent_id=base64_decode($absentId);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'user_id' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['absent_id'] = $absent_id;
|
||||||
|
$saved_data=AssignAbsence::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Substitute User has been added successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return view('admin.assign-absences.create', compact('user_lists', 'absent'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($absentId)
|
||||||
|
{
|
||||||
|
$absent_id=base64_decode($absentId);
|
||||||
|
$absent = Absent::where('absents.id',$absent_id)
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'absents.*')
|
||||||
|
->first();
|
||||||
|
$assign_absence = AssignAbsence::where('absent_id',$absent_id)->first();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '<>', $absent->user_id)
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
if($assign_absence):
|
||||||
|
return view('admin.assign-absences.edit', compact('user_lists', 'absent', 'assign_absence'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid assign absence id.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $absentId)
|
||||||
|
{
|
||||||
|
$id=base64_decode($absentId);
|
||||||
|
$absent = AssignAbsence::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'user_id' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$absent->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Substitute User has been updated successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-assign-absence', $absentId);
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = Absent::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Absent has been deleted successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = Absent::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Absent has been updated successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin\Auth;
|
||||||
|
|
||||||
|
use App\Admin;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Cookie;
|
||||||
|
use Session;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/admin/dashboard';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest:admin')->except('logout');
|
||||||
|
}
|
||||||
|
protected function guard()
|
||||||
|
{
|
||||||
|
return Auth::guard('admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function credentials(Request $request)
|
||||||
|
{
|
||||||
|
$field = filter_var($request->get($this->username()), FILTER_VALIDATE_EMAIL)
|
||||||
|
? $this->username()
|
||||||
|
: 'username';
|
||||||
|
|
||||||
|
return [
|
||||||
|
$field => $request->get($this->username()),
|
||||||
|
'password' => $request->password,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
protected function attemptLogin(Request $request)
|
||||||
|
{
|
||||||
|
return $this->guard()->attempt(
|
||||||
|
$this->credentials($request), $request->has('remember')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
protected function authenticated(Request $request, $user)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'You are successfully logged in.');
|
||||||
|
if($request->has('remember')):
|
||||||
|
return redirect()->route('dashboard')->cookie('cookie_remember', 1)->cookie('cookie_password', $request->password)->cookie('cookie_username', $request->get($this->username()));
|
||||||
|
else:
|
||||||
|
return redirect()->route('dashboard')->cookie('cookie_remember', '')->cookie('cookie_password', '')->cookie('cookie_username', '');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
$this->guard()->logout();
|
||||||
|
$request->session()->invalidate();
|
||||||
|
Session::flash('success_message', 'You are successfully logged out.');
|
||||||
|
return redirect('/admin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,168 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Contact;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class ContactsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$contacts = DB::table('contacts')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.contacts.index', compact('contacts'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.contacts.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'organization_name' => 'required|unique:contacts,organization_name|max:150',
|
||||||
|
'alternative_name' => 'max:150',
|
||||||
|
'address' => 'required',
|
||||||
|
'telephone_number' => 'required|numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=Contact::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Contact has been added successfully');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-contact');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$contact = Contact::where('id', '=', $id)->first();
|
||||||
|
if($contact):
|
||||||
|
return view('admin.contacts.edit', compact('contact'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid contact id.');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$contact = Contact::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'organization_name' => 'required|unique:contacts,organization_name,'.$id.'|max:150',
|
||||||
|
'alternative_name' => 'max:150',
|
||||||
|
'address' => 'required',
|
||||||
|
'telephone_number' => 'required|numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$contact->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Contact has been updated successfully');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-contact');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$contact = Contact::findOrFail($id);
|
||||||
|
$delete_contact = $contact->delete();
|
||||||
|
if($delete_contact):
|
||||||
|
Session::flash('success_message', 'Contact has been deleted successfully');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_contact = Contact::findOrFail($id);
|
||||||
|
if($find_contact->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_contact->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Contact has been updated successfully');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Absent;
|
||||||
|
use App\User;
|
||||||
|
use App\Role;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
$todays_absent_user = DB::table('absents')
|
||||||
|
->join('users', 'absents.user_id', '=', 'users.id')
|
||||||
|
->join('role_user', 'absents.user_id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'absents.id as absent_id')
|
||||||
|
->orderBy('absents.id', 'desc')
|
||||||
|
->where([['start_date', '<=', date('Y-m-d')],['end_date', '>=', date('Y-m-d')]])
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->get();
|
||||||
|
$users = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.id as role_id')
|
||||||
|
->where('users.status', '=', 1)
|
||||||
|
->where('users.working_status', '=', 1)
|
||||||
|
->where('roles.id', '=', 1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$roles = Role::orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.home', compact('todays_absent_user', 'users', 'roles'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\DeliveryType;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class DeliveryTypesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$delivery_types = DeliveryType::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.delivery-types.index', compact('delivery_types', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.delivery-types.create', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = DeliveryType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=DeliveryType::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Delivery type has been added successfully');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-delivery-type');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delivery_type = DeliveryType::where('id', '=', $id)->first();
|
||||||
|
if($delivery_type):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.delivery-types.edit', compact('delivery_type', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid delivery type id.');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delivery_type = DeliveryType::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = DeliveryType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$delivery_type->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Delivery type has been updated successfully');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-delivery-type');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = DeliveryType::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Delivery type has been deleted successfully');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = DeliveryType::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Delivery type has been updated successfully');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('delivery-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,250 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Department;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class DepartmentsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$departments = DB::table('departments')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->where('roles.id', '<=', 2)
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.departments.index', compact('departments', 'users', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$departments=Department::where('status', '1')->orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->where('roles.id', '<=', 2)
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.departments.create', compact('departments', 'users', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Department name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Department::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Department name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=Department::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Department has been added successfully');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-department');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$department = Department::where('id', '=', $id)->first();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->where('roles.id', '<=', 2)
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
if($department):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$department_lists=Department::where([['id','<>',$id], ['status', '=',1]])->orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
return view('admin.departments.edit', compact('department', 'department_lists', 'users', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid department id.');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$department = Department::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Department::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Delivery type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$department->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Department has been updated successfully');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-department');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$department = Department::findOrFail($id);
|
||||||
|
$department_lists=Department::where('parent_id',$id)->get()->toArray();
|
||||||
|
if(!empty($department_lists)):
|
||||||
|
Session::flash('error_message', 'Please delete all related department first.');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$delete_department = $department->delete();
|
||||||
|
if($delete_department):
|
||||||
|
Session::flash('success_message', 'Department has been deleted successfully');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_department = Department::findOrFail($id);
|
||||||
|
if($find_department->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_department->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Department has been updated successfully');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('departments');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,215 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\DocumentType;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class DocumentTypesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$document_types = DocumentType::orderBy('id', 'desc')->get();
|
||||||
|
//print_r($document_types);exit;
|
||||||
|
return view('admin.document-types.index', compact('document_types', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.document-types.create', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Document type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = DocumentType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Document type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=DocumentType::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Document type has been added successfully');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-document-type');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$document_type = DocumentType::where('id', '=', $id)->first();
|
||||||
|
if($document_type):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.document-types.edit', compact('document_type', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid document type id.');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$document_type = DocumentType::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Document type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = DocumentType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Document type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$document_type->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Document type has been updated successfully');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-document-type');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = DocumentType::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Document type has been deleted successfully');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = DocumentType::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Document type has been updated successfully');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('document-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\WorkflowDocument;
|
||||||
|
use App\WorkflowType;
|
||||||
|
use App\Priority;
|
||||||
|
use App\DeliveryType;
|
||||||
|
use App\DocumentType;
|
||||||
|
use App\Contact;
|
||||||
|
use App\Department;
|
||||||
|
use App\Setting;
|
||||||
|
use App\User;
|
||||||
|
use App\WorkflowDocumentUser;
|
||||||
|
use App\WorkflowDocumentFile;
|
||||||
|
use App\WorkflowDocumentSender;
|
||||||
|
use App\WorkflowDocumentProcess;
|
||||||
|
use App\UserNotification;
|
||||||
|
use App\Promotion;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use File;
|
||||||
|
|
||||||
|
class DocumentsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$limit_val = (isset($setting->data_limit_per_page) && $setting->data_limit_per_page > 0) ? $setting->data_limit_per_page : 100;
|
||||||
|
$limit_val = 10;
|
||||||
|
$workflow_documents = new WorkflowDocument;
|
||||||
|
$search = request()->search ?? '';
|
||||||
|
if(request()->has('search') && strlen($search) > 0)
|
||||||
|
{
|
||||||
|
$workflow_documents = $workflow_documents->where(function($q) use($search){
|
||||||
|
$q->where('registration_number', 'LIKE', '%'.$search.'%')
|
||||||
|
->orWhere('temporary_registration_number', 'LIKE', '%' . $search . '%');
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
$search = request()->search;
|
||||||
|
}
|
||||||
|
|
||||||
|
$workflow_documents = $workflow_documents->where('is_deleted', 0)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->paginate($limit_val);
|
||||||
|
|
||||||
|
$workflow_types = WorkflowType::orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.documents.index', compact('workflow_documents', 'workflow_types', 'search'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function archives()
|
||||||
|
{
|
||||||
|
$workflow_documents = DB::table('workflow_documents')
|
||||||
|
->where('is_deleted',1)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$workflow_types = WorkflowType::orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.documents.archives', compact('workflow_documents', 'workflow_types'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function archive($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$workflow_document = WorkflowDocument::findOrFail($id);
|
||||||
|
$workflow_document_update = WorkflowDocument::where('id',$id)->update(['is_deleted'=>1]);
|
||||||
|
if($workflow_document_update):
|
||||||
|
Session::flash('success_message', 'Workflow document has been deleted successfully');
|
||||||
|
return redirect()->route('present-documents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('present-documents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$workflow_document = WorkflowDocument::findOrFail($id);
|
||||||
|
if($workflow_document){
|
||||||
|
$process = WorkflowDocumentProcess::where('workflow_document_id', $workflow_document->id)->get();
|
||||||
|
if($process){
|
||||||
|
foreach($process as $pro){
|
||||||
|
$proc = WorkflowDocumentProcess::findOrFail($pro->id);
|
||||||
|
$proc->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$files = WorkflowDocumentFile::where('workflow_document_id', $workflow_document->id)->get();
|
||||||
|
if($files){
|
||||||
|
foreach($files as $f_data){
|
||||||
|
$file = WorkflowDocumentFile::findOrFail($f_data->id);
|
||||||
|
if($file->delete())
|
||||||
|
if(File::exists($file))
|
||||||
|
unlink(public_path($file->place_of_the_documents.'/'.$file->document_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$Sender = WorkflowDocumentSender::where('workflow_document_id', $workflow_document->id)->get();
|
||||||
|
if($Sender){
|
||||||
|
foreach($Sender as $s_data){
|
||||||
|
$sd_data = WorkflowDocumentSender::findOrFail($s_data->id);
|
||||||
|
$sd_data->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$users = WorkflowDocumentUser::where('workflow_document_id', $workflow_document->id)->get();
|
||||||
|
if($users){
|
||||||
|
foreach($users as $u_data){
|
||||||
|
$user = WorkflowDocumentUser::findOrFail($u_data->id);
|
||||||
|
$user->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$delete_documents = $workflow_document->delete();
|
||||||
|
if($delete_documents):
|
||||||
|
Session::flash('success_message', 'Workflow document has been deleted successfully');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}else{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_department = Department::findOrFail($id);
|
||||||
|
if($find_department->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_department->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Department has been updated successfully');
|
||||||
|
return redirect()->route('workflow_documents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('workflow_documents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,188 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Language;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class LanguagesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.languages.index', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.languages.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:languages,name|max:100',
|
||||||
|
'short_name' => 'required|unique:languages,short_name|max:100',
|
||||||
|
'serial_no' => 'numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['short_name'] = strtolower($input['short_name']);
|
||||||
|
$saved_data=Language::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
saveJSONFile($input['short_name'], openJSONFile('en'));
|
||||||
|
Session::flash('success_message', 'Language has been added successfully');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-language');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$language = Language::where('id', '=', $id)->first();
|
||||||
|
if($language):
|
||||||
|
return view('admin.languages.view', compact('language'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid language id.');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function key_value_store(Request $request)
|
||||||
|
{
|
||||||
|
$language = Language::findOrFail($request->id);
|
||||||
|
$data = openJSONFile($language->short_name);
|
||||||
|
foreach ($request->key as $key => $key) {
|
||||||
|
$data[$key] = $request->key[$key];
|
||||||
|
}
|
||||||
|
saveJSONFile($language->short_name, $data);
|
||||||
|
Session::flash('success_message', __('Key-Value updated for ').$language->name);
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$language = Language::where('id', '=', $id)->first();
|
||||||
|
if($language):
|
||||||
|
return view('admin.languages.edit', compact('language'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid language id.');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$language = Language::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:languages,name,'.$id.'|max:100',
|
||||||
|
'short_name' => 'required|unique:languages,short_name,'.$id.'|max:100',
|
||||||
|
'serial_no' => 'numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['short_name'] = strtolower($input['short_name']);
|
||||||
|
$saved_data=$language->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Language has been updated successfully');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-language');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$language = Language::findOrFail($id);
|
||||||
|
$delete_language = $language->delete();
|
||||||
|
if($delete_language):
|
||||||
|
Session::flash('success_message', 'Language has been deleted successfully');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_language = Language::findOrFail($id);
|
||||||
|
if($find_language->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_language->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Language has been updated successfully');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('languages');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Notification;
|
||||||
|
use App\Department;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class NotificationsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$notifications = DB::table('notifications')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.notifications.index', compact('notifications'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.notifications.create', compact('users', 'languages', 'departments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'title' => 'required|max:150',
|
||||||
|
'title_tm' => 'required|max:150',
|
||||||
|
'title_ru' => 'required|max:150',
|
||||||
|
'text' => 'required|max:150',
|
||||||
|
'text_tm' => 'required|max:150',
|
||||||
|
'text_ru' => 'required|max:150',
|
||||||
|
'users' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['users']=json_encode($input['users']);
|
||||||
|
$saved_data=Notification::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Notification has been added successfully');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-notification');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$notification = Notification::where('id', '=', $id)->first();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
if($notification):
|
||||||
|
return view('admin.notifications.edit', compact('notification', 'user_lists'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid notification id.');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$notification = Notification::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'title' => 'required|max:150',
|
||||||
|
'title_tm' => 'required|max:150',
|
||||||
|
'title_ru' => 'required|max:150',
|
||||||
|
'text' => 'required|max:150',
|
||||||
|
'text_tm' => 'required|max:150',
|
||||||
|
'text_ru' => 'required|max:150',
|
||||||
|
'users' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['users']=json_encode($input['users']);
|
||||||
|
$saved_data=$notification->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Notification has been updated successfully');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-notification');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$notification = Notification::findOrFail($id);
|
||||||
|
$delete_notification = $notification->delete();
|
||||||
|
if($delete_notification):
|
||||||
|
Session::flash('success_message', 'Notification has been deleted successfully');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_notification = Notification::findOrFail($id);
|
||||||
|
if($find_notification->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_notification->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Notification has been updated successfully');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('notifications');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Permission;
|
||||||
|
use App\PermissionRole;
|
||||||
|
use App\User;
|
||||||
|
use App\Role;
|
||||||
|
use App\Department;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
class PermissionRolesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$role_permissons = PermissionRole::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.permission-roles.index', compact('role_permissons'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$roles=Role::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
$departments=Department::where('status', '=', 1)->orderBy('id', 'asc')->get();
|
||||||
|
$permissions=Permission::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
return view('admin.permission-roles.create', compact('roles', 'departments', 'permissions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'role_id' => 'required',
|
||||||
|
'permission_ids' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$exit_role_permissons = PermissionRole::where('role_id', $input['role_id'])->where('department_id', $input['department_id'])->first();
|
||||||
|
if($exit_role_permissons){
|
||||||
|
Session::flash('error_message', 'Permission already exists. You can check here.');
|
||||||
|
return redirect()->route('edit-permission-role', base64_encode($exit_role_permissons->id));
|
||||||
|
}
|
||||||
|
$input['permission_ids']=json_encode($input['permission_ids']);
|
||||||
|
$saved_data=PermissionRole::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Permission Role has been added successfully');
|
||||||
|
return redirect()->route('permission-roles');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$user = PermissionRole::where('id', '=', $id)->first();
|
||||||
|
if($user):
|
||||||
|
$roles=Role::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
$departments=Department::where('status', '=', 1)->orderBy('id', 'asc')->get();
|
||||||
|
$permissions=Permission::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
return view('admin.permission-roles.edit', compact('user', 'roles', 'departments', 'permissions'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid Permission Role id.');
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$permission = PermissionRole::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'role_id' => 'required',
|
||||||
|
'permission_ids' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$exit_role_permissons = PermissionRole::where('role_id', $input['role_id'])->where('department_id', $input['department_id'])->where('id', '<>', $id)->first();
|
||||||
|
if($exit_role_permissons){
|
||||||
|
Session::flash('error_message', 'Permission already exists. You can check here.');
|
||||||
|
return redirect()->route('edit-permission-role', base64_encode($exit_role_permissons->id));
|
||||||
|
}
|
||||||
|
$input['permission_ids']=json_encode($input['permission_ids']);
|
||||||
|
$saved_data=$permission->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Permission Role has been updated successfully');
|
||||||
|
return redirect()->route('permission-roles');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = PermissionRole::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Permission Role has been deleted successfully');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Permission;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
class PermissionsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$permissions = DB::table('permissions')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.permissions.index', compact('permissions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('admin.permissions.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:permissions,name|max:191',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=Permission::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Permission has been added successfully');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$permission = Permission::where('id', '=', $id)->first();
|
||||||
|
if($permission):
|
||||||
|
return view('admin.permissions.edit', compact('permission'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid Permission id.');
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$permission = Permission::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:permissions,name,'.$id.'|max:191',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$permission->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Permission has been updated successfully');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-permission');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = Permission::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Permission has been deleted successfully');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('permissions');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Priority;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class PrioritiesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$priorities = Priority::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.priorities.index', compact('priorities', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.priorities.create', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Priority name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Priority::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Priority name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=Priority::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Priority has been added successfully');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-priority');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$priority = Priority::where('id', '=', $id)->first();
|
||||||
|
if($priority):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.priorities.edit', compact('priority', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid priority id.');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$priority = Priority::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Priority name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Priority::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Priority name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$priority->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Priority has been updated successfully');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-priority');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_priority = Priority::where('id', $id)->delete();
|
||||||
|
if($delete_priority):
|
||||||
|
Session::flash('success_message', 'Priority has been deleted successfully');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_priority = Priority::findOrFail($id);
|
||||||
|
if($find_priority->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_priority->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Priority has been updated successfully');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('priorities');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,277 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Promotion;
|
||||||
|
use App\User;
|
||||||
|
use App\Department;
|
||||||
|
use App\WorkflowDocumentUser;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
class PromotionsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$promotions = DB::table('promotions')->orderBy('promotions.id', 'desc')->get();
|
||||||
|
return view('admin.promotions.index', compact('promotions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
// ->where('users.status', '=', '1')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
return view('admin.promotions.create', compact('user_lists'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'user_id' => 'required',
|
||||||
|
'last_user_id' => 'required',
|
||||||
|
'till_date' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$user_id = $request->input('user_id');
|
||||||
|
if($input['till_date'] != "")
|
||||||
|
$input['till_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['till_date'])->format('Y-m-d');
|
||||||
|
$saved_data=Promotion::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$current_user = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '=', $user_id)
|
||||||
|
->first();
|
||||||
|
$workFlowDocumentUser = WorkflowDocumentUser::where('user_id', $input['last_user_id'])->get();
|
||||||
|
if(!empty($workFlowDocumentUser)){
|
||||||
|
foreach($workFlowDocumentUser as $doceUser){
|
||||||
|
$checkDocumentUser = WorkflowDocumentUser::where('user_id',$current_user->id)
|
||||||
|
->where('workflow_document_id',$doceUser->workflow_document_id)
|
||||||
|
->where('status', 'Y')
|
||||||
|
->first();
|
||||||
|
if(!isset($checkDocumentUser)){
|
||||||
|
$supporter_input['_token']=$input['_token'];
|
||||||
|
$supporter_input['workflow_document_id']=$doceUser->workflow_document_id;
|
||||||
|
$supporter_input['user_id']=$current_user->id;
|
||||||
|
$supporter_input['process_id']=$doceUser->process_id;
|
||||||
|
$supporter_input['user_type']='S';
|
||||||
|
$supporter_input['user_name']=$current_user->first_name.' '.$current_user->last_name;
|
||||||
|
$supporter_input['user_email']=$current_user->email;
|
||||||
|
$supporter_input['user_role']=$current_user->role_name;
|
||||||
|
$supporter_input['added_by']=$input['last_user_id'];
|
||||||
|
$supporter_input['is_read']=$doceUser->is_read;
|
||||||
|
$supporter_input['promotion_id']=$saved_data->id;
|
||||||
|
$supporter_department = Department::where('id',$current_user->department_id)->first();
|
||||||
|
if($supporter_department)
|
||||||
|
{
|
||||||
|
$supporter_input['user_department']=$supporter_department->name;
|
||||||
|
}
|
||||||
|
$supporter_save=WorkflowDocumentUser::create($supporter_input);
|
||||||
|
$doceUser->status = "N";
|
||||||
|
$doceUser->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session::flash('success_message', 'Merge Users documents has been added successfully');
|
||||||
|
return redirect()->route('merged-users');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return view('admin.promotions.create', compact('user_lists', 'absent'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'No edit');
|
||||||
|
return back();
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$promotion = Promotion::where('id',$id)->first();
|
||||||
|
$current_user = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '=', $promotion->user_id)
|
||||||
|
->first();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '<>', $promotion->user_id)
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
if($promotion):
|
||||||
|
return view('admin.promotions.edit', compact('user_lists', 'promotion', 'current_user'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid Merge Users documents id.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $absentId)
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'No update');
|
||||||
|
return back();
|
||||||
|
$id=base64_decode($absentId);
|
||||||
|
$promotion = Promotion::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'last_user_id' => 'required',
|
||||||
|
'till_date' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if($promotion->last_user_id != $input['last_user_id']){
|
||||||
|
$updateDocumentUser = WorkflowDocumentUser::where('promotion_id', $promotion->id)->update(['status'=>'N']);
|
||||||
|
}
|
||||||
|
if($input['till_date'] != "")
|
||||||
|
$input['till_date'] = Carbon\Carbon::createFromFormat('m/d/Y', $input['till_date'])->format('Y-m-d');
|
||||||
|
$saved_data=$promotion->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$current_user = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name')
|
||||||
|
->where('users.id', '=', $promotion->user_id)
|
||||||
|
->first();
|
||||||
|
$workFlowDocumentUser = WorkflowDocumentUser::where('user_id', $input['last_user_id'])->get();
|
||||||
|
if(!empty($workFlowDocumentUser)){
|
||||||
|
foreach($workFlowDocumentUser as $doceUser){
|
||||||
|
$checkDocumentUser = WorkflowDocumentUser::where('user_id',$current_user->id)
|
||||||
|
->where('workflow_document_id',$doceUser->workflow_document_id)
|
||||||
|
->where('status', 'Y')
|
||||||
|
->first();
|
||||||
|
if(!isset($checkDocumentUser)){
|
||||||
|
$supporter_input['_token']=$input['_token'];
|
||||||
|
$supporter_input['workflow_document_id']=$doceUser->workflow_document_id;
|
||||||
|
$supporter_input['user_id']=$current_user->id;
|
||||||
|
$supporter_input['process_id']=$doceUser->process_id;
|
||||||
|
$supporter_input['user_type']='S';
|
||||||
|
$supporter_input['user_name']=$current_user->first_name.' '.$current_user->last_name;
|
||||||
|
$supporter_input['user_email']=$current_user->email;
|
||||||
|
$supporter_input['user_role']=$current_user->role_name;
|
||||||
|
$supporter_input['added_by']=$input['last_user_id'];
|
||||||
|
$supporter_input['promotion_id']=$saved_data->id;
|
||||||
|
$supporter_department = Department::where('id',$current_user->department_id)->first();
|
||||||
|
if($supporter_department)
|
||||||
|
{
|
||||||
|
$supporter_input['user_department']=$supporter_department->name;
|
||||||
|
}
|
||||||
|
$supporter_save=WorkflowDocumentUser::create($supporter_input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session::flash('success_message', 'Merge Users documents has been updated successfully');
|
||||||
|
return redirect()->route('merged-users');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-assign-absence', $absentId);
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'No delete');
|
||||||
|
return back();
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = Promotion::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
$updateDocumentUser = WorkflowDocumentUser::where('promotion_id', $id)->update(['status'=>'N']);
|
||||||
|
Session::flash('success_message', 'Merge Users documents has been deleted successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'No edit');
|
||||||
|
return back();
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = Promotion::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Absent has been updated successfully');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('absents');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\RegNumber;
|
||||||
|
|
||||||
|
use DB;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class RegNumberController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$row = new RegNumber;
|
||||||
|
$search='';
|
||||||
|
if($request->has('search') && strlen($request->search))
|
||||||
|
{
|
||||||
|
$row = $row->where('reg_number', 'LIKE', '%'.$request->search.'%');
|
||||||
|
$search = $request->search;
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_cancelled=0;
|
||||||
|
if($request->has('is_cancelled'))
|
||||||
|
{
|
||||||
|
if($request->input('is_cancelled') == 1)
|
||||||
|
{
|
||||||
|
$row = $row->where('is_cancelled', 1);
|
||||||
|
$is_cancelled = 1;
|
||||||
|
}
|
||||||
|
else if($request->input('is_cancelled') == 2)
|
||||||
|
{
|
||||||
|
$row = $row->where('is_cancelled', 0);
|
||||||
|
$is_cancelled = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = $row->orderBy('id', 'desc')->paginate(100);
|
||||||
|
return view('admin.registration_numbers.index')->with('regnumbers', $row)->with('search', $search)->with('is_cancelled', $is_cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetSeqNumber(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['seq_inc']))
|
||||||
|
{
|
||||||
|
RegNumber::resetSeqNumber($input['seq_inc'], RegNumber::INC);
|
||||||
|
}
|
||||||
|
if(isset($input['seq_out']))
|
||||||
|
{
|
||||||
|
RegNumber::resetSeqNumber($input['seq_out'], RegNumber::OUT);
|
||||||
|
}
|
||||||
|
if(isset($input['seq_int']))
|
||||||
|
{
|
||||||
|
RegNumber::resetSeqNumber($input['seq_int'], RegNumber::ITR);
|
||||||
|
}
|
||||||
|
if(isset($input['seq_tmp']))
|
||||||
|
{
|
||||||
|
RegNumber::resetSeqNumber($input['seq_tmp'], RegNumber::TMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::flash('success_message', 'Sequence Number has been added successfully');
|
||||||
|
return redirect()->route('registration_number.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSeqNumber()
|
||||||
|
{
|
||||||
|
$row = DB::table('reg_number_seq')->first();
|
||||||
|
|
||||||
|
return view('admin.registration_numbers.edit')->with('sequence', $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,146 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\RemoteContact;
|
||||||
|
use App\RemoteContactApi;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
class RemoteContactApiController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* private filter function
|
||||||
|
* @return RemoteContactApi model
|
||||||
|
*/
|
||||||
|
private function search($str)
|
||||||
|
{
|
||||||
|
$a = RemoteContactApi::where('archive', 0);
|
||||||
|
if(strlen(trim($str)) > 0)
|
||||||
|
{
|
||||||
|
$a = $a->where(function($query) use ($str){
|
||||||
|
$query->orWhere('method', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhere('description', 'LIKE', '%'. $str .'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request, RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
if($remotecontact->direction == 0)
|
||||||
|
return back();
|
||||||
|
$search = $request->input('search');
|
||||||
|
$row = $this->search($search)->where('remote_contact_id', $remotecontact->id);
|
||||||
|
$row = $row->orderBy('id', 'desc')->with('remotecontact.contact:id,organization_name')->paginate(100)->appends([
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('admin.remote_contacts_api.index')->with('remotecontactsapi', $row)->with('remotecontact', $remotecontact)->with('search', $search);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create(RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
if($remotecontact->direction == 0)
|
||||||
|
return back();
|
||||||
|
return view('admin.remote_contacts_api.create')->with('remotecontact', $remotecontact);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request, RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
if($remotecontact->direction == 0)
|
||||||
|
return back();
|
||||||
|
$validate = $this->rules();
|
||||||
|
if($validate->fails())
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->withErrors($validate)->withInput();
|
||||||
|
|
||||||
|
$remotecontactapi = new RemoteContactApi($validate->valid());
|
||||||
|
$remotecontactapi->remote_contact_id = $remotecontact->id;
|
||||||
|
if($remotecontactapi->save())
|
||||||
|
{
|
||||||
|
\Session::flash('success_message', 'API added successfully');
|
||||||
|
return redirect()->route('remote_contacts_api.index', $remotecontact);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->with('error', 'action create error')->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(RemoteContactApi $remotecontactapi)
|
||||||
|
{
|
||||||
|
return view('admin.remote_contacts_api.edit')->with('remotecontactapi', $remotecontactapi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, RemoteContactApi $remotecontactapi)
|
||||||
|
{
|
||||||
|
$validate = $this->rules();
|
||||||
|
if($validate->fails())
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->withErrors($validate)->withInput();
|
||||||
|
|
||||||
|
$remotecontactapi->update($validate->valid());
|
||||||
|
if($remotecontactapi->save())
|
||||||
|
{
|
||||||
|
\Session::flash('success_message', 'API updated successfully');
|
||||||
|
return redirect()->route('remote_contacts_api.index', $remotecontactapi->remotecontact);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->with('error', 'action create error')->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy(RemoteContactApi $remotecontactapi)
|
||||||
|
{
|
||||||
|
$remotecontactapi->archive = 1;
|
||||||
|
$remotecontactapi->connection_string= $remotecontactapi->connection_string . '__' . now();
|
||||||
|
if($remotecontactapi->save())
|
||||||
|
{
|
||||||
|
\Session::flash('success_message', 'RemoteContactApi deleted successfully');
|
||||||
|
return redirect()->route('remote_contacts_api.index', $remotecontactapi->remotecontact);
|
||||||
|
}
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'connection_string' => 'required',
|
||||||
|
'connection_method' => 'required',
|
||||||
|
'mandatory_fields' => 'required',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\RemoteContact;
|
||||||
|
use App\RemoteContactApi;
|
||||||
|
use App\Contact;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
class RemoteContactController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* private filter function
|
||||||
|
* @return RemoteContact model
|
||||||
|
*/
|
||||||
|
private function search($str, $direction=2)
|
||||||
|
{
|
||||||
|
$a = RemoteContact::where('archive', 0);
|
||||||
|
if(strlen(trim($str)) > 0)
|
||||||
|
{
|
||||||
|
$a = $a->where(function($query) use ($str){
|
||||||
|
$query->orWhere('login', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhere('description', 'LIKE', '%'. $str .'%');
|
||||||
|
});
|
||||||
|
|
||||||
|
$a = $a->orWhereHas('contact', function($query) use ($str){
|
||||||
|
$query->where('organization_name', 'LIKE', '%'. $str .'%')
|
||||||
|
->where('alternative_name', 'LIKE', '%'. $str .'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if($direction != 2)
|
||||||
|
return $a->where('direction', $direction);
|
||||||
|
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$search = $request->input('search');
|
||||||
|
$direction = $request->input('direction') ?? 2;
|
||||||
|
$row = $this->search($search, $direction);
|
||||||
|
$row = $row->orderBy('id', 'desc')->with('contact:id,organization_name')->paginate(100)->appends([
|
||||||
|
'search' => $search,
|
||||||
|
'direction' => $direction,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('admin.remote_contacts.index')->with('remotecontacts', $row)->with('search', $search)->with('direction', $direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
// $remotecontact = new RemoteContact;
|
||||||
|
$contacts = Contact::where('status', 1)->where('is_approved', 1)->get(['id', 'organization_name']);
|
||||||
|
|
||||||
|
return view('admin.remote_contacts.create')->with('contacts', $contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validate = $this->rules();
|
||||||
|
if($validate->fails())
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->withErrors($validate)->withInput();
|
||||||
|
|
||||||
|
$remotecontact = new RemoteContact($validate->valid());
|
||||||
|
if($remotecontact->save())
|
||||||
|
{
|
||||||
|
\Session::flash('success_message', 'RemoteContact has been added successfully');
|
||||||
|
return redirect()->route('remote_contacts.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->with('error', 'action create error')->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit(RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
if($remotecontact->archive == 1)
|
||||||
|
return back()->with('error', 'already archived');
|
||||||
|
|
||||||
|
return view('admin.remote_contacts.edit')->with('remotecontact', $remotecontact);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
$validate = $this->updateRules();
|
||||||
|
|
||||||
|
if($validate->fails())
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->withErrors($validate)->withInput();
|
||||||
|
|
||||||
|
$remotecontact->update($validate->valid());
|
||||||
|
|
||||||
|
if($remotecontact->save())
|
||||||
|
{
|
||||||
|
\Session::flash('success_message', 'Priority has been updated successfully');
|
||||||
|
return redirect()->route('remote_contacts.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->with('prev-url', $request->input('prev-url'))->with('error', 'action create error')->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, RemoteContact $remotecontact)
|
||||||
|
{
|
||||||
|
$remotecontact->archive = 1;
|
||||||
|
$remotecontact->login = $remotecontact->login . '__' . now();
|
||||||
|
if($remotecontact->save())
|
||||||
|
{
|
||||||
|
RemoteContactApi::where('remote_contact_id', $remotecontact->id)->update(['archive' => 1]);
|
||||||
|
\Session::flash('success_message', 'Remote Contact deleted successfully');
|
||||||
|
return redirect()->route('remote_contacts.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'contact_id' => 'required',
|
||||||
|
'direction' => 'required',
|
||||||
|
'login' => 'required',
|
||||||
|
'password' => 'required',
|
||||||
|
'public_key' => 'nullable',
|
||||||
|
'description' => 'nullable | max:255',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function updateRules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'direction' => 'required',
|
||||||
|
'login' => 'required',
|
||||||
|
'password' => 'required',
|
||||||
|
'public_key' => 'nullable',
|
||||||
|
'description' => 'nullable | max:255',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Role;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class RolesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$roles = Role::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.roles.index', compact('roles', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.roles.create', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Role name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Role::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Role name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=Role::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Role has been added successfully');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-role');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$role = Role::where('id', '=', $id)->first();
|
||||||
|
if($role):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.roles.edit', compact('role', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid role id.');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$role = Role::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Role name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = Role::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Role name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Role has been updated successfully');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-role');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_role = Role::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Role has been deleted successfully');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_role = Role::findOrFail($id);
|
||||||
|
if($find_role->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_role->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Role has been updated successfully');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('roles');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class SettingsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$reg_format = [
|
||||||
|
'0' => 'PRX-YYYY-MM-DD-SEQ',
|
||||||
|
'1' => 'PRX-YYYY-MM-SEQ',
|
||||||
|
'2' => 'PRX-YYYY-SEQ',
|
||||||
|
'3' => 'PRX-SEQ'
|
||||||
|
];
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
if($setting):
|
||||||
|
return view('admin.settings.edit', compact('setting', 'languages','reg_format'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid setting id.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'up_website_logo' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
'up_fabicon' => 'mimes:ico|max:2048',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$organization_name=[];
|
||||||
|
$organization_address=[];
|
||||||
|
$copyright_content=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($input['organization_name_'.$language->short_name])):
|
||||||
|
$organization_name[$language->short_name]= $input['organization_name_'.$language->short_name];
|
||||||
|
else:
|
||||||
|
$organization_name[$language->short_name]= '';
|
||||||
|
endif;
|
||||||
|
if(isset($input['organization_address_'.$language->short_name])):
|
||||||
|
$organization_address[$language->short_name]= $input['organization_address_'.$language->short_name];
|
||||||
|
else:
|
||||||
|
$organization_address[$language->short_name]= '';
|
||||||
|
endif;
|
||||||
|
if(isset($input['copyright_content_'.$language->short_name])):
|
||||||
|
$copyright_content[$language->short_name]= $input['copyright_content_'.$language->short_name];
|
||||||
|
else:
|
||||||
|
$copyright_content[$language->short_name]= '';
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$input['organization_name'] = json_encode($organization_name);
|
||||||
|
$input['organization_address'] = json_encode($organization_address);
|
||||||
|
$input['copyright_content'] = json_encode($copyright_content);
|
||||||
|
|
||||||
|
if(isset($input['up_website_logo']) && $input['up_website_logo']->getError() == 0 && $input['up_website_logo']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
if($setting->website_logo != "" && file_exists(public_path('uploads/setting_folder/'.$setting->image)))
|
||||||
|
$prev_website_logo = $setting->website_logo;
|
||||||
|
$website_logo = "profile_".time().'.'.$input['up_website_logo']->getClientOriginalExtension();
|
||||||
|
$input['website_logo'] = $website_logo;
|
||||||
|
}
|
||||||
|
if(isset($input['up_fabicon']) && $input['up_fabicon']->getError() == 0 && $input['up_fabicon']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
if($setting->fabicon != "" && file_exists(public_path('uploads/setting_folder/'.$setting->image)))
|
||||||
|
$prev_fabicon = $setting->fabicon;
|
||||||
|
$fabicon = "profile_".time().'.'.$input['up_fabicon']->getClientOriginalExtension();
|
||||||
|
$input['fabicon'] = $fabicon;
|
||||||
|
}
|
||||||
|
$saved_data=$setting->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
if(isset($input['up_website_logo']) && $input['up_website_logo']->getError() == 0 && $input['up_website_logo']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['up_website_logo']->move(public_path('uploads/setting_folder'), $website_logo);
|
||||||
|
if(isset($prev_website_logo) && $prev_website_logo != "" && file_exists(public_path('uploads/setting_folder/'.$prev_website_logo)))
|
||||||
|
unlink(public_path('uploads/setting_folder/'.$prev_website_logo));
|
||||||
|
}
|
||||||
|
if(isset($input['up_fabicon']) && $input['up_fabicon']->getError() == 0 && $input['up_fabicon']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['up_fabicon']->move(public_path('uploads/setting_folder'), $fabicon);
|
||||||
|
if(isset($prev_fabicon) && $prev_fabicon != "" && file_exists(public_path('uploads/setting_folder/'.$prev_fabicon)))
|
||||||
|
unlink(public_path('uploads/setting_folder/'.$prev_fabicon));
|
||||||
|
}
|
||||||
|
Session::flash('success_message', 'Settings has been updated successfully');
|
||||||
|
return redirect()->route('edit-setting');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-setting');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,193 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\User;
|
||||||
|
use App\MyFile;
|
||||||
|
use App\Directory;
|
||||||
|
use App\Setting;
|
||||||
|
use App\Department;
|
||||||
|
use App\SharedFile;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class SharedFilesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$directories = DB::table('directories')
|
||||||
|
->where('by_admin', 1)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.shared-files.index', compact('directories', 'users', 'departments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$directories=Directory::where('by_admin', 1)
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.shared-files.create', compact('directories', 'users', 'departments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:directories,name|max:191',
|
||||||
|
'permission' => 'required',
|
||||||
|
'share_to' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$input['by_admin']=1;
|
||||||
|
$input['year'] = date('Y');
|
||||||
|
$directory_save=Directory::create($input);
|
||||||
|
if($directory_save)
|
||||||
|
{
|
||||||
|
if($input['share_to'] !== null)
|
||||||
|
{
|
||||||
|
$share_input=$input;
|
||||||
|
$share_input['directory_id']=$directory_save['id'];
|
||||||
|
$share_input['type']='D';
|
||||||
|
$share_to=explode('-',$input['share_to']);
|
||||||
|
if($share_to[0] == 'uid')
|
||||||
|
{
|
||||||
|
$share_input['user_id'] = $share_to[1];
|
||||||
|
}
|
||||||
|
elseif($share_to[0] == 'did')
|
||||||
|
{
|
||||||
|
$share_input['department_id'] = $share_to[1];
|
||||||
|
}
|
||||||
|
$saved_data=SharedFile::create($share_input);
|
||||||
|
}
|
||||||
|
Session::flash('success_message', __('Directory has been added successfully'));
|
||||||
|
return redirect()->route('shared-directories');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$directory = Directory::where('id', '=', $id)->first();
|
||||||
|
if($directory):
|
||||||
|
$users = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('users.status', '=', '1')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('roles.id', 'asc')
|
||||||
|
->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
$sharedfile = SharedFile::where('directory_id', $directory->id)->where('by_admin', 1)->first();
|
||||||
|
return view('admin.shared-files.edit', compact('directory', 'users', 'departments', 'sharedfile'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid directory id.');
|
||||||
|
return redirect()->route('shared-directories');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$directory = Directory::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'name' => 'required|unique:directories,name,'.$id.'|max:191',
|
||||||
|
'permission' => 'required',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$directory->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$update = SharedFile::where('directory_id', $directory->id)->where('by_admin', 1)->update(['permission'=>$input['permission']]);
|
||||||
|
Session::flash('success_message', 'Directory has been updated successfully');
|
||||||
|
return redirect()->route('shared-directories');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$update = SharedFile::where('directory_id', $id)->delete();
|
||||||
|
$delete_role = Directory::where('id', $id)->delete();
|
||||||
|
if($delete_role):
|
||||||
|
Session::flash('success_message', 'Directory has been deleted successfully');
|
||||||
|
return redirect()->route('shared-directories');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('shared-directories');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,210 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Translation;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class TranslationsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->where('status', '1')
|
||||||
|
->where('id', '<>', $setting->default_language)
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$translations = DB::table('translations')
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.translations.index', compact('translations', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->where('id', '<>', $setting->default_language)
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$default_language = DB::table('languages')
|
||||||
|
->where('id', '=', $setting->default_language)
|
||||||
|
->first();
|
||||||
|
return view('admin.translations.create', compact('languages', 'default_language'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->where('id', '<>', $setting->default_language)
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'primary_text' => 'required|unique:translations,primary_text',
|
||||||
|
]);
|
||||||
|
$translation_text=[];
|
||||||
|
$input = $request->all();
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
$translation_text[$language->short_name]= $input['translation_text_'.$language->short_name];
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$input['translation_text'] = json_encode($translation_text);
|
||||||
|
$saved_data=Translation::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', 'Translation Text has been added successfully');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-translation');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$translation = Translation::where('id', '=', $id)->first();
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->where('status', '1')
|
||||||
|
->where('id', '<>', $setting->default_language)
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$default_language = DB::table('languages')
|
||||||
|
->where('id', '=', $setting->default_language)
|
||||||
|
->first();
|
||||||
|
if($translation):
|
||||||
|
return view('admin.translations.edit', compact('translation','languages', 'default_language'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid translation id.');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$translation = Translation::findOrFail($id);
|
||||||
|
$setting = Setting::first();
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->where('id', '<>', $setting->default_language)
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'primary_text' => 'required|unique:translations,primary_text,'.$id,
|
||||||
|
]);
|
||||||
|
$translation_text=[];
|
||||||
|
$input = $request->all();
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
$translation_text[$language->short_name]= $input['translation_text_'.$language->short_name];
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$input['translation_text'] = json_encode($translation_text);
|
||||||
|
$saved_data=$translation->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Translation has been updated successfully');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-translation');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$translation = Translation::findOrFail($id);
|
||||||
|
$delete_translation = $translation->delete();
|
||||||
|
if($delete_translation):
|
||||||
|
Session::flash('success_message', 'Translation has been deleted successfully');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_translation = Translation::findOrFail($id);
|
||||||
|
if($find_translation->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_translation->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Translation has been updated successfully');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('translations');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,257 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\User;
|
||||||
|
use App\Role;
|
||||||
|
use App\Department;
|
||||||
|
use App\RoleUser;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class UsersController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$users = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('users.status', 'desc')
|
||||||
|
->orderBy('users.working_status', 'desc')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get();
|
||||||
|
return view('admin.users.index', compact('users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$roles=Role::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
$departments=Department::where('status', '=', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.users.create', compact('roles', 'departments', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parentusers(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('roles.id', '=', ($input['data_id']-1))
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
return response()->json(['user_lists'=>$user_lists]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'first_name' => 'required|max:150',
|
||||||
|
'last_name' => 'required|max:150',
|
||||||
|
'username' => 'required|unique:users,username|max:100',
|
||||||
|
'email' => 'unique:users,email|email|max:255',
|
||||||
|
'password' => 'required|min:6|confirmed',
|
||||||
|
'cell_phone_number' => 'numeric',
|
||||||
|
'up_profile_picture' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$userImageName = "profile_".time().'.'.$input['up_profile_picture']->getClientOriginalExtension();
|
||||||
|
$input['profile_picture'] = $userImageName;
|
||||||
|
}
|
||||||
|
$input['user_disk_quota'] = $setting->default_disk_quota;
|
||||||
|
$input['password']=bcrypt($input['password']);
|
||||||
|
$saved_data=User::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
$input['up_profile_picture']->move(public_path('uploads/user_folder'), $userImageName);
|
||||||
|
|
||||||
|
$RoleUserInput['_token']=$input['_token'];
|
||||||
|
$RoleUserInput['user_id']=$saved_data->id;
|
||||||
|
$RoleUserInput['role_id']=$input['role_id'];
|
||||||
|
$saved_RoleUser=RoleUser::create($RoleUserInput);
|
||||||
|
Session::flash('success_message', 'User has been added successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-user');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$user = User::where('id', '=', $id) ->join('role_user', 'users.id', '=', 'role_user.user_id')->first();
|
||||||
|
if($user):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$user_lists = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.working_status', '=', '1')
|
||||||
|
->where('roles.id', '=', ($user->role_id-1))
|
||||||
|
->select(DB::raw("CONCAT(users.first_name, ' ',users.last_name) AS user_details"), 'users.id', 'roles.name as role_name')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
|
$roles=Role::orderBy('id', 'asc')->pluck('name', 'id')->toArray();
|
||||||
|
$departments=Department::where('status', '=', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('admin.users.edit', compact('user', 'roles', 'user_lists', 'departments', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid user id.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'first_name' => 'required|max:150',
|
||||||
|
'last_name' => 'required|max:150',
|
||||||
|
'username' => 'required|unique:users,username,'.$id.'|max:100',
|
||||||
|
'email' => 'unique:users,email,'.$id.'|email|max:255',
|
||||||
|
'password' => 'confirmed',
|
||||||
|
'cell_phone_number' => 'nullable|numeric',
|
||||||
|
'up_profile_picture' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
if($user->profile_picture != "" && file_exists(public_path('uploads/user_folder/'.$user->image)))
|
||||||
|
$prev_image = $user->profile_picture;
|
||||||
|
$userImageName = "profile_".time().'.'.$input['up_profile_picture']->getClientOriginalExtension();
|
||||||
|
$input['profile_picture'] = $userImageName;
|
||||||
|
}
|
||||||
|
if($request['password']!=""):
|
||||||
|
$input['password']=bcrypt($request['password']);
|
||||||
|
else:
|
||||||
|
unset($input['password']);
|
||||||
|
endif;
|
||||||
|
if($request->input('working_status') == 0 || $request->input('status') == 0)
|
||||||
|
$input['password'] = bcrypt(bin2hex(random_bytes(100)));
|
||||||
|
|
||||||
|
$saved_data=$user->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['up_profile_picture']->move(public_path('uploads/user_folder'), $userImageName);
|
||||||
|
if(isset($prev_image) && $prev_image != "" && file_exists(public_path('uploads/user_folder/'.$prev_image)))
|
||||||
|
unlink(public_path('uploads/user_folder/'.$prev_image));
|
||||||
|
}
|
||||||
|
$roleuser = RoleUser::where('user_id', '=', $id)->update(['role_id'=>$input['role_id']]);
|
||||||
|
Session::flash('success_message', 'User has been updated successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-user');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_user = User::where('id', '=', $id)->update(['working_status'=>0, 'password'=>bcrypt(bin2hex(random_bytes(100)))]);
|
||||||
|
if($delete_user):
|
||||||
|
Session::flash('success_message', 'User has been deleted successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_user = User::findOrFail($id);
|
||||||
|
if($find_user->status==1)
|
||||||
|
{
|
||||||
|
$status=0;
|
||||||
|
$find_user->password = bcrypt(bin2hex(random_bytes(100)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_user->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'User has been updated successfully');
|
||||||
|
return redirect()->route('users');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('users');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\WorkflowType;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
class WorkflowTypesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:admin');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$workflow_types = WorkflowType::orderBy('id', 'desc')->get();
|
||||||
|
return view('admin.workflow-types.index', compact('workflow_types', 'languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('admin.workflow-types.create', compact('languages'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Workflow type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = WorkflowType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Workflow type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=WorkflowType::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Workflow type has been added successfully');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('add-workflow-type');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$workflow_type = WorkflowType::where('id', '=', $id)->first();
|
||||||
|
if($workflow_type):
|
||||||
|
return view('admin.workflow-types.edit', compact('workflow_type', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'Invalid work flow type id.');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$workflow_type = WorkflowType::findOrFail($id);
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
$request->session()->put('old_data', $request->all());
|
||||||
|
$name=[];
|
||||||
|
$error_array=[];
|
||||||
|
if(!empty($languages)):
|
||||||
|
foreach($languages as $language):
|
||||||
|
if(isset($request['name_'.$language->short_name])):
|
||||||
|
if($request['name_'.$language->short_name]== ''):
|
||||||
|
Session::flash('error_message', 'Workflow type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is required.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$exists_check = WorkflowType::where('name', 'LIKE', '%"'.$language->short_name.'":"'.$request['name_'.$language->short_name].'"%')->where('id', '<>', $id)->first();
|
||||||
|
if(isset($exists_check) && !empty($exists_check)):
|
||||||
|
Session::flash('error_message', 'Workflow type name for '.$language->name.' ( '.strtoupper($language->short_name).' ) is already exists.');
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
$name[$language->short_name]= $request['name_'.$language->short_name];
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
$request['name'] = json_encode($name);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$workflow_type->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
$request->session()->forget('old_data');
|
||||||
|
Session::flash('success_message', 'Workflow type has been updated successfully');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('edit-workflow-type');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$delete_workflow_type = WorkflowType::where('id', $id)->delete();
|
||||||
|
if($delete_workflow_type):
|
||||||
|
Session::flash('success_message', 'Workflow type has been deleted successfully');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_workflow_type = WorkflowType::findOrFail($id);
|
||||||
|
if($find_workflow_type->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_workflow_type->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', 'Workflow type has been updated successfully');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', 'We are having some problem. Please try later.');
|
||||||
|
return redirect()->route('workflow-types');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,210 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\RemoteContact;
|
||||||
|
use App\RemoteTransfer;
|
||||||
|
use App\Permission;
|
||||||
|
use App\Notifications\DocumentNotification;
|
||||||
|
use Notification;
|
||||||
|
use Validator;
|
||||||
|
use File;
|
||||||
|
use Hash;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
|
class ApiController extends Controller
|
||||||
|
{
|
||||||
|
static $timeout = 20;
|
||||||
|
private function isAllowed($login, $pass, $checkIP=false)
|
||||||
|
{
|
||||||
|
$remote_contact = RemoteContact::where('login', $login)->where('direction', 0)->where('password', $pass)->first();
|
||||||
|
if(!$remote_contact)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// if($checkIP)
|
||||||
|
// if(!isset(static::$ip[$login]) || !(static::$ip[$login] == request()->getClientIp()))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
return $remote_contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'registration_number' => 'required',
|
||||||
|
'registration_date' => 'required | date | date_format:Y-m-d',
|
||||||
|
'file' => 'required|mimes:doc,docx,xls,xlsx,pdf,txt,jpeg,jpg,png|max:20480',
|
||||||
|
'description' => 'nullable | max:255',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkStatusRules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'receipt' => 'required',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function receiveDocument(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if(!$request->hasHeader('login') || !$request->hasHeader('password'))
|
||||||
|
return response()->json(['success' => false, 'error' => 'login and password required'], 401);
|
||||||
|
|
||||||
|
$remote_contact = $this->isAllowed($request->header()['login'][0], $request->header()['password'][0]);
|
||||||
|
if( $remote_contact == false)
|
||||||
|
return response()->json(['success' => false, 'error' => 'Unauthorized'], 401);
|
||||||
|
|
||||||
|
$validate = $this->rules();
|
||||||
|
if($validate->fails())
|
||||||
|
return response()->json(['success' => false, 'error'=>$validate->errors()], 400);
|
||||||
|
|
||||||
|
$transfer = new RemoteTransfer;
|
||||||
|
$transfer->receipt = \sha1(rand(99999, 9999999999));
|
||||||
|
$transfer->login = $request->header()['login'][0];
|
||||||
|
$transfer->direction = 0;
|
||||||
|
$transfer->status = 3;
|
||||||
|
$transfer->send_at = now();
|
||||||
|
// $transfer->description = $request->input('description');
|
||||||
|
$transfer->content = json_encode(['registration_number' => $request->input('registration_number') ?? '', 'registration_date'=>$request->input('registration_date') ?? '', 'topic'=>$request->input('topic') ?? '']);
|
||||||
|
$transfer->contact_id = $remote_contact->contact_id;
|
||||||
|
|
||||||
|
if ($request->hasFile('file'))
|
||||||
|
{
|
||||||
|
if(!empty($request->file()) && is_array($request->file()))
|
||||||
|
{
|
||||||
|
$place_of_the_documents='documents/'.date('Y').'/'.'remote';
|
||||||
|
$files = $request->file();
|
||||||
|
foreach($files as $key=>$file)
|
||||||
|
{
|
||||||
|
if(!File::isDirectory(public_path().'/'.$place_of_the_documents))
|
||||||
|
File::makeDirectory(public_path().'/'.$place_of_the_documents, 0777, true, true);
|
||||||
|
|
||||||
|
$document_name = 'remote' . '_' . md5($file->getClientOriginalName() . microtime()) .'.'. $file->getClientOriginalExtension();;
|
||||||
|
$file->move(public_path($place_of_the_documents), $document_name);
|
||||||
|
|
||||||
|
$transfer->place_of_the_documents = $place_of_the_documents;
|
||||||
|
$transfer->document_name = $document_name;
|
||||||
|
|
||||||
|
if(!in_array($file->getClientOriginalExtension(), ['pdf', 'zip', 'tar', 'rar', 'exe', 'gz']))
|
||||||
|
{
|
||||||
|
shell_exec('export HOME=/tmp && /usr/bin/libreoffice --headless --convert-to pdf ' . public_path($place_of_the_documents) . '/' . $document_name . ' --outdir ' . public_path($place_of_the_documents));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($transfer->save())
|
||||||
|
{
|
||||||
|
$link = route('transfers.show', base64_encode($transfer->id));
|
||||||
|
|
||||||
|
$permitted_users = Permission::getPermittedUsersList(13);
|
||||||
|
foreach($permitted_users as $puser)
|
||||||
|
{
|
||||||
|
Notification::send($puser, new DocumentNotification($transfer->id, "api", "received", $link));
|
||||||
|
}
|
||||||
|
return response()->json(['success' => true, 'data' => ['receipt' => $transfer->receipt]], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
\Log::info(['error' => $th->getMessage()]);
|
||||||
|
return response()->json(['success' => false, 'error' => 'unknown error'], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkStatus(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if(!$request->hasHeader('login') || !$request->hasHeader('password'))
|
||||||
|
return response()->json(['success' => false, 'error' => 'login and password required'], 401);
|
||||||
|
|
||||||
|
$remote_contact = $this->isAllowed($request->header()['login'][0], $request->header()['password'][0]);
|
||||||
|
if( $remote_contact == false)
|
||||||
|
return response()->json(['success' => false, 'error' => 'Unauthorized'], 401);
|
||||||
|
|
||||||
|
$validate = $this->checkStatusRules();
|
||||||
|
if($validate->fails())
|
||||||
|
return response()->json(['success' => false, 'error'=>$validate->errors()], 400);
|
||||||
|
|
||||||
|
$transfer = RemoteTransfer::where('receipt', $request->input('receipt'))->first();
|
||||||
|
if(!$transfer)
|
||||||
|
return response()->json(['success' => false, 'error'=>'not found'], 404);
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json(['success' => true, 'data' => ['status' => $transfer->status]], 200);
|
||||||
|
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
\Log::info(['error' => $th->getMessage()]);
|
||||||
|
return response()->json(['success' => false, 'error' => 'unknown error'], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendDocuments($id=null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$remotetransfers = ($id == null) ? RemoteTransfer::where('direction', 1)->whereIn('status', [1, 4])->get() : RemoteTransfer::where('id', $id)->get();
|
||||||
|
if($remotetransfers)
|
||||||
|
{
|
||||||
|
foreach($remotetransfers as $remotetransfer)
|
||||||
|
{
|
||||||
|
$this->sendDocument($remotetransfer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
\Log::info(['error' => $th->getMessage()]);
|
||||||
|
return response()->json(['success' => false, 'data' => 'unknown error'], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatus(Request $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendDocument(RemoteTransfer $remotetransfer)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$remotecontact = RemoteContact::where('archive', 0)->where('direction', 1)->where('contact_id', $remotetransfer->contact_id)->whereHas('remotecontactapis')->with('remotecontactapis')->first();
|
||||||
|
$api = $remotecontact->remotecontactapis->first();
|
||||||
|
|
||||||
|
$file_path = public_path().'/'.$remotetransfer->place_of_the_documents.'/'.$remotetransfer->document_name;
|
||||||
|
$client = new Client(['base_uri' => $api->connection_string, 'verify'=>false, 'timeout'=>static::$timeout, 'headers'=>['login'=>$remotecontact->login, 'password'=>$remotecontact->password]]);
|
||||||
|
|
||||||
|
$data[] = [
|
||||||
|
'name' => 'file',
|
||||||
|
'contents' => fopen($file_path, 'rb'),
|
||||||
|
'filename' => $remotetransfer->document_name,
|
||||||
|
];
|
||||||
|
|
||||||
|
$contents = json_decode($remotetransfer->content);
|
||||||
|
foreach($contents as $key=>$value)
|
||||||
|
{
|
||||||
|
$data[] =['name' => $key, 'contents'=>$value];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $client->request($api->connection_method, '',[
|
||||||
|
'multipart' => $data,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if($response->getStatusCode() == 200)
|
||||||
|
{
|
||||||
|
$result = json_decode($response->getBody()->getContents());
|
||||||
|
if($result->success == "true")
|
||||||
|
{
|
||||||
|
$remotetransfer->receipt = $result->data->receipt;
|
||||||
|
$remotetransfer->status = 2;
|
||||||
|
$remotetransfer->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::info(['success'=>false, 'msg'=>'connection refused', 'info'=>$e->getMessage()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\User;
|
||||||
|
use Cookie;
|
||||||
|
use Session;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/documents';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest')->except('logout');
|
||||||
|
}
|
||||||
|
protected function credentials(Request $request)
|
||||||
|
{
|
||||||
|
$field = 'username';
|
||||||
|
return [
|
||||||
|
$field => $request->get($this->username()),
|
||||||
|
'password' => $request->password,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
protected function attemptLogin(Request $request)
|
||||||
|
{
|
||||||
|
return $this->guard()->attempt(
|
||||||
|
$this->credentials($request), $request->has('remember')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
protected function authenticated(Request $request, $user)
|
||||||
|
{
|
||||||
|
if($user->user_language)
|
||||||
|
{
|
||||||
|
$request->session()->put('locale', $user->user_language);
|
||||||
|
$log_update= User::where('id', '=', $user->id)->update(['is_log_in'=>1, 'working_status'=>1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::flash('success_message', __('You are successfully logged in.'));
|
||||||
|
if($request->has('remember'))
|
||||||
|
return redirect()->route('documents', 'Incoming')->cookie('front_cookie_remember', 1)->cookie('front_cookie_password', $request->password)->cookie('front_cookie_username', $request->get($this->username()));
|
||||||
|
// return redirect()->route('user-dashboard')->cookie('front_cookie_remember', 1)->cookie('front_cookie_password', $request->password)->cookie('front_cookie_username', $request->get($this->username()));
|
||||||
|
else
|
||||||
|
return redirect()->route('documents', 'Incoming')->cookie('front_cookie_remember', '')->cookie('front_cookie_password', '')->cookie('front_cookie_username', '');
|
||||||
|
}
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
$log_update= User::where('id', '=', Auth::user()->id)->update(['is_log_in'=>0]);
|
||||||
|
$this->guard()->logout();
|
||||||
|
$request->session()->invalidate();
|
||||||
|
Session::flash('success_message', __('You are successfully logged out.'));
|
||||||
|
return redirect()->route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('signed')->only('verify');
|
||||||
|
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\WorkflowDocument;
|
||||||
|
use App\Comment;
|
||||||
|
use App\Setting;
|
||||||
|
use Validator;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class CommentsController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$workflow_document = WorkflowDocument::findOrFail($id);
|
||||||
|
$setting = Setting::first();
|
||||||
|
$comments = Comment::where('workflow_document_id', $workflow_document->id)->get();
|
||||||
|
|
||||||
|
|
||||||
|
return $comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validate = $this->rules();
|
||||||
|
|
||||||
|
if($validate->fails())
|
||||||
|
return back()->withErrors($validate)->withInput();
|
||||||
|
|
||||||
|
$document = WorkflowDocument::findOrFail($request->workflow_document_id);
|
||||||
|
|
||||||
|
$comment = new Comment($validate->valid());
|
||||||
|
$comment->comment = nl2br($request->input('comment'));
|
||||||
|
$comment->user_id = auth()->user()->id;
|
||||||
|
$comment->save();
|
||||||
|
|
||||||
|
Session::flash('success_message', __('Comment created.'));
|
||||||
|
return redirect()->route('details',base64_encode($document->id))->withInput(['tab'=>$request->tab]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rules()
|
||||||
|
{
|
||||||
|
return Validator::make(request()->all(), [
|
||||||
|
'workflow_document_id' => 'required',
|
||||||
|
'comment' => 'required',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,201 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Contact;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class ContactsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:web');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function search(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$request->session()->put('search_val', $input['search']);
|
||||||
|
return redirect()->route('contact-list');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
if(isset($setting->data_limit_per_page) && $setting->data_limit_per_page > 0)
|
||||||
|
{
|
||||||
|
$limit_val = $setting->data_limit_per_page;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$limit_val = 20;
|
||||||
|
}
|
||||||
|
$search_val = null;
|
||||||
|
if($request->session()->has('search_val')){
|
||||||
|
$search_val = $request->session()->get('search_val');
|
||||||
|
$request->session()->forget('search_val');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->ajax())
|
||||||
|
$search_val = $request->input('search');
|
||||||
|
|
||||||
|
if($search_val !== null)
|
||||||
|
{
|
||||||
|
$contacts = Contact::orderBy('id', 'desc')
|
||||||
|
->where('organization_name', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('alternative_name', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('address', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('telephone_number', 'like', '%'.$search_val.'%')
|
||||||
|
->paginate($limit_val)->appends([
|
||||||
|
'search_val' => $search_val
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$contacts = Contact::orderBy('id', 'desc')->paginate($limit_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->ajax())
|
||||||
|
return response()->json($contacts->map(function($item, $key){
|
||||||
|
return $item->only(['id', 'organization_name']);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return view('contacts.index', compact('contacts', 'search_val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('contacts.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'organization_name' => 'required|unique:contacts,organization_name|max:150',
|
||||||
|
'alternative_name' => 'max:150',
|
||||||
|
'address' => 'required',
|
||||||
|
'telephone_number' => 'required|numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if(Auth::user()->department_id != 7):
|
||||||
|
$input['is_approved']='0';
|
||||||
|
endif;
|
||||||
|
$saved_data=Contact::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', __('Contact has been added successfully'));
|
||||||
|
return redirect()->route('contact-list');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('add-contact-list');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$contact = Contact::findOrFail($id);
|
||||||
|
if($contact):
|
||||||
|
return view('contacts.edit', compact('contact'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('Invalid contact id.'));
|
||||||
|
return redirect()->route('contact-list');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$contact = Contact::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'organization_name' => 'required|unique:contacts,organization_name,'.$id.'|max:150',
|
||||||
|
'alternative_name' => 'max:150',
|
||||||
|
'address' => 'required',
|
||||||
|
'telephone_number' => 'required|numeric',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
$saved_data=$contact->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', __('Contact has been updated successfully'));
|
||||||
|
return redirect()->route('contact-list');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('edit-contact-list');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function statusupdate($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$find_contact = Contact::findOrFail($id);
|
||||||
|
if($find_contact->status==1)
|
||||||
|
$status=0;
|
||||||
|
else
|
||||||
|
$status=1;
|
||||||
|
$input=[
|
||||||
|
'status'=>$status
|
||||||
|
];
|
||||||
|
$saved_data=$find_contact->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', __('Contact has been updated successfully'));
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('contacts');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,275 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\WorkflowDocument;
|
||||||
|
use App\WorkflowType;
|
||||||
|
use App\WorkflowDocumentFile;
|
||||||
|
use App\WorkflowDocumentUser;
|
||||||
|
use App\WorkflowDocumentProcess;
|
||||||
|
use App\WorkflowDocumentSender;
|
||||||
|
use App\Department;
|
||||||
|
use App\User;
|
||||||
|
use App\Event;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Exports\ListingExport;
|
||||||
|
use Excel;
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:web');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function basicDashboard()
|
||||||
|
{
|
||||||
|
return view('dashboard.basic');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function advancedDashboard(Request $request)
|
||||||
|
{
|
||||||
|
if(!in_array(14, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', __('no permission'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
$regdate = '';
|
||||||
|
if($request->has('reg_date'))
|
||||||
|
{
|
||||||
|
$regdates = preg_split("/\s+:\s+/", trim($request->input('reg_date')));
|
||||||
|
$date['f'] = Carbon::createFromFormat('d-m-Y', $regdates[0])->format('Y-m-d') . ' 00:00:00';
|
||||||
|
$date['t'] = Carbon::createFromFormat('d-m-Y', $regdates[1])->format('Y-m-d') . ' 23:59:59';
|
||||||
|
$regdate = trim($request->input('reg_date'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$date['f'] = Carbon::now()->startOfDay()->format('Y-m-d H:i:s');
|
||||||
|
$date['t'] = Carbon::now()->endOfDay()->format('Y-m-d H:i:s');
|
||||||
|
$regdate = Carbon::now()->startOfDay()->format('d-m-Y') . " : " . Carbon::now()->endOfDay()->format('d-m-Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$departments = Department::where('status', 1)->get();
|
||||||
|
$workfloworkflowtypes = WorkflowType::where('id', '!=', 4)->orderBy('id', 'asc')->get();
|
||||||
|
$setting = Setting::first();
|
||||||
|
|
||||||
|
$total_documents = DB::table('workflow_documents as w')
|
||||||
|
->join('workflow_types as wt', 'wt.id', '=', 'w.workflow_type_id')
|
||||||
|
->where('w.is_deleted', 0)
|
||||||
|
->groupBy('w.workflow_type_id')
|
||||||
|
->groupBy('w.status')
|
||||||
|
->selectRaw('w.workflow_type_id, wt.name, w.status, count(*) as count')
|
||||||
|
->whereBetween('w.registration_date', [$date['f'], $date['t']])
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$sub_departments = DB::table('workflow_document_process')
|
||||||
|
->selectRaw('workflow_document_id, max(id) as maxid')
|
||||||
|
->groupBy('workflow_document_id')
|
||||||
|
->where('user_type', 'R');
|
||||||
|
|
||||||
|
$total_departments = DB::table('workflow_documents as w')
|
||||||
|
->join('workflow_types as wt', 'wt.id', '=', 'w.workflow_type_id')
|
||||||
|
->join('workflow_document_process as wp', 'wp.workflow_document_id', '=', 'w.id')
|
||||||
|
->joinSub($sub_departments, 'sb', function($join){
|
||||||
|
$join->on('sb.maxid', '=', 'wp.id');
|
||||||
|
})
|
||||||
|
->where('w.is_deleted', 0)
|
||||||
|
->whereBetween('w.registration_date', [$date['f'], $date['t']])
|
||||||
|
->selectRaw('wt.name as workflow_type_name, wt.id as workflow_type_id, w.status, wp.user_department as department, count(*) as count')
|
||||||
|
->groupBy('w.workflow_type_id')
|
||||||
|
->groupBy('w.status')
|
||||||
|
->groupBy('wp.user_department')
|
||||||
|
->orderBy('w.id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
// echo '<pre>';
|
||||||
|
// print_r($total_documents->toArray());
|
||||||
|
// echo '</pre>';
|
||||||
|
// die();
|
||||||
|
// dd($regdate);
|
||||||
|
|
||||||
|
return view('dashboard.advanced', compact('total_documents', 'setting', 'total_departments', 'departments', 'workfloworkflowtypes', 'regdate'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filterDocuments($reg_date, $workflowtype, $status, $not, $department='', $type=null)
|
||||||
|
{
|
||||||
|
$workflowtypes = WorkflowType::where('status', $workflowtype)->get(['id', 'name']);
|
||||||
|
|
||||||
|
$input['reg_date'] = $reg_date;
|
||||||
|
$input['workflowtype'] = $workflowtype;
|
||||||
|
$input['status'] = $status;
|
||||||
|
$input['not'] = $not ?? 'N';
|
||||||
|
$input['department'] = $department;
|
||||||
|
$input['export'] = $type;
|
||||||
|
|
||||||
|
$regdates = preg_split("/\s+:\s+/", trim($input['reg_date']));
|
||||||
|
$f = Carbon::createFromFormat('d-m-Y', $regdates[0])->format('Y-m-d') . ' 00:00:00';
|
||||||
|
$t = Carbon::createFromFormat('d-m-Y', $regdates[1])->format('Y-m-d') . ' 23:59:59';
|
||||||
|
|
||||||
|
$documents = WorkflowDocument::where('workflow_type_id', $input['workflowtype'])->whereBetween('registration_date', [$f , $t]);
|
||||||
|
$input['compare'] = ($input['not'] == 'Y') ? '!=' : '=';
|
||||||
|
// if($input['status'] != 'x')
|
||||||
|
// $documents = $documents->where('status', $compare, $input['status']);
|
||||||
|
|
||||||
|
if($input['department'] != 'x')
|
||||||
|
{
|
||||||
|
// dd($input);
|
||||||
|
$ds = Department::all();
|
||||||
|
$did = 0;
|
||||||
|
foreach($ds as $d)
|
||||||
|
{
|
||||||
|
if(dataTranslation($d->name) == $input['department'])
|
||||||
|
{
|
||||||
|
$did = $d->id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_ids = User::where('department_id', $did)->pluck('id')->toArray();
|
||||||
|
if($input['workflowtype'] == 3)
|
||||||
|
$documents = $documents->whereHas('workflowprocesses', function($q) use($user_ids, $input){
|
||||||
|
$q->whereIn('user_id', $user_ids);
|
||||||
|
});
|
||||||
|
else
|
||||||
|
$documents = $documents->whereHas('workflowprocesses', function($q) use($user_ids, $input){
|
||||||
|
$q->whereIn('user_id', $user_ids)
|
||||||
|
->where('status', $input['compare'], $input['status']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if($input['status'] != 'x')
|
||||||
|
{
|
||||||
|
$documents = $documents->where('status', $input['compare'], $input['status']);
|
||||||
|
// $documents = $documents->whereHas('workflowprocesses', function($q) use($input){
|
||||||
|
// $q->where('status', $input['compare'], $input['status']);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($input);
|
||||||
|
|
||||||
|
if(isset($input['export']))
|
||||||
|
return [$workflowtypes, $input, $documents->get(), 'dashboard'];
|
||||||
|
|
||||||
|
$documents = $documents->orderBy('id', 'desc')->paginate(20)->appends([
|
||||||
|
'reg_date' => $reg_date ?? '',
|
||||||
|
'workflowtype' => $workflowtype ?? 1,
|
||||||
|
'status'=>$status ?? '',
|
||||||
|
'not' => $not ?? 'N',
|
||||||
|
'department' => $department ?? ''
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('dashboard.list', compact('input', 'documents', 'workflowtypes'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request, $type=null)
|
||||||
|
{
|
||||||
|
$type = (in_array($type, ['xlsx', 'csv', 'pdf'])) ? $type : 'xlsx';
|
||||||
|
$new_req = new \Illuminate\Http\Request;
|
||||||
|
$new_req->setMethod('GET');
|
||||||
|
$new_req = (clone request())->replace(json_decode($request->input('export-filterBy'), true));
|
||||||
|
$row = $this->filterDocuments($new_req->reg_date, $new_req->workflowtype, $new_req->status, $new_req->not, $new_req->department, 'export');
|
||||||
|
$name = 'documents' . '_' . now()->format('d-m-Y') . '.' . $type;
|
||||||
|
|
||||||
|
return Excel::download(new ListingExport($row), $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calendar()
|
||||||
|
{
|
||||||
|
if(Auth::user()->department_id== 7)
|
||||||
|
{
|
||||||
|
$workflow_documents = DB::table('workflow_documents')->get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$workflow_documents = DB::table('workflow_documents')
|
||||||
|
->join('workflow_document_users', 'workflow_documents.id', '=', 'workflow_document_users.workflow_document_id')
|
||||||
|
->select('workflow_documents.*')
|
||||||
|
->where('workflow_document_users.user_id', Auth::user()->id)
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
$custom_event = Event::where('user_id',Auth::user()->id)->get();
|
||||||
|
return view('calendar', compact('workflow_documents', 'custom_event'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeEvent(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['start_date_time']) && $input['start_date_time'] != "")
|
||||||
|
$input['start_date_time'] = Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['start_date_time'])->format('Y-m-d H:i');
|
||||||
|
if(isset($input['end_date_time']) && $input['end_date_time'] != "")
|
||||||
|
$input['end_date_time'] = Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['end_date_time'])->format('Y-m-d H:i');
|
||||||
|
$input['user_id'] = Auth::user()->id;
|
||||||
|
$saved_data=Event::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
Session::flash('success_message', __('Event has been added successfully'));
|
||||||
|
}else{
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
}
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteEvent($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$event = Event::findOrFail($id);
|
||||||
|
$delete_event = $event->delete();
|
||||||
|
if($delete_event):
|
||||||
|
Session::flash('success_message', __('Event has been deleted successfully'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
endif;
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$event = Event::where('id', '=', $id)->first();
|
||||||
|
if($event):
|
||||||
|
return view('includes.event-update', compact('event', 'setting'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateEvent (Request $request, $id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$event = Event::findOrFail($id);
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['start_date_time']) && $input['start_date_time'] != "")
|
||||||
|
$input['start_date_time'] = Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['start_date_time'])->format('Y-m-d H:i');
|
||||||
|
if(isset($input['end_date_time']) && $input['end_date_time'] != "")
|
||||||
|
$input['end_date_time'] = Carbon\Carbon::createFromFormat('d/m/Y H:i', $input['end_date_time'])->format('Y-m-d H:i');
|
||||||
|
$saved_data=$event->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
Session::flash('success_message', __('Event has been updated successfully'));
|
||||||
|
return redirect()->route('calendar');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Session;
|
||||||
|
use App;
|
||||||
|
|
||||||
|
class LanguageController extends Controller
|
||||||
|
{
|
||||||
|
public function changeLanguage(Request $request)
|
||||||
|
{
|
||||||
|
$languages=[
|
||||||
|
'en'=>'English',
|
||||||
|
'tm'=>'Turkmen',
|
||||||
|
'ru'=>'Russia',
|
||||||
|
];
|
||||||
|
$request->session()->put('locale', $request->locale);
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Language;
|
||||||
|
use App\User;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
class LanguagesController extends Controller
|
||||||
|
{
|
||||||
|
public function changeLanguage(Request $request)
|
||||||
|
{
|
||||||
|
$id=Auth::user()->id;
|
||||||
|
$update_language = User::where('id', $id)->update(['user_language'=>$request->short_name]);
|
||||||
|
$request->session()->put('locale', $request->short_name);
|
||||||
|
$language = Language::where('short_name', $request->short_name)->first();
|
||||||
|
Session::flash('success_message', __('Language changed to ').' '.$language->name);
|
||||||
|
return 'ok';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\WorkflowDocument;
|
||||||
|
use App\WorkflowType;
|
||||||
|
use App\Exports\ListingExport;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Excel;
|
||||||
|
|
||||||
|
class ListingController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
// dd($input);
|
||||||
|
$workflowtypes = WorkflowType::where('status', 1)->where('id', '!=', 4)->get(['id', 'name']);
|
||||||
|
$input['status'] = isset($input['status']) ? $input['status'] : 0;
|
||||||
|
if(!$request->has('reg_date'))
|
||||||
|
return view('listings.index', compact('workflowtypes', 'input'));
|
||||||
|
|
||||||
|
$regdates = preg_split("/\s+:\s+/", trim($input['reg_date']));
|
||||||
|
$f = Carbon::createFromFormat('d-m-Y', $regdates[0])->format('Y-m-d') . ' 00:00:00';
|
||||||
|
$t = Carbon::createFromFormat('d-m-Y', $regdates[1])->format('Y-m-d') . ' 23:59:59';
|
||||||
|
|
||||||
|
$documents = WorkflowDocument::where('workflow_type_id', $input['workflowtype'])->where('is_deleted', 0)->whereBetween('registration_date', [$f , $t]);
|
||||||
|
if(isset($input['registration_number']) && strlen($input['registration_number'])>0)
|
||||||
|
$documents = $documents->where(function($q) use($input){
|
||||||
|
$q->orWhere('registration_number', 'LIKE', '%' . $input['registration_number'] . '%')
|
||||||
|
->orWhere('temporary_registration_number', 'LIKE', '%' . $input['registration_number'] . '%');
|
||||||
|
});
|
||||||
|
|
||||||
|
if(isset($input['status']) && in_array($input['status'], [1, 2]))
|
||||||
|
{
|
||||||
|
$st = 'Approved';
|
||||||
|
$st = ($input['workflowtype'] == 1) ? 'Complete' : $st;
|
||||||
|
$not = ($input['status'] == 1) ? '=' : '!=';
|
||||||
|
$documents = $documents->where('status', $not, $st);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($input['contact_id']) && count($input['contact_id'])>0)
|
||||||
|
$documents = $documents->whereHas('senders', function($q) use($input){
|
||||||
|
$q->whereIn('contact_id', $input['contact_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// $workflowtypename = dataTranslation(WorkflowType::find($input['workflowtype'])->name);
|
||||||
|
if(isset($input['export']))
|
||||||
|
return [$workflowtypes, $input, $documents->get()];
|
||||||
|
|
||||||
|
$documents = $documents->orderBy('id', 'desc')->paginate(100)->appends([
|
||||||
|
'reg_date' => $input['reg_date'] ?? '',
|
||||||
|
'registration_number' => $input['registration_number'] ?? '',
|
||||||
|
'contact_id'=>$input['contact_id'] ?? [],
|
||||||
|
'workflowtype' => $input['workflowtype'] ?? 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('listings.index', compact('workflowtypes', 'input', 'documents'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request, $type=null)
|
||||||
|
{
|
||||||
|
$type = (in_array($type, ['xlsx', 'csv', 'pdf'])) ? $type : 'xlsx';
|
||||||
|
$new_req = new \Illuminate\Http\Request;
|
||||||
|
$new_req->setMethod('GET');
|
||||||
|
$new_req = (clone request())->replace(json_decode($request->input('export-filterBy'), true));
|
||||||
|
$row = $this->index($new_req);
|
||||||
|
$name = 'documents' . '_' . now()->format('d-m-Y') . '.' . $type;
|
||||||
|
|
||||||
|
return Excel::download(new ListingExport($row), $name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,705 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\User;
|
||||||
|
use App\MyFile;
|
||||||
|
use App\Setting;
|
||||||
|
use App\Department;
|
||||||
|
use App\SharedFile;
|
||||||
|
use Session;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class MyFilesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:web');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search(Request $request, $directory=null)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$request->session()->put('search_val', $input['search']);
|
||||||
|
if($directory != null)
|
||||||
|
{
|
||||||
|
return redirect()->route('my-files', $directory);
|
||||||
|
}
|
||||||
|
return redirect()->route('my-files');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index($directory=null)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$parent_id = 0;
|
||||||
|
$parent_directories = [];
|
||||||
|
$last = null;
|
||||||
|
if($directory !== null)
|
||||||
|
{
|
||||||
|
$parent_id = base64_decode($directory);
|
||||||
|
$parent_directories = MyFile::getPathArray($parent_id);
|
||||||
|
$last = array_key_last($parent_directories);
|
||||||
|
}
|
||||||
|
$directories=Myfile::where('user_id', auth()->user()->id)->where('parent_id', $parent_id)->where('is_temp', 0)->orderBy('id', 'desc')->get();
|
||||||
|
return view('my-files.index', compact('setting', 'directories', 'parent_id', 'parent_directories', 'last'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($directory=null)
|
||||||
|
{
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
$directory_id = base64_decode($directory);
|
||||||
|
$directory = MyFile::find($directory_id);
|
||||||
|
|
||||||
|
if($directory->user_id != auth()->user()->id)
|
||||||
|
{
|
||||||
|
$shared = SharedFile::where('shared_by', $directory->user_id)->where('permission', 2)->where(function($q){
|
||||||
|
$q->orWhere('user_id', auth()->user()->id)
|
||||||
|
->orWhere('department_id', auth()->user()->department_id);
|
||||||
|
})->get();
|
||||||
|
// dd($shared);
|
||||||
|
// return response()->json(['result' => 'success', 'data' => $shared->count()]);
|
||||||
|
// return response()->json(['result' => 'success', 'data' => $shared->first()->id]);
|
||||||
|
|
||||||
|
if(count($shared)>0)
|
||||||
|
{
|
||||||
|
$flag=false;
|
||||||
|
// return response()->json(['result' => 'success', 'data' => $shared->first()->file_id]);
|
||||||
|
foreach($shared as $sh)
|
||||||
|
{
|
||||||
|
if(preg_match("/;".$sh->file_id.";/", $directory->path_to_root . ";".$directory->id.";"))
|
||||||
|
{
|
||||||
|
$flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// return response()->json(['result' => 'success', 'data' => $directory->path_to_root . $directory->id.";"]);
|
||||||
|
if($flag==true)
|
||||||
|
{
|
||||||
|
$view = view('my-files.create')->with('directory_id', $directory->id)->with('flag', $flag)->render();
|
||||||
|
return response()->json(['result' => 'success', 'data' => $view]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response()->json(['result'=>'error', 'data'=> __('We are having some problem. Please try later.')]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$directoryid = ($directory) ? $directory->id : 0;
|
||||||
|
$view = view('my-files.create')->with('directory_id', $directoryid)->render();
|
||||||
|
return response()->json(['result' => 'success', 'data' => $view]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['directory_name']) && $input['directory_name'] !== null)
|
||||||
|
{
|
||||||
|
$directory_input['_token']=$input['_token'];
|
||||||
|
$directory_input['name']=$input['directory_name'];
|
||||||
|
$directory_input['description']=$input['description'] ?? '';
|
||||||
|
$directory_input['year'] = date('Y');
|
||||||
|
$directory_input['is_temp'] = 0;
|
||||||
|
$directory_input['file_type'] = 0;
|
||||||
|
if($input['flag'])
|
||||||
|
{
|
||||||
|
$directory_input['user_id'] = MyFile::where('id', $input['parent_id'])->first()->user_id;
|
||||||
|
$directory_input['shared_user_id'] = auth()->user()->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$directory_input['user_id'] = auth()->user()->id;
|
||||||
|
|
||||||
|
if($input['parent_id'] !== null)
|
||||||
|
{
|
||||||
|
// if directory_id is not belongs to auth()->user()->id ???
|
||||||
|
$directory_input['parent_id'] = $input['parent_id'];
|
||||||
|
$directory_input['path_to_root'] = MyFile::getPathToRootString($input['parent_id']);
|
||||||
|
}
|
||||||
|
$directory_save=MyFile::create($directory_input);
|
||||||
|
if($directory_save)
|
||||||
|
{
|
||||||
|
$input['parent_id'] = $directory_save['id'];
|
||||||
|
// $directory_path = directory_path($directory_save['id'], '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($input['parent_id'] == null)
|
||||||
|
{
|
||||||
|
$input['parent_id'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$input['user_id']=auth()->user()->id;
|
||||||
|
$input['path_to_root'] = MyFile::getPathToRootString($input['parent_id']);
|
||||||
|
$input['shared_user_id'] = null;
|
||||||
|
if($input['flag'])
|
||||||
|
{
|
||||||
|
$input['user_id'] = MyFile::where('id', $input['parent_id'])->first()->user_id;
|
||||||
|
$input['shared_user_id'] = auth()->user()->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($input);
|
||||||
|
if(isset($input['file_ids']) && $input['file_ids']!='')
|
||||||
|
{
|
||||||
|
$file_ids_array = explode(';',$input['file_ids']);
|
||||||
|
if(is_array($file_ids_array) && !empty($file_ids_array)){
|
||||||
|
foreach($file_ids_array as $key => $file_id){
|
||||||
|
$file = MyFile::where('id',$file_id)->first();
|
||||||
|
if(isset($file))
|
||||||
|
{
|
||||||
|
MyFile::find($file->id)->update(['is_temp'=>0, 'user_id'=>$input['user_id'], 'shared_user_id'=>$input['shared_user_id'], 'path_to_root'=>$input['path_to_root'], 'description' =>$input['description'], 'parent_id'=>$input['parent_id']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session::flash('success_message', __('My files has been added successfully'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeFiles(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$file_name='';
|
||||||
|
|
||||||
|
// $setting = Setting::first();
|
||||||
|
$place_of_the_file='my-files/'.auth()->user()->id;
|
||||||
|
|
||||||
|
$input['place_of_the_file']= $place_of_the_file;
|
||||||
|
$input['user_id']=auth()->user()->id;
|
||||||
|
$input['file_type'] = 1;
|
||||||
|
$input['year'] = date('Y');
|
||||||
|
|
||||||
|
if(isset($input['files']) && is_array($input['files']) && !empty($input['files']))
|
||||||
|
{
|
||||||
|
foreach($input['files'] as $key => $file)
|
||||||
|
{
|
||||||
|
$file = $input['files'];
|
||||||
|
if(isset($file) && $file->getError() == 0 && $file->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['file_size'] = $file_size = ($file->getClientSize() / 1024)/1024;
|
||||||
|
$user = User::where('id', auth()->user()->id)->first();
|
||||||
|
$user_new_disk_uses = $user->user_disk_uses > 0 ? $user->user_disk_uses + $file_size : $file_size;
|
||||||
|
if($user_new_disk_uses < $user->user_disk_quota)
|
||||||
|
{
|
||||||
|
User::where('id', auth()->user()->id)->update(['user_disk_uses'=> $user_new_disk_uses]);
|
||||||
|
$input['name_org'] = $file->getClientOriginalName();
|
||||||
|
$input['name'] = $file_name = md5($file->getClientOriginalName() . microtime()) .'.'. $file->getClientOriginalExtension();
|
||||||
|
$saved_data=MyFile::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$file->move(public_path($place_of_the_file), $file_name);
|
||||||
|
$files_val[$key]['data']= $saved_data;
|
||||||
|
$files_val[$key]['type']= 'success';
|
||||||
|
$files_val[$key]['message']= __('File uploaded successfully');
|
||||||
|
|
||||||
|
if(!in_array($file->getClientOriginalExtension(), ['pdf', 'zip', 'tar', 'rar', 'exe', 'gz']))
|
||||||
|
{
|
||||||
|
shell_exec('export HOME=/tmp && /usr/bin/libreoffice --headless --convert-to pdf ' . public_path($place_of_the_file) . '/' . $file_name . ' --outdir ' . public_path($place_of_the_file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$files_val[$key]['data']= [];
|
||||||
|
$files_val[$key]['type']= 'error';
|
||||||
|
$files_val[$key]['message']= __('Exceed Disk Quota');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file = $input['files'];
|
||||||
|
$key = 0;
|
||||||
|
if(isset($file) && $file->getError() == 0 && $file->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['file_size'] = $file_size = ($file->getClientSize() / 1024)/1024;
|
||||||
|
$user = User::where('id', auth()->user()->id)->first();
|
||||||
|
$user_new_disk_uses = $user->user_disk_uses > 0 ? $user->user_disk_uses + $file_size : $file_size;
|
||||||
|
if($user_new_disk_uses < $user->user_disk_quota)
|
||||||
|
{
|
||||||
|
User::where('id', auth()->user()->id)->update(['user_disk_uses'=> $user_new_disk_uses]);
|
||||||
|
$input['name_org'] = $file->getClientOriginalName();
|
||||||
|
$input['name'] = $file_name = md5($file->getClientOriginalName() . microtime()) .'.'. $file->getClientOriginalExtension();
|
||||||
|
$saved_data=MyFile::create($input);
|
||||||
|
if($saved_data)
|
||||||
|
{
|
||||||
|
$file->move(public_path($place_of_the_file), $file_name);
|
||||||
|
$files_val[$key]['data']= $saved_data;
|
||||||
|
$files_val[$key]['type']= 'success';
|
||||||
|
$files_val[$key]['message']= __('File uploaded successfully');
|
||||||
|
|
||||||
|
if(!in_array($file->getClientOriginalExtension(), ['pdf', 'zip', 'tar', 'rar', 'exe', 'gz']))
|
||||||
|
{
|
||||||
|
shell_exec('export HOME=/tmp && /usr/bin/libreoffice --headless --convert-to pdf ' . public_path($place_of_the_file) . '/' . $file_name . ' --outdir ' . public_path($place_of_the_file));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$files_val[$key]['data']= [];
|
||||||
|
$files_val[$key]['type']= 'error';
|
||||||
|
$files_val[$key]['message']= __('Exceed Disk Quota');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response()->json($files_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($directory_enc)
|
||||||
|
{
|
||||||
|
if($directory_enc)
|
||||||
|
{
|
||||||
|
$directory = MyFile::find(base64_decode($directory_enc));
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->user_id != auth()->user()->id)
|
||||||
|
return response()->json(['result'=>'error', 'data'=> __('We are having some problem. Please try later.')]);
|
||||||
|
|
||||||
|
$view = view('my-files.edit')->with('directory', $directory)->render();
|
||||||
|
return response()->json(['result' => 'success', 'data' => $view]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['result' => 'false', 'data' => __('We are having some problem. Please try later.')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$input = request()->all();
|
||||||
|
if(!isset($input['directory_id']))
|
||||||
|
{
|
||||||
|
Session::flash('success_message', __('My files has been added successfully'));
|
||||||
|
return redirect(route('my-files'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$directory = MyFile::find(base64_decode($input['directory_id']));
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
$directory->description = $input['description'];
|
||||||
|
|
||||||
|
if($directory->file_type == 0)
|
||||||
|
$directory->name = $input['directory_name'];
|
||||||
|
else if($directory->file_type == 1)
|
||||||
|
$directory->name_org = $input['directory_name'];
|
||||||
|
|
||||||
|
$directory->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::flash('success_message', __('My files has been added successfully'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
$directory = MyFile::find(base64_decode($id));
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->file_type == 1)
|
||||||
|
{
|
||||||
|
$directory->delete();
|
||||||
|
unlink(public_path($directory->place_of_the_file.'/'.$directory->name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$folders = MyFile::where('is_temp', 0)->where('user_id', auth()->user()->id)->where('path_to_root', 'LIKE', '%;'.$directory->id.';%')->orderByDesc('path_to_root')->get();
|
||||||
|
foreach($folders as $folder)
|
||||||
|
{
|
||||||
|
if(Str::contains($folder->path_to_root, ";".$directory->id.";"))
|
||||||
|
{
|
||||||
|
$folder->delete();
|
||||||
|
if($folder->file_type == 1)
|
||||||
|
unlink(public_path($folder->place_of_the_file.'/'.$folder->name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$directory->delete();
|
||||||
|
SharedFile::deleteRelatedShares($directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Session::flash('success_message', __('Directory has been deleted successfully'));
|
||||||
|
return redirect()->route('my-files', base64_encode($directory->parent_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$file = MyFile::find($id);
|
||||||
|
if($file):
|
||||||
|
return view('my-files.view', compact('file'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function download($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$file = MyFile::find($id);
|
||||||
|
|
||||||
|
if($file && $file->file_type == 1)
|
||||||
|
if(file_exists(public_path($file->getPathOrg())))
|
||||||
|
return response()->download(public_path($file->getPathOrg()), $file->getReadableName());
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// File Share Methods
|
||||||
|
|
||||||
|
public function indexShare($directory=null)
|
||||||
|
{
|
||||||
|
$directory = MyFile::where('user_id', auth()->user()->id)->where('id', base64_decode($directory))->first();
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
$shared_files = SharedFile::where('shared_by', auth()->user()->id)->where('file_id', $directory->id)->get();
|
||||||
|
return view('my-files.share-index')->with('directory', $directory)->with('shared_files', $shared_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createShare($directory)
|
||||||
|
{
|
||||||
|
if(isset($directory))
|
||||||
|
{
|
||||||
|
$directory = MyFile::where('user_id', auth()->user()->id)->where('id', base64_decode($directory))->first();
|
||||||
|
if($directory->user_id != auth()->user()->id)
|
||||||
|
return response()->json(['result'=>'error', 'data'=> __('We are having some problem. Please try later.')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$users = User::where('status', 1)->where('working_status', 1)->get(['id', 'first_name', 'last_name']);
|
||||||
|
$departments = Department::where('status', 1)->get(['id', 'name']);
|
||||||
|
$view = view('my-files.share')
|
||||||
|
->with('directory', $directory)
|
||||||
|
->with('users', $users)
|
||||||
|
->with('departments', $departments)
|
||||||
|
->render();
|
||||||
|
return response()->json(['result' => 'success', 'data' => $view]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function share(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$file = MyFile::where('user_id', auth()->user()->id)->where('id', $input['id'])->first();
|
||||||
|
if($file)
|
||||||
|
{
|
||||||
|
$input['parent_id'] = $file->parent_id;
|
||||||
|
$input['shared_by'] = auth()->user()->id;
|
||||||
|
$input['file_type'] = $file->file_type;
|
||||||
|
$input['file_id'] = $file->id;
|
||||||
|
$input['path_to_root'] = $file->path_to_root;
|
||||||
|
|
||||||
|
$departments = (isset($input['departments'])) ? Department::whereIn('id', $input['departments'])->get() : [];
|
||||||
|
$exist_department_ids = [];
|
||||||
|
|
||||||
|
|
||||||
|
foreach($departments as $department)
|
||||||
|
{
|
||||||
|
if(SharedFile::validShare($input['file_id'], $department->id, 'department', $input['permission']))
|
||||||
|
{
|
||||||
|
$input['department_id'] = $department->id;
|
||||||
|
$saved_data=SharedFile::create($input);
|
||||||
|
}
|
||||||
|
$exist_department_ids[]=$department->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $exist_department_ids[]=SharedFile::where('file_id', $file->id)->where('permission', $input['permission'])->whereNotNull('department_id')->pluck('department_id');
|
||||||
|
|
||||||
|
// $users = (isset($input['users'])) ? User::whereIn('id', $input['users'])->whereNotIn('department_id', $exist_department_ids)->get() : [];
|
||||||
|
$users = (isset($input['users'])) ? User::whereIn('id', $input['users'])->get() : [];
|
||||||
|
foreach($users as $user)
|
||||||
|
{
|
||||||
|
// if(!SharedFile::where('permission', $input['permission'])->where('user_id', $user->id)->where('file_id', $file->id)->exists())
|
||||||
|
if(SharedFile::validShare($input['file_id'], $user->id, 'user', $input['permission']))
|
||||||
|
{
|
||||||
|
$input['user_id'] = $user->id;
|
||||||
|
$saved_data=SharedFile::create($input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($saved_data))
|
||||||
|
{
|
||||||
|
Session::flash('success_message', __('My files has been added successfully'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteShare($share_id)
|
||||||
|
{
|
||||||
|
$shareid = base64_decode($share_id);
|
||||||
|
$shared = SharedFile::find($shareid);
|
||||||
|
|
||||||
|
if($shared)
|
||||||
|
$shared->delete();
|
||||||
|
|
||||||
|
Session::flash('success_message', __('My files has been added successfully'));
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================================
|
||||||
|
|
||||||
|
public function sharedFiles($share_id, $directory=null)
|
||||||
|
{
|
||||||
|
$parent_id = null;
|
||||||
|
$directories = [];
|
||||||
|
$shared_files = [];
|
||||||
|
$permission = '';
|
||||||
|
$write = false;
|
||||||
|
$sharedby='';
|
||||||
|
$prev_url = '';
|
||||||
|
$share_id = base64_decode($share_id);
|
||||||
|
if($directory !== null)
|
||||||
|
{
|
||||||
|
$parent=MyFile::where('id', base64_decode($directory))->first();
|
||||||
|
if($parent)
|
||||||
|
{
|
||||||
|
$shared = SharedFile::where('file_id', $parent->id)
|
||||||
|
->where(function($q){
|
||||||
|
$q->where('user_id', auth()->user()->id)
|
||||||
|
->orWhere('department_id', auth()->user()->department_id);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
|
||||||
|
// dd($share_id . " -- " . 'null'. " -- ". $parent->id);
|
||||||
|
if($shared)
|
||||||
|
{
|
||||||
|
$directories = MyFile::where('parent_id', $parent->id)->get();
|
||||||
|
$write = ($shared->permission == 'Write') ? true : false;
|
||||||
|
$permission = __($shared->permission);
|
||||||
|
$sharedby = $shared->sharedby->getFullName();
|
||||||
|
$share_id = (($share_id == 0) && ($shared->id !=0)) ? $shared->file_id : $share_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(preg_match("/;".$share_id.";/", $parent->path_to_root))
|
||||||
|
{
|
||||||
|
$shared = SharedFile::where('file_id', $share_id)->first();
|
||||||
|
// dd($shared);
|
||||||
|
if($shared)
|
||||||
|
{
|
||||||
|
$directories = MyFile::where('parent_id', $parent->id)->get();
|
||||||
|
$write = ($shared->permission == 'Write') ? true : false;
|
||||||
|
$permission = __($shared->permission);
|
||||||
|
$sharedby = $shared->sharedby->getFullName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$shared_files = SharedFile::where('show_home', 1)
|
||||||
|
->where(function($q){
|
||||||
|
$q->where('user_id', auth()->user()->id)
|
||||||
|
->orWhere('department_id', auth()->user()->department_id);
|
||||||
|
})
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$prev_url = route('shared-files', ['share_id'=>base64_encode($share_id), 'directory'=>null]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$prev_url = route('shared-files', ['shared_id'=>base64_encode($share_id), 'directory'=>base64_encode($parent->parent_id)]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$shared_files = SharedFile::where('show_home', 1)
|
||||||
|
->where(function($q){
|
||||||
|
$q->where('user_id', auth()->user()->id)
|
||||||
|
->orWhere('department_id', auth()->user()->department_id);
|
||||||
|
})
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$prev_url = route('shared-files', ['share_id'=>base64_encode($share_id), 'directory'=>null]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$shared_files = SharedFile::where('show_home', 1)
|
||||||
|
->where(function($q){
|
||||||
|
$q->where('user_id', auth()->user()->id)
|
||||||
|
->orWhere('department_id', auth()->user()->department_id);
|
||||||
|
})
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get();
|
||||||
|
$prev_url = route('shared-files', ['share_id'=>base64_encode($share_id), 'directory'=>null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$setting = Setting::first();
|
||||||
|
$parent_id = (isset($parent)) ? $parent->id : null;
|
||||||
|
|
||||||
|
// dd($parent_id);
|
||||||
|
// $users = User::getUserRole()->get();
|
||||||
|
// $departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('my-files.shared-files', compact('shared_files', 'directories', 'parent_id', 'prev_url', 'sharedby', 'permission', 'share_id', 'write', 'setting'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sharedView($directory)
|
||||||
|
{
|
||||||
|
$directory = MyFile::find(base64_decode($directory));
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
$found = false;
|
||||||
|
$shares = SharedFile::where(function($q){$q->orWhere('department_id', auth()->user()->department_id)->orWhere('user_id', auth()->user()->id);})->where('show_home', 1)->get(['id', 'file_id']);
|
||||||
|
foreach($shares as $share)
|
||||||
|
{
|
||||||
|
if(preg_match("/;".$share->file_id.";/", $directory->path_to_root) || ($share->file_id ==$directory->id))
|
||||||
|
$found=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($found)
|
||||||
|
return redirect(route('view-my-files', base64_encode($directory->id)));
|
||||||
|
// return $this->view(base64_encode($directory->id));
|
||||||
|
}
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xxdeleteFiles(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$file = MyFile::findOrFail($input['id']);
|
||||||
|
$delete_file = $file->delete();
|
||||||
|
if($delete_file):
|
||||||
|
SharedFile::where('file_id', $file->id)->delete();
|
||||||
|
$user = User::where('id',Auth::user()->id)->first();
|
||||||
|
$user_new_disk_uses = $user->user_disk_uses + $file->file_size;
|
||||||
|
User::where('id',Auth::user()->id)->update(['user_disk_uses'=> $user_new_disk_uses]);
|
||||||
|
unlink(public_path($file->place_of_the_files.'/'.$file->files_name));
|
||||||
|
endif;
|
||||||
|
echo __('Deleted File ').$file->files_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xxdeleteDirectory($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$directory = Directory::findOrFail($id);
|
||||||
|
foreach(Directory::where('parent_id', $id)->get() as $related_directory)
|
||||||
|
{
|
||||||
|
foreach(MyFile::where('directory_id', $related_directory->id)->get() as $myfile)
|
||||||
|
{
|
||||||
|
$file = MyFile::findOrFail($myfile->id);
|
||||||
|
$file->delete();
|
||||||
|
SharedFile::where('file_id', $myfile->id)->delete();
|
||||||
|
unlink(public_path($file->place_of_the_files.'/'.$file->files_name));
|
||||||
|
}
|
||||||
|
$child_directory = Directory::findOrFail($related_directory->id);
|
||||||
|
$child_directory->delete();
|
||||||
|
SharedFile::where('directory_id', $related_directory->id)->delete();
|
||||||
|
}
|
||||||
|
$delete_directory = $directory->delete();
|
||||||
|
SharedFile::where('directory_id', $directory->id)->delete();
|
||||||
|
if($delete_directory):
|
||||||
|
Session::flash('success_message', __('Directory has been deleted successfully'));
|
||||||
|
return redirect()->route('my-files');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('my-files');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xxdelete($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$file = MyFile::findOrFail($id);
|
||||||
|
$delete_file = $file->delete();
|
||||||
|
if($delete_file):
|
||||||
|
SharedFile::where('file_id', $file->id)->delete();
|
||||||
|
unlink(public_path($file->place_of_the_files.'/'.$file->files_name));
|
||||||
|
Session::flash('success_message', __('File has been deleted successfully'));
|
||||||
|
return redirect()->back();
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xxindex($directory=null)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$parent_id = 0;
|
||||||
|
$parent_directories = [];
|
||||||
|
if($directory !== null)
|
||||||
|
{
|
||||||
|
$parent_id = base64_decode($directory);
|
||||||
|
$parent_directories = Directory::getPathArray($parent_id);
|
||||||
|
$last = array_key_last($parent_directories);
|
||||||
|
}
|
||||||
|
$directories=Directory::where('user_id', Auth::user()->id)->orderBy('id', 'desc')->get();
|
||||||
|
$prev_url = url()->previous();
|
||||||
|
|
||||||
|
$users = User::getUserRole()->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('my-files.index', compact('setting', 'directories', 'parent_id', 'parent_directories', 'last', 'prev_url', 'users', 'departments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function xxsharedFiles($directory=null)
|
||||||
|
{
|
||||||
|
$parent_id = 0;
|
||||||
|
$parent_directory = [];
|
||||||
|
if($directory !== null)
|
||||||
|
{
|
||||||
|
$parent_id = base64_decode($directory);
|
||||||
|
$parent_directory=Directory::where('id', $parent_id)->first();
|
||||||
|
}
|
||||||
|
$shared_files=SharedFile::where('parent_id', 0)->where(function($q){$q->where('user_id', Auth::user()->id)->orWhere('department_id', Auth::user()->department_id);})->orderBy('id', 'desc');
|
||||||
|
$shared_file_parent_ids = $shared_files->pluck('directory_id');
|
||||||
|
$shared_directories = SharedFile::where('parent_id', '!=', 0)->where(function($q){$q->where('user_id', Auth::user()->id)->orWhere('department_id', Auth::user()->department_id);})->orderBy('id', 'desc')->get();
|
||||||
|
$extra = [];
|
||||||
|
// dd($shared_directories);
|
||||||
|
foreach($shared_directories as $sh)
|
||||||
|
{
|
||||||
|
if($sh->type == "D")
|
||||||
|
{
|
||||||
|
$path_array = Directory::getPathToRoot($sh->directory_id);
|
||||||
|
$exist = false;
|
||||||
|
foreach($shared_file_parent_ids as $shf)
|
||||||
|
{
|
||||||
|
if(in_array($shf, $path_array))
|
||||||
|
{
|
||||||
|
$exist = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($exist == false)
|
||||||
|
$extra[]=$sh->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($sh->type == "F")
|
||||||
|
{
|
||||||
|
$path_array = MyFile::getPathToRoot($sh->parent_id, true);
|
||||||
|
$exist = false;
|
||||||
|
foreach($shared_file_parent_ids as $shf)
|
||||||
|
{
|
||||||
|
if(in_array($shf, $path_array))
|
||||||
|
{
|
||||||
|
$exist = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($exist == false)
|
||||||
|
$extra[]=$sh->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$shared_files = $shared_files->get();
|
||||||
|
if(count($extra)>0)
|
||||||
|
$shared_files = $shared_files->merge(SharedFile::whereIn('id', $extra)->get());
|
||||||
|
|
||||||
|
$setting = Setting::first();
|
||||||
|
$prev_url = url()->previous();
|
||||||
|
|
||||||
|
$users = User::getUserRole()->get();
|
||||||
|
$departments = Department::where('status', 1)->orderBy('id', 'asc')->get();
|
||||||
|
return view('my-files.shared-files', compact('setting', 'shared_files', 'parent_id', 'parent_directory', 'prev_url', 'users', 'departments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,283 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\RemoteTransfer;
|
||||||
|
use App\WorkflowDocument;
|
||||||
|
use App\WorkflowDocumentSender;
|
||||||
|
use App\WorkflowDocumentFile;
|
||||||
|
use App\RemoteContact;
|
||||||
|
use App\Contact;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class RemoteTransferController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* private filter function
|
||||||
|
* @return RemoteTransfer model
|
||||||
|
*/
|
||||||
|
private function search($str, $direction=2)
|
||||||
|
{
|
||||||
|
$a = new RemoteTransfer;
|
||||||
|
if(strlen(trim($str)) > 0)
|
||||||
|
{
|
||||||
|
$a = $a->where(function($query) use ($str){
|
||||||
|
$query->orWhere('login', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhere('receipt', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhere('content', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhere('description', 'LIKE', '%'. $str .'%')
|
||||||
|
->orWhereHas('contact', function($query) use ($str){
|
||||||
|
$query->where('organization_name', 'LIKE', '%'. $str .'%');
|
||||||
|
});;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if($direction != 2)
|
||||||
|
return $a->where('direction', $direction);
|
||||||
|
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
if(!in_array(12, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'no permission');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
$search = $request->input('search');
|
||||||
|
$direction = $request->input('direction') ?? 2;
|
||||||
|
$row = $this->search($search, $direction);
|
||||||
|
$row = $row->orderBy('id', 'desc')->with('contact:id,organization_name')->paginate(30)->appends([
|
||||||
|
'search' => $search,
|
||||||
|
'direction' => $direction,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view('remote_transfers.index')->with('transfers', $row)->with('search', $search)->with('direction', $direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function create($id=null)
|
||||||
|
{
|
||||||
|
if(!$id || !in_array(13, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'no permission');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->store($id);
|
||||||
|
return redirect()->route('transfers.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function store($id)
|
||||||
|
{
|
||||||
|
if($id == null)
|
||||||
|
return back();
|
||||||
|
$sender = null;
|
||||||
|
$document = WorkflowDocument::findOrFail(base64_decode($id));
|
||||||
|
|
||||||
|
|
||||||
|
$senders = WorkflowDocumentSender::where('workflow_document_id', $document->id)->get();
|
||||||
|
foreach($senders as $sender)
|
||||||
|
{
|
||||||
|
$remotecontact = RemoteContact::where('archive', 0)->where('direction', 1)->where('contact_id', $sender->contact_id)->whereHas('remotecontactapis')->with('remotecontactapis')->first();
|
||||||
|
if(!$remotecontact)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$file = WorkflowDocumentFile::where('workflow_document_id', $document->id)->get()->last();
|
||||||
|
//fill mandatory fields
|
||||||
|
$content = [];
|
||||||
|
$fields = $remotecontact->remotecontactapis->first()->mandatory_fields;
|
||||||
|
$fields = array_map('trim', explode(',', $fields));
|
||||||
|
foreach ($fields as $field)
|
||||||
|
{
|
||||||
|
$pair = array_map('trim', explode(':', $field));
|
||||||
|
$key = $pair[0] ?? '';
|
||||||
|
$value = ($pair[1] == 'file') ? 'file' : $document->{$pair[1]};
|
||||||
|
|
||||||
|
if ($value == null || strlen($value) == 0 || $value == 'file')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$content[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$remotetransfer = new RemoteTransfer;
|
||||||
|
$data = [
|
||||||
|
'login' => $remotecontact->login,
|
||||||
|
'workflow_document_id' => $document->id,
|
||||||
|
'direction' => 1,
|
||||||
|
'status' => 0,
|
||||||
|
'send_at' => now(),
|
||||||
|
'content' => json_encode($content),
|
||||||
|
'place_of_the_documents' => $file->place_of_the_documents,
|
||||||
|
'document_name' => $file->document_name,
|
||||||
|
'contact_id' => $remotecontact->contact_id,
|
||||||
|
];
|
||||||
|
|
||||||
|
$remotetransfer->fill($data);
|
||||||
|
$remotetransfer->save();
|
||||||
|
}
|
||||||
|
return redirect()->route('transfers.index');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function send(RemoteTransfer $remotetransfer)
|
||||||
|
{
|
||||||
|
if(!in_array(13, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'no permission');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($remotetransfer->status == 0)
|
||||||
|
{
|
||||||
|
$remotetransfer->status = 1;
|
||||||
|
$remotetransfer->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// call send Api
|
||||||
|
app('App\Http\Controllers\ApiController')->sendDocuments($remotetransfer->id);
|
||||||
|
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancel(RemoteTransfer $remotetransfer)
|
||||||
|
{
|
||||||
|
if(!in_array(13, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'no permission');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array($remotetransfer->status, ['default', 'in process']))
|
||||||
|
{
|
||||||
|
$remotetransfer->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function accept(RemoteTransfer $remotetransfer)
|
||||||
|
{
|
||||||
|
if(!in_array(13, auth()->user()->getPermissionList()))
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'no permission');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
$contact = Contact::where('id', $remotetransfer->contact_id)->first();
|
||||||
|
|
||||||
|
if(!$contact)
|
||||||
|
{
|
||||||
|
\Session::flash('error_message', 'Contact not found');
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['registration_number'] = json_decode($remotetransfer->content)->registration_number;
|
||||||
|
$data['registration_date'] = json_decode($remotetransfer->content)->registration_date;
|
||||||
|
$data['topic'] = json_decode($remotetransfer->content)->topic;
|
||||||
|
$data['contact_id'] = $remotetransfer->contact_id;
|
||||||
|
$data['path'] = $remotetransfer->place_of_the_documents . '/' . $remotetransfer->document_name;
|
||||||
|
$data['file'] = $remotetransfer->document_name;
|
||||||
|
|
||||||
|
$remotetransfer->read_at = now();
|
||||||
|
$remotetransfer->save();
|
||||||
|
return redirect(route('create_document_workflow', $data));
|
||||||
|
// return redirect(app('App\Http\Controllers\WorkflowDocumentsController')->create("aman"));
|
||||||
|
// dd($remotetransfer);
|
||||||
|
// dd(json_decode($remotetransfer->content));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function show($base_id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($base_id);
|
||||||
|
$remotetransfer = RemoteTransfer::find($id);
|
||||||
|
|
||||||
|
if($remotetransfer)
|
||||||
|
{
|
||||||
|
if (\File::exists($remotetransfer->place_of_the_documents . '/' . pathinfo($remotetransfer->document_name, PATHINFO_FILENAME) . '.pdf'))
|
||||||
|
$link = asset($remotetransfer->place_of_the_documents.'/'. pathinfo($remotetransfer->document_name, PATHINFO_FILENAME) . '.pdf');
|
||||||
|
else
|
||||||
|
$link = asset($remotetransfer->place_of_the_documents.'/'. $remotetransfer->document_name);
|
||||||
|
|
||||||
|
|
||||||
|
if($link)
|
||||||
|
{
|
||||||
|
$notifications_update = auth()->user()->unreadNotifications()->where('workflow_document_id', $id)->update(['read_at'=>now()->format('Y-m-d H:i:s')]);
|
||||||
|
if($notifications_update){
|
||||||
|
if(Session::has('unread_notification_number')){
|
||||||
|
$notification_number = Session::get('unread_notification_number');
|
||||||
|
Session::put('unread_notification_number', $notification_number-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect($link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ReportController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Notification;
|
||||||
|
use App\Setting;
|
||||||
|
use Auth;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Carbon;
|
||||||
|
|
||||||
|
|
||||||
|
class UserNotificationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:web');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$limit_val = 10;
|
||||||
|
if(isset($setting->data_limit_per_page) && $setting->data_limit_per_page > 0)
|
||||||
|
{
|
||||||
|
$limit_val = $setting->data_limit_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
|
$notifications = Notification::where('notifiable_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate($limit_val);
|
||||||
|
return view('notifications', compact('notifications'));
|
||||||
|
}
|
||||||
|
public function headerNotifications(Request $request)
|
||||||
|
{
|
||||||
|
$notifications = Notification::where('notifiable_id', Auth::user()->id)->whereNull('read_at')->orderBy('created_at', 'desc')->get();
|
||||||
|
$count_not = count($notifications);
|
||||||
|
$request->session()->put('unread_notification_number', $count_not);
|
||||||
|
return view('includes.header-notifications', compact('notifications', 'count_not'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function markAsRead()
|
||||||
|
{
|
||||||
|
Notification::where('notifiable_id', Auth::user()->id)->whereNull('read_at')->update(['read_at' => now()->format('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
|
return back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,172 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\User;
|
||||||
|
use App\Role;
|
||||||
|
use App\Department;
|
||||||
|
use App\RoleUser;
|
||||||
|
use App\Setting;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class UsersController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth:web');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search(Request $request)
|
||||||
|
{
|
||||||
|
$input = $request->all();
|
||||||
|
$request->session()->put('search_val', $input['search']);
|
||||||
|
return redirect()->route('people');
|
||||||
|
}
|
||||||
|
public function people(Request $request)
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
if(isset($setting->data_limit_per_page) && $setting->data_limit_per_page > 0)
|
||||||
|
{
|
||||||
|
$limit_val = $setting->data_limit_per_page;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$limit_val = 10;
|
||||||
|
}
|
||||||
|
$search_val = null;
|
||||||
|
if($request->session()->has('search_val')){
|
||||||
|
$search_val = $request->session()->get('search_val');
|
||||||
|
$request->session()->forget('search_val');
|
||||||
|
}
|
||||||
|
if($search_val !== null)
|
||||||
|
{
|
||||||
|
$users = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->where('users.first_name', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('users.last_name', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('users.username', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('users.email', 'like', '%'.$search_val.'%')
|
||||||
|
->orWhere('roles.name', 'like', '%'.$search_val.'%')
|
||||||
|
->paginate($limit_val);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$users = DB::table('users')
|
||||||
|
->join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->orderBy('users.id', 'desc')
|
||||||
|
->paginate($limit_val);
|
||||||
|
}
|
||||||
|
//print_r($users);exit;
|
||||||
|
return view('users.index', compact('users', 'search_val'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function view($id)
|
||||||
|
{
|
||||||
|
$id=base64_decode($id);
|
||||||
|
$user =DB::table('users')->join('role_user', 'users.id', '=', 'role_user.user_id')->join('roles', 'role_user.role_id', '=', 'roles.id')->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')->where('users.id', '=', $id)->first();
|
||||||
|
if($user):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('users.view', compact('user', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('Invalid user id.'));
|
||||||
|
return redirect()->back();
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function profile()
|
||||||
|
{
|
||||||
|
$id=Auth::user()->id;
|
||||||
|
$user = User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.id', '=', $id)
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->first();
|
||||||
|
if($user):
|
||||||
|
$languages = DB::table('languages')
|
||||||
|
->orderBy('serial_no', 'asc')
|
||||||
|
->get();
|
||||||
|
return view('users.profile', compact('user', 'languages'));
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('login');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function updateProfile(Request $request)
|
||||||
|
{
|
||||||
|
$id=Auth::user()->id;
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$validatedData = $this->validate($request, [
|
||||||
|
'first_name' => 'required|max:150',
|
||||||
|
'last_name' => 'required|max:150',
|
||||||
|
'email' => 'required|unique:users,email,'.$id.'|email|max:255',
|
||||||
|
'password' => 'confirmed',
|
||||||
|
'cell_phone_number' => 'required|numeric',
|
||||||
|
'home_address' => 'required',
|
||||||
|
'up_profile_picture' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
]);
|
||||||
|
$input = $request->all();
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
if($user->profile_picture != "" && file_exists(public_path('uploads/user_folder/'.$user->image)))
|
||||||
|
$prev_image = $user->profile_picture;
|
||||||
|
$userImageName = "profile_".time().'.'.$input['up_profile_picture']->getClientOriginalExtension();
|
||||||
|
$input['profile_picture'] = $userImageName;
|
||||||
|
}
|
||||||
|
if($request['password']!=""):
|
||||||
|
$input['password']=bcrypt($request['password']);
|
||||||
|
else:
|
||||||
|
unset($input['password']);
|
||||||
|
endif;
|
||||||
|
$input['username']= $user->username;
|
||||||
|
$saved_data=$user->fill($input)->save();
|
||||||
|
if($saved_data):
|
||||||
|
if(isset($input['up_profile_picture']) && $input['up_profile_picture']->getError() == 0 && $input['up_profile_picture']->getClientOriginalName() != "")
|
||||||
|
{
|
||||||
|
$input['up_profile_picture']->move(public_path('uploads/user_folder'), $userImageName);
|
||||||
|
if(isset($prev_image) && $prev_image != "" && file_exists(public_path('uploads/user_folder/'.$prev_image)))
|
||||||
|
unlink(public_path('uploads/user_folder/'.$prev_image));
|
||||||
|
}
|
||||||
|
Session::flash('success_message', __('Your profile has been updated successfully.'));
|
||||||
|
return redirect()->route('profile');
|
||||||
|
else:
|
||||||
|
Session::flash('error_message', __('We are having some problem. Please try later.'));
|
||||||
|
return redirect()->route('profile');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,141 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Directory;
|
||||||
|
use App\Absent;
|
||||||
|
use App\User;
|
||||||
|
use App\PermissionRole;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open Translation File
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
if (! function_exists('check_permissions')) {
|
||||||
|
function check_permissions($permission)
|
||||||
|
{
|
||||||
|
$return_val = false;
|
||||||
|
$user = App\User::join('role_user', 'users.id', '=', 'role_user.user_id')
|
||||||
|
->join('roles', 'role_user.role_id', '=', 'roles.id')
|
||||||
|
->where('users.id', '=', Auth::user()->id)
|
||||||
|
->select('users.*', 'roles.name as role_name', 'roles.id as role_id', 'users.id as id')
|
||||||
|
->first();
|
||||||
|
$permissionRoles = PermissionRole::where('role_id', $user->role_id)
|
||||||
|
->where('department_id', $user->department_id)
|
||||||
|
->first();
|
||||||
|
if($permissionRoles){
|
||||||
|
$permission_array = json_decode($permissionRoles->permission_ids, true);
|
||||||
|
if(is_array($permission_array)){
|
||||||
|
if(in_array($permission, $permission_array)){
|
||||||
|
$return_val = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! function_exists('user_status')) {
|
||||||
|
function user_status($user)
|
||||||
|
{
|
||||||
|
$data=[];
|
||||||
|
$absent = Absent::where([
|
||||||
|
['user_id', '=', $user->id],
|
||||||
|
['start_date', '<=', date('Y-m-d')],
|
||||||
|
['end_date', '>=', date('Y-m-d')]
|
||||||
|
])->orderBy('start_date','desc')
|
||||||
|
->first();
|
||||||
|
if(isset($absent) && !empty($absent)){
|
||||||
|
$data['status'] = __("Absent");
|
||||||
|
$data['class'] = "avatar-away";
|
||||||
|
$data['avatar-suffix'] = "away";
|
||||||
|
}
|
||||||
|
elseif($user->working_status == 0){
|
||||||
|
$data['status'] = __("Off");
|
||||||
|
$data['class'] = "avatar-off";
|
||||||
|
$data['avatar-suffix'] = "off";
|
||||||
|
}
|
||||||
|
elseif($user->is_log_in == 1){
|
||||||
|
$data['status'] = __("Online");
|
||||||
|
$data['class'] = "avatar-online";
|
||||||
|
$data['avatar-suffix'] = "online";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data['status'] = __("Busy");
|
||||||
|
$data['class'] = "avatar-busy";
|
||||||
|
$data['avatar-suffix'] = "busy";
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! function_exists('previous_route')) {
|
||||||
|
/**
|
||||||
|
* Generate a route name for the previous request.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
function previous_route()
|
||||||
|
{
|
||||||
|
$previousRequest = app('request')->create(app('url')->previous());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$routeName = app('router')->getRoutes()->match($previousRequest)->getName();
|
||||||
|
} catch (NotFoundHttpException $exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $routeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('directory_path')) {
|
||||||
|
function directory_path($id, $path)
|
||||||
|
{
|
||||||
|
$directory = Directory::where('id', $id)->first();
|
||||||
|
if($directory !== null)
|
||||||
|
{
|
||||||
|
if($directory->parent_id > 0)
|
||||||
|
{
|
||||||
|
$directory_path = $directory->name.'/'.$path;
|
||||||
|
return directory_path($directory->parent_id, $directory_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $directory_path = $directory->name.'/'.$path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dataTranslation($data, $vlocale=null){
|
||||||
|
$data_val='';
|
||||||
|
if(Session::has('locale')){
|
||||||
|
$locale = Session::get('locale') ?? Config::get('app.locale');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$locale = 'tm';
|
||||||
|
}
|
||||||
|
$locale = ($vlocale !=null) ? $vlocale: $locale;
|
||||||
|
$jsonString = json_decode($data, true);
|
||||||
|
if(isset($jsonString[$locale]))
|
||||||
|
$data_val = $jsonString[$locale];
|
||||||
|
return $data_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openJSONFile($code){
|
||||||
|
$jsonString = [];
|
||||||
|
if(File::exists(base_path('resources/lang/'.$code.'.json'))){
|
||||||
|
$jsonString = file_get_contents(base_path('resources/lang/'.$code.'.json'));
|
||||||
|
$jsonString = json_decode($jsonString, true);
|
||||||
|
}
|
||||||
|
return $jsonString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save JSON File
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
function saveJSONFile($code, $data){
|
||||||
|
ksort($data);
|
||||||
|
$jsonData = json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
|
||||||
|
file_put_contents(base_path('resources/lang/'.$code.'.json'), stripslashes($jsonData));
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
\App\Http\Middleware\Localization::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
'throttle:60,1',
|
||||||
|
'bindings',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'revalidate' => \App\Http\Middleware\RevalidateBackHistory::class,
|
||||||
|
'redirectif' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
|
||||||
|
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
|
||||||
|
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
|
||||||
|
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The priority-sorted list of middleware.
|
||||||
|
*
|
||||||
|
* This forces non-global middleware to always be in the given order.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middlewarePriority = [
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\Authenticate::class,
|
||||||
|
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
\Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
|
||||||
|
class Authenticate extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||||
|
|
||||||
|
class CheckForMaintenanceMode extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
|
||||||
|
class EncryptCookies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the cookies that should not be encrypted.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use App;
|
||||||
|
use Session;
|
||||||
|
use Config;
|
||||||
|
|
||||||
|
class Localization
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
if(Session::has('locale')){
|
||||||
|
$locale = Session::get('locale');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$locale = 'en';
|
||||||
|
}
|
||||||
|
|
||||||
|
App::setLocale($locale);
|
||||||
|
$request->session()->put('locale', $locale);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
class RedirecIncomplete
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
if(Auth::guard('web')->check())
|
||||||
|
{
|
||||||
|
if(Auth::user()->is_profile_complete == "N"):
|
||||||
|
Session::flash('error_message', 'Please complete your profile first.');
|
||||||
|
return redirect()->route('profile');
|
||||||
|
endif;
|
||||||
|
}
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null $guard
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next, $guard = null)
|
||||||
|
{
|
||||||
|
if(Auth::guard('admin')->check())
|
||||||
|
{
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
elseif(Auth::guard('web')->check())
|
||||||
|
{
|
||||||
|
return redirect()->route('documents', ['type'=>'Incoming']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfNotAdmin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null $guard
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next, $guard = 'admin')
|
||||||
|
{
|
||||||
|
if (!Auth::guard($guard)->check()) {
|
||||||
|
return redirect('');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class RevalidateBackHistory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$response = $next($request);
|
||||||
|
// return $response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
|
||||||
|
// ->header('Pragma','no-cache')
|
||||||
|
// ->header('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
|
||||||
|
|
||||||
|
$response->headers->set('Access-Control-Allow-Origin' , '*');
|
||||||
|
$response->headers->set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE');
|
||||||
|
$response->headers->set('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
|
||||||
|
class TrimStrings extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the attributes that should not be trimmed.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array|string
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $addHttpCookie = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'/admin/logout',
|
||||||
|
'/logout',
|
||||||
|
'/dd-files-store',
|
||||||
|
'/store-files',
|
||||||
|
'/store-files-delete',
|
||||||
|
'/store-process-files',
|
||||||
|
'/store-process-files-delete',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Language extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'languages';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'short_name', 'serial_no', 'status',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class MyFile extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'my_files';
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'file_type', 'parent_id', 'year', 'description', 'tags', 'name_org', 'place_of_the_file', 'is_temp', 'file_size', 'user_id', 'shared_user_id', 'path_to_root'
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getPathToRoot($did)
|
||||||
|
{
|
||||||
|
if(!isset($did) || $did==null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
$directory = MyFile::find($did);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->parent_id == 0)
|
||||||
|
return [$directory->id];
|
||||||
|
else
|
||||||
|
return array_merge(MyFile::getPathToRoot($directory->parent_id), [$directory->id]);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPathToRootString($did)
|
||||||
|
{
|
||||||
|
$a = MyFile::getPathToRoot($did);
|
||||||
|
|
||||||
|
return (count($a)>0) ? ";" . implode(";", $a) . ";" : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPathArray($did)
|
||||||
|
{
|
||||||
|
if(!isset($did) || $did==null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
$directory = MyFile::find($did);
|
||||||
|
if($directory)
|
||||||
|
{
|
||||||
|
if($directory->parent_id == 0)
|
||||||
|
return [$directory->id => $directory->name];
|
||||||
|
else
|
||||||
|
return MyFile::getPathArray($directory->parent_id) + [$directory->id => $directory->name];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
if($this->file_type == 1 && $this->name_org != null)
|
||||||
|
return $this->name_org;
|
||||||
|
else
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileType()
|
||||||
|
{
|
||||||
|
if($this->file_type == 1)
|
||||||
|
return pathinfo($this->name, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPathOrg()
|
||||||
|
{
|
||||||
|
return $this->place_of_the_file . '/' . $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPathPdf()
|
||||||
|
{
|
||||||
|
if($this->file_type == 1)
|
||||||
|
return $this->place_of_the_file . '/' . pathinfo($this->name, PATHINFO_FILENAME) . '.pdf';
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
public function getReadableName()
|
||||||
|
{
|
||||||
|
if($this->file_type == 1)
|
||||||
|
return pathinfo($this->name_org, PATHINFO_FILENAME) . '.' . pathinfo($this->name, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function getFileTypeAttribute($attribute)
|
||||||
|
// {
|
||||||
|
// try{
|
||||||
|
// $v = $this->getFileTypeOptions()[$attribute];
|
||||||
|
// }
|
||||||
|
// catch(\Throwable $th){
|
||||||
|
// $v = "Error";
|
||||||
|
// }
|
||||||
|
// return $v;
|
||||||
|
// }
|
||||||
|
// public function getFileTypeOptions()
|
||||||
|
// {
|
||||||
|
// return [
|
||||||
|
// 0 => 'D',
|
||||||
|
// 1 => 'F',
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Notification extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'notifications';
|
||||||
|
protected $fillable = ['type', 'notifiable_type', 'notifiable_id', 'workflow_document_id', 'data', 'read_at'];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'data' => 'json'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
|
||||||
|
class DocumentNotification extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
public $document_id;
|
||||||
|
public $type;
|
||||||
|
public $action;
|
||||||
|
public $link;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($document_id, $type, $action, $link)
|
||||||
|
{
|
||||||
|
$this->document_id = $document_id;
|
||||||
|
$this->type = $type;
|
||||||
|
$this->action = $action;
|
||||||
|
$this->link = $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return [customDocumentChannel::class, 'broadcast'];
|
||||||
|
// return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toDatabase($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'type' => $this->type,
|
||||||
|
'action' => $this->action,
|
||||||
|
'link' => $this->link,
|
||||||
|
'workflow_document_id' => $this->document_id
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class customDocumentChannel
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function send($notifiable, Notification $notification)
|
||||||
|
{
|
||||||
|
$data = $notification->toDatabase($notifiable);
|
||||||
|
$document_id = $data['workflow_document_id'];
|
||||||
|
unset($data['workflow_document_id']);
|
||||||
|
|
||||||
|
\App\Notification::where('notifiable_id', $notifiable->id)->where('workflow_document_id', $document_id)->whereNull('read_at')->update(['read_at'=>now()->format('Y-m-d H:i:s')]);
|
||||||
|
|
||||||
|
return $notifiable->routeNotificationFor('database')->create([
|
||||||
|
'id' => $notification->id,
|
||||||
|
'workflow_document_id'=> $document_id,
|
||||||
|
'notifiable_type' => $notifiable->user_id,
|
||||||
|
'type' => get_class($notification),
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\SharedFile;
|
||||||
|
use App\User;
|
||||||
|
|
||||||
|
class SharedFileObserver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the shared file "created" event.
|
||||||
|
*
|
||||||
|
* @param \App\SharedFile $sharedFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function created(SharedFile $sharedFile)
|
||||||
|
{
|
||||||
|
if($sharedFile->department_id!=null)
|
||||||
|
{
|
||||||
|
$users = User::where('department_id', $sharedFile->department->id)->pluck('id')->toArray();
|
||||||
|
$files = SharedFile::where('shared_by', auth()->user()->id)->where('path_to_root', 'LIKE', '%;'. $sharedFile->file_id .';%')
|
||||||
|
->where(function($q) use($sharedFile, $users){
|
||||||
|
$q->orWhere('department_id', $sharedFile->department_id)
|
||||||
|
->orWhereIn('user_id', $users);
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
foreach($files as $file)
|
||||||
|
{
|
||||||
|
$file->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($sharedFile->user_id!=null)
|
||||||
|
{
|
||||||
|
$files = SharedFile::where('shared_by', auth()->user()->id)->where('user_id', $sharedFile->user_id)->where('path_to_root', 'LIKE', '%;'. $sharedFile->file_id .';%')->get();
|
||||||
|
foreach($files as $file)
|
||||||
|
{
|
||||||
|
$file->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($sharedFile->permission == 1) && SharedFile::where('file_id', $sharedFile->file_id)->where('user_id', $sharedFile->user_id)->where('department_id', $sharedFile->department_id)->where('permission', 2)->exist())
|
||||||
|
$sharedFile->delete();
|
||||||
|
else if($sharedFile->permission == 2)
|
||||||
|
if(SharedFile::where('file_id', $sharedFile->file_id)->where('user_id', $sharedFile->user_id)->where('department_id', $sharedFile->department_id)->where('permission', 1)->exist())
|
||||||
|
SharedFile::where('file_id', $sharedFile->file_id)->where('user_id', $sharedFile->user_id)->where('department_id', $sharedFile->department_id)->where('permission', 1)->delete();
|
||||||
|
|
||||||
|
|
||||||
|
if($sharedFile->path_to_root == "")
|
||||||
|
{
|
||||||
|
$sharedFile->show_home = 1;
|
||||||
|
$sharedFile->saveWithoutEvents();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$found=false;
|
||||||
|
$shares = SharedFile::where('department_id', $sharedFile->department_id)->where('user_id', $sharedFile->user_id)->where('file_id', $sharedFile->file_id)->get(['id', 'show_home']);
|
||||||
|
foreach($shares as $share)
|
||||||
|
{
|
||||||
|
if(preg_match("/;".$share->file_id.";/", $sharedFile->path_to_root))
|
||||||
|
$found=true;
|
||||||
|
}
|
||||||
|
if($found == false)
|
||||||
|
{
|
||||||
|
$sharedFile->show_home = 1;
|
||||||
|
$sharedFile->saveWithoutEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the shared file "updated" event.
|
||||||
|
*
|
||||||
|
* @param \App\SharedFile $sharedFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function updated(SharedFile $sharedFile)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the shared file "deleted" event.
|
||||||
|
*
|
||||||
|
* @param \App\SharedFile $sharedFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function deleted(SharedFile $sharedFile)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the shared file "restored" event.
|
||||||
|
*
|
||||||
|
* @param \App\SharedFile $sharedFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function restored(SharedFile $sharedFile)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the shared file "force deleted" event.
|
||||||
|
*
|
||||||
|
* @param \App\SharedFile $sharedFile
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function forceDeleted(SharedFile $sharedFile)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Permission extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'permissions';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'display_name',
|
||||||
|
'description',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getPermittedUsersList($pid)
|
||||||
|
{
|
||||||
|
$deps = PermissionRole::where('permission_ids', 'LIKE', '%"'.$pid.'"%')->pluck('department_id')->toArray();
|
||||||
|
$roles = PermissionRole::where('permission_ids', 'LIKE', '%"'.$pid.'"%')->pluck('role_id')->toArray();
|
||||||
|
|
||||||
|
$u = User::whereIn('department_id', $deps)->whereHas('role_user', function($q) use($roles){
|
||||||
|
$q->whereIn('role_id', $roles);
|
||||||
|
})->get(['id', 'first_name', 'last_name']);
|
||||||
|
|
||||||
|
|
||||||
|
return $u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PermissionRole extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'permission_role';
|
||||||
|
protected $fillable = [
|
||||||
|
'role_id',
|
||||||
|
'department_id',
|
||||||
|
'permission_ids',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PermissionUser extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'permission_user';
|
||||||
|
protected $fillable = [
|
||||||
|
'permission_id',
|
||||||
|
'user_id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Priority extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'priorities';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'completion_day',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Promotion extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'promotions';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'last_user_id',
|
||||||
|
'till_date',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
use App\SharedFile;
|
||||||
|
use App\Observers\SharedFileObserver;
|
||||||
|
|
||||||
|
Use Schema;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Schema::defaultStringLength(191);
|
||||||
|
SharedFile::observe(SharedFileObserver::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The policy mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any authentication / authorization services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerPolicies();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
|
||||||
|
class BroadcastServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Broadcast::routes();
|
||||||
|
|
||||||
|
require base_path('routes/channels.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The event listener mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $listen = [
|
||||||
|
Registered::class => [
|
||||||
|
SendEmailVerificationNotification::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any events for your application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class HelperServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$file = app_path('Http/Helper.php');
|
||||||
|
if (file_exists($file)) {
|
||||||
|
require_once($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This namespace is applied to your controller routes.
|
||||||
|
*
|
||||||
|
* In addition, it is set as the URL generator's root namespace.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $namespace = 'App\Http\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define your route model bindings, pattern filters, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the routes for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function map()
|
||||||
|
{
|
||||||
|
$this->mapApiRoutes();
|
||||||
|
|
||||||
|
$this->mapWebRoutes();
|
||||||
|
|
||||||
|
$this->mapAdminRoutes();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the "web" routes for the application.
|
||||||
|
*
|
||||||
|
* These routes all receive session state, CSRF protection, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function mapWebRoutes()
|
||||||
|
{
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/web.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the "api" routes for the application.
|
||||||
|
*
|
||||||
|
* These routes are typically stateless.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function mapApiRoutes()
|
||||||
|
{
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function mapAdminRoutes()
|
||||||
|
{
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace.'\Admin')
|
||||||
|
->group(base_path('routes/admin.php'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RegNumber extends Model
|
||||||
|
{
|
||||||
|
const INC = 1;
|
||||||
|
const OUT = 2;
|
||||||
|
const ITR = 3;
|
||||||
|
const TMP = 4;
|
||||||
|
|
||||||
|
protected $fillable = ['reg_number', 'user_id'];
|
||||||
|
static $doctype = ['1' => 'seq_inc', '2'=>'seq_out', '3'=>'seq_int', '4' => 'seq_tmp'];
|
||||||
|
static $prefix = ['1' => 'registration_number_prefix', '2'=>'outgoing_registration_number_prefix', '3'=>'internal_registration_number_prefix', '4' => 'temporary_registration_number_prefix'];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsCancelledAttribute($attribute)
|
||||||
|
{
|
||||||
|
return ($attribute == 1) ? 'Yes' : 'No';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateRegNumber($rn)
|
||||||
|
{
|
||||||
|
if(DB::table('reg_numbers')->where('reg_number', $rn)->exists())
|
||||||
|
DB::table('reg_numbers')->where('reg_number', $rn)->update(['is_cancelled'=>0]);
|
||||||
|
}
|
||||||
|
public static function getNextRegNumber($userid, $dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isset(self::$doctype[$dt]))
|
||||||
|
{
|
||||||
|
$setting = Setting::first();
|
||||||
|
$vprefix = self::$prefix[$dt];
|
||||||
|
|
||||||
|
$registration_number= (($setting->$vprefix && $setting->$vprefix!='') ? $setting->$vprefix.'-' : '') . static::getRegFormat($setting->is_registration_number_with_date) . '-' . sprintf('%04d', (static::getNextSeq($dt)));
|
||||||
|
|
||||||
|
if(RegNumber::create(['user_id' => $userid, 'reg_number' => $registration_number]))
|
||||||
|
return $registration_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getRegFormat($val)
|
||||||
|
{
|
||||||
|
$reg_format = [
|
||||||
|
'0' => 'PRX-YYYY-MM-DD-SEQ',
|
||||||
|
'1' => 'PRX-YYYY-MM-SEQ',
|
||||||
|
'2' => 'PRX-YYYY-SEQ',
|
||||||
|
'3' => 'PRX-SEQ'
|
||||||
|
];
|
||||||
|
$res='';
|
||||||
|
if($val == 0)
|
||||||
|
$res = date('Y-m-d');
|
||||||
|
else if($val == 1)
|
||||||
|
$res = date('Y-m');
|
||||||
|
else if($val == 2)
|
||||||
|
$res = date('Y');
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getLatestSeq($dt)
|
||||||
|
{
|
||||||
|
if(isset(self::$doctype[$dt]))
|
||||||
|
{
|
||||||
|
$dtype = self::$doctype[$dt];
|
||||||
|
return DB::table('reg_number_seq')->first()->$dtype;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNextSeq($dt)
|
||||||
|
{
|
||||||
|
if(isset(self::$doctype[$dt]))
|
||||||
|
{
|
||||||
|
$dtype = self::$doctype[$dt];
|
||||||
|
try {
|
||||||
|
$seq = static::getLatestSeq($dt)+1;
|
||||||
|
DB::table('reg_number_seq')->update([$dtype=>$seq]);
|
||||||
|
return $seq;
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function resetSeqNumber($seq, $type=null)
|
||||||
|
{
|
||||||
|
if($type == null)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
DB::table('reg_number_seq')->update([
|
||||||
|
'seq_inc' => $seq,
|
||||||
|
'seq_out' => $seq,
|
||||||
|
'seq_int' => $seq,
|
||||||
|
'seq_tmp' => $seq
|
||||||
|
]);
|
||||||
|
} catch(\Throwable $th){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(isset(self::$doctype[$type]))
|
||||||
|
{
|
||||||
|
$dtype = self::$doctype[$type];
|
||||||
|
try {
|
||||||
|
DB::table('reg_number_seq')->update([$dtype=>$seq]);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RemoteContact extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['contact_id', 'direction', 'login', 'password', 'public_key', 'description'];
|
||||||
|
|
||||||
|
public function contact()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Contact::class, 'contact_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remotecontactapis()
|
||||||
|
{
|
||||||
|
return $this->hasMany(RemoteContactApi::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirection()
|
||||||
|
{
|
||||||
|
return ($this->direction) ? "Out" : "In";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirectionWithArrow()
|
||||||
|
{
|
||||||
|
return ($this->direction) ? "Out <i class='fa fa-long-arrow-right'></i>" : "In <i class='fa fa-long-arrow-left'></i>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RemoteContactApi extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['remote_contact_id', 'connection_string', 'connection_method', 'mandatory_fields', 'type'];
|
||||||
|
|
||||||
|
public function remotecontact()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(RemoteContact::class, 'remote_contact_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RemoteTransfer extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $fillable = ['receipt', 'login', 'direction', 'status', 'send_at', 'workflow_document_id', 'content', 'document_name', 'place_of_the_documents', 'contact_id'];
|
||||||
|
|
||||||
|
public function contact()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Contact::class, 'contact_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirection()
|
||||||
|
{
|
||||||
|
return ($this->direction) ? "Out" : "In";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusAttribute($attribute)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
$v = $this->getStatusOptions()[$attribute];
|
||||||
|
}
|
||||||
|
catch(\Throwable $th){
|
||||||
|
$v = "Error";
|
||||||
|
}
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusOptions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
0 => 'default',
|
||||||
|
1 => 'in process',
|
||||||
|
2 => 'send',
|
||||||
|
3 => 'received',
|
||||||
|
4 => 'connection error',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRegNumber()
|
||||||
|
{
|
||||||
|
return $this->login ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue