init
This commit is contained in:
commit
76bf79a6e6
15
.editorconfig
Normal file
15
.editorconfig
Normal file
@ -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,yaml}]
|
||||||
|
indent_size = 2
|
56
.env
Normal file
56
.env
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
APP_NAME=EDCWEBMIN
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:zCMEQrWsq7AnMzNwwjLX860aU7cXRabT0aCz9ygbnZo=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
APP_VERSION=1.1.0
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=pusher
|
||||||
|
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_MAILER=smtp
|
||||||
|
# MAIL_HOST=smtp.mailtrap.io
|
||||||
|
# MAIL_PORT=2525
|
||||||
|
# MAIL_USERNAME=null
|
||||||
|
# MAIL_PASSWORD=null
|
||||||
|
# MAIL_ENCRYPTION=null
|
||||||
|
# MAIL_FROM_ADDRESS=null
|
||||||
|
# MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
# MAIL_DRIVER=smtp
|
||||||
|
# MAIL_HOST=huit.co.id
|
||||||
|
# MAIL_PORT=587
|
||||||
|
# MAIL_USERNAME=official@huit.co.id
|
||||||
|
# MAIL_PASSWORD=Huitsportwear@2021
|
||||||
|
# MAIL_ENCRYPTION=TLS
|
||||||
|
# MAIL_FROM_NAME=Huit
|
||||||
|
|
||||||
|
MAIL_DRIVER=smtp
|
||||||
|
MAIL_HOST=mail.basys.co.id
|
||||||
|
MAIL_PORT=587
|
||||||
|
MAIL_USERNAME=zamzam@basys.co.id
|
||||||
|
MAIL_PASSWORD=Basys2021
|
||||||
|
MAIL_ENCRYPTION=TLS
|
||||||
|
MAIL_FROM_NAME=NTT
|
||||||
|
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
|
||||||
|
PUSHER_APP_ID=1182799
|
||||||
|
PUSHER_APP_KEY=5c4e0152c7db8c84fe35
|
||||||
|
PUSHER_APP_SECRET=222b92d912744f64eb2a
|
||||||
|
PUSHER_APP_CLUSTER=ap3
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
46
.env.example
Normal file
46
.env.example
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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_MAILER=smtp
|
||||||
|
MAIL_HOST=smtp.mailtrap.io
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
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}"
|
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
* text=auto
|
||||||
|
*.css linguist-vendored
|
||||||
|
*.scss linguist-vendored
|
||||||
|
*.js linguist-vendored
|
||||||
|
CHANGELOG.md export-ignore
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/node_modules
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/vendor
|
||||||
|
.phpunit.result.cache
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
12
.gitlab-ci.yml
Normal file
12
.gitlab-ci.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# You can override the included template(s) by including variable overrides
|
||||||
|
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
|
||||||
|
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
|
||||||
|
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
|
||||||
|
# Note that environment variables can be set in several places
|
||||||
|
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
sast:
|
||||||
|
stage: test
|
||||||
|
include:
|
||||||
|
- template: Security/SAST.gitlab-ci.yml
|
52
.htaccess
Normal file
52
.htaccess
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
|
||||||
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule ^(.*)/$ /$1 [L,R=301]
|
||||||
|
|
||||||
|
# Handle Front Controller...
|
||||||
|
RewriteCond %{REQUEST_URI} !(\.json|\.css|\.mkv|\.js|\.jpeg|\.png|\.jpg|\.gif|robots\.txt|\.ttf|\.woff|\.woff2|\.mp4|\.webm|\.ico|\.svg)$ [NC]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
|
||||||
|
#RewriteRule ^(.*)$ public/$1 [L]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_URI} !^/public/
|
||||||
|
RewriteRule ^(file|css|js|assets_admin|assets|assets_client|vendors|content|images|img|fonts|extras|lan_id)/(.*)$ public/$1/$2 [L,NC]
|
||||||
|
|
||||||
|
# Handle Authorization Header
|
||||||
|
RewriteCond %{HTTP:Authorization} .
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
</IfModule>
|
||||||
|
<IfModule mod_expires.c>
|
||||||
|
ExpiresActive On
|
||||||
|
|
||||||
|
# Images
|
||||||
|
ExpiresByType image/jpeg "access plus 1 year"
|
||||||
|
ExpiresByType image/gif "access plus 1 year"
|
||||||
|
ExpiresByType image/png "access plus 1 year"
|
||||||
|
ExpiresByType image/webp "access plus 1 year"
|
||||||
|
ExpiresByType image/svg+xml "access plus 1 year"
|
||||||
|
ExpiresByType image/x-icon "access plus 1 year"
|
||||||
|
|
||||||
|
# Video
|
||||||
|
ExpiresByType video/mp4 "access plus 1 year"
|
||||||
|
ExpiresByType video/mpeg "access plus 1 year"
|
||||||
|
|
||||||
|
# CSS, JavaScript
|
||||||
|
ExpiresByType text/css "access plus 1 month"
|
||||||
|
ExpiresByType text/javascript "access plus 1 month"
|
||||||
|
ExpiresByType application/javascript "access plus 1 month"
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ExpiresByType application/pdf "access plus 1 month"
|
||||||
|
ExpiresByType application/x-shockwave-flash "access plus 1 month"
|
||||||
|
</IfModule>
|
13
.styleci.yml
Normal file
13
.styleci.yml
Normal file
@ -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
|
11
Jenkinsfile
vendored
Normal file
11
Jenkinsfile
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Deliver') {
|
||||||
|
steps {
|
||||||
|
sh 'sudo /var/edc-app/deliver-webmin-pos-edc.sh'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
README.md
Normal file
93
README.md
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# pos-edc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||||
|
|
||||||
|
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||||
|
|
||||||
|
## Add your files
|
||||||
|
|
||||||
|
- [ ] [Create](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||||
|
- [ ] [Add files using the command line](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd existing_repo
|
||||||
|
git remote add origin https://gitlab.com/b2049/ntt/pos/pos-edc.git
|
||||||
|
git branch -M main
|
||||||
|
git push -uf origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
## Integrate with your tools
|
||||||
|
|
||||||
|
- [ ] [Set up project integrations](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://gitlab.com/b2049/ntt/pos/pos-edc/-/settings/integrations)
|
||||||
|
|
||||||
|
## Collaborate with your team
|
||||||
|
|
||||||
|
- [ ] [Invite team members and collaborators](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/members/)
|
||||||
|
- [ ] [Create a new merge request](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||||
|
- [ ] [Automatically close issues from merge requests](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||||
|
- [ ] [Enable merge request approvals](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||||
|
- [ ] [Automatically merge when pipeline succeeds](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||||
|
|
||||||
|
## Test and Deploy
|
||||||
|
|
||||||
|
Use the built-in continuous integration in GitLab.
|
||||||
|
|
||||||
|
- [ ] [Get started with GitLab CI/CD](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||||
|
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||||
|
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||||
|
- [ ] [Use pull-based deployments for improved Kubernetes management](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||||
|
- [ ] [Set up protected environments](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Editing this README
|
||||||
|
|
||||||
|
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://gitlab.com/-/experiment/new_project_readme_content:27fa3d9dd96b56d6339cd7991c464008?https://www.makeareadme.com/) for this template.
|
||||||
|
|
||||||
|
## Suggestions for a good README
|
||||||
|
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||||
|
|
||||||
|
## Name
|
||||||
|
Choose a self-explaining name for your project.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||||
|
|
||||||
|
## Badges
|
||||||
|
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||||
|
|
||||||
|
## Visuals
|
||||||
|
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
State if you are open to contributions and what your requirements are for accepting them.
|
||||||
|
|
||||||
|
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||||
|
|
||||||
|
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||||
|
|
||||||
|
## Authors and acknowledgment
|
||||||
|
Show your appreciation to those who have contributed to the project.
|
||||||
|
|
||||||
|
## License
|
||||||
|
For open source projects, say how it is licensed.
|
||||||
|
|
||||||
|
## Project status
|
||||||
|
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||||
|
|
18527
_ide_helper.php
Normal file
18527
_ide_helper.php
Normal file
File diff suppressed because it is too large
Load Diff
41
app/Admin.php
Normal file
41
app/Admin.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class Admin extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
protected $table = 'users_admin';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'username', 'email', 'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password', 'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast to native types.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
41
app/Console/Kernel.php
Normal file
41
app/Console/Kernel.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
// $schedule->command('inspire')->hourly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
35
app/Customer.php
Normal file
35
app/Customer.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class Customer extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
|
protected $table = 'mst_customer';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'username','email', 'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
41
app/Events/StatusLiked.php
Normal file
41
app/Events/StatusLiked.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
|
||||||
|
class StatusLiked implements ShouldBroadcast
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $username;
|
||||||
|
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($username)
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
$this->message = "{$username} liked your status";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['status-liked'];
|
||||||
|
}
|
||||||
|
}
|
55
app/Exceptions/Handler.php
Normal file
55
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
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 \Throwable $exception
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function report(Throwable $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Throwable $exception
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function render($request, Throwable $exception)
|
||||||
|
{
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
}
|
44
app/Exports/ExcelExport.php
Normal file
44
app/Exports/ExcelExport.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class ExcelExport implements FromView,ShouldAutoSize,WithColumnFormatting
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function __construct($param)
|
||||||
|
{
|
||||||
|
$this->param = $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view($this->param['view'], [
|
||||||
|
'param' => $this->param
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'C' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_NUMBER
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
56
app/Exports/ExcelExportCSV.php
Normal file
56
app/Exports/ExcelExportCSV.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToModel;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
|
||||||
|
|
||||||
|
class ExcelExportCSV implements FromView,ShouldAutoSize,WithColumnFormatting,WithCustomCsvSettings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function __construct($param)
|
||||||
|
{
|
||||||
|
$this->param = $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view($this->param['view'], [
|
||||||
|
'param' => $this->param
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'B' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'D' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'E' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'F' => NumberFormat::FORMAT_NUMBER,
|
||||||
|
'G' => NumberFormat::FORMAT_NUMBER
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCsvSettings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'delimiter' => ","
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
289
app/Exports/IcsExport.php
Normal file
289
app/Exports/IcsExport.php
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use App\Model\Audit\AuditFindingModel;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||||
|
use Maatwebsite\Excel\Events\AfterSheet;
|
||||||
|
use Maatwebsite\Excel\Events\BeforeExport;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\Border;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||||
|
use Maatwebsite\Excel\Sheet;
|
||||||
|
|
||||||
|
class IcsExport implements WithColumnFormatting,FromView,WithEvents
|
||||||
|
{
|
||||||
|
public function __construct($t_mulai,$t_selesai,$persiapan,$jenis_cetak)
|
||||||
|
{
|
||||||
|
$this->t_mulai = $t_mulai;
|
||||||
|
$this->t_selesai = $t_selesai;
|
||||||
|
$this->persiapan = $persiapan;
|
||||||
|
$this->jenis_cetak = $jenis_cetak;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
// KCP
|
||||||
|
if ($this->jenis_cetak == 1) {
|
||||||
|
return view('export.xlsx_cetak_risk_register', [
|
||||||
|
't_mulai' => $this->t_mulai,
|
||||||
|
't_selesai' => $this->t_selesai,
|
||||||
|
'persiapan' => $this->persiapan
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
return view('export.xlsx_cetak_formula', [
|
||||||
|
't_mulai' => $this->t_mulai,
|
||||||
|
't_selesai' => $this->t_selesai,
|
||||||
|
'persiapan' => $this->persiapan
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function columnFormats(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Z' => Border::BORDER_MEDIUM
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerEvents(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
return [
|
||||||
|
AfterSheet::class => function(AfterSheet $event) {
|
||||||
|
|
||||||
|
$t_mulai = date('Y-m-d',strtotime($this->t_mulai));
|
||||||
|
$t_selesai = date('Y-m-d',strtotime($this->t_selesai));
|
||||||
|
$persiapan = $this->persiapan;
|
||||||
|
|
||||||
|
$penugasan = $persiapan;
|
||||||
|
if ($penugasan == "semua") {
|
||||||
|
$t_mulai = date('Y-m-d',strtotime($t_mulai));
|
||||||
|
$t_selesai = date('Y-m-d',strtotime($t_selesai));
|
||||||
|
$filter_penugasan = "";
|
||||||
|
}else{
|
||||||
|
$date_penugasan = collect(\DB::select("SELECT audit_tittle, ma.start_date, ma.end_date FROM master_audit_job maj
|
||||||
|
join master_audit_plan ma on ma.id = maj.audit_plan_id
|
||||||
|
where maj.id = ".$penugasan))->first();
|
||||||
|
|
||||||
|
$t_mulai = $date_penugasan->start_date;
|
||||||
|
$t_selesai = $date_penugasan->end_date;
|
||||||
|
$filter_penugasan = " and audit_job_id = ".$penugasan;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////KCP
|
||||||
|
if ($this->jenis_cetak == 1) {
|
||||||
|
|
||||||
|
$d_sebab = collect(\DB::select("SELECT * FROM reff_aspek order by code"))->count();
|
||||||
|
$d_bidang = collect(\DB::select("SELECT DISTINCT ON (rsca.definition ) rsca.definition as bidang,ri.bidang_ics
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics where finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan))->count();
|
||||||
|
|
||||||
|
$d_bidang_c = \DB::select("SELECT DISTINCT ON (rsca.definition ) rsca.definition as bidang,ri.bidang_ics
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics");
|
||||||
|
|
||||||
|
$count_isc = 0;
|
||||||
|
$count_data = 0;
|
||||||
|
|
||||||
|
foreach ($d_bidang_c as $db) {
|
||||||
|
|
||||||
|
|
||||||
|
$d_isc = \DB::select("SELECT DISTINCT ON(bidang_ics) rsca.definition as bidang,ri.bidang_ics
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics
|
||||||
|
where rsca.definition = '".$db->bidang."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($d_isc as $di) {
|
||||||
|
$count_isc++;
|
||||||
|
|
||||||
|
$data = \DB::select("SELECT maf.* ,rsca.definition as bidang,ri.bidang_ics, ra.code as sebab_code
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics
|
||||||
|
join reff_aspek ra on ra.id = maf.jenis_sebab
|
||||||
|
where ri.bidang_ics = '".$di->bidang_ics."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
|
||||||
|
|
||||||
|
foreach ($data as $d) {
|
||||||
|
$count_data++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$total_row = $d_sebab+$count_isc+$count_data+($d_bidang*3)+7+6;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A7:W9')
|
||||||
|
->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$styleArray = [
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||||
|
'color' => ['argb' => '000000'],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$event->sheet->getDelegate()->getStyle('A7:W'.$total_row)->applyFromArray($styleArray);
|
||||||
|
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('A')->setWidth(5.7);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('B')->setWidth(3);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('C')->setWidth(3);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('D')->setWidth(52);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('E')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('F')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('G')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('H')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('I')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('J')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('K')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('L')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('M')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('N')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('O')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('P')->setWidth(5);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('S')->setWidth(10);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('T')->setWidth(20);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('U')->setWidth(10);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('V')->setWidth(50);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('W')->setWidth(20);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')
|
||||||
|
->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')->getFont()->setSize(10);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A7:W8')->getFont()->setBold(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')->getFont()->setName('Arial');
|
||||||
|
$event->sheet->getDelegate()->getStyle('D1:D500')->getAlignment()->setWrapText(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('V1:V500')->getAlignment()->setWrapText(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('T8')->getAlignment()->setWrapText(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('W7')->getAlignment()->setWrapText(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
////////////////////FORMULA
|
||||||
|
else{
|
||||||
|
|
||||||
|
|
||||||
|
$d_init_bobot = \DB::select("SELECT DISTINCT ON (bobot.nama) rsca.definition as bidang,rsca.id as kode_bidang,ri.bidang_ics,bobot.*
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics
|
||||||
|
join bobot on bobot.id = rsca.id_bobot
|
||||||
|
where finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
|
||||||
|
|
||||||
|
$d_bidang = \DB::select("SELECT DISTINCT ON (rsca.definition ) rsca.definition as bidang,rsca.id as kode_bidang,ri.bidang_ics
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics where finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
|
||||||
|
|
||||||
|
$no = 1;
|
||||||
|
|
||||||
|
foreach($d_bidang as $db){
|
||||||
|
|
||||||
|
|
||||||
|
$d_isc = \DB::select("SELECT DISTINCT ON(bidang_ics) rsca.definition as bidang,ri.id as id_bidang_ics
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics
|
||||||
|
where rsca.id = '".$db->kode_bidang."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."' ".$filter_penugasan);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($d_isc as $di){
|
||||||
|
|
||||||
|
$data = \DB::select("SELECT maf.* ,rsca.id as kode_bidang,rsca.definition as bidang,ri.bidang_ics, ra.code as sebab_code
|
||||||
|
FROM master_audit_finding maf
|
||||||
|
join reff_sub_class_audit rsca on rsca.id = maf.id_program
|
||||||
|
join reff_ics ri on ri.id = maf.ics
|
||||||
|
join reff_aspek ra on ra.id = maf.jenis_sebab
|
||||||
|
where ri.id = '".$di->id_bidang_ics."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($data as $d){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$no++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$total_row_formula = (count($d_init_bobot))+$no+35;
|
||||||
|
|
||||||
|
$headst = [
|
||||||
|
'borders' => [
|
||||||
|
'outline' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||||
|
'color' => ['argb' => '000000'],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$event->sheet->getDelegate()->getStyle('A2:M3')->applyFromArray($headst);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A5:M7')->applyFromArray($headst);
|
||||||
|
|
||||||
|
$styleArray = [
|
||||||
|
'borders' => [
|
||||||
|
'allBorders' => [
|
||||||
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
||||||
|
'color' => ['argb' => '000000'],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$event->sheet->getDelegate()->getStyle('A10:M'.$total_row_formula)->applyFromArray($styleArray);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('A')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('B')->setWidth(42);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('C')->setWidth(15);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('D')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('E')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('F')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('G')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('H')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('I')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('J')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('K')->setWidth(5);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('L')->setWidth(15);
|
||||||
|
$event->sheet->getDelegate()->getColumnDimension('M')->setWidth(15);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')
|
||||||
|
->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')->getFont()->setSize(10);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A10:M12')->getFont()->setBold(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A1:W500')->getFont()->setName('Arial');
|
||||||
|
$event->sheet->getDelegate()->getStyle('A10:M12')->getAlignment()->setWrapText(true);
|
||||||
|
$event->sheet->getDelegate()->getStyle('A10:W12')
|
||||||
|
->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A2:W3')
|
||||||
|
->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->getStyle('A2:M3')->getFont()->setBold(true);
|
||||||
|
|
||||||
|
$event->sheet->getDelegate()->setShowGridlines(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset emails and
|
||||||
|
| includes a trait which assists in sending these notifications from
|
||||||
|
| your application to your users. Feel free to explore this trait.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
198
app/Http/Controllers/Auth/LoginController.php
Normal file
198
app/Http/Controllers/Auth/LoginController.php
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
|
||||||
|
use Validator, Redirect, Auth, Session, DB, Hash;
|
||||||
|
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Login Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles authenticating users for the application and
|
||||||
|
| redirecting them to your home screen. The controller uses a trait
|
||||||
|
| to conveniently provide its functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// $this->middleware('guest')->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function username()
|
||||||
|
{
|
||||||
|
$identity = request()->get('identity');
|
||||||
|
$password = request()->get('password');
|
||||||
|
|
||||||
|
$fieldName = filter_var($identity, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
|
||||||
|
request()->merge([$fieldName => $identity]);
|
||||||
|
|
||||||
|
return $fieldName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Validate the user login.
|
||||||
|
* @param Request $request
|
||||||
|
*/
|
||||||
|
protected function validateLogin(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate(
|
||||||
|
$request,
|
||||||
|
[
|
||||||
|
'identity' => 'required|string',
|
||||||
|
'password' => 'required|string',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'identity.required' => 'Username or email is required',
|
||||||
|
'password.required' => 'Password is required',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
protected function sendFailedLoginResponse(Request $request)
|
||||||
|
{
|
||||||
|
$request->session()->put('login_error', trans('auth.failed'));
|
||||||
|
throw ValidationException::withMessages(
|
||||||
|
[
|
||||||
|
'error' => [trans('auth.failed')],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login_admin(Request $request)
|
||||||
|
{
|
||||||
|
if (Auth::guard('admin')->check()) {
|
||||||
|
$datas['title'] = 'Dashboard';
|
||||||
|
$datas['ref_user'] = \DB::select("SELECT * FROM users_admin WHERE status_user = 't'");
|
||||||
|
return $this->bsGetView('content.dashboard',$datas);
|
||||||
|
}else{
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function logout_admin() {
|
||||||
|
$user = DB::table('users_admin')->where('id',Auth::guard('admin')->user()->id)->first();
|
||||||
|
$event = "Logout User ID:".Auth::guard('admin')->user()->id;
|
||||||
|
|
||||||
|
|
||||||
|
$this->auditTrailLog($event,"Logout Log WEBMIN_BANK",'',json_encode($user),'');
|
||||||
|
|
||||||
|
Session::flush();
|
||||||
|
Auth::guard('admin')->logout();
|
||||||
|
return redirect()->route('admin.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function authenticate(Request $request)
|
||||||
|
{
|
||||||
|
$credentials = $request->only('username', 'password');
|
||||||
|
$user = DB::table('users_admin')->where('username', $request->input('username'))->first();
|
||||||
|
|
||||||
|
if (!is_null($user)) {
|
||||||
|
|
||||||
|
$checkPassword = $this->hashPasswordCheck($request->input('password'),$user->password);
|
||||||
|
|
||||||
|
if($checkPassword != $user->password){
|
||||||
|
$data = User::find($user->id);
|
||||||
|
$data->wrong_password = $data->wrong_password+1;
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
if ($data->wrong_password > 6) {
|
||||||
|
$data = User::find($user->id);
|
||||||
|
$data->status_user = 'f';
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
$event = 'Status User Telah di block, silahkan hubungi admin';
|
||||||
|
$this->auditTrailLog($event,"Invalid Login Log",'',json_encode($user),'');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'Status User Telah di block, silahkan hubungi admin'
|
||||||
|
]);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$event = 'Username atau Password salah';
|
||||||
|
$this->auditTrailLog($event,"Invalid Login Log",'',json_encode($user),'');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'Username atau Password salah'
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->status_user == 'f'){
|
||||||
|
|
||||||
|
$event = 'Akun anda tidak aktif. Silahkan hubungi admin.';
|
||||||
|
$this->auditTrailLog($event,"Invalid Login Log",'',json_encode($user),'');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 1,
|
||||||
|
'rm' => 'Akun anda tidak aktif. Silahkan hubungi admin.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::regenerate();
|
||||||
|
|
||||||
|
Session::put('id', $user->id);
|
||||||
|
|
||||||
|
$event = 'Login User Success';
|
||||||
|
$this->auditTrailLog($event,"Login Log",'',json_encode($user),'');
|
||||||
|
|
||||||
|
Auth::guard('admin')->loginUsingId($user->id);
|
||||||
|
// Auth::loginUsingId();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 3,
|
||||||
|
'rm' => 'success',
|
||||||
|
'role' => $user->role
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$event = 'Username atau Password salah, user :'.$request->input('username');
|
||||||
|
$this->auditTrailLog($event,"Invalid Login Log",'',json_encode($user),'');
|
||||||
|
// login failed
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'Username atau Password salah'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
74
app/Http/Controllers/Auth/RegisterController.php
Normal file
74
app/Http/Controllers/Auth/RegisterController.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'],
|
||||||
|
'username' => ['required', 'string', 'max:255', 'unique:bank_users'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:bank_users'],
|
||||||
|
'password' => ['required', 'string', 'min:6', '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'],
|
||||||
|
'username' => $data['username'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest');
|
||||||
|
}
|
||||||
|
}
|
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Email Verification Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling email verification for any
|
||||||
|
| user that recently registered with the application. Emails may also
|
||||||
|
| be re-sent if the user didn't receive the original email message.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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');
|
||||||
|
}
|
||||||
|
}
|
43
app/Http/Controllers/AuthController.php
Normal file
43
app/Http/Controllers/AuthController.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Interfaces\APIInterface;
|
||||||
|
use App\Interfaces\AuthApps;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
public function login(AuthApps $authApps){
|
||||||
|
if ($authApps->check()){
|
||||||
|
return redirect("/dashboard");
|
||||||
|
}
|
||||||
|
return view("login");
|
||||||
|
}
|
||||||
|
public function doLogin(Request $request, AuthApps $authApps, APIInterface $API){
|
||||||
|
|
||||||
|
$data["username"] = $request->get("username");
|
||||||
|
$data["password"] = $request->get("password");
|
||||||
|
// dd($data);
|
||||||
|
// dd($request->all());
|
||||||
|
$result = $API->post("auth/login" , $data);
|
||||||
|
// dd($result);
|
||||||
|
if ($result->rc == 200){
|
||||||
|
$authApps->add($result->data->token);
|
||||||
|
return redirect("/dashboard");
|
||||||
|
}else{
|
||||||
|
return redirect()->back()->withErrors(['errorLogin' => $result->rm]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function logoutEx(AuthApps $authApps){
|
||||||
|
$authApps->clear();
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
|
public function check(APIInterface $API){
|
||||||
|
// $API->doPost();
|
||||||
|
// $authApps->clear();
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
|
}
|
419
app/Http/Controllers/Controller.php
Normal file
419
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,419 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use Request as Req;
|
||||||
|
use App\Models\AuditTrailModel;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use DB;
|
||||||
|
use App\Models\CustomerModel;
|
||||||
|
use App\Models\NotifListModel;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Endroid\QrCode\QrCode;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
date_default_timezone_set('Asia/Jakarta');
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
|
||||||
|
public function bsGetView($view,$param)
|
||||||
|
{
|
||||||
|
// if (Auth::user()->role == 2){
|
||||||
|
// if($view == 'content.ref.index'){
|
||||||
|
// return view('errors.404');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
$isAllow = false;
|
||||||
|
$urlCheck = substr(\Request::getRequestUri(),1);
|
||||||
|
|
||||||
|
if (!Auth::user()) {
|
||||||
|
Auth::guard('admin')->logout();
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$check = \DB::select("SELECT m.* from menu m
|
||||||
|
join menu_privilege mp on mp.menu_uid = m.menu_uid
|
||||||
|
where mp.group_id = ?",[Auth::user()->role]);
|
||||||
|
|
||||||
|
foreach ($check as $key => $v) {
|
||||||
|
if($v->url == '/'.$urlCheck){
|
||||||
|
$isAllow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isAllow) {
|
||||||
|
if (Req::ajax()) {
|
||||||
|
return view('content.onlyContent')->nest('child', $view,$param);
|
||||||
|
}else {
|
||||||
|
return view('content.main')->nest('child', $view,$param);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public function convertDate($date)
|
||||||
|
{
|
||||||
|
return date('Y-m-d',strtotime($date));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cleanString($string) {
|
||||||
|
// $string = str_replace(' ', '', $string);
|
||||||
|
$string = str_replace('(', '', $string);
|
||||||
|
$string = str_replace(')', '', $string);
|
||||||
|
|
||||||
|
return preg_replace('/[^a-zA-Z0-9,()%@_ ]/', '', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkRoleAccessRef($type)
|
||||||
|
{
|
||||||
|
$isAllow = false;
|
||||||
|
|
||||||
|
$check = \DB::select("SELECT m.* from menu m join menu_privilege mp on mp.menu_uid = m.menu_uid where mp.group_id = ?",[Auth::user()->role]);
|
||||||
|
|
||||||
|
foreach ($check as $key => $v) {
|
||||||
|
$typeUrl = substr($v->url, strpos($v->url, "=") + 1);
|
||||||
|
if($typeUrl == $type){
|
||||||
|
$isAllow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $isAllow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkRoleAccess($type)
|
||||||
|
{
|
||||||
|
$isAllow = false;
|
||||||
|
|
||||||
|
$check = \DB::select("SELECT m.* from menu m join menu_privilege mp on mp.menu_uid = m.menu_uid where mp.group_id = ?",[Auth::user()->role]);
|
||||||
|
|
||||||
|
foreach ($check as $key => $v) {
|
||||||
|
$typeUrl = substr($v->url, strpos($v->url, "list/") + 5);
|
||||||
|
|
||||||
|
if($typeUrl == $type){
|
||||||
|
$isAllow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $isAllow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decryptId($request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($request->id) {
|
||||||
|
$decId = Crypt::decryptString($request->id);
|
||||||
|
|
||||||
|
$request->merge([
|
||||||
|
'id' => $decId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->get_id) {
|
||||||
|
$decId = Crypt::decryptString($request->get_id);
|
||||||
|
|
||||||
|
$request->merge([
|
||||||
|
'get_id' => $decId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->outlet_id) {
|
||||||
|
$decId = Crypt::decryptString($request->outlet_id);
|
||||||
|
|
||||||
|
$request->merge([
|
||||||
|
'outlet_id' => $decId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($request->get_mid_tax) {
|
||||||
|
$decId = Crypt::decryptString($request->get_mid_tax);
|
||||||
|
|
||||||
|
$request->merge([
|
||||||
|
'get_mid_tax' => $decId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ['rc' => 0, 'data'=> $request];
|
||||||
|
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
return ['rc' => 0, 'data'=> $request];
|
||||||
|
// return ['rc' => 999, 'data'=> 'Fak ╭∩╮(︶_︶)╭∩╮'];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function decryptIdOnly($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$decId = Crypt::decryptString($id);
|
||||||
|
return $decId;
|
||||||
|
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
return ['rc' => 999, 'data'=> 'Fak ╭∩╮(︶_︶)╭∩╮'];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hashPassword($password)
|
||||||
|
{
|
||||||
|
$iterations = 310000;
|
||||||
|
$salt = openssl_random_pseudo_bytes(16);
|
||||||
|
$hash_password = hash_pbkdf2('sha256', $password, $salt,$iterations,0, false);
|
||||||
|
$salt = bin2hex($salt);
|
||||||
|
|
||||||
|
return $salt.$hash_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hashPasswordCheck($passwordInput,$passwordUser)
|
||||||
|
{
|
||||||
|
$salt = substr($passwordUser,0,32);
|
||||||
|
$saltHex = hex2bin($salt);
|
||||||
|
|
||||||
|
$iterations = 310000;
|
||||||
|
$hash_password = hash_pbkdf2('sha256', $passwordInput, $saltHex,$iterations,0, false);
|
||||||
|
return $salt.$hash_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function convertDateYear($date)
|
||||||
|
{
|
||||||
|
return date('Y',strtotime($date));
|
||||||
|
}
|
||||||
|
public function convertDateMonth($date)
|
||||||
|
{
|
||||||
|
return date('m',strtotime($date));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function responseData($code, $message){
|
||||||
|
return ['code' => $code, 'message'=> $message];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNasabah($id)
|
||||||
|
{
|
||||||
|
return \DB::select("SELECT * FROM users where user_uid = ".$id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserAdmin($id)
|
||||||
|
{
|
||||||
|
return \DB::select("SELECT * FROM users_admin where id = ".$id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rupiah($nominal)
|
||||||
|
{
|
||||||
|
return "Rp ".number_format($nominal,0,",",".");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNotifDesc($status)
|
||||||
|
{
|
||||||
|
$data = DB::selectOne("select notif from notif_format where id = ?",[$status]);
|
||||||
|
return $data->notif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearSeparator($nominal)
|
||||||
|
{
|
||||||
|
if($nominal){
|
||||||
|
$nom = str_replace('.','',$nominal);
|
||||||
|
$nom = str_replace(',','.',$nom);
|
||||||
|
}else{
|
||||||
|
$nom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $nom;
|
||||||
|
|
||||||
|
|
||||||
|
// return str_replace('.','',$nominal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function numFormat($nominal)
|
||||||
|
{
|
||||||
|
return number_format($nominal,0,",",".");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendNotif($cust_id,$text,$type)
|
||||||
|
{
|
||||||
|
$data = new NotifListModel();
|
||||||
|
$data->cust_id = $cust_id;
|
||||||
|
$data->notif = $text;
|
||||||
|
$data->type = $type;
|
||||||
|
|
||||||
|
$data->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendMail($view,$data)
|
||||||
|
{
|
||||||
|
Mail::send($view, $data, function ($message) use ($data) {
|
||||||
|
$message->from('official@huit.co.id', 'HUIT SPORTWEAR');
|
||||||
|
$message->to($data['sendto']);
|
||||||
|
$message->subject($data['subject']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function auditTrail($event,$data)
|
||||||
|
{
|
||||||
|
$get = collect(\DB::select("SELECT max(id) as max_id FROM audits"))->first();
|
||||||
|
|
||||||
|
$d = new AuditTrailModel();
|
||||||
|
$d->id = $get->max_id+1;
|
||||||
|
$d->user_id = Auth::user()->id;
|
||||||
|
$d->event = Auth::user()->username."|".$event;
|
||||||
|
$d->auditable_type = $data;
|
||||||
|
$d->auditable_id = 0;
|
||||||
|
$d->created_at = Date('Y-m-d H:i:s');
|
||||||
|
$d->save();
|
||||||
|
Log::info($event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function auditTrailValue($event,$data,$table,$newvalue,$oldvalue)
|
||||||
|
{
|
||||||
|
$get = collect(\DB::select("SELECT max(id) as max_id FROM audits"))->first();
|
||||||
|
|
||||||
|
$d = new AuditTrailModel();
|
||||||
|
$d->id = $get->max_id+1;
|
||||||
|
$d->user_id = Auth::user()->id;
|
||||||
|
$d->event = Auth::user()->username."|".$event;
|
||||||
|
$d->auditable_type = $data;
|
||||||
|
$d->auditable_id = 0;
|
||||||
|
$d->created_at = Date('Y-m-d H:i:s');
|
||||||
|
$d->old_value = $oldvalue;
|
||||||
|
$d->new_value = $newvalue;
|
||||||
|
$d->table = $table;
|
||||||
|
$d->save();
|
||||||
|
Log::info($event."|".$newvalue."|".$oldvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function auditTrailLog($event,$data,$table,$newvalue,$oldvalue)
|
||||||
|
{
|
||||||
|
$get = collect(\DB::select("SELECT max(id) as max_id FROM audits"))->first();
|
||||||
|
|
||||||
|
$d = new AuditTrailModel();
|
||||||
|
$d->id = $get->max_id+1;
|
||||||
|
|
||||||
|
$d->event = $event;
|
||||||
|
$d->auditable_type = $data;
|
||||||
|
$d->auditable_id = 0;
|
||||||
|
$d->created_at = Date('Y-m-d H:i:s');
|
||||||
|
$d->old_value = $oldvalue;
|
||||||
|
$d->new_value = $newvalue;
|
||||||
|
$d->table = $table;
|
||||||
|
$d->save();
|
||||||
|
Log::info($event."|".$newvalue."|".$oldvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function DeleteWhere($table,$id,$condition)
|
||||||
|
{
|
||||||
|
DB::table($table)->where('votes', '>', 100)->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_data(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
// LOCAL get
|
||||||
|
if ($request->input('type') == 'local') {
|
||||||
|
|
||||||
|
|
||||||
|
$response = json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
// LOCAL POST WITH ID
|
||||||
|
elseif ($request->input('type') == 'local_id') {
|
||||||
|
|
||||||
|
|
||||||
|
$response = json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
//API
|
||||||
|
else{
|
||||||
|
$url = $request->input('url').$request->input('id');
|
||||||
|
$response = Http::withToken('eyJhbGciOiJIUzUxMiJ9.eyJhdXRob3JpdGllcyI6WyJST0xFX1dFQk1JTiJdLCJzdWIiOiJ3ZWJtaW4ifQ.IyFC9q18ehYtCUsOcLzHxnXbFog92DTCZxY2aR49NFElmIBFKBup2LC7Ld28m3mdDPYvI4UaUlsp1CbqwfMf0Q')
|
||||||
|
->get(env('API_BASE').$url)->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerencanaanByJobId($id)
|
||||||
|
{
|
||||||
|
$getPerencanaan = collect(\DB::select("SELECT map.*
|
||||||
|
from master_audit_plan map
|
||||||
|
join master_audit_job maj on maj.audit_plan_id = map.id
|
||||||
|
where maj.id = ?",[$id]))->first();
|
||||||
|
|
||||||
|
return $getPerencanaan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerencanaanByPlanId($id)
|
||||||
|
{
|
||||||
|
$getPerencanaan = collect(\DB::select("SELECT map.*
|
||||||
|
from master_audit_plan map where map.id = ?",[$id]))->first();
|
||||||
|
|
||||||
|
return $getPerencanaan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateQR($data)
|
||||||
|
{
|
||||||
|
$toko_name = Str::of($data->toko_nm)->slug('_');
|
||||||
|
$fileName = $data->toko_id. '_' . $toko_name . '_qrcode' . '.png';
|
||||||
|
|
||||||
|
|
||||||
|
$qrCode = new QrCode();
|
||||||
|
$pathImgFile = public_path('qrcode') . "/" . $fileName;
|
||||||
|
|
||||||
|
|
||||||
|
$d_json = [
|
||||||
|
'toko_id' => Crypt::encryptString($data->toko_id),
|
||||||
|
'toko_nm' => $data->toko_nm,
|
||||||
|
'mid' => $data->mid
|
||||||
|
];
|
||||||
|
|
||||||
|
// $dataQR = json_encode($d_json);
|
||||||
|
|
||||||
|
|
||||||
|
$enc_data = Crypt::encryptString($data->toko_id);
|
||||||
|
// $dec_data = Crypt::decryptString($enc_data);
|
||||||
|
|
||||||
|
$qrCode->setText($enc_data)
|
||||||
|
->setSize(600)
|
||||||
|
->setPadding(30)
|
||||||
|
->setErrorCorrection('high')
|
||||||
|
->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
|
||||||
|
->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
|
||||||
|
// Path to your logo with transparency
|
||||||
|
->setLogo(public_path('/img/') . "bank_ntt.png")
|
||||||
|
// Set the size of your logo, default is 48
|
||||||
|
->setLogoSize(150)
|
||||||
|
->setImageType(QrCode::IMAGE_TYPE_PNG);
|
||||||
|
$qrCode->save($pathImgFile);
|
||||||
|
|
||||||
|
return $fileName;
|
||||||
|
|
||||||
|
} // end function
|
||||||
|
|
||||||
|
|
||||||
|
}
|
23
app/Http/Controllers/FeedController.php
Normal file
23
app/Http/Controllers/FeedController.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App;
|
||||||
|
use App\Post;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class FeedController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function rssFeed(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
372
app/Http/Controllers/GlobalController.php
Normal file
372
app/Http/Controllers/GlobalController.php
Normal file
@ -0,0 +1,372 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Interfaces\APIInterface;
|
||||||
|
use App\Interfaces\AuthApps;
|
||||||
|
use App\Interfaces\AppUtility;
|
||||||
|
use App;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use PDF;
|
||||||
|
use Excel;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Auth;
|
||||||
|
use App\Exports\ExcelExport;
|
||||||
|
use App\Exports\ExcelExportCSV;
|
||||||
|
|
||||||
|
use App\Exports\IcsExport;
|
||||||
|
use Hash;
|
||||||
|
use DB;
|
||||||
|
use File;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\RequestOptions;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
use GuzzleHttp\Exception\ServerException;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
date_default_timezone_set('Asia/Jakarta');
|
||||||
|
|
||||||
|
class GlobalController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function export_any(Request $request, $typeExport,$id) {
|
||||||
|
|
||||||
|
switch ($id) {
|
||||||
|
|
||||||
|
case 'laporan_billing':
|
||||||
|
$view = 'export.'.$typeExport.'_billing';
|
||||||
|
$nameFile = 'billing-'.date('d-m-Y').'.'.$typeExport;
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
$dtable = DB::table("bill")
|
||||||
|
->join("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "bill.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("promo_voucher", function($join){
|
||||||
|
$join->on("promo_voucher.promo_voucher_id", "=", "bill.promo_voucher_id");
|
||||||
|
})
|
||||||
|
->join("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "bill.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("bill.*", "promo_voucher.promo_code", "reff_payment_status.payment_status_nm", "users.user_nm", "users.outlet_id", "merchant_nm")
|
||||||
|
->where("bill.crtdt", ">=", $startDate)
|
||||||
|
->where("bill.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$param['data'] = $dtable;
|
||||||
|
$param['view'] = $view;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'laporan_order':
|
||||||
|
$view = 'export.'.$typeExport.'_order';
|
||||||
|
$nameFile = 'order-'.date('d-m-Y').'.'.$typeExport;
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
$dtable = DB::table("orders")
|
||||||
|
->join("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "orders.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("outlet", function($join){
|
||||||
|
$join->on("outlet.outlet_id", "=", "orders.outlet_id");
|
||||||
|
})
|
||||||
|
->join("reff_order_type", function($join){
|
||||||
|
$join->on("reff_order_type.order_type_id", "=", "orders.order_type_id");
|
||||||
|
})
|
||||||
|
->join("reff_bill_type", function($join){
|
||||||
|
$join->on("reff_bill_type.bill_type_id", "=", "orders.bill_type_id");
|
||||||
|
})
|
||||||
|
->join("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "orders.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("orders.*", "reff_bill_type.*", "merchant_nm", "reff_payment_status.payment_status_nm", "users.user_nm", "orders.outlet_id", "reff_order_type.*")
|
||||||
|
->where("orders.crtdt", ">=", $startDate)
|
||||||
|
->where("orders.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
$param['data'] = $dtable;
|
||||||
|
$param['view'] = $view;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'laporan_transaction':
|
||||||
|
$view = 'export.'.$typeExport.'_transaction';
|
||||||
|
$nameFile = 'transaction-'.date('d-m-Y').'.'.$typeExport;
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = DB::table("payment")
|
||||||
|
->leftJoin("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "payment.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_payment_type", function($join){
|
||||||
|
$join->on("reff_payment_type.payment_type_id", "=", "payment.payment_type_id");
|
||||||
|
})
|
||||||
|
->leftJoin("customer", function($join){
|
||||||
|
$join->on("customer.customer_id", "=", "payment.customer_id");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "payment.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("payment.*", "reff_payment_type.*", "merchant_nm", "reff_payment_status.payment_status_nm", "users.user_nm", "payment.outlet_id", "customer.customer_nm")
|
||||||
|
->where("payment.crtdt", ">=", $startDate)
|
||||||
|
->where("payment.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$param['data'] = $dtable;
|
||||||
|
$param['view'] = $view;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'laporan_gross':
|
||||||
|
$view = 'export.'.$typeExport.'_gross';
|
||||||
|
$nameFile = 'gross-'.date('d-m-Y').'.'.$typeExport;
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = DB::table("payment")
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("payment.mid", "=", "merchant.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("outlet", function($join){
|
||||||
|
$join->on("outlet.outlet_id", "=", "payment.outlet_id");
|
||||||
|
})
|
||||||
|
->leftJoin("bill", function($join){
|
||||||
|
$join->on("bill.bill_id", "=", "payment.bill_id");
|
||||||
|
})
|
||||||
|
->leftJoin("orders_bill", function($join){
|
||||||
|
$join->on("orders_bill.bill_id", "=", "bill.bill_id");
|
||||||
|
})
|
||||||
|
->leftJoin("orders", function($join){
|
||||||
|
$join->on("orders.order_id", "=", "orders_bill.order_id");
|
||||||
|
})
|
||||||
|
->select("merchant.mid", "merchant.merchant_nm", "outlet.outlet_id", "outlet.outlet_nm",
|
||||||
|
DB::raw("payment.crtdt::date"), DB::raw("sum (payment.total_amount) as total_amount"),
|
||||||
|
DB::raw("sum (bill.tax_amount) as tax", "sum (bill.charge_amount) as charge"),
|
||||||
|
DB::raw("sum (bill.bill_amount) as gross_sales"),
|
||||||
|
DB::raw("sum (orders.total_amount_base) as cogs"),
|
||||||
|
DB::raw("sum (bill.bill_amount) - sum (distinct orders.total_amount_base) as gross_profit"),
|
||||||
|
DB::raw("count (payment.payment_id) as count_trx"),
|
||||||
|
DB::raw("count (orders.order_id) as count_order"))
|
||||||
|
->where("payment.payment_status_id", "=", 1)
|
||||||
|
->where("bill.crtdt", ">=", $startDate)
|
||||||
|
->where("bill.crtdt", "<=", $endDate)
|
||||||
|
->groupBy("merchant.mid","merchant.merchant_nm","outlet.outlet_id","outlet.outlet_nm",DB::raw("payment.crtdt::date"))
|
||||||
|
->orderByDesc(DB::raw("payment.crtdt::date"))
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('payment.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
$param['data'] = $dtable;
|
||||||
|
$param['view'] = $view;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'generate_qr_code' :
|
||||||
|
$path = public_path('qrcode');
|
||||||
|
File::cleanDirectory($path);
|
||||||
|
|
||||||
|
$view = 'export.'.$typeExport.'_qr_code';
|
||||||
|
$nameFile = 'toko-'.date('d-m-Y').'.'.$typeExport;
|
||||||
|
$customPaper = 'a4';
|
||||||
|
$paperType = 'potrait';
|
||||||
|
$param['data_toko'] = DB::table('toko')
|
||||||
|
->join('merchant','merchant.mid','toko.mid')
|
||||||
|
->where('toko_id',$request->toko_id)->first();
|
||||||
|
$param['data_qr'] = $this->generateQR($param['data_toko'], 0);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($typeExport == 'pdf') {
|
||||||
|
$pdf = PDF::loadView($view,$param)->setPaper($customPaper, $paperType);
|
||||||
|
$pdf->getDomPDF()->set_option("enable_php", true)->set_option("enable_javascript", true);
|
||||||
|
// if($request->get('setAct') == 'download'){
|
||||||
|
// return $pdf->download($nameFile);
|
||||||
|
// }else{
|
||||||
|
return $pdf->stream($nameFile);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
elseif ($typeExport == 'xlsx') {
|
||||||
|
return Excel::download(new ExcelExport($param), $nameFile);
|
||||||
|
}
|
||||||
|
elseif ($typeExport == 'csv') {
|
||||||
|
return Excel::download(new ExcelExportCSV($param), $nameFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function ref_any(Request $request,$type)
|
||||||
|
{
|
||||||
|
switch($type){
|
||||||
|
case 'mst_agency':
|
||||||
|
|
||||||
|
if ($request->input('role') == 4) {
|
||||||
|
$datas = \DB::select("SELECT * FROM mst_agency WHERE is_active = 't' and usertypeid = ? and id = 11",[$request->input('src_by')]);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$datas = \DB::select("SELECT * FROM mst_agency WHERE is_active = 't' and usertypeid = ?",[$request->input('src_by')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'merchant' :
|
||||||
|
$check = DB::table('users')->select('mid')->where('role_id','MERCHANT_OPR')->get()->toArray();
|
||||||
|
$temp = [];
|
||||||
|
|
||||||
|
foreach ($check as $key => $value) {
|
||||||
|
array_push($temp,"'".$value->mid."'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($request->input('src_by')){
|
||||||
|
$src = "'".$request->input('src_by')."'";
|
||||||
|
$temp = \array_diff($temp, [$src]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$arr_check = implode(",",$temp);
|
||||||
|
|
||||||
|
// if($temp){
|
||||||
|
// $datas = \DB::select("SELECT * FROM merchant WHERE mid not in (".$arr_check.")");
|
||||||
|
// }else{
|
||||||
|
$datas = \DB::select("SELECT * FROM merchant");
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'jenis_user':
|
||||||
|
if ($request->input('src_by') == 4) {
|
||||||
|
$datas = \DB::select("SELECT * FROM usertype WHERE id in (1,2)");
|
||||||
|
}else{
|
||||||
|
$datas = \DB::select("SELECT * FROM usertype WHERE is_active = 't'");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'tax' :
|
||||||
|
$datas = \DB::select("SELECT * from reff_tax");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'outlet' :
|
||||||
|
$datas = \DB::select("SELECT * from outlet m where mid = ?",[$request->input('src_by')]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'tipe_toko' :
|
||||||
|
$datas = \DB::select("SELECT * from merchant_toko_type m
|
||||||
|
join reff_toko_type rt on rt.ttid = m.ttid
|
||||||
|
where mid = ?",[$request->input('src_by')]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'edc' :
|
||||||
|
$datas = \DB::select("SELECT * from device m
|
||||||
|
where outlet_id is null and brand = ?",[$request->input('src_by')]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'type_user':
|
||||||
|
$merchant = DB::table('merchant')->where('mid',$request->input('src_by'))->first();
|
||||||
|
|
||||||
|
$arr_type = [];
|
||||||
|
if($merchant->is_park_active == true){
|
||||||
|
array_push($arr_type,'1');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($merchant->is_market_active == true){
|
||||||
|
array_push($arr_type,'2');
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = implode(",",$arr_type);
|
||||||
|
|
||||||
|
$datas = \DB::select("SELECT * from reff_user_type m where type in (".$type.")");
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => $datas
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
452
app/Http/Controllers/HomeController.php
Normal file
452
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,452 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Request as Req;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Session;
|
||||||
|
use DB;
|
||||||
|
use Response;
|
||||||
|
use Hash;
|
||||||
|
use Redirect;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// $this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application dashboard.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Support\Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$datas['title'] = 'Dashboard';
|
||||||
|
// $datas['ref_user'] = \DB::select("SELECT * FROM users WHERE user_status_id = 1");
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return $this->bsGetView('content.dashboard_pemda',$datas);
|
||||||
|
}else{
|
||||||
|
return $this->bsGetView('content.dashboard',$datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function home()
|
||||||
|
{
|
||||||
|
$datas['title'] = 'Dashboard';
|
||||||
|
// $datas['ref_user'] = \DB::select("SELECT * FROM users WHERE user_status_id = 1");
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return $this->bsGetView('content.dashboard_pemda',$datas);
|
||||||
|
}else{
|
||||||
|
return $this->bsGetView('content.dashboard',$datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function data(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$getDate = $this->convertDate($request->tanggal_filter);
|
||||||
|
$getDateYear = $this->convertDateYear($request->tanggal_filter);
|
||||||
|
$getDateMonth = $this->convertDateMonth($request->tanggal_filter);
|
||||||
|
|
||||||
|
$data['p_outlet'] = \DB::table('merchant')->count('mid');
|
||||||
|
|
||||||
|
$data['p_order'] = \DB::table('orders')->select('orders.*')
|
||||||
|
->join('users','users.user_id','orders.user_id')
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('users.mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
->count('order_id');
|
||||||
|
|
||||||
|
$data['p_transaction'] = \DB::table('payment')
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$data['p_product'] = \DB::table('product')
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
->count('product_id');
|
||||||
|
|
||||||
|
$data['stock_minimum'] = \DB::table('product_outlet')
|
||||||
|
->join('product','product.product_id','product_outlet.product_id')
|
||||||
|
->join('merchant','merchant.mid','product.mid')
|
||||||
|
->join('outlet','outlet.outlet_id','product_outlet.outlet_id')
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('product.mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
->orderBy('stock_qty')->limit('10')->get();
|
||||||
|
|
||||||
|
$data['best_product'] = DB::table("orders_product")
|
||||||
|
->join("product", function($join){
|
||||||
|
$join->on("product.product_id", "=", "orders_product.product_id");
|
||||||
|
})
|
||||||
|
->selectRaw("sum (qty) as jumlah,product_nm")
|
||||||
|
->limit(10)
|
||||||
|
->orderBy("jumlah","desc")
|
||||||
|
->groupBy("product_nm")
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('product.mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for ($bulan=1; $bulan <= 12; $bulan++) {
|
||||||
|
|
||||||
|
$grafik = \DB::table('payment')->whereMonth('crtdt','=',$bulan)
|
||||||
|
->whereYear('crtdt',$getDateYear)
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$temp_grafik[] = $grafik;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_grafik['Transaction'] = $temp_grafik;
|
||||||
|
$data['grafik'] = $data_grafik;
|
||||||
|
|
||||||
|
// GRAPH TIME
|
||||||
|
|
||||||
|
for ($time=1; $time <= 24; $time++) {
|
||||||
|
|
||||||
|
$grafik_time = \DB::table('payment')
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
// ->whereMonth('crtdt','=',date('m'))
|
||||||
|
// ->whereDay('crtdt', date('d'))
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
->whereRaw('EXTRACT(HOUR FROM crtdt) = ?',[$time])
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$temp_grafik_time[] = $grafik_time;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_grafik_time['Transaction'] = $temp_grafik_time;
|
||||||
|
$data['grafik_time'] = $data_grafik_time;
|
||||||
|
|
||||||
|
// GRAPH TIME
|
||||||
|
|
||||||
|
// GRAPH WEEK
|
||||||
|
|
||||||
|
for ($week=0; $week <= 6; $week++) {
|
||||||
|
|
||||||
|
$grafik_week = \DB::table('payment')
|
||||||
|
->whereYear('crtdt',$getDateYear)
|
||||||
|
->whereMonth('crtdt','=',$getDateMonth)
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
// ->whereMonth('crtdt','=',date('m'))
|
||||||
|
->whereRaw('EXTRACT(dow FROM crtdt) = ?',[$week])
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$temp_grafik_week[] = $grafik_week;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_grafik_week['Transaction'] = $temp_grafik_week;
|
||||||
|
$data['grafik_week'] = $data_grafik_week;
|
||||||
|
|
||||||
|
// GRAPH WEEK
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant_filter != null) {
|
||||||
|
if ($request->merchant_filter == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$checkMid = DB::table('merchant')->where('mid',$request->merchant_filter)->count();
|
||||||
|
|
||||||
|
if ($checkMid > 0) {
|
||||||
|
$filterMerchant = " and p.mid = '".$request->merchant_filter."' ";
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and p.mid = '$' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
m.mid ,
|
||||||
|
m.merchant_nm ,
|
||||||
|
o.outlet_id ,
|
||||||
|
o.outlet_nm ,
|
||||||
|
p.crtdt::date,
|
||||||
|
sum(distinct p.total_amount) as total_amount,
|
||||||
|
sum(distinct b.tax_amount) as tax,
|
||||||
|
sum(distinct b.charge_amount) as charge ,
|
||||||
|
sum(distinct b.bill_amount) as gross_sales,
|
||||||
|
sum(omd.base_price * omd.qty) + sum(op.base_price * op.qty) as cogs,
|
||||||
|
sum(distinct b.bill_amount) - (sum(omd.base_price * omd.qty) + sum(op.base_price * op.qty)) as gross_profit,
|
||||||
|
count(distinct p.payment_id) as count_trx,
|
||||||
|
count(distinct op.order_id) as count_order
|
||||||
|
from
|
||||||
|
payment p
|
||||||
|
left join merchant m on
|
||||||
|
p.mid = m.mid
|
||||||
|
left join outlet o on
|
||||||
|
o.outlet_id = p.outlet_id
|
||||||
|
left join bill b on
|
||||||
|
b.bill_id = p.bill_id
|
||||||
|
left join bill_orders_product bop on
|
||||||
|
bop.bill_id = b.bill_id
|
||||||
|
left join orders_product op on
|
||||||
|
bop.order_product_id = op.order_product_id
|
||||||
|
left join orders_modifier_detail omd on
|
||||||
|
op.order_product_id = omd.order_product_id
|
||||||
|
where p.payment_status_id = 1 ".$filterMerchant."
|
||||||
|
group by
|
||||||
|
m.mid ,
|
||||||
|
m.merchant_nm ,
|
||||||
|
o.outlet_id ,
|
||||||
|
o.outlet_nm ,
|
||||||
|
p.crtdt::date
|
||||||
|
");
|
||||||
|
|
||||||
|
$total_sales = 0;
|
||||||
|
$total_tax = 0;
|
||||||
|
$total_trx = 0;
|
||||||
|
|
||||||
|
foreach ($dtable as $v) {
|
||||||
|
$total_sales += $v->gross_sales;
|
||||||
|
$total_tax += $v->tax;
|
||||||
|
$total_trx += $v->count_trx;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['p_omzet'] = $total_sales;
|
||||||
|
|
||||||
|
$data['p_tax'] = $total_tax;
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data'=> $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function data_pemda(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$getDate = $this->convertDate($request->tanggal_filter);
|
||||||
|
$getDateYear = $this->convertDateYear($request->tanggal_filter);
|
||||||
|
$getDateMonth = $this->convertDateMonth($request->tanggal_filter);
|
||||||
|
|
||||||
|
$data['p_outlet'] = \DB::table('merchant')->count('mid');
|
||||||
|
|
||||||
|
$data['p_order'] = \DB::table('orders')->select('orders.*')
|
||||||
|
->join('users','users.user_id','orders.user_id')
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('users.mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
->when(request('outlet_filter') != 'all', function ($query) {
|
||||||
|
$query->where('orders.outlet_id', request('outlet_filter'));
|
||||||
|
})
|
||||||
|
->count('order_id');
|
||||||
|
|
||||||
|
$data['p_transaction'] = \DB::table('payment')
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
->when(request('outlet_filter') != 'all', function ($query) {
|
||||||
|
$query->where('payment.outlet_id', request('outlet_filter'));
|
||||||
|
})
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$data['p_product'] = \DB::table('product')
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('product.mid', request('merchant_filter'));
|
||||||
|
})
|
||||||
|
// ->when(request('outlet_filter') != 'all', function ($query) {
|
||||||
|
// $query->where('users.outlet_id', request('outlet_filter'));
|
||||||
|
// })
|
||||||
|
->count('product_id');
|
||||||
|
|
||||||
|
|
||||||
|
for ($bulan=1; $bulan <= 12; $bulan++) {
|
||||||
|
|
||||||
|
$grafik = \DB::table('payment')->whereMonth('crtdt','=',$bulan)
|
||||||
|
->whereYear('crtdt',$getDateYear)
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$temp_grafik[] = $grafik;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_grafik['Transaction'] = $temp_grafik;
|
||||||
|
$data['grafik'] = $data_grafik;
|
||||||
|
|
||||||
|
// GRAPH TIME
|
||||||
|
|
||||||
|
for ($time=1; $time <= 24; $time++) {
|
||||||
|
|
||||||
|
$grafik_time = \DB::table('payment')
|
||||||
|
// ->whereYear('crtdt',$request->tahun)
|
||||||
|
// ->whereMonth('crtdt','=',date('m'))
|
||||||
|
// ->whereDay('crtdt', date('d'))
|
||||||
|
->whereDate('crtdt',$getDate)
|
||||||
|
->whereRaw('EXTRACT(HOUR FROM crtdt) = ?',[$time])
|
||||||
|
|
||||||
|
->when(request('merchant_filter') != 'all', function ($query) {
|
||||||
|
$query->where('mid', request('merchant_filter'));
|
||||||
|
})->count('payment_id');
|
||||||
|
|
||||||
|
$temp_grafik_time[] = $grafik_time;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_grafik_time['Transaction'] = $temp_grafik_time;
|
||||||
|
$data['grafik_time'] = $data_grafik_time;
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant_filter != null) {
|
||||||
|
if ($request->merchant_filter == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$checkMid = DB::table('merchant')->where('mid',$request->merchant_filter)->count();
|
||||||
|
|
||||||
|
if ($checkMid > 0) {
|
||||||
|
$filterMerchant = " and p.mid = '".$request->merchant_filter."' ";
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and p.mid = '$' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filterOutlet = '';
|
||||||
|
|
||||||
|
if ($request->outlet_filter != null) {
|
||||||
|
if ($request->outlet_filter == 'all') {
|
||||||
|
$filterOutlet = '';
|
||||||
|
}else{
|
||||||
|
$checkOutlet = DB::table('outlet')->where('outlet_id',$request->outlet_filter)->count();
|
||||||
|
|
||||||
|
if ($checkOutlet > 0) {
|
||||||
|
$filterOutlet = " and o.outlet_id = '".$request->outlet_filter."' ";
|
||||||
|
}else{
|
||||||
|
$filterOutlet = " and o.outlet_id = '$' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
m.mid ,
|
||||||
|
m.merchant_nm ,
|
||||||
|
o.outlet_id ,
|
||||||
|
o.outlet_nm ,
|
||||||
|
p.crtdt::date,
|
||||||
|
sum(distinct p.total_amount) as total_amount,
|
||||||
|
sum(distinct b.tax_amount) as tax,
|
||||||
|
sum(distinct b.charge_amount) as charge ,
|
||||||
|
sum(distinct b.bill_amount) as gross_sales,
|
||||||
|
sum(omd.base_price * omd.qty) + sum(op.base_price * op.qty) as cogs,
|
||||||
|
sum(distinct b.bill_amount) - (sum(omd.base_price * omd.qty) + sum(op.base_price * op.qty)) as gross_profit,
|
||||||
|
count(distinct p.payment_id) as count_trx,
|
||||||
|
count(distinct op.order_id) as count_order
|
||||||
|
from
|
||||||
|
payment p
|
||||||
|
left join merchant m on
|
||||||
|
p.mid = m.mid
|
||||||
|
left join outlet o on
|
||||||
|
o.outlet_id = p.outlet_id
|
||||||
|
left join bill b on
|
||||||
|
b.bill_id = p.bill_id
|
||||||
|
left join bill_orders_product bop on
|
||||||
|
bop.bill_id = b.bill_id
|
||||||
|
left join orders_product op on
|
||||||
|
bop.order_product_id = op.order_product_id
|
||||||
|
left join orders_modifier_detail omd on
|
||||||
|
op.order_product_id = omd.order_product_id
|
||||||
|
where p.payment_status_id = 1 ".$filterMerchant.$filterOutlet."
|
||||||
|
group by
|
||||||
|
m.mid ,
|
||||||
|
m.merchant_nm ,
|
||||||
|
o.outlet_id ,
|
||||||
|
o.outlet_nm ,
|
||||||
|
p.crtdt::date
|
||||||
|
");
|
||||||
|
|
||||||
|
$total_sales = 0;
|
||||||
|
$total_tax = 0;
|
||||||
|
$total_trx = 0;
|
||||||
|
|
||||||
|
foreach ($dtable as $v) {
|
||||||
|
$total_sales += $v->gross_sales;
|
||||||
|
$total_tax += $v->tax;
|
||||||
|
$total_trx += $v->count_trx;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['p_omzet'] = $total_sales;
|
||||||
|
|
||||||
|
$data['p_tax'] = $total_tax;
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data'=> $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function set_session_theme(Request $request)
|
||||||
|
{
|
||||||
|
Session::put('theme', $request->input('theme'));
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 1,
|
||||||
|
'rm' => $request->input('theme')
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_bahasa(Request $request)
|
||||||
|
{
|
||||||
|
App::setLocale('en');
|
||||||
|
Session::put('bahasa', $request->input('bahasa'));
|
||||||
|
return Redirect::back();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
151
app/Http/Controllers/ManagementContentController.php
Normal file
151
app/Http/Controllers/ManagementContentController.php
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\AuditTrailModel;
|
||||||
|
use Response;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Request as Req;
|
||||||
|
use App\Models\Audit\TemplateKKAModel;
|
||||||
|
use App\Models\Audit\AuditFindingModel;
|
||||||
|
use App\Models\Audit\HistoryPemilikModel;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
use Str;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Exports\IcsExport;
|
||||||
|
use App\Models\HomeModel;
|
||||||
|
|
||||||
|
|
||||||
|
date_default_timezone_set('Asia/Jakarta');
|
||||||
|
|
||||||
|
class ManagementContentController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function list(Request $request, $type)
|
||||||
|
{
|
||||||
|
$checkRole = $this->checkRoleAccess($type);
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'audit_trail':
|
||||||
|
$view = 'content.management_content.audit_trail.index';
|
||||||
|
$dataPage['title'] = 'List Audit Trail';
|
||||||
|
$dataPage['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Role User","all","role_name"],
|
||||||
|
["Username","all","name"],
|
||||||
|
["Event","all","event"],
|
||||||
|
["Data","all","auditable_type"],
|
||||||
|
["Tanggal","all","created_at"]
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'home':
|
||||||
|
$view = 'content.management_content.home.index';
|
||||||
|
$dataPage['title'] = 'Master Home';
|
||||||
|
// $dataPage['mst_home'] = \DB::select("SELECT * from mst_home");
|
||||||
|
// $dataPage['ref_katalog'] = \DB::select("SELECT * FROM ref_catalog WHERE is_active = 't'");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type != 'home') {
|
||||||
|
foreach($dataPage['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$dataPage['head'] = implode(",",$arrHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dataPage['type'] = $type;
|
||||||
|
// $dataPage['tahun'] = \DB::select("SELECT distinct on (periode_year) periode_year from master_audit_plan order by periode_year desc");
|
||||||
|
$dataPage['ref_user'] = \DB::select("SELECT * from users_admin where status_user = 't' and role = 2 order by id desc");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$dataPage['table'] = route('management_content.data_table',$type);
|
||||||
|
|
||||||
|
return $this->bsGetView($view,$dataPage);
|
||||||
|
}
|
||||||
|
public function data_table(Request $request, $type)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccess($type);
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'audit_trail':
|
||||||
|
$data = \DB::select("SELECT audits.id,rru.description as role_name, bu.username as name,bu.email,audits.event,audits.auditable_type,audits.created_at
|
||||||
|
FROM audits
|
||||||
|
left join users_admin bu on bu.id = audits.user_id
|
||||||
|
left join groups_admin rru on rru.id = bu.role
|
||||||
|
order by audits.created_at desc");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTables::of($data)
|
||||||
|
->editColumn('created_at',function($data) use ($type) {
|
||||||
|
if($type == 'audit_trail'){
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->created_at));
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
->addColumn('action', function ($data) use ($type) {
|
||||||
|
$btn = '';
|
||||||
|
|
||||||
|
return '
|
||||||
|
<div class="dropdown dropdown-inline">
|
||||||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">
|
||||||
|
<span class="svg-icon svg-icon-md">
|
||||||
|
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
||||||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<rect x="0" y="0" width="24" height="24"/>
|
||||||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
|
||||||
|
<ul class="navi flex-column navi-hover py-2">
|
||||||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">
|
||||||
|
Choose an action:
|
||||||
|
</li>
|
||||||
|
'.$btn.'
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
})
|
||||||
|
->rawColumns(['group_kka','status', 'action'])
|
||||||
|
->make(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_any(Request $request, $type)
|
||||||
|
{
|
||||||
|
$checkRole = $this->checkRoleAccess($type);
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
// HOME
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
175
app/Http/Controllers/MenuController.php
Normal file
175
app/Http/Controllers/MenuController.php
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\MenuModel;
|
||||||
|
use Response;
|
||||||
|
use Auth, Session;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Request as Req;
|
||||||
|
use DB;
|
||||||
|
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
|
||||||
|
class MenuController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function admin_index($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::guard('admin')->user()->role != 1) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == 'admin') {
|
||||||
|
$datas['title'] = 'Menu Management';
|
||||||
|
$datas['getMenu'] = \DB::select("SELECT * from menu order by seq");
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas['table'] = route('data.menu',$id);
|
||||||
|
$datas['admin_menu_get'] = route('menu.menu_get',$id);
|
||||||
|
$datas['admin_menu_store'] = route('menu.store',$id);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->bsGetView('content.menu_admin.index',$datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function admin_data($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::guard('admin')->user()->role != 1) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == 'admin') {
|
||||||
|
$data = \DB::select("SELECT *,id as list_menu FROM groups_admin order by id desc");
|
||||||
|
}else{
|
||||||
|
$data = \DB::select("SELECT user_type_name as description,user_type_uid as list_menu FROM reff_user_type order by user_type_uid desc");
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTables::of($data)
|
||||||
|
->addColumn('action', function ($data) {
|
||||||
|
|
||||||
|
return '
|
||||||
|
<div class="dropdown dropdown-inline">
|
||||||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">
|
||||||
|
<span class="svg-icon svg-icon-md">
|
||||||
|
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
||||||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<rect x="0" y="0" width="24" height="24"/>
|
||||||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
|
||||||
|
<ul class="navi flex-column navi-hover py-2">
|
||||||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">
|
||||||
|
Choose an action:
|
||||||
|
</li>
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="modalMenu('.$data->list_menu.',`'.$data->description.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-list-ul"></i></span>
|
||||||
|
<span class="navi-text">Akses Menu</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
})
|
||||||
|
->editColumn('list_menu',function($data) use($id) {
|
||||||
|
|
||||||
|
if ($id == 'admin') {
|
||||||
|
$getMenu = \DB::select("SELECT * from menu_privilege rrm
|
||||||
|
join menu rm on rm.menu_uid = rrm.menu_uid
|
||||||
|
where group_id = ? and has_children = 't' order by rm.menu_uid",[$data->list_menu]);
|
||||||
|
|
||||||
|
$menu_list = '';
|
||||||
|
foreach ($getMenu as $key => $v) {
|
||||||
|
$menu_list .= '<span class="label label-lg label-success label-inline mr-2 mb-2">'.$v->menu.'</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$getMenu = \DB::select("SELECT * from privilege rrm
|
||||||
|
join menu_cms rm on rm.menu_cms_uid = rrm.menu_cms_uid
|
||||||
|
where user_type_uid = ? and has_children = 't' order by rm.menu_cms_uid",[$data->list_menu]);
|
||||||
|
|
||||||
|
$menu_list = '';
|
||||||
|
foreach ($getMenu as $key => $v) {
|
||||||
|
$menu_list .= '<span class="label label-lg label-success label-inline mr-2 mb-2">'.$v->menu_cms.'</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $menu_list;
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
->rawColumns(['list_menu','action'])
|
||||||
|
->make(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function admin_menu_get(Request $request,$id)
|
||||||
|
{
|
||||||
|
if (Auth::guard('admin')->user()->role != 1) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == 'admin') {
|
||||||
|
$data = \DB::select("SELECT * FROM menu_privilege where group_id = ?",[$request->post('id')]);
|
||||||
|
}else{
|
||||||
|
$data = \DB::select("SELECT *,menu_cms_uid as menu_uid FROM privilege where user_type_uid = ?",[$request->post('id')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function admin_store(Request $request,$id)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Auth::guard('admin')->user()->role != 1) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == 'admin') {
|
||||||
|
DB::table('menu_privilege')->where('group_id', $request->post('get_id'))->delete();
|
||||||
|
$menu_id = $request->post('menu_id');
|
||||||
|
if ($menu_id) {
|
||||||
|
foreach ($menu_id as $key => $v) {
|
||||||
|
// $seq = DB::table('menu_privilege')->max('id');
|
||||||
|
|
||||||
|
DB::table('menu_privilege')->insert([
|
||||||
|
// 'id' => $seq+1,
|
||||||
|
'group_id' => $request->post('get_id'),
|
||||||
|
'menu_uid' => $v
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
DB::table('privilege')->where('user_type_uid', $request->post('get_id'))->delete();
|
||||||
|
$menu_id = $request->post('menu_id');
|
||||||
|
if ($menu_id) {
|
||||||
|
foreach ($menu_id as $key => $v) {
|
||||||
|
// $seq = DB::table('menu_privilege')->max('id');
|
||||||
|
|
||||||
|
DB::table('privilege')->insert([
|
||||||
|
// 'id' => $seq+1,
|
||||||
|
'user_type_uid' => $request->post('get_id'),
|
||||||
|
'menu_cms_uid' => $v
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "Berhasil"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
609
app/Http/Controllers/RefController.php
Normal file
609
app/Http/Controllers/RefController.php
Normal file
@ -0,0 +1,609 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use DB;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use App\Imports\DeviceImport;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
|
||||||
|
date_default_timezone_set('Asia/Jakarta');
|
||||||
|
|
||||||
|
class RefController extends Controller
|
||||||
|
{
|
||||||
|
// LIST BUTTON
|
||||||
|
// edit,active,setting_menu
|
||||||
|
|
||||||
|
public function getInit($request,$route)
|
||||||
|
{
|
||||||
|
$modelName = '\\App\Models\\'.$route.'Model';
|
||||||
|
$model = new $modelName;
|
||||||
|
$data = $model->initData($request,$route);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
//INIT
|
||||||
|
$init = $this->getInit($request,$request->get('type'));
|
||||||
|
$route = $init['route'];
|
||||||
|
$param['title'] = $init['title'];
|
||||||
|
$param['tableHead'] = $init['tableHead'];
|
||||||
|
$param['head'] = $init['head'];
|
||||||
|
|
||||||
|
$view = 'content.ref.index';
|
||||||
|
|
||||||
|
//END INIT
|
||||||
|
|
||||||
|
$param['table'] = route('ref.data')."?type=".$route;
|
||||||
|
$param['edit'] = route('ref.edit')."?type=".$route;
|
||||||
|
$param['store'] = route('ref.store')."?type=".$route;
|
||||||
|
$param['storeCustom'] = route('ref.storeCustom')."?type=".$route;
|
||||||
|
$param['setActive'] = route('ref.setActive')."?type=".$route;
|
||||||
|
$param['delete'] = route('ref.hapus')."?type=".$route;
|
||||||
|
$param['import_xls'] = route('ref.import.xls')."?type=".$route;
|
||||||
|
|
||||||
|
$param['vForm'] = 'content.ref.'.$route.'.form';
|
||||||
|
$param['vAction'] = 'content.ref.'.$route.'.action';
|
||||||
|
$param['init'] = $init;
|
||||||
|
|
||||||
|
//REF
|
||||||
|
$param['ref_role'] = \DB::select("SELECT * FROM groups_admin WHERE is_active = 't'");
|
||||||
|
|
||||||
|
return $this->bsGetView($view,$param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function data(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$init = $this->getInit($request,$request->get('type'));
|
||||||
|
$type = $request->get('type');
|
||||||
|
$data = $init['data_table'];
|
||||||
|
|
||||||
|
$modelName = '\\App\Models\\'.$init['route'].'Model';
|
||||||
|
$model = new $modelName;
|
||||||
|
$dt = $model->getDT($data,$init);
|
||||||
|
|
||||||
|
$dt->addColumn('action', function ($data) use($init,$type) {
|
||||||
|
// $param['id_key'] = $data->{$init['db_key']};
|
||||||
|
$param['id_key'] = Crypt::encryptString($data->{$init['db_key']});
|
||||||
|
$param['data'] = $data;
|
||||||
|
$param['type'] = $type;
|
||||||
|
//SET BUTTON
|
||||||
|
return $this->getButtonAction($init['actButton'],$param);
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->rawColumns(['logo','user_status_id','is_hotel','is_resto','is_mini_atm_active','tax_list','sn_list','is_sale_active','tsid','action','is_active','is_park_active','is_market_active','product_nominal']);
|
||||||
|
return $dt->make(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
//GET INIT
|
||||||
|
$init = $this->getInit($request,$request->get('type'));
|
||||||
|
$get_id = $request->input('get_id');
|
||||||
|
$setField = $init['set_field'];
|
||||||
|
|
||||||
|
if ($get_id) {
|
||||||
|
$get_id = $this->decryptIdOnly($get_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SPECIAL CONDITION
|
||||||
|
$check = $this->specialCondition($init['db'],$setField,$get_id);
|
||||||
|
if ($check['rc'] == 99) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $check['rm']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//IF EDIT DATA
|
||||||
|
if ($get_id) {
|
||||||
|
if (isset($init['timestamps'])) {
|
||||||
|
$setField['updated_at'] = date('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
$oldData = DB::table($init['db'])->where($init['db_key'], $get_id)->first();
|
||||||
|
DB::table($init['db'])->where($init['db_key'], $get_id)->update($setField);
|
||||||
|
$event = "Edit Data ".$request->get('type');
|
||||||
|
$this->auditTrailValue($event,"Referensi",$init['db'],json_encode($setField),json_encode($oldData));
|
||||||
|
|
||||||
|
//IF ADD DATA
|
||||||
|
}else {
|
||||||
|
|
||||||
|
if (isset($init['timestamps'])) {
|
||||||
|
$setField['created_at'] = date('Y-m-d H:i:s');
|
||||||
|
$setField['updated_at'] = date('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
$seq = DB::table($init['db'])->max($init['db_key']);
|
||||||
|
$setField[$init['db_key']] = $seq+1;
|
||||||
|
DB::table($init['db'])->insert($setField);
|
||||||
|
|
||||||
|
$event = "Tambah Data ".$request->get('type');
|
||||||
|
$this->auditTrailValue($event,"Referensi",$init['db'],json_encode($setField),'');
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// // 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryt = $this->decryptId($request);
|
||||||
|
|
||||||
|
|
||||||
|
if ($decryt['rc'] == 0) {
|
||||||
|
$init = $this->getInit($decryt['data'],$request->get('type'));
|
||||||
|
$modelName = '\\App\Models\\'.$init['route'].'Model';
|
||||||
|
$model = new $modelName;
|
||||||
|
return $model->storeCustom($request->get('act'),$decryt['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function edit(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryt = $this->decryptId($request);
|
||||||
|
|
||||||
|
if ($decryt['rc'] == 0) {
|
||||||
|
$init = $this->getInit($decryt['data'],$request->get('type'));
|
||||||
|
|
||||||
|
$getData = $init['get_data_edit'];
|
||||||
|
|
||||||
|
if($request->get('type') == 'merchant'){
|
||||||
|
$getData['merchant']->get_id = Crypt::encryptString($getData['merchant']->mid);
|
||||||
|
}
|
||||||
|
else if($request->get('type') == 'toko'){
|
||||||
|
$getData['outlet']->outlet_id = Crypt::encryptString($getData['outlet']->outlet_id);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$getData->{$init['db_key']} = Crypt::encryptString($getData->{$init['db_key']});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'data' => $getData
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hapus(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryt = $this->decryptId($request);
|
||||||
|
|
||||||
|
if ($decryt['rc'] == 0) {
|
||||||
|
$init = $this->getInit($decryt['data'],$request->get('type'));
|
||||||
|
DB::table($init['db'])->where($init['db_key'], $decryt['data']->id)->delete();
|
||||||
|
|
||||||
|
$event = "Hapus Data ".$request->get('type');
|
||||||
|
|
||||||
|
$this->auditTrailValue($event,"Data",$init['db'],$decryt['data']->id,'');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "Berhasil"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function SetActive(Request $request)
|
||||||
|
{
|
||||||
|
//GET INIT
|
||||||
|
$checkRole = $this->checkRoleAccessRef($request->get('type'));
|
||||||
|
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$decryt = $this->decryptId($request);
|
||||||
|
|
||||||
|
if ($decryt['rc'] == 0) {
|
||||||
|
$init = $this->getInit($decryt['data'],$request->get('type'));
|
||||||
|
|
||||||
|
$id = $request->input('id');
|
||||||
|
$isActive = $request->input('active');
|
||||||
|
|
||||||
|
if ($isActive == true) {
|
||||||
|
DB::table($init['db'])->where($init['db_key'], $decryt['data']->id)->update([
|
||||||
|
'is_active' => false,
|
||||||
|
]);
|
||||||
|
$reqMessage = 'berhasil dinonaktifkan';
|
||||||
|
|
||||||
|
$event = $request->get('type')." ".$reqMessage;
|
||||||
|
// $this->auditTrail($event,"Referensi");
|
||||||
|
$this->auditTrailValue($event,"Aktifasi",$init['db'],$decryt['data']->id,'');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if ($init['db'] == 'mst_wscreen') {
|
||||||
|
DB::table('mst_wscreen')->update(['is_active' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table($init['db'])->where($init['db_key'], $decryt['data']->id)->update([
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
$reqMessage = 'berhasil diaktifkan';
|
||||||
|
$event = $request->get('type')." ".$reqMessage;
|
||||||
|
// $this->auditTrail($event,"Referensi");
|
||||||
|
$this->auditTrailValue($event,"Aktifasi",$init['db'],$decryt['data']->id,'');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => $reqMessage
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function importXls(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($request->hasFile('xls_file')){
|
||||||
|
|
||||||
|
$import = new DeviceImport;
|
||||||
|
Excel::import($import, $request->file('xls_file'));
|
||||||
|
|
||||||
|
if ($import->validate) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Data Tidak Sesuai',
|
||||||
|
'msg'=> $import->validate
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'berhasil',
|
||||||
|
'msg' => 'berhasil'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getButtonAction($typeButton,$param)
|
||||||
|
{
|
||||||
|
$editBtn ="";
|
||||||
|
$detailBtn ="";
|
||||||
|
$ActiveBtn = "";
|
||||||
|
$deleteBtn = "";
|
||||||
|
|
||||||
|
// DETAIL BUTTON
|
||||||
|
if ( in_array("detail", $typeButton)) {
|
||||||
|
$detailBtn = '<li class="navi-item">
|
||||||
|
<a onclick="detail(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-arrows-alt"></i></span>
|
||||||
|
<span class="navi-text"> Detail</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// EDIT BUTTON
|
||||||
|
if (in_array("edit", $typeButton)) {
|
||||||
|
|
||||||
|
$editBtn = ' <li class="navi-item">
|
||||||
|
<a onclick="edit(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-edit"></i></span>
|
||||||
|
<span class="navi-text"> Edit</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ACTIVE BUTTON
|
||||||
|
if (in_array("active", $typeButton)) {
|
||||||
|
if ($param['data']->is_active == 't') {
|
||||||
|
$ActiveBtn = '
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="setActive(`'.$param['id_key'].'`,`'.$param['data']->is_active.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-times-circle-o"></i> </span>
|
||||||
|
<span class="navi-text">Deactived</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}else{
|
||||||
|
$ActiveBtn = '
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="setActive(`'.$param['id_key'].'`,`'.$param['data']->is_active.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-check-circle-o"></i> </span>
|
||||||
|
<span class="navi-text">Active</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE BUTTON
|
||||||
|
if ( in_array("delete", $typeButton)) {
|
||||||
|
$deleteBtn = '<li class="navi-item">
|
||||||
|
<a onclick="hapus(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-trash"></i></span>
|
||||||
|
<span class="navi-text"> Hapus</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$etcButton = '';
|
||||||
|
|
||||||
|
// CONDITION BUTTON
|
||||||
|
|
||||||
|
// if ($param['type'] == 'merchant') {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
if ($param['type'] == 'statustrx') {
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="detail(`'.$param['data']->id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-list"></i></span>
|
||||||
|
<span class="navi-text">Detail</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($param['type'] == 'useredc') {
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="resetPassword(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-key"></i></span>
|
||||||
|
<span class="navi-text">Reset Password</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
if (Auth::guard('admin')->user()->role == 1) {
|
||||||
|
if ($param['data']->user_status_id == 3) {
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="aktifUser(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-check-circle"></i> </span>
|
||||||
|
<span class="navi-text">Aktifkan User</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}else{
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="blockUser(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-ban"></i> </span>
|
||||||
|
<span class="navi-text">Block User</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($param['type'] == 'rekaptrx') {
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="detail(`'.$param['data']->jenis_transaksi.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-list"></i></span>
|
||||||
|
<span class="navi-text">Detail</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($param['type'] == 'merchant') {
|
||||||
|
|
||||||
|
$etcButton = '
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="tax(`'.$param['id_key'].'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-list"></i> </span>
|
||||||
|
<span class="navi-text">List Tax</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($param['type'] == 'toko') {
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="confirm(`'.$param['data']->outlet_id.'`,`'.$param['data']->outlet_nm.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-qrcode"></i></span>
|
||||||
|
<span class="navi-text">Confirm Outlet</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
|
||||||
|
$etcButton .= '<li class="navi-item">
|
||||||
|
<a onclick="edc(`'.$param['id_key'].'`,`'.$param['data']->outlet_nm.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-list"></i></span>
|
||||||
|
<span class="navi-text">Link EDC</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONDITION BUTTON
|
||||||
|
|
||||||
|
|
||||||
|
$resultBtn = $etcButton.$editBtn.$ActiveBtn.$detailBtn.$deleteBtn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return '
|
||||||
|
<div class="dropdown dropdown-inline">
|
||||||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">
|
||||||
|
<span class="svg-icon svg-icon-md">
|
||||||
|
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
||||||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<rect x="0" y="0" width="24" height="24"/>
|
||||||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
|
||||||
|
<ul class="navi flex-column navi-hover py-2">
|
||||||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">
|
||||||
|
Choose an action:
|
||||||
|
</li>
|
||||||
|
'.$resultBtn.'
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function specialCondition($db,$setField,$get_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
//IF EDIT DATA
|
||||||
|
if ($get_id) {
|
||||||
|
if ($db == 'device') {
|
||||||
|
|
||||||
|
$data = DB::table('device')->where('device_id',$get_id)->first();
|
||||||
|
|
||||||
|
$validText = '';
|
||||||
|
|
||||||
|
if ($setField['sn'] == $data->sn) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$CheckSN = DB::table('device')->where('sn',$setField['sn'])->count();
|
||||||
|
$validSN = ($CheckSN > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validSN == false) {
|
||||||
|
$validText .= '<li>Serial Number Telah Digunakan.</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($setField['imei'] == $data->imei) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$CheckIMEI = DB::table('device')->where('imei',$setField['imei'])->count();
|
||||||
|
$validIMEI = ($CheckIMEI > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validIMEI == false) {
|
||||||
|
$validText .= '<li>IMEI Telah Digunakan.</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$validTextCont = '<ul style="margin-left:-20px;list-style-type:circle;">'.$validText.'</ul>';
|
||||||
|
|
||||||
|
if ($validText) {
|
||||||
|
$response['rm'] = $validTextCont;
|
||||||
|
$response['rc'] = 99;
|
||||||
|
}else{
|
||||||
|
$response['rm'] = "Pass";
|
||||||
|
$response['rc'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$response['rm'] = "Pass";
|
||||||
|
$response['rc'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
//IF ADD DATA
|
||||||
|
else{
|
||||||
|
if ($db == 'device') {
|
||||||
|
$CheckSN = DB::table('device')->where('sn',$setField['sn'])->count();
|
||||||
|
$CheckIMEI = DB::table('device')->where('imei',$setField['imei'])->count();
|
||||||
|
|
||||||
|
$validText = '';
|
||||||
|
|
||||||
|
if ($CheckSN > 0) {
|
||||||
|
$validText .= '<li>Serial Number Telah Digunakan.</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($CheckIMEI > 0) {
|
||||||
|
$validText .= '<li>IMEI Telah Digunakan.</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$validTextCont = '<ul style="margin-left:-20px;list-style-type:circle;">'.$validText.'</ul>';
|
||||||
|
|
||||||
|
if ($validText) {
|
||||||
|
$response['rm'] = $validTextCont;
|
||||||
|
$response['rc'] = 99;
|
||||||
|
}else{
|
||||||
|
$response['rm'] = "Pass";
|
||||||
|
$response['rc'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$response['rm'] = "Pass";
|
||||||
|
$response['rc'] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
591
app/Http/Controllers/UserController.php
Normal file
591
app/Http/Controllers/UserController.php
Normal file
@ -0,0 +1,591 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\User;
|
||||||
|
use Response;
|
||||||
|
use DB;
|
||||||
|
use Auth, Session;
|
||||||
|
use Yajra\DataTables\DataTables;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Request as Req;
|
||||||
|
use App\Events\StatusLiked;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function list(Request $request, $type)
|
||||||
|
{
|
||||||
|
$checkRole = $this->checkRoleAccess($type);
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'user_management':
|
||||||
|
$view = 'content.user_management.user';
|
||||||
|
$dataPage['title'] = 'List User Bank';
|
||||||
|
$dataPage['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Role","all","role_name"],
|
||||||
|
["Username","all","username"],
|
||||||
|
["E-Mail","all","email"],
|
||||||
|
["Nama Lengkap","all","full_name"],
|
||||||
|
["Status","all","status_user"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//REF
|
||||||
|
$dataPage['ref_role'] = DB::table('groups_admin')->where('is_active','t')->get();
|
||||||
|
|
||||||
|
foreach($dataPage['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$dataPage['head'] = implode(",",$arrHead);
|
||||||
|
$dataPage['type'] = $type;
|
||||||
|
$dataPage['table'] = route('user.data_table',$type);
|
||||||
|
|
||||||
|
return $this->bsGetView('content.user.index',$dataPage);
|
||||||
|
}
|
||||||
|
public function data_table(Request $request, $type)
|
||||||
|
{
|
||||||
|
|
||||||
|
$checkRole = $this->checkRoleAccess($type);
|
||||||
|
if ($checkRole == false) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
|
||||||
|
$SessionUser = Session::get('user');
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'user_management':
|
||||||
|
$data = \DB::select("SELECT users_admin.*,full_name, users_admin.id as admin_id,rsu.description as role_name
|
||||||
|
FROM users_admin join groups_admin rsu on rsu.id = users_admin.role order by users_admin.id desc");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTables::of($data)
|
||||||
|
->addColumn('action', function ($data) {
|
||||||
|
|
||||||
|
$actBlock = '';
|
||||||
|
$id = Crypt::encryptString($data->admin_id);
|
||||||
|
if (Auth::user()->role == 1) {
|
||||||
|
// if ($data->role != 1) {
|
||||||
|
if ($data->status_user == 'f') {
|
||||||
|
$actBlock = '<li class="navi-item">
|
||||||
|
<a onclick="aktifUser(`'.$id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-check-circle"></i> </span>
|
||||||
|
<span class="navi-text">Aktifkan User</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}else{
|
||||||
|
$actBlock = '<li class="navi-item">
|
||||||
|
<a onclick="blockUser(`'.$id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-ban"></i> </span>
|
||||||
|
<span class="navi-text">Block User</span>
|
||||||
|
</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return '
|
||||||
|
<div class="dropdown dropdown-inline">
|
||||||
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">
|
||||||
|
<span class="svg-icon svg-icon-md">
|
||||||
|
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
||||||
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||||
|
<rect x="0" y="0" width="24" height="24"/>
|
||||||
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">
|
||||||
|
<ul class="navi flex-column navi-hover py-2">
|
||||||
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">
|
||||||
|
Choose an action:
|
||||||
|
</li>
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="edit(`'.$id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-edit"></i></span>
|
||||||
|
<span class="navi-text"> Edit</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="del(`'.$id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-trash"></i> </span>
|
||||||
|
<span class="navi-text">Hapus</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="navi-item">
|
||||||
|
<a onclick="resetPassword(`'.$id.'`)" class="navi-link">
|
||||||
|
<span class="navi-icon"><i class="la la-key"></i> </span>
|
||||||
|
<span class="navi-text">Reset Password</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
'.$actBlock.'
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
->editColumn('status_user',function($data) {
|
||||||
|
return ($data->status_user == 't') ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Blocked</span>';
|
||||||
|
})
|
||||||
|
->rawColumns(['status_user','action'])
|
||||||
|
->make(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_any(Request $request, $type)
|
||||||
|
{
|
||||||
|
|
||||||
|
$bypassRole = ['changePassword','get_user_detail','store_logout','check_expired_password'];
|
||||||
|
|
||||||
|
if (!in_array($type, $bypassRole)) {
|
||||||
|
|
||||||
|
if (Auth::guard('admin')->user()->role != 1) {
|
||||||
|
return view('errors.404');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// USER
|
||||||
|
switch ($type) {
|
||||||
|
case 'user_store':
|
||||||
|
return $this->act_user_store($request);
|
||||||
|
break;
|
||||||
|
case 'user_delete':
|
||||||
|
return $this->act_user_delete(Crypt::decryptString($request->input('id')));
|
||||||
|
break;
|
||||||
|
case 'user_reset_password':
|
||||||
|
return $this->act_user_reset_password(Crypt::decryptString($request->input('id')));
|
||||||
|
break;
|
||||||
|
case 'get_user_detail':
|
||||||
|
return $this->act_get_user_detail(Crypt::decryptString($request->input('id')));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'changePassword':
|
||||||
|
return $this->act_changePassword($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'get_notif':
|
||||||
|
return $this->act_get_notif($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'read_notif':
|
||||||
|
return $this->act_read_notif($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'store_logout':
|
||||||
|
return $this->act_store_logout($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'generate_key':
|
||||||
|
return $this->act_generate_key($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'user_block':
|
||||||
|
return $this->act_user_block(Crypt::decryptString($request->input('id')));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'user_aktif':
|
||||||
|
return $this->act_user_aktif(Crypt::decryptString($request->input('id')));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'check_expired_password':
|
||||||
|
return $this->check_expired_password($request);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_user_store(Request $request)
|
||||||
|
{
|
||||||
|
$get = collect(\DB::select("SELECT max(id) as max_id FROM users_admin"))->first();
|
||||||
|
|
||||||
|
$id = $request->input('get_id');
|
||||||
|
if ($id) {
|
||||||
|
$id = Crypt::decryptString($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
// VALIDATE
|
||||||
|
if ($id == '') {
|
||||||
|
$checkCode = DB::table('users_admin')->where('username', $request->username)->count();
|
||||||
|
$checkEmail = DB::table('users_admin')->where('email', $request->email)->count();
|
||||||
|
|
||||||
|
if ($checkCode > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Username ".$request->username." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($checkEmail > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "email ".$request->email." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$dataCheck = DB::table('users_admin')->where('id',$id)->first();
|
||||||
|
|
||||||
|
if ($request->username == $dataCheck->username) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$checkCode = DB::table('users_admin')->where('username',$request->username)->count();
|
||||||
|
$validNMID = ($checkCode > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validNMID == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Username ".$request->username." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->email == $dataCheck->email) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$checkEmail = DB::table('users_admin')->where('email',$request->email)->count();
|
||||||
|
$validName = ($checkEmail > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validName == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "email ".$request->email." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$oldData = null;
|
||||||
|
if ($id == "") {
|
||||||
|
|
||||||
|
$event = "Tambah User ".$request->input('username');
|
||||||
|
$data = new User();
|
||||||
|
$data->id = $get->max_id+1;
|
||||||
|
$data->status_user = 't';
|
||||||
|
$data->date_password = date('Y-m-d', strtotime("-62 days"));
|
||||||
|
$data->password = $this->hashPassword('Admin123');
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$oldData = \DB::table('users_admin')->where('id',$id)->first();
|
||||||
|
$event = "Ubah User ".$request->input('username');
|
||||||
|
$data = User::find($id);
|
||||||
|
$rolename = DB::table('groups_admin')->where('id',$data->role)->first();
|
||||||
|
$rolename_new = DB::table('groups_admin')->where('id',$request->role)->first();
|
||||||
|
|
||||||
|
if ($data->role !== $request->post('role') ) {
|
||||||
|
$event = 'Change Privilege from '.$rolename->name.' to '.$rolename_new->name;
|
||||||
|
|
||||||
|
if ($request->post('role') != 1 && $data->role == 1) {
|
||||||
|
$this->auditTrailValue($event,"Downgrade Privilege",'users_admin',json_encode($data),json_encode($oldData));
|
||||||
|
}else{
|
||||||
|
$this->auditTrailValue($event,"elevation of privilege",'users_admin',json_encode($data),json_encode($oldData));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->role = $request->input('role');
|
||||||
|
$data->phone = $request->input('phone');
|
||||||
|
$data->email = $this->cleanString($request->input('email'));
|
||||||
|
$data->full_name = $this->cleanString($request->input('full_name'));
|
||||||
|
$data->username = $this->cleanString($request->input('username'));
|
||||||
|
$data->address = $request->input('address');
|
||||||
|
$data->mid = $request->input('mid');
|
||||||
|
$data->id_kota = $request->input('id_kota');
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
$this->auditTrailValue($event,"User Bank",'users_admin',json_encode($data),json_encode($oldData));
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// // 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_get_user_detail($id)
|
||||||
|
{
|
||||||
|
$data = collect(\DB::select("SELECT * FROM users_admin where id = ?",[$id]))->first();
|
||||||
|
|
||||||
|
$data->id = Crypt::encryptString($data->id);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_user_delete($id)
|
||||||
|
{
|
||||||
|
$user = $this->getUserAdmin($id);
|
||||||
|
$event = "Hapus User ".$user[0]->username;
|
||||||
|
// $this->auditTrail($event,"User Admin");
|
||||||
|
|
||||||
|
$this->auditTrailValue($event,"User Bank",'users_admin',json_encode($user),'');
|
||||||
|
|
||||||
|
|
||||||
|
if ($id == 1) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Super Admin Tidak Dapat Dihapus !"
|
||||||
|
]);
|
||||||
|
}else {
|
||||||
|
User::destroy($id);
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "Berhasil Dihapus !"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_user_reset_password($id)
|
||||||
|
{
|
||||||
|
$user = $this->getUserAdmin($id);
|
||||||
|
$event = "Reset Password User ".$user[0]->username;
|
||||||
|
$this->auditTrail($event,"User Admin");
|
||||||
|
|
||||||
|
$data = User::find($id);
|
||||||
|
$data->password = $this->hashPassword('Admin123');
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => $user[0]->username." Berhasil di reset password !"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_user_block($id)
|
||||||
|
{
|
||||||
|
$user = $this->getUserAdmin($id);
|
||||||
|
$event = "Block User ".$user[0]->username;
|
||||||
|
$this->auditTrail($event,"User Bank");
|
||||||
|
|
||||||
|
$data = User::find($id);
|
||||||
|
$data->status_user = 'f';
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => $user[0]->username." Berhasil di Block !"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_user_aktif($id)
|
||||||
|
{
|
||||||
|
$user = $this->getUserAdmin($id);
|
||||||
|
$event = "Aktif User ".$user[0]->username;
|
||||||
|
$this->auditTrail($event,"User Bank");
|
||||||
|
|
||||||
|
$data = User::find($id);
|
||||||
|
$data->status_user = 't';
|
||||||
|
$data->wrong_password = 0;
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => $user[0]->username." Berhasil di Aktif !"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function act_changePassword(Request $request)
|
||||||
|
{
|
||||||
|
$user = $this->getUserAdmin(Auth::guard('admin')->user()->id);
|
||||||
|
|
||||||
|
|
||||||
|
$data = User::find(Auth::guard('admin')->user()->id);
|
||||||
|
|
||||||
|
$checkPassword = $this->hashPasswordCheck($request->input('oldPassword'),$data->password);
|
||||||
|
|
||||||
|
if ($checkPassword == $data->password) {
|
||||||
|
|
||||||
|
if (!preg_match('/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/',$request->input('newPassword')))
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Aturan Password Tidak Sesuai !'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$getLimit = DB::table('config_map')->where('config_map_id','pass_max_history')->first();
|
||||||
|
|
||||||
|
$checkHistoryPassword = DB::table('password_history')
|
||||||
|
->where('user_admin',Auth::guard('admin')->user()->id)
|
||||||
|
->limit($getLimit->config_map_val)
|
||||||
|
->orderByDesc('crtdt')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($checkHistoryPassword as $k => $v) {
|
||||||
|
$checkPasswordOld = $this->hashPasswordCheck($request->input('newPassword'),$v->password);
|
||||||
|
if ($checkPasswordOld == $v->password) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Password sudah pernah digunakan, gunakan passsword lain.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkSame = $this->hashPasswordCheck($request->input('newPassword'),$data->password);
|
||||||
|
if ($checkSame == $data->password) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Password harus berbeda dengan password sebelumnya.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data->password = $this->hashPassword($request->input('newPassword'));
|
||||||
|
$data->date_password = date('Y-m-d');
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
DB::table('password_history')->insert([
|
||||||
|
'password' => $this->hashPassword($request->input('oldPassword')),
|
||||||
|
'crtdt' => date('Y-m-d'),
|
||||||
|
'user_admin' => Auth::guard('admin')->user()->id
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$event = "Ubah Password User ".$user[0]->username;
|
||||||
|
$this->auditTrail($event,"User Admin");
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'Berhasil Merubah Password !'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Password Lama Tidak Sesuai !'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_generate_key(Request $request)
|
||||||
|
{
|
||||||
|
$data = User::find(Auth::guard('admin')->user()->id);
|
||||||
|
$data->key = $request->key;
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'Berhasil Generate Key Baru !',
|
||||||
|
'data' => $request->key
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function act_get_notif(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_read_notif(Request $request)
|
||||||
|
{
|
||||||
|
DB::table('mst_notif')
|
||||||
|
->where('is_admin', 't')
|
||||||
|
->update(['is_read' => 1]);
|
||||||
|
|
||||||
|
$c_notif = collect(\DB::select("SELECT count(cust_id) as j FROM mst_notif where is_read is null and is_admin = 't' GROUP BY cust_id"))->first();
|
||||||
|
|
||||||
|
$numNotif = 0;
|
||||||
|
if ($c_notif) {
|
||||||
|
$numNotif = $c_notif->j;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'jumlah' => $numNotif
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function act_store_logout(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$user = DB::table('users_admin')->where('id',Auth::guard('admin')->user()->id)->first();
|
||||||
|
$event = "Logout User ID:".Auth::guard('admin')->user()->id;
|
||||||
|
|
||||||
|
|
||||||
|
$this->auditTrailLog($event,"Logout Log WEBMIN_BANK",'',json_encode($user),'');
|
||||||
|
|
||||||
|
Session::flush();
|
||||||
|
Auth::guard('admin')->logout();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'success'
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function check_expired_password(Request $request)
|
||||||
|
{
|
||||||
|
$check = DB::selectOne('SELECT CURRENT_DATE - date_password + 1 AS days
|
||||||
|
FROM users_admin
|
||||||
|
where id = ?',[Auth::guard('admin')->user()->id]);
|
||||||
|
|
||||||
|
if ($check->days > 60) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => 'Change Password'
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => 'success'
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
69
app/Http/Kernel.php
Normal file
69
app/Http/Kernel.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?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\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Fruitcake\Cors\HandleCors::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,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
'throttle:60,1',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'idle.screen.timeout' => \App\Http\Middleware\IdleScreenTimeout::class,
|
||||||
|
'prevent.back.history' => \App\Http\Middleware\PreventBackHistory::class,
|
||||||
|
];
|
||||||
|
}
|
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@ -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|null
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('admin.viewlogin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
@ -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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
40
app/Http/Middleware/IdleScreenTimeout.php
Normal file
40
app/Http/Middleware/IdleScreenTimeout.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class IdleScreenTimeout
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
// TODO idle screen time
|
||||||
|
$appsToken = session()->get("AppsToken");
|
||||||
|
if ($appsToken != null){
|
||||||
|
$lastIdleTime = session()->get("lastIdleTime");
|
||||||
|
if ($lastIdleTime == null){
|
||||||
|
session()->put('lastIdleTime', time());
|
||||||
|
}else{
|
||||||
|
if (time() - $lastIdleTime > 60){
|
||||||
|
session()->forget("lastIdleTime");
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$request->session()->flush();
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
|
// return $next($request);
|
||||||
|
$response = $next($request);
|
||||||
|
return $response->header('Cache-Control','no-cache, no-store, max-age=0, must-revalidate')
|
||||||
|
->header('Pragma','no-cache')
|
||||||
|
->header('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
|
||||||
|
}
|
||||||
|
}
|
22
app/Http/Middleware/PreventBackHistory.php
Normal file
22
app/Http/Middleware/PreventBackHistory.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class PreventBackHistory {
|
||||||
|
/**
|
||||||
|
* 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','Sun, 02 Jan 1990 00:00:00 GMT');
|
||||||
|
}
|
||||||
|
}
|
27
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
27
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
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($guard)->check()) {
|
||||||
|
return redirect(RouteServiceProvider::HOME);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
18
app/Http/Middleware/TrimStrings.php
Normal file
18
app/Http/Middleware/TrimStrings.php
Normal file
@ -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',
|
||||||
|
];
|
||||||
|
}
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||||
|
|
||||||
|
class TrustHosts extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the host patterns that should be trusted.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function hosts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
23
app/Http/Middleware/TrustProxies.php
Normal file
23
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array|string|null
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||||
|
}
|
26
app/Http/Middleware/VerifyCsrfToken.php
Normal file
26
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'set_bahasa',
|
||||||
|
'set_session_theme',
|
||||||
|
// 'getlogout',
|
||||||
|
// 'login'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $addHttpCookie = false;
|
||||||
|
protected function addCookieToResponse($request, $response)
|
||||||
|
{
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
104
app/Imports/DeviceImport.php
Normal file
104
app/Imports/DeviceImport.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\deviceModel;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToModel;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Validators\Failure;
|
||||||
|
use Maatwebsite\Excel\Concerns\Importable;
|
||||||
|
use Maatwebsite\Excel\Concerns\SkipsOnError;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||||
|
use Maatwebsite\Excel\Concerns\SkipsErrors;
|
||||||
|
|
||||||
|
class DeviceImport implements ToCollection, WithHeadingRow, SkipsOnError
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $row
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Model|null
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Importable, SkipsErrors;
|
||||||
|
|
||||||
|
public $validate;
|
||||||
|
|
||||||
|
public function collection(Collection $rows)
|
||||||
|
{
|
||||||
|
$checkData = '';
|
||||||
|
|
||||||
|
foreach ($rows as $key => $row)
|
||||||
|
{
|
||||||
|
if ($row['sn'] == '' || $row['sn'] == null) {
|
||||||
|
$checkData .= '<li>Kolom <b>sn</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
}
|
||||||
|
if ($row['imei'] == '' || $row['imei'] == null) {
|
||||||
|
$checkData .= '<li>Kolom <b>imei</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
}
|
||||||
|
if ($row['brand'] == '' || $row['brand'] == null) {
|
||||||
|
$checkData .= '<li>Kolom <b>brand</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
}
|
||||||
|
if ($row['model'] == '' || $row['model'] == null) {
|
||||||
|
$checkData .= '<li>Kolom <b>model</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
}
|
||||||
|
if ($row['tid'] == '' || $row['tid'] == null) {
|
||||||
|
$checkData .= '<li>Kolom <b>tid</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
}
|
||||||
|
if (!is_int($row['tid'])) {
|
||||||
|
$checkData .= '<li>Kolom <b>tid</b> Pada Baris '.($key+1).' Harus Angka </li>';
|
||||||
|
}
|
||||||
|
if (!is_int($row['brand'])) {
|
||||||
|
$checkData .= '<li>Kolom <b>brand</b> Pada Baris '.($key+1).' Harus Angka Berupa ID Brand </li>';
|
||||||
|
}
|
||||||
|
// if ($row['mid'] == '' || $row['mid'] == null) {
|
||||||
|
// $checkData .= '<li>Kolom <b>mid</b> Pada Baris '.($key+1).' Tidak Boleh Kosong </li>';
|
||||||
|
// }
|
||||||
|
|
||||||
|
$checkSN = \DB::table('device')->where('sn',$row['sn'])->first();
|
||||||
|
|
||||||
|
if ($checkSN) {
|
||||||
|
$checkData .= "<li>Serial Number (sn) :<b>".$row['sn']."</b> Pada Baris ".($key+1)." Sudah Terdaftar </li>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkBrand = \DB::table('reff_brand')->where('id_brand',$row['brand'])->count();
|
||||||
|
|
||||||
|
if ($checkBrand == 0) {
|
||||||
|
$checkData .= "<li>ID Brand :<b>".$row['brand']."</b> Pada Baris ".($key+1)." Tidak Terdaftar </li>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$this->validate = $checkData;
|
||||||
|
|
||||||
|
if ($checkData == '') {
|
||||||
|
foreach ($rows as $row)
|
||||||
|
{
|
||||||
|
// $get = \DB::table('device')->max('device_id');
|
||||||
|
|
||||||
|
deviceModel::create([
|
||||||
|
// 'device_id' => $get+1,
|
||||||
|
'sn' => $cGlobal->cleanString($row['sn']),
|
||||||
|
'imei' => $cGlobal->cleanString($row['imei']),
|
||||||
|
'brand' => $cGlobal->cleanString($row['brand']),
|
||||||
|
'model' => $cGlobal->cleanString($row['model']),
|
||||||
|
'tid' => $cGlobal->cleanString($row['tid']),
|
||||||
|
// 'mid' => $row['mid'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
app/Interfaces/APIInterface.php
Normal file
14
app/Interfaces/APIInterface.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
abstract class APIInterface
|
||||||
|
{
|
||||||
|
abstract function get($path, $auth = null);
|
||||||
|
abstract function post($path, $data, $auth = null);
|
||||||
|
abstract function delete($path, $auth = null);
|
||||||
|
|
||||||
|
}
|
13
app/Interfaces/AppUtility.php
Normal file
13
app/Interfaces/AppUtility.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
interface AppUtility
|
||||||
|
{
|
||||||
|
public function loadView(AuthApps $authApps, Request $request, $result, $dataPage, $page, $mainView = 'content.main');
|
||||||
|
public function loadData(AuthApps $authApps,$result);
|
||||||
|
public function loadTableData(AuthApps $authApps,Request $request,$result);
|
||||||
|
}
|
16
app/Interfaces/AuditPlanModel.php
Normal file
16
app/Interfaces/AuditPlanModel.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Audit;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use OwenIt\Auditing\Contracts\Auditable;
|
||||||
|
|
||||||
|
class AuditPlanModel extends Model implements Auditable
|
||||||
|
{
|
||||||
|
use \OwenIt\Auditing\Auditable;
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'master_audit_plan';
|
||||||
|
}
|
15
app/Interfaces/AuthApps.php
Normal file
15
app/Interfaces/AuthApps.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
interface AuthApps
|
||||||
|
{
|
||||||
|
public function check();
|
||||||
|
public function add($token);
|
||||||
|
public function token();
|
||||||
|
public function clear();
|
||||||
|
public function addMsg($message);
|
||||||
|
public function clearMsg();
|
||||||
|
}
|
17
app/Models/AuditTrailModel.php
Normal file
17
app/Models/AuditTrailModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AuditTrailModel extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'audits';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
17
app/Models/HomeModel.php
Normal file
17
app/Models/HomeModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class HomeModel extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'mst_home';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
16
app/Models/MenuModel.php
Normal file
16
app/Models/MenuModel.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class MenuModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'group_id';
|
||||||
|
protected $table = 'menu_privilege';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
73
app/Models/bankModel.php
Normal file
73
app/Models/bankModel.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class bankModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'reff_bank';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Bank';
|
||||||
|
$data['actButton'] = ['edit','active'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Bank Code","all","bank_code"],
|
||||||
|
["Bank Name","all","bank_name"],
|
||||||
|
["Status","all","is_active"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_bank order by id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'bank_name' => $request->post('bank_name'),
|
||||||
|
'bank_code' => $request->post('bank_code'),
|
||||||
|
'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_bank where id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
$dt->editColumn('is_active',function($data) {
|
||||||
|
return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
135
app/Models/billingModel.php
Normal file
135
app/Models/billingModel.php
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class billingModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'bill_id';
|
||||||
|
protected $table = 'bill';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Billing';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Merchant","all","merchant_nm"],
|
||||||
|
["Time","all","crtdt"],
|
||||||
|
["Staff","all","user_nm"],
|
||||||
|
["Amount","all","bill_amount"],
|
||||||
|
["Tax","all","tax_amount"],
|
||||||
|
["Service Percentage","all","charge_service_prs"],
|
||||||
|
["Charge Amount","all","charge_amount"],
|
||||||
|
["Total Amount","all","total_amount"],
|
||||||
|
["Billing Code","none","bill_code"],
|
||||||
|
["Promo Voucher","none","promo_code"],
|
||||||
|
["Payment Status","all","payment_status_nm"]
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = DB::table("bill")
|
||||||
|
->join("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "bill.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("promo_voucher", function($join){
|
||||||
|
$join->on("promo_voucher.promo_voucher_id", "=", "bill.promo_voucher_id");
|
||||||
|
})
|
||||||
|
->join("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "bill.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("bill.*", "promo_voucher.promo_code", "reff_payment_status.payment_status_nm", "users.user_nm", "users.outlet_id", "merchant_nm")
|
||||||
|
->where("bill.crtdt", ">=", $startDate)
|
||||||
|
->where("bill.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('crtdt',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->crtdt));
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('bill_amount',function($data) {
|
||||||
|
return number_format($data->bill_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('tax_amount',function($data) {
|
||||||
|
return number_format($data->tax_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('charge_amount',function($data) {
|
||||||
|
return number_format($data->charge_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('total_amount',function($data) {
|
||||||
|
return number_format($data->total_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('charge_service_prs',function($data) {
|
||||||
|
return number_format($data->charge_service_prs,0,",",".")."%";
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
66
app/Models/brandModel.php
Normal file
66
app/Models/brandModel.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class brandModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'id_brand';
|
||||||
|
protected $table = 'reff_brand';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Brand';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["ID","all","id_brand"],
|
||||||
|
["Nama Brand","all","name_brand"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_brand order by id_brand desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'name_brand' => $cGlobal->cleanString($request->post('name_brand'))
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_brand where id_brand = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
105
app/Models/deviceModel.php
Normal file
105
app/Models/deviceModel.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class deviceModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'device_id';
|
||||||
|
protected $table = 'device';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'device_id','sn', 'imei', 'brand', 'model', 'tid','mid',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'EDC Device';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["ID","all","device_id"],
|
||||||
|
["Serial Number","all","sn"],
|
||||||
|
["IMEI","all","imei"],
|
||||||
|
["Brand","all","name_brand"],
|
||||||
|
["Model","all","model"],
|
||||||
|
["Terminal ID","all","tid"],
|
||||||
|
["Merchant Name","all","merchant_nm"],
|
||||||
|
["Outlet Name","all","outlet_nm"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = DB::table("device")
|
||||||
|
->leftJoin("reff_brand", function($join){
|
||||||
|
$join->on("reff_brand.id_brand", "=", "device.brand");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "device.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("outlet", function($join){
|
||||||
|
$join->on("outlet.outlet_id", "=", "device.outlet_id");
|
||||||
|
})
|
||||||
|
->orderBy("device_id","desc")
|
||||||
|
->when(request('merchant') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant != 'all') {
|
||||||
|
$query->where('device.mid', $request->merchant);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'sn' => $cGlobal->cleanString($request->post('sn')),
|
||||||
|
'imei' => $cGlobal->cleanString($request->post('imei')),
|
||||||
|
'brand' => $request->post('brand'),
|
||||||
|
'model' => $cGlobal->cleanString($request->post('model')),
|
||||||
|
'tid' => $cGlobal->cleanString($request->post('tid')),
|
||||||
|
'mid' => $request->post('mid')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM device where device_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
// $dt->editColumn('is_active',function($data) {
|
||||||
|
// return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
// });
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
136
app/Models/grossModel.php
Normal file
136
app/Models/grossModel.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class grossModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'outlet_id';
|
||||||
|
protected $table = 'outlet';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Gross Profit and Sales';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Tanggal","all","crtdt"],
|
||||||
|
["Merchant","all","merchant_nm"],
|
||||||
|
["Outlet","all","outlet_nm"],
|
||||||
|
["Gross Sales","all","gross_sales"],
|
||||||
|
["Gross Profit","all","gross_profit"],
|
||||||
|
["Trx","all","count_trx"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$dtable = DB::table("payment")
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("payment.mid", "=", "merchant.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("outlet", function($join){
|
||||||
|
$join->on("outlet.outlet_id", "=", "payment.outlet_id");
|
||||||
|
})
|
||||||
|
->leftJoin("bill", function($join){
|
||||||
|
$join->on("bill.bill_id", "=", "payment.bill_id");
|
||||||
|
})
|
||||||
|
->leftJoin("orders_bill", function($join){
|
||||||
|
$join->on("orders_bill.bill_id", "=", "bill.bill_id");
|
||||||
|
})
|
||||||
|
->leftJoin("orders", function($join){
|
||||||
|
$join->on("orders.order_id", "=", "orders_bill.order_id");
|
||||||
|
})
|
||||||
|
->select("merchant.mid", "merchant.merchant_nm", "outlet.outlet_id", "outlet.outlet_nm",
|
||||||
|
DB::raw("payment.crtdt::date"), DB::raw("sum (payment.total_amount) as total_amount"),
|
||||||
|
DB::raw("sum (bill.tax_amount) as tax", "sum (bill.charge_amount) as charge"),
|
||||||
|
DB::raw("sum (bill.bill_amount) as gross_sales"),
|
||||||
|
DB::raw("sum (orders.total_amount_base) as cogs"),
|
||||||
|
DB::raw("sum (bill.bill_amount) - sum (distinct orders.total_amount_base) as gross_profit"),
|
||||||
|
DB::raw("count (payment.payment_id) as count_trx"),
|
||||||
|
DB::raw("count (orders.order_id) as count_order"))
|
||||||
|
->where("payment.payment_status_id", "=", 1)
|
||||||
|
->where("bill.crtdt", ">=", $startDate)
|
||||||
|
->where("bill.crtdt", "<=", $endDate)
|
||||||
|
->groupBy("merchant.mid","merchant.merchant_nm","outlet.outlet_id","outlet.outlet_nm",DB::raw("payment.crtdt::date"))
|
||||||
|
->orderByDesc(DB::raw("payment.crtdt::date"))
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('payment.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('crtdt',function($data) {
|
||||||
|
return date('d-m-Y',strtotime($data->crtdt));
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('gross_sales',function($data) {
|
||||||
|
return number_format($data->gross_sales,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('gross_profit',function($data) {
|
||||||
|
return number_format($data->gross_profit,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
app/Models/kotaModel.php
Normal file
73
app/Models/kotaModel.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class kotaModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'city_id';
|
||||||
|
protected $table = 'reff_city';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Kota';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Nama Kota","all","city_nm"],
|
||||||
|
["Kode Dati","all","dati_code"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_city order by city_id desc");
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'city_nm' => $cGlobal->cleanString($request->post('city_nm')),
|
||||||
|
'dati_code' => $cGlobal->cleanString($request->post('dati_code'))
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_city where city_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
119
app/Models/laporanmarketModel.php
Normal file
119
app/Models/laporanmarketModel.php
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class laporanmarketModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'pasar_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Market';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Transaction Time","all","transaction_time"],
|
||||||
|
["Merchant ID","all","mid"],
|
||||||
|
["Merchant Name","all","merchant_nm"],
|
||||||
|
["Toko","all","toko_nm"],
|
||||||
|
["Toko Code","all","toko_kd"],
|
||||||
|
["Keterangan","all","keterangan"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["No Resi","all","no_resi"],
|
||||||
|
["Status","all","transaction_status_desc"]
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and pt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
transaction_id,
|
||||||
|
transaction_time,
|
||||||
|
pt.mid,
|
||||||
|
m.merchant_nm ,
|
||||||
|
pt.toko_id,
|
||||||
|
t.toko_nm ,
|
||||||
|
t.toko_kd ,
|
||||||
|
rtt.keterangan ,
|
||||||
|
amount ,
|
||||||
|
no_resi ,
|
||||||
|
pt.transaction_status_id,
|
||||||
|
rts.transaction_status_desc,
|
||||||
|
pt.berita
|
||||||
|
from
|
||||||
|
pasar_transaction pt
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = pt.mid
|
||||||
|
left join reff_transaction_status rts on
|
||||||
|
pt.transaction_status_id = rts.transaction_status_id
|
||||||
|
left join toko t on
|
||||||
|
pt.toko_id = t.toko_id
|
||||||
|
left join merchant_toko_type mtt on
|
||||||
|
mtt.merchant_ttid = t.merchant_ttid left join reff_toko_type rtt on mtt.ttid = mtt.ttid
|
||||||
|
where transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
$dt->editColumn('transaction_id',function($data) {
|
||||||
|
return substr($data->transaction_id, 0, 18);
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('amount',function($data) {
|
||||||
|
return number_format($data->amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
118
app/Models/laporanparkirModel.php
Normal file
118
app/Models/laporanparkirModel.php
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class laporanparkirModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'park_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Parkir';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Transaction Time","all","transaction_time"],
|
||||||
|
["Merchant ID","all","mid"],
|
||||||
|
["Merchant Name","all","merchant_nm"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["Vehicle","all","vehicle_type_nm"],
|
||||||
|
["Plat No","all","plat_no"],
|
||||||
|
["No Resi","all","no_resi"],
|
||||||
|
["Status","all","transaction_status_desc"],
|
||||||
|
["Keterangan","all","berita"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and pt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
transaction_id,
|
||||||
|
transaction_time,
|
||||||
|
pt.mid,
|
||||||
|
m.merchant_nm ,
|
||||||
|
pt.vehicle_type_id ,
|
||||||
|
rvt.vehicle_type_nm ,
|
||||||
|
plat_no ,
|
||||||
|
amount ,
|
||||||
|
no_resi ,
|
||||||
|
pt.transaction_status_id,
|
||||||
|
rts.transaction_status_desc,
|
||||||
|
pt.berita
|
||||||
|
from
|
||||||
|
park_transaction pt
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = pt.mid
|
||||||
|
left join reff_transaction_status rts on
|
||||||
|
pt.transaction_status_id = rts.transaction_status_id
|
||||||
|
left join reff_vehicle_type rvt on
|
||||||
|
pt.vehicle_type_id = rvt.vehicle_type_id
|
||||||
|
where transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
$dt->editColumn('transaction_id',function($data) {
|
||||||
|
return substr($data->transaction_id, 0, 18);
|
||||||
|
});
|
||||||
|
$dt->editColumn('amount',function($data) {
|
||||||
|
return number_format($data->amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
142
app/Models/laporansaleModel.php
Normal file
142
app/Models/laporansaleModel.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class laporansaleModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'transfer_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Sale';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Transaction Time","all","transaction_time"],
|
||||||
|
["Dest Acc No","all","dest_acct_no"],
|
||||||
|
["Account No","all","account_number"],
|
||||||
|
["Source Name","none","source_name"],
|
||||||
|
["Dest Name","none","dest_name"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["Service Name","all","service_name"],
|
||||||
|
["Username","none","username"],
|
||||||
|
["Nomor Kartu","all","card_no"],
|
||||||
|
["Status","all","transaction_status_desc"],
|
||||||
|
["Response UID","none","response_uid"],
|
||||||
|
["Service ID","none","service_id"],
|
||||||
|
["keterangan","all","msg"],
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and tt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
tt.transaction_id,
|
||||||
|
tt.transaction_time,
|
||||||
|
tt.dest_acct_no,
|
||||||
|
tt.account_number,
|
||||||
|
tt.source_name,
|
||||||
|
tt.dest_name,
|
||||||
|
tt.amount,
|
||||||
|
service_name,
|
||||||
|
username,
|
||||||
|
tt.card_no,
|
||||||
|
transaction_status_desc,
|
||||||
|
r.response_uid ,
|
||||||
|
r.service_id ,
|
||||||
|
r.msg,
|
||||||
|
bank_name,
|
||||||
|
(case
|
||||||
|
when r.msg isnull then (
|
||||||
|
select
|
||||||
|
msg
|
||||||
|
from
|
||||||
|
responsecode
|
||||||
|
where
|
||||||
|
service_id = '0'
|
||||||
|
and response_uid = tt.rc_sw
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as keterangan
|
||||||
|
from
|
||||||
|
transfer_transaction tt
|
||||||
|
left join service on
|
||||||
|
tt.service_id = service.service_id
|
||||||
|
left join users on
|
||||||
|
tt.user_uid = users.user_uid
|
||||||
|
left join reff_transaction_status on
|
||||||
|
tt.transaction_status_id = reff_transaction_status.transaction_status_id
|
||||||
|
left join responsecode r on
|
||||||
|
r.response_uid = tt.rc_sw
|
||||||
|
and r.service_id = tt.service_id
|
||||||
|
and r.lang = 'in'
|
||||||
|
left join reff_bank rb on
|
||||||
|
rb.bank_code = tt.bank_code
|
||||||
|
where service.service_group in ('sale')
|
||||||
|
and transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
$dt->editColumn('transaction_id',function($data) {
|
||||||
|
return substr($data->transaction_id, 0, 18);
|
||||||
|
});
|
||||||
|
$dt->editColumn('amount',function($data) {
|
||||||
|
return number_format($data->amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
296
app/Models/merchantModel.php
Normal file
296
app/Models/merchantModel.php
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Models\merchantParkModel;
|
||||||
|
use App\Models\deviceModel;
|
||||||
|
use App\Models\tokofeeModel;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class merchantModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'mid';
|
||||||
|
protected $table = 'merchant';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Merchant';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
// ["Logo","all","logo"],
|
||||||
|
["Merchant Code","all","mid"],
|
||||||
|
["Merchant Name","all","merchant_nm"],
|
||||||
|
["Address","all","address"],
|
||||||
|
["Phone","all","phone_no"],
|
||||||
|
|
||||||
|
["Tax","all","tax_list"],
|
||||||
|
["Hotel","all","is_hotel"],
|
||||||
|
["Restoran","all","is_resto"],
|
||||||
|
// ["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Auth::user()->role != 3) {
|
||||||
|
array_push($data['tableHead'],["Act","all","action"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
|
||||||
|
$dtable = \DB::table($this->table)
|
||||||
|
->select("merchant.*", DB::raw("string_agg(DISTINCT reff_tax.tax_nm || ' (' || reff_tax.tax_prs || '%)' ,', ') as tax_list"))
|
||||||
|
|
||||||
|
->leftJoin("device", function($join){
|
||||||
|
$join->on("device.mid", "=", "merchant.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant_tax", function($join){
|
||||||
|
$join->on("merchant_tax.mid", "=", "merchant.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_tax", function($join){
|
||||||
|
$join->on("reff_tax.tax_id", "=", "merchant_tax.tax_id");
|
||||||
|
})
|
||||||
|
->groupBy("merchant.mid")
|
||||||
|
->orderBy('merchant_nm')
|
||||||
|
->when(Auth::user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('city_id', Auth::user()->id_kota);
|
||||||
|
})
|
||||||
|
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
// 'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "No Access"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$data['get_data_edit']['merchant'] = \DB::selectOne("SELECT * from merchant m where m.mid = ?",[$request->post('id')]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('is_hotel',function($data) {
|
||||||
|
return ($data->is_hotel == true) ? '<span class="label label-success label-rounded mr-2"><i class="las la-check"></i></span>':'<span class="label label-danger label-rounded mr-2" style="background-color: #d1d1d1 !important;"><i class="las la-times"></i></span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('is_resto',function($data) {
|
||||||
|
return ($data->is_resto == true) ? '<span class="label label-success label-rounded mr-2"><i class="las la-check"></i></span>':'<span class="label label-danger label-rounded mr-2" style="background-color: #d1d1d1 !important;"><i class="las la-times"></i></span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$dt->editColumn('tax_list',function($data) {
|
||||||
|
$list = '';
|
||||||
|
$dList = explode(",",$data->tax_list);
|
||||||
|
|
||||||
|
if($data->tax_list){
|
||||||
|
foreach ($dList as $key => $v) {
|
||||||
|
$list .= '<span class="label label-danger label-inline mr-2">'.$v.'</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('logo',function($data) {
|
||||||
|
return '<img style="width:50px;" src="'.asset('gallery').'/'.$data->logo.'" alt="">';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom($act,Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
$titleTrail = 'Merchant';
|
||||||
|
switch ($act) {
|
||||||
|
case 'storeMerchant':
|
||||||
|
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "No Access"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $request->input('get_id');
|
||||||
|
|
||||||
|
$oldData = null;
|
||||||
|
|
||||||
|
// VALIDATE
|
||||||
|
if ($id == '') {
|
||||||
|
$checkMID = DB::table('merchant')->where('mid', $request->mid)->count();
|
||||||
|
// $checkNMID = DB::table('merchant')->where('nmid', $request->nmid)->count();
|
||||||
|
$checkPHONE = DB::table('merchant')->where('phone_no', $request->phone_no)->count();
|
||||||
|
|
||||||
|
if ($checkMID > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "MID ".$request->mid." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($checkPHONE > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Phone No ".$request->phone_no." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$dataCheck = DB::table('merchant')->where('mid',$id)->first();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($request->phone_no == $dataCheck->phone_no) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$checkPHONE = DB::table('merchant')->where('phone_no',$request->phone_no)->count();
|
||||||
|
$validPHONE = ($checkPHONE > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validPHONE == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Phone No ".$request->phone_no." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == "") {
|
||||||
|
$event = "Tambah ".$titleTrail." ".$request->input('merchant_nm');
|
||||||
|
$datas = new merchantModel();
|
||||||
|
$datas->mid = $cGlobal->cleanString($request->mid);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$event = "Ubah ".$titleTrail." ".$request->input('merchant_nm');
|
||||||
|
$oldData = \DB::table($this->table)->where('mid',$id)->first();
|
||||||
|
$datas = merchantModel::find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$datas->merchant_nm = $cGlobal->cleanString($request->merchant_nm);
|
||||||
|
$datas->address = $request->address;
|
||||||
|
$datas->phone_no = $request->phone_no;
|
||||||
|
$datas->nmid = $cGlobal->cleanString($request->nmid);
|
||||||
|
$datas->is_hotel = $request->is_hotel;
|
||||||
|
$datas->is_resto = $request->is_resto;
|
||||||
|
|
||||||
|
// $datas->email = $request->email;
|
||||||
|
|
||||||
|
$datas->city_id = $request->kota;
|
||||||
|
$datas->save();
|
||||||
|
|
||||||
|
|
||||||
|
$cGlobal->auditTrailValue($event,$titleTrail,$this->table,json_encode($datas),json_encode($oldData));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'listTax':
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "No Access"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$dataList = DB::table('merchant_tax')->where('mid',$request->id)->get();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'list' => $dataList
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'addTax':
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "No Access"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$listAdd = $request->tax_select;
|
||||||
|
DB::table('merchant_tax')->where('mid', $request->get_mid_tax)->delete();
|
||||||
|
|
||||||
|
if ($listAdd) {
|
||||||
|
foreach ($listAdd as $k => $v) {
|
||||||
|
|
||||||
|
$datas = [
|
||||||
|
'mid' => $request->get_mid_tax,
|
||||||
|
'tax_id' => $v
|
||||||
|
];
|
||||||
|
|
||||||
|
DB::table('merchant_tax')->insert($datas);
|
||||||
|
|
||||||
|
$cGlobal->auditTrailValue("Merchant Tax",$titleTrail,'merchant_tax',json_encode($datas),'');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
app/Models/merchantParkModel.php
Normal file
16
app/Models/merchantParkModel.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class merchantParkModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'mid';
|
||||||
|
protected $table = 'merchant_park_fee';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
125
app/Models/orderModel.php
Normal file
125
app/Models/orderModel.php
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class orderModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'order_id';
|
||||||
|
protected $table = 'orders';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Order';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Merchant","all","merchant_nm"],
|
||||||
|
["Time","all","crtdt"],
|
||||||
|
["Staff","all","user_nm"],
|
||||||
|
["Order Type","all","order_type_nm"],
|
||||||
|
["Pay Date","all","paydt"],
|
||||||
|
["Order Code","all","order_code"],
|
||||||
|
["Billing Type","all","bill_type_nm"],
|
||||||
|
["Customer Alias","all","customer_alias"],
|
||||||
|
["Payment Status","all","payment_status_nm"]
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dtable = DB::table("orders")
|
||||||
|
->join("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "orders.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("outlet", function($join){
|
||||||
|
$join->on("outlet.outlet_id", "=", "orders.outlet_id");
|
||||||
|
})
|
||||||
|
->join("reff_order_type", function($join){
|
||||||
|
$join->on("reff_order_type.order_type_id", "=", "orders.order_type_id");
|
||||||
|
})
|
||||||
|
->join("reff_bill_type", function($join){
|
||||||
|
$join->on("reff_bill_type.bill_type_id", "=", "orders.bill_type_id");
|
||||||
|
})
|
||||||
|
->join("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "orders.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("orders.*", "reff_bill_type.*", "merchant_nm", "reff_payment_status.payment_status_nm", "users.user_nm", "orders.outlet_id", "reff_order_type.*")
|
||||||
|
->where("orders.crtdt", ">=", $startDate)
|
||||||
|
->where("orders.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('crtdt',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->crtdt));
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('paydt',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->paydt));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
135
app/Models/paymentModel.php
Normal file
135
app/Models/paymentModel.php
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class paymentModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'payment_pln_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Payment';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Payment Time","all","transaction_time"],
|
||||||
|
["Merchant ID","all","mid"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["Fee","all","fee"],
|
||||||
|
["Account No","all","account_number"],
|
||||||
|
// ["IdPel","all","phone_no"],
|
||||||
|
["Product Group Name","all","product_group_name"],
|
||||||
|
["No Resi","all","no_resi"],
|
||||||
|
["Terminal ID","all","tid"],
|
||||||
|
["Status","all","transaction_status_desc"],
|
||||||
|
["Keterangan","all","msg"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and pt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
pt.*,
|
||||||
|
username,
|
||||||
|
service_name,
|
||||||
|
transaction_status_desc,
|
||||||
|
pg.product_group_name,
|
||||||
|
(case
|
||||||
|
when r.msg isnull then (
|
||||||
|
select
|
||||||
|
msg
|
||||||
|
from
|
||||||
|
responsecode
|
||||||
|
where
|
||||||
|
service_id = '0'
|
||||||
|
and response_uid =
|
||||||
|
(case
|
||||||
|
when pt.rc_biller isnull then pt.rc_sw
|
||||||
|
else
|
||||||
|
(case
|
||||||
|
when pt.rc_biller = '0' then '00'
|
||||||
|
else pt.rc_biller
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as msg
|
||||||
|
from
|
||||||
|
payment_pln_transaction pt
|
||||||
|
left join users on
|
||||||
|
pt.user_uid = users.user_uid
|
||||||
|
left join service on
|
||||||
|
pt.service_id = service.service_id
|
||||||
|
left join reff_transaction_status on
|
||||||
|
pt.transaction_status_id = reff_transaction_status.transaction_status_id
|
||||||
|
left join product_group pg on
|
||||||
|
pg.product_group_id = pt.product_group_id
|
||||||
|
left join responsecode r on
|
||||||
|
r.service_id = pt.service_id
|
||||||
|
and r.response_uid =
|
||||||
|
case
|
||||||
|
when pt.rc_biller isnull then pt.rc_sw
|
||||||
|
else pt.rc_biller
|
||||||
|
end
|
||||||
|
and r.lang = 'in'
|
||||||
|
where transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
87
app/Models/productModel.php
Normal file
87
app/Models/productModel.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class productModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'product';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Product';
|
||||||
|
$data['actButton'] = ['edit','active'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
// ["Rank","all","rank"],
|
||||||
|
["Product ID","all","product_id"],
|
||||||
|
["Product Name","all","product_name"],
|
||||||
|
["Nominal","all","product_nominal"],
|
||||||
|
["Status","all","is_active"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from product order by id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
$nominal_id = explode(".",$request->post('product_nominal'));
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'product_id' => $request->input('product_group_id').".".$nominal_id[0],
|
||||||
|
'product_name' => $request->post('product_name'),
|
||||||
|
'product_group_id' => $request->post('product_group_id'),
|
||||||
|
'product_nominal' => $cGlobal->clearSeparator($request->product_nominal),
|
||||||
|
'rank' => $request->post('rank'),
|
||||||
|
'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM product where id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
$dt->editColumn('is_active',function($data) {
|
||||||
|
return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
});
|
||||||
|
$dt->editColumn('product_nominal',function($data) {
|
||||||
|
return "<div class='text-right'>Rp ".number_format($data->product_nominal,0,",",".")."</div>";
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
140
app/Models/purchaseModel.php
Normal file
140
app/Models/purchaseModel.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class purchaseModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'payment_pln_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Purchase';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Purchase Time","all","transaction_time"],
|
||||||
|
["Merchant ID","all","mid"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["Fee","all","fee"],
|
||||||
|
["Account No","all","account_number"],
|
||||||
|
["IdPel","all","phone_no"],
|
||||||
|
["Product Group Name","all","product_group_name"],
|
||||||
|
["No Resi","all","no_resi"],
|
||||||
|
["Terminal ID","all","tid"],
|
||||||
|
["Status","all","transaction_status_desc"],
|
||||||
|
["Keterangan","all","msg"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and pt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
pt.*,
|
||||||
|
username,
|
||||||
|
service_name,
|
||||||
|
merchant_nm,
|
||||||
|
transaction_status_desc,
|
||||||
|
pg.product_group_name,
|
||||||
|
(case
|
||||||
|
when r.msg isnull then (
|
||||||
|
select
|
||||||
|
msg
|
||||||
|
from
|
||||||
|
responsecode
|
||||||
|
where
|
||||||
|
service_id = '0'
|
||||||
|
and response_uid =
|
||||||
|
(case
|
||||||
|
when pt.rc_biller isnull then pt.rc_sw
|
||||||
|
else
|
||||||
|
(case
|
||||||
|
when pt.rc_biller = '0' then '00'
|
||||||
|
else pt.rc_biller
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as msg
|
||||||
|
from
|
||||||
|
purchase_transaction pt
|
||||||
|
left join users on
|
||||||
|
pt.user_uid = users.user_uid
|
||||||
|
left join merchant on
|
||||||
|
merchant.mid = pt.mid
|
||||||
|
left join service on
|
||||||
|
pt.service_id = service.service_id
|
||||||
|
left join reff_transaction_status on
|
||||||
|
pt.transaction_status_id = reff_transaction_status.transaction_status_id
|
||||||
|
left join product_group pg on
|
||||||
|
pg.product_group_id = pt.product_group_id
|
||||||
|
left join responsecode r on
|
||||||
|
r.service_id = pt.service_id
|
||||||
|
and r.response_uid =
|
||||||
|
case
|
||||||
|
when pt.rc_biller isnull then pt.rc_sw
|
||||||
|
else pt.rc_biller
|
||||||
|
end
|
||||||
|
and r.lang = 'in'
|
||||||
|
where transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
$dt->editColumn('transaction_id',function($data) {
|
||||||
|
return substr($data->transaction_id, 0, 18);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
454
app/Models/rekaptrxModel.php
Normal file
454
app/Models/rekaptrxModel.php
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class rekaptrxModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Rekap Transaksi';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Jenis Transaksi","all","jenis_transaksi"],
|
||||||
|
["Berhasil","all","berhasil"],
|
||||||
|
["Gagal","all","gagal"],
|
||||||
|
["Pending","all","pending"],
|
||||||
|
["Batal","all","batal"],
|
||||||
|
["Total","all","total"],
|
||||||
|
["Persentase","all","prosentase_keberhasilan"],
|
||||||
|
["Act","all","action"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = 'jenis_transaksi';
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and t.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = DB::select("SELECT
|
||||||
|
(case
|
||||||
|
when s.service_group in ('antarbank', 'transfer') then 'trf'
|
||||||
|
else s.service_group
|
||||||
|
end) as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as total,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as berhasil,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
group by jenis_transaksi", ['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('prosentase_keberhasilan', function ($data) {
|
||||||
|
return number_format($data->prosentase_keberhasilan,2,",",".").'%';
|
||||||
|
});
|
||||||
|
|
||||||
|
// $dt->editColumn('transaction_id',function($data) {
|
||||||
|
// return substr($data->transaction_id, 0, 18);
|
||||||
|
// });
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom($act,Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
$titleTrail = 'Status Transaksi';
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and t.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = null;
|
||||||
|
|
||||||
|
switch ($act) {
|
||||||
|
case 'listDetail':
|
||||||
|
|
||||||
|
switch ($request->type) {
|
||||||
|
case 'trf':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('antarbank', 'transfer')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// ['branchCode' => $request->branchCode,'startDate' => $startDate,'endDate' => $endDate]
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'payment':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('payment')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'purchase':
|
||||||
|
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('purchase')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// ['branchCode' => $request->branchCode,'startDate' => $startDate,'endDate' => $endDate]
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'sale':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('sale')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'market':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('market')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
break;
|
||||||
|
case 'parkir':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
s.service_group as product_group_id,
|
||||||
|
s.service_group as jenis_transaksi,
|
||||||
|
count(t.transaction_id) as jumlah_transaksi,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end) as transaksi_sukses,
|
||||||
|
count(case when t.transaction_status_id = 1 then 1 else null end) as transaksi_gagal,
|
||||||
|
count(case when t.transaction_status_id = 2 then 1 else null end) as transaksi_pending,
|
||||||
|
count(case when t.transaction_status_id = 3 then 1 else null end) as transaksi_batal,
|
||||||
|
count(case when t.transaction_status_id = 0 then 1 else null end)* 100 / count(t.transaction_id) as prosentase_keberhasilan
|
||||||
|
from
|
||||||
|
transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join users u on
|
||||||
|
t.user_uid = u.user_uid
|
||||||
|
left join merchant m on
|
||||||
|
m.mid = t.mid
|
||||||
|
where
|
||||||
|
t.transaction_time::date between :startDate and :endDate ".$filterMerchant."
|
||||||
|
and s.service_group in ('parkir')
|
||||||
|
group by
|
||||||
|
jenis_transaksi",['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'listDetailGagal':
|
||||||
|
switch ($request->type) {
|
||||||
|
case 'trf':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
e.response_uid ,
|
||||||
|
(case
|
||||||
|
when r.msg_id is null then (
|
||||||
|
select
|
||||||
|
r1.msg
|
||||||
|
from
|
||||||
|
responsecode r1
|
||||||
|
where
|
||||||
|
r1.service_id = '0'
|
||||||
|
and r1.response_uid = e.response_uid
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as penyebab_gagal,
|
||||||
|
count(t.transaction_id) as jumlah,
|
||||||
|
100 * count(t.transaction_id) / sum(count(t.transaction_id)) over () as pct
|
||||||
|
from
|
||||||
|
transfer_transaction t
|
||||||
|
join service s on
|
||||||
|
t.service_id = s.service_id
|
||||||
|
left join event e on
|
||||||
|
t.event_uid = e.event_uid
|
||||||
|
left join responsecode r on
|
||||||
|
t.service_id = r.service_id
|
||||||
|
and e.response_uid = r.response_uid
|
||||||
|
and r.lang = 'in'
|
||||||
|
where
|
||||||
|
e.response_uid <> '00'
|
||||||
|
and s.service_group = :service_group and t.transaction_time::date between :startDate and :endDate
|
||||||
|
group by
|
||||||
|
e.response_uid ,
|
||||||
|
penyebab_gagal
|
||||||
|
order by
|
||||||
|
jumlah desc",['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// ['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'payment':
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
e.response_uid ,
|
||||||
|
(case
|
||||||
|
when r.msg_id is null then (
|
||||||
|
select
|
||||||
|
r1.msg
|
||||||
|
from
|
||||||
|
responsecode r1
|
||||||
|
where
|
||||||
|
r1.service_id = '0'
|
||||||
|
and r1.response_uid = e.response_uid
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as penyebab_gagal,
|
||||||
|
count(t.transaction_id) as jumlah,
|
||||||
|
100 * count(t.transaction_id) / sum(count(t.transaction_id)) over () as pct
|
||||||
|
from
|
||||||
|
payment_pln_transaction t
|
||||||
|
left join event e on
|
||||||
|
t.event_uid = e.event_uid
|
||||||
|
left join responsecode r on
|
||||||
|
t.service_id = r.service_id
|
||||||
|
and e.response_uid = r.response_uid
|
||||||
|
and r.lang = 'in'
|
||||||
|
where
|
||||||
|
e.response_uid <> '00'
|
||||||
|
and t.product_group_id = :service_group and t.transaction_time::date between :startDate and :endDate
|
||||||
|
group by
|
||||||
|
e.response_uid ,
|
||||||
|
penyebab_gagal
|
||||||
|
order by
|
||||||
|
jumlah desc",['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// ['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'purchase':
|
||||||
|
|
||||||
|
$data = \DB::select("SELECT
|
||||||
|
e.response_uid ,
|
||||||
|
(case
|
||||||
|
when r.msg_id is null then (
|
||||||
|
select
|
||||||
|
r1.msg
|
||||||
|
from
|
||||||
|
responsecode r1
|
||||||
|
where
|
||||||
|
r1.service_id = '0'
|
||||||
|
and r1.response_uid = e.response_uid
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as penyebab_gagal,
|
||||||
|
count(t.transaction_id) as jumlah,
|
||||||
|
100 * count(t.transaction_id) / sum(count(t.transaction_id)) over () as pct
|
||||||
|
from
|
||||||
|
purchase_transaction t
|
||||||
|
left join event e on
|
||||||
|
t.event_uid = e.event_uid
|
||||||
|
left join responsecode r on
|
||||||
|
t.service_id = r.service_id
|
||||||
|
and e.response_uid = r.response_uid
|
||||||
|
and r.lang = 'in'
|
||||||
|
where
|
||||||
|
e.response_uid <> '00'
|
||||||
|
and t.product_group_id = :service_group and t.transaction_time::date between :startDate and :endDate
|
||||||
|
group by
|
||||||
|
e.response_uid ,
|
||||||
|
penyebab_gagal
|
||||||
|
order by
|
||||||
|
jumlah desc",['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// ['service_group' => $request->service_group,'startDate' => $startDate,'endDate' => $endDate]
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
app/Models/roleModel.php
Normal file
73
app/Models/roleModel.php
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Datatables, DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class roleModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'groups_admin';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Role User';
|
||||||
|
$data['actButton'] = ['edit','active'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Role User","all","description"],
|
||||||
|
["Status","all","is_active"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from groups_admin order by id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'name' => $cGlobal->cleanString($request->post('description')),
|
||||||
|
'description' => $request->post('description'),
|
||||||
|
'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM groups_admin where id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
$dt->editColumn('is_active',function($data) {
|
||||||
|
return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
153
app/Models/statustrxModel.php
Normal file
153
app/Models/statustrxModel.php
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class statustrxModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'response_uid';
|
||||||
|
protected $table = 'event';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Status Transaksi';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["ID","all","id"],
|
||||||
|
["Message","all","msg"],
|
||||||
|
["Frekuensi","all","frek"],
|
||||||
|
["Presentase","all","presentase"],
|
||||||
|
["Act","all","action"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and t.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT event.response_uid,event.response_uid as id, responsecode.msg as msg,
|
||||||
|
count(event.response_uid) as frek, concat(
|
||||||
|
round((round(count(event.response_uid),2) / (SELECT round(count(response_uid),2) as zz from event))*100,2) ,' %' ) as presentase
|
||||||
|
from event
|
||||||
|
join responsecode on responsecode.response_uid = event.response_uid
|
||||||
|
where responsecode.service_id = '0' and responsecode.lang in ('id','in')
|
||||||
|
and event.crtdt::date between :startDate and :endDate
|
||||||
|
GROUP BY event.response_uid,msg
|
||||||
|
order by event.response_uid,presentase
|
||||||
|
", ['startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
|
||||||
|
// $dt->editColumn('transaction_id',function($data) {
|
||||||
|
// return substr($data->transaction_id, 0, 18);
|
||||||
|
// });
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom($act,Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
$titleTrail = 'Status Transaksi';
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
switch ($act) {
|
||||||
|
case 'listDetail':
|
||||||
|
|
||||||
|
$data = \DB::select("SELECT event.service_id as id,service.service_name as msg,
|
||||||
|
count(event.service_id) as frek,
|
||||||
|
concat(round((round(count(event.service_id),2) / (SELECT round(count(service_id),2) as zz from event where event.response_uid = :id and event.crtdt::date between :startDate and :endDate ))*100,2) ,' %' ) as presentase
|
||||||
|
from event
|
||||||
|
join service on service.service_id = event.service_id
|
||||||
|
where event.response_uid = :id and event.crtdt::date between :startDate and :endDate
|
||||||
|
GROUP BY event.service_id,service_name
|
||||||
|
order by event.service_id,presentase
|
||||||
|
",['id' => $request->id,'startDate' => $startDate,'endDate' => $endDate]);
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data' => $data
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
app/Models/taxModel.php
Normal file
68
app/Models/taxModel.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Auth;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class taxModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'tax_id';
|
||||||
|
protected $table = 'reff_tax';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Tax';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Tax Name","all","tax_nm"],
|
||||||
|
["Percentage","all","tax_prs"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_tax order by tax_id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'tax_nm' => $cGlobal->cleanString($request->post('tax_nm')),
|
||||||
|
'tax_prs' => $request->post('tax_prs')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_tax where tax_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
414
app/Models/tokoModel.php
Normal file
414
app/Models/tokoModel.php
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class tokoModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'outlet_id';
|
||||||
|
protected $table = 'outlet';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Outlet';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Merchant Name","all","merchant_nm"],
|
||||||
|
["Nama outlet","all","outlet_nm"],
|
||||||
|
["Kode outlet","all","outlet_code"],
|
||||||
|
["Jenis","all","outlet_type_nm"],
|
||||||
|
["Alamat","all","address"],
|
||||||
|
["Kota","all","city_nm"],
|
||||||
|
["MID Trx","all","mid_trx"],
|
||||||
|
["EDC Device","all","sn_list"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
|
||||||
|
$dtable = \DB::table('outlet')
|
||||||
|
->select("outlet.*","reff_outlet_type.*","reff_city.*","merchant.merchant_nm", DB::raw("string_agg(DISTINCT device.sn,', ') as sn_list"))
|
||||||
|
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "outlet.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_city", function($join){
|
||||||
|
$join->on("reff_city.city_id", "=", "outlet.city_id");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_outlet_type", function($join){
|
||||||
|
$join->on("reff_outlet_type.outlet_type_id", "=", "outlet.outlet_type_id");
|
||||||
|
})
|
||||||
|
->leftJoin("device", function($join){
|
||||||
|
$join->on("device.outlet_id", "=", "outlet.outlet_id");
|
||||||
|
})
|
||||||
|
->groupBy("outlet.outlet_id","reff_city.city_id","merchant.merchant_nm","reff_outlet_type.outlet_type_id")
|
||||||
|
->orderByDesc('outlet.outlet_id')
|
||||||
|
->when(Auth::user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('outlet.city_id', Auth::user()->id_kota);
|
||||||
|
})
|
||||||
|
->when(request('merchant') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant != 'all') {
|
||||||
|
$query->where('outlet.mid', $request->merchant);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'mid_trx' => $request->post('mid_trx'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit']['outlet'] = collect(\DB::select("SELECT * FROM outlet where outlet_id = ?",[$request->post('id')]))->first();
|
||||||
|
$data['get_data_edit']['bank'] = DB::table('outlet_bank')->where('outlet_id',$request->post('id'))->get();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
// if ($request->post('id')) {
|
||||||
|
// $data['get_data_edit'] = collect(\DB::select("SELECT * FROM outlet where outlet_id = ?",[$request->post('id')]))->first();
|
||||||
|
// }
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('sn_list',function($data) {
|
||||||
|
$list = '';
|
||||||
|
$dList = explode(",",$data->sn_list);
|
||||||
|
|
||||||
|
if($data->sn_list){
|
||||||
|
foreach ($dList as $key => $v) {
|
||||||
|
$list .= '<span class="label label-success label-inline mr-2 mb-2">'.$v.'</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom($act,Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
$titleTrail = 'Outlet';
|
||||||
|
switch ($act) {
|
||||||
|
|
||||||
|
case 'storeToko':
|
||||||
|
|
||||||
|
$id = $request->input('get_id');
|
||||||
|
|
||||||
|
$oldData = null;
|
||||||
|
|
||||||
|
// VALIDATE
|
||||||
|
if ($id == '') {
|
||||||
|
$checkCode = DB::table('outlet')->where('outlet_code', $request->outlet_code)->count();
|
||||||
|
$checkNameOutlet = DB::table('outlet')->where('mid',$request->mid)->where('outlet_nm','ilike', '%' .$request->outlet_nm. '%')->count();
|
||||||
|
|
||||||
|
if ($checkCode > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Kode Outlet ".$request->outlet_code." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($checkNameOutlet > 0) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Nama Outlet ".$request->outlet_nm." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$dataCheck = DB::table('outlet')->where('outlet_id',$id)->first();
|
||||||
|
|
||||||
|
if ($request->outlet_code == $dataCheck->outlet_code) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$checkCode = DB::table('outlet')->where('outlet_code',$request->outlet_code)->count();
|
||||||
|
$validNMID = ($checkCode > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validNMID == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Kode Outlet ".$request->outlet_code." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->outlet_nm == $dataCheck->outlet_nm) {
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$checkNameOutlet = DB::table('outlet')->where('mid',$request->mid)->where('outlet_nm','ilike', '%' .$request->outlet_nm. '%')->count();
|
||||||
|
$validName = ($checkNameOutlet > 0) ? false : true;
|
||||||
|
|
||||||
|
if ($validName == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Nama Outlet ".$request->outlet_nm." Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id == "") {
|
||||||
|
$event = "Tambah ".$titleTrail." ".$request->input('outlet_nm');
|
||||||
|
$getMaxId = \DB::table('outlet')->max('outlet_id');
|
||||||
|
$datas = new tokoModel();
|
||||||
|
$datas->outlet_id = $getMaxId+1;
|
||||||
|
$datas->is_active = 'f';
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
$event = "Ubah ".$titleTrail." ".$request->input('outlet_nm');
|
||||||
|
$oldData = \DB::table($this->table)->where('outlet_id',$id)->first();
|
||||||
|
$datas = tokoModel::find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas->mid = $request->mid;
|
||||||
|
$datas->outlet_nm = $cGlobal->cleanString($request->outlet_nm);
|
||||||
|
$datas->address = $cGlobal->cleanString($request->post('address'));
|
||||||
|
$datas->outlet_code = $request->post('outlet_code');
|
||||||
|
$datas->outlet_type_id = $request->post('outlet_type_id');
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
$datas->city_id = Auth::user()->id_kota;
|
||||||
|
}else{
|
||||||
|
$datas->city_id = $request->post('city_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$datas->nmid = $request->post('nmid');
|
||||||
|
|
||||||
|
$datas->is_charge_service = $request->post('is_charge_service');
|
||||||
|
$datas->charge_service_prs = ($request->post('is_charge_service') == 't') ? $request->post('charge_service_prs'):0;
|
||||||
|
|
||||||
|
$datas->save();
|
||||||
|
|
||||||
|
$outletBank = $request->outlet_bank;
|
||||||
|
|
||||||
|
DB::table('outlet_bank')->where('outlet_id', $datas->outlet_id)->delete();
|
||||||
|
|
||||||
|
if ($outletBank) {
|
||||||
|
foreach ($outletBank as $k => $v) {
|
||||||
|
|
||||||
|
$getMaxIdM = \DB::table('outlet_bank')->max('outlet_bank_id');
|
||||||
|
|
||||||
|
$datasAdd = [
|
||||||
|
'outlet_bank_id' => $getMaxIdM+1,
|
||||||
|
'outlet_id' => $datas->outlet_id,
|
||||||
|
'bank_code' => $v
|
||||||
|
|
||||||
|
];
|
||||||
|
DB::table('outlet_bank')->insert($datasAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$cGlobal->auditTrailValue($event,$titleTrail,$this->table,json_encode($datas),json_encode($oldData));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'storeConfirm':
|
||||||
|
$id = $request->input('get_outlet_id');
|
||||||
|
$oldData = null;
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
$getOutlet = DB::table('outlet')->where('outlet_id',$id)->first();
|
||||||
|
|
||||||
|
if ($getOutlet->city_id != Auth::user()->id_kota){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$event = "Confirm ".$titleTrail." ".$request->input('outlet_nm');
|
||||||
|
$oldData = \DB::table($this->table)->where('outlet_id',$id)->first();
|
||||||
|
$datas = tokoModel::find($id);
|
||||||
|
$datas->mid_trx = $request->post('mid_trx');
|
||||||
|
$datas->save();
|
||||||
|
|
||||||
|
$cGlobal->auditTrailValue($event,$titleTrail,$this->table,json_encode($datas),json_encode($oldData));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'dataConfirm':
|
||||||
|
$dataList = DB::table('outlet')
|
||||||
|
->where('outlet_id',$request->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
$getOutlet = DB::table('outlet')->where('outlet_id',$id)->first();
|
||||||
|
|
||||||
|
if ($getOutlet->city_id != Auth::user()->id_kota){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'data' => $dataList
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'listEdc':
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
$getOutlet = DB::table('outlet')->where('outlet_id',$request->id)->first();
|
||||||
|
|
||||||
|
if ($getOutlet->city_id != Auth::user()->id_kota){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataList = DB::table('device')
|
||||||
|
->leftJoin('reff_brand','reff_brand.id_brand','device.brand')
|
||||||
|
// ->where('mid',$request->id)
|
||||||
|
->where('outlet_id',$request->id)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'list' => $dataList
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'addEdc':
|
||||||
|
|
||||||
|
$getOutlet = DB::table('outlet')->where('outlet_id',$request->outlet_id)->first();
|
||||||
|
$getDevice = DB::table('device')->where('device_id',$request->device_id)->first();
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
|
||||||
|
if ($getOutlet->city_id != Auth::user()->id_kota){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($getDevice->outlet_id != null){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$edc = deviceModel::find($request->device_id);
|
||||||
|
$edc->mid = $getOutlet->mid;
|
||||||
|
$edc->outlet_id = $request->outlet_id;
|
||||||
|
$edc->save();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses",
|
||||||
|
'title' => $getOutlet->outlet_nm
|
||||||
|
]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'removeEdc':
|
||||||
|
|
||||||
|
if (Auth::user()->role == 3) {
|
||||||
|
$getOutlet = DB::table('device')
|
||||||
|
->join('outlet','device.outlet_id','outlet.outlet_id')
|
||||||
|
->where('device_id',$request->device_id)->first();
|
||||||
|
|
||||||
|
if ($getOutlet->city_id != Auth::user()->id_kota){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Tidak Memiliki Akses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$edc = deviceModel::find($request->device_id);
|
||||||
|
$edc->mid = null;
|
||||||
|
$edc->outlet_id = null;
|
||||||
|
$edc->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
app/Models/tokofeeModel.php
Normal file
17
app/Models/tokofeeModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class tokofeeModel extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $primaryKey = 'merchant_ttid';
|
||||||
|
protected $table = 'merchant_toko_type';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
128
app/Models/transactionModel.php
Normal file
128
app/Models/transactionModel.php
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class transactionModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'payment_id';
|
||||||
|
protected $table = 'payment';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Transaction';
|
||||||
|
$data['actButton'] = [];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Merchant","all","merchant_nm"],
|
||||||
|
["Time","all","crtdt"],
|
||||||
|
["Staff","all","user_nm"],
|
||||||
|
["Pay Amount","all","pay_amount"],
|
||||||
|
["Payment Type","all","payment_type_nm"],
|
||||||
|
["Card Number","all","card_no"],
|
||||||
|
["Customer","all","customer_nm"],
|
||||||
|
["Change Amount","all","change_amount"],
|
||||||
|
["Total Amount","all","total_amount"],
|
||||||
|
["Payment Status","all","payment_status_nm"]
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
if ($request->startDate) {
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
}else{
|
||||||
|
$startDate = date('Y-m-d').' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d').' 24:00:00';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dtable = DB::table("payment")
|
||||||
|
->leftJoin("users", function($join){
|
||||||
|
$join->on("users.user_id", "=", "payment.user_id");
|
||||||
|
})
|
||||||
|
->leftJoin("merchant", function($join){
|
||||||
|
$join->on("merchant.mid", "=", "users.mid");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_payment_type", function($join){
|
||||||
|
$join->on("reff_payment_type.payment_type_id", "=", "payment.payment_type_id");
|
||||||
|
})
|
||||||
|
->leftJoin("customer", function($join){
|
||||||
|
$join->on("customer.customer_id", "=", "payment.customer_id");
|
||||||
|
})
|
||||||
|
->leftJoin("reff_payment_status", function($join){
|
||||||
|
$join->on("reff_payment_status.payment_status_id", "=", "payment.payment_status_id");
|
||||||
|
})
|
||||||
|
->select("payment.*", "reff_payment_type.*", "merchant_nm", "reff_payment_status.payment_status_nm", "users.user_nm", "payment.outlet_id", "customer.customer_nm")
|
||||||
|
->where("payment.crtdt", ">=", $startDate)
|
||||||
|
->where("payment.crtdt", "<=", $endDate)
|
||||||
|
->when(request('merchant_filter') != null, function ($query) use ($request) {
|
||||||
|
if ($request->merchant_filter != 'all') {
|
||||||
|
$query->where('users.mid', $request->merchant_filter);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when(Auth::guard('admin')->user()->role == 3, function ($query) use ($request) {
|
||||||
|
$query->where('merchant.city_id', Auth::guard('admin')->user()->id_kota);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('crtdt',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->crtdt));
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('pay_amount',function($data) {
|
||||||
|
return number_format($data->pay_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('change_amount',function($data) {
|
||||||
|
return number_format($data->change_amount,0,",",".");
|
||||||
|
});
|
||||||
|
|
||||||
|
$dt->editColumn('total_amount',function($data) {
|
||||||
|
return number_format($data->total_amount,0,",",".");
|
||||||
|
});
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
136
app/Models/transferModel.php
Normal file
136
app/Models/transferModel.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class transferModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'transaction_id';
|
||||||
|
protected $table = 'transfer_transaction';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Laporan Transfer';
|
||||||
|
$data['actButton'] = [''];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Transfer Time","all","transaction_time"],
|
||||||
|
["Jenis Transfer","all","service_name"],
|
||||||
|
["Bank Tujuan","all","bank_name"],
|
||||||
|
["No Rekening Tujuan","all","dest_acct_no"],
|
||||||
|
["Account No","all","account_number"],
|
||||||
|
["Card No","all","card_no"],
|
||||||
|
["From","all","source_name"],
|
||||||
|
["To","all","dest_name"],
|
||||||
|
["Amount","all","amount"],
|
||||||
|
["Status","all","transaction_status_desc"],
|
||||||
|
["Keterangan","all","keterangan"],
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$startDate = date('Y-m-d',strtotime($request->startDate)).' 00:00:00';
|
||||||
|
$endDate = date('Y-m-d',strtotime($request->endDate)).' 24:00:00';
|
||||||
|
|
||||||
|
$filterMerchant = '';
|
||||||
|
|
||||||
|
if ($request->merchant != null) {
|
||||||
|
if ($request->merchant == 'all') {
|
||||||
|
$filterMerchant = '';
|
||||||
|
}else{
|
||||||
|
$filterMerchant = " and tt.mid = '".$request->merchant."' ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT
|
||||||
|
tt.transaction_id,
|
||||||
|
tt.transaction_time,
|
||||||
|
tt.dest_acct_no,
|
||||||
|
tt.account_number,
|
||||||
|
tt.source_name,
|
||||||
|
tt.dest_name,
|
||||||
|
tt.amount,
|
||||||
|
service_name,
|
||||||
|
username,
|
||||||
|
tt.card_no,
|
||||||
|
transaction_status_desc,
|
||||||
|
r.response_uid ,
|
||||||
|
r.service_id ,
|
||||||
|
r.msg,
|
||||||
|
bank_name,
|
||||||
|
(case
|
||||||
|
when r.msg isnull then (
|
||||||
|
select
|
||||||
|
msg
|
||||||
|
from
|
||||||
|
responsecode
|
||||||
|
where
|
||||||
|
service_id = '0'
|
||||||
|
and response_uid = tt.rc_sw
|
||||||
|
and lang = 'in')
|
||||||
|
else r.msg
|
||||||
|
end ) as keterangan
|
||||||
|
from
|
||||||
|
transfer_transaction tt
|
||||||
|
left join service on
|
||||||
|
tt.service_id = service.service_id
|
||||||
|
left join users on
|
||||||
|
tt.user_uid = users.user_uid
|
||||||
|
left join reff_transaction_status on
|
||||||
|
tt.transaction_status_id = reff_transaction_status.transaction_status_id
|
||||||
|
left join responsecode r on
|
||||||
|
r.response_uid = tt.rc_sw
|
||||||
|
and r.service_id = tt.service_id
|
||||||
|
and r.lang = 'in'
|
||||||
|
left join reff_bank rb on
|
||||||
|
rb.bank_code = tt.bank_code
|
||||||
|
where service.service_group in ('antarbank', 'transfer')
|
||||||
|
and transaction_time >= ? and transaction_time <= ? ".$filterMerchant,[$startDate,$endDate]);
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('transaction_time',function($data) {
|
||||||
|
return date('d-m-Y H:i:s',strtotime($data->transaction_time));
|
||||||
|
});
|
||||||
|
$dt->editColumn('transaction_id',function($data) {
|
||||||
|
return substr($data->transaction_id, 0, 18);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
69
app/Models/typeproductModel.php
Normal file
69
app/Models/typeproductModel.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Exception;
|
||||||
|
use Datatables, DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class typeproductModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'product_type_id';
|
||||||
|
protected $table = 'reff_product_type';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Type Product';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Type Name","all","product_type_nm"],
|
||||||
|
["POS Type","all","pos_type"],
|
||||||
|
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_product_type order by product_type_id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'product_type_nm' => $cGlobal->cleanString($request->post('product_type_nm')),
|
||||||
|
'pos_type' => $cGlobal->cleanString($request->post('pos_type'))
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_product_type where product_type_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
81
app/Models/typetokoModel.php
Normal file
81
app/Models/typetokoModel.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class typetokoModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'ttid';
|
||||||
|
protected $table = 'reff_toko_type';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Tipe Toko';
|
||||||
|
$data['actButton'] = ['edit','active'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Jenis Toko","all","keterangan"],
|
||||||
|
// ["Harga","all","harga"],
|
||||||
|
["Status","all","is_active"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_toko_type order by ttid desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'keterangan' => $cGlobal->cleanString($request->post('keterangan')),
|
||||||
|
// 'harga' => $cGlobal->clearSeparator($request->post('harga')),
|
||||||
|
'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_toko_type where ttid = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
|
||||||
|
$dt->editColumn('is_active',function($data) {
|
||||||
|
return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
// $dt->editColumn('harga',function($data) {
|
||||||
|
// return "Rp ".number_format($data->harga,0,",",".");
|
||||||
|
// });
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
213
app/Models/useredcModel.php
Normal file
213
app/Models/useredcModel.php
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Datatables, DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class useredcModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'user_id';
|
||||||
|
protected $table = 'users';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'User Merchant ';
|
||||||
|
$data['actButton'] = ['edit'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["Merchant","all","merchant_nm"],
|
||||||
|
["Username","all","username"],
|
||||||
|
["Nama User","all","user_nm"],
|
||||||
|
["No HP","all","phone_no"],
|
||||||
|
["KTP","all","ktp"],
|
||||||
|
["Alamat","all","address"],
|
||||||
|
["status","all","user_status_id"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT user_id,users.user_status_id,username,user_nm,users.phone_no,ktp,users.address,merchant_nm,user_status_nm from users
|
||||||
|
join merchant m on m.mid = users.mid
|
||||||
|
join reff_user_status on reff_user_status.user_status_id = users.user_status_id
|
||||||
|
where role_id = 'MERCHANT_OPR'
|
||||||
|
order by user_id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM users where user_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
$dt->editColumn('user_status_id',function($data) {
|
||||||
|
return ($data->user_status_id == 1) ? '<span class="label label-success label-inline mr-2">'.$data->user_status_nm.'</span>':'<span class="label label-danger label-inline mr-2">'.$data->user_status_nm.'</span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCustom($act,Request $request)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try{
|
||||||
|
|
||||||
|
$cGlobal = new Controller();
|
||||||
|
$titleTrail = 'User Merchant';
|
||||||
|
switch ($act) {
|
||||||
|
case 'storeUser':
|
||||||
|
|
||||||
|
$id = $request->input('get_id');
|
||||||
|
|
||||||
|
$oldData = null;
|
||||||
|
|
||||||
|
if ($id == "") {
|
||||||
|
$event = "Tambah ".$titleTrail;
|
||||||
|
|
||||||
|
$getMaxId = \DB::table('users')->max('user_id');
|
||||||
|
$datas = new useredcModel();
|
||||||
|
$datas->user_id = $getMaxId+1;
|
||||||
|
$datas->password_retry = 0;
|
||||||
|
// $datas->date_password = date('Y-m-d');
|
||||||
|
$datas->date_password = date('Y-m-d', strtotime("-62 days"));
|
||||||
|
$exitUser = DB::table('users')->where('username', $request->post('username'))->count();
|
||||||
|
if($exitUser > 0){
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Username Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$datas->password = $cGlobal->hashPassword('P@55w0rd');
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$event = "Ubah ".$titleTrail;
|
||||||
|
$oldData = \DB::table($this->table)->where('user_id',$id)->first();
|
||||||
|
$datas = useredcModel::find($id);
|
||||||
|
|
||||||
|
if ($request->post('username') == $oldData->username) {
|
||||||
|
$valid = true;
|
||||||
|
}else{
|
||||||
|
$data = \DB::select("SELECT * FROM users where username = ?",[$request->post('username')]);
|
||||||
|
$valid = (count($data) > 0) ? false : true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($valid == false) {
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => "Username Sudah Terdaftar"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$datas->username = $cGlobal->cleanString($request->post('username'));
|
||||||
|
|
||||||
|
$datas->user_nm = $cGlobal->cleanString($request->post('user_nm'));
|
||||||
|
$datas->phone_no = $request->post('phone_no');
|
||||||
|
$datas->ktp = $request->post('ktp');
|
||||||
|
$datas->email = $request->post('email');
|
||||||
|
|
||||||
|
$datas->address = $request->post('address');
|
||||||
|
$datas->mid = $request->post('mid');
|
||||||
|
$datas->role_id = 'MERCHANT_OPR';
|
||||||
|
$datas->user_status_id = 1;
|
||||||
|
|
||||||
|
$datas->reg_date = date('Y-m-d H:i:s');
|
||||||
|
$datas->save();
|
||||||
|
|
||||||
|
|
||||||
|
$cGlobal->auditTrailValue($event,$titleTrail,$this->table,json_encode($datas),json_encode($oldData));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'resetPassword':
|
||||||
|
|
||||||
|
$event = "Reset Password User";
|
||||||
|
$cGlobal->auditTrail($event,"User");
|
||||||
|
$data = useredcModel::find($request->id);
|
||||||
|
$data->password = $cGlobal->hashPassword('P@55w0rd');
|
||||||
|
$data->password_retry = 0;
|
||||||
|
$data->date_password = date('Y-m-d');
|
||||||
|
$data->save();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'blockUser':
|
||||||
|
|
||||||
|
$data = useredcModel::find($request->id);
|
||||||
|
$data->user_status_id = 3;
|
||||||
|
$data->password_retry = 0;
|
||||||
|
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
$cGlobal->auditTrail("Block User ID ".$request->id,"User");
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'aktifkUser':
|
||||||
|
$data = useredcModel::find($request->id);
|
||||||
|
$data->user_status_id = 1;
|
||||||
|
$data->password_retry = 0;
|
||||||
|
|
||||||
|
$data->save();
|
||||||
|
|
||||||
|
$cGlobal->auditTrail("Aktifkan User ID ".$request->id,"User");
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 0,
|
||||||
|
'rm' => "sukses"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
catch (QueryException $e){
|
||||||
|
|
||||||
|
if($e->getCode() == '23505'){
|
||||||
|
$response = "Terjadi Duplikasi Data, Data Gagal Disimpan !";
|
||||||
|
}else{
|
||||||
|
$response = "Terjadi Kesalahan, Data Tidak Sesuai !";
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'rc' => 99,
|
||||||
|
'rm' => $response,
|
||||||
|
// 'msg' => $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
app/Models/vehicleModel.php
Normal file
72
app/Models/vehicleModel.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\DataTables as DT;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class vehicleModel extends Model
|
||||||
|
{
|
||||||
|
protected $primaryKey = 'vehicle_type_id';
|
||||||
|
protected $table = 'reff_vehicle_type';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function initData($request,$route)
|
||||||
|
{
|
||||||
|
// INIT DB
|
||||||
|
$data['title'] = 'Vehicle';
|
||||||
|
$data['actButton'] = ['edit','active'];
|
||||||
|
$data['tableHead'] =
|
||||||
|
array(
|
||||||
|
["ID","all","vehicle_type_id"],
|
||||||
|
["Vehicle Name","all","vehicle_type_nm"],
|
||||||
|
["Status","all","is_active"],
|
||||||
|
["Act","all","action"]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$data['db'] = $this->table;
|
||||||
|
$data['db_key'] = $this->primaryKey;
|
||||||
|
$data['route'] = $route;
|
||||||
|
|
||||||
|
$dtable = \DB::select("SELECT * from reff_vehicle_type order by vehicle_type_id desc");
|
||||||
|
|
||||||
|
// LIST DATA TABLE
|
||||||
|
$data['data_table'] = $dtable;
|
||||||
|
|
||||||
|
// FORM FIELD FOR STORE
|
||||||
|
$data['set_field'] = [
|
||||||
|
'vehicle_type_nm' => $request->post('vehicle_type_nm'),
|
||||||
|
'is_active' => $request->post('is_active')
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET DATA FOR EDIT
|
||||||
|
if ($request->post('id')) {
|
||||||
|
$data['get_data_edit'] = collect(\DB::select("SELECT * FROM reff_vehicle_type where vehicle_type_id = ?",[$request->post('id')]))->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data['tableHead'] as $v){
|
||||||
|
$arrHead[] = $v[2];
|
||||||
|
}
|
||||||
|
$data['head'] = implode(",",$arrHead);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDT($data,$init)
|
||||||
|
{
|
||||||
|
$dt = DT::of($data);
|
||||||
|
$dt->editColumn('is_active',function($data) {
|
||||||
|
return ($data->is_active == true) ? '<span class="label label-success label-inline mr-2">Active</span>':'<span class="label label-danger label-inline mr-2">Non-Active</span>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
app/Models/viewModel.php
Normal file
17
app/Models/viewModel.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Datatables, DB;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class viewModel extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $table = 'history_view';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
38
app/Providers/AppServiceProvider.php
Normal file
38
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Interfaces\APIInterface;
|
||||||
|
use App\Interfaces\AuthApps;
|
||||||
|
use App\Services\APIService;
|
||||||
|
use App\Services\AuthService;
|
||||||
|
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if ($this->app->environment() !== 'production') {
|
||||||
|
$this->app->register(IdeHelperServiceProvider::class);
|
||||||
|
}
|
||||||
|
$this->app->bind(AuthApps::class, AuthService::class);
|
||||||
|
$this->app->bind(APIInterface::class, APIService::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class BroadcastServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Broadcast::routes();
|
||||||
|
|
||||||
|
require base_path('routes/channels.php');
|
||||||
|
}
|
||||||
|
}
|
34
app/Providers/EventServiceProvider.php
Normal file
34
app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
80
app/Providers/RouteServiceProvider.php
Normal file
80
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
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';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path to the "home" route for your application.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const HOME = '/home';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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'));
|
||||||
|
}
|
||||||
|
}
|
44
app/Providers/TranslationServiceProvider.php
Normal file
44
app/Providers/TranslationServiceProvider.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class TranslationServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path to the current lang files.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $langPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new service provider instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->langPath = resource_path('lang/'.App::getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap the application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Cache::rememberForever('translations', function () {
|
||||||
|
return collect(File::allFiles($this->langPath))->flatMap(function ($file) {
|
||||||
|
return [
|
||||||
|
($translation = $file->getBasename('.php')) => trans($translation),
|
||||||
|
];
|
||||||
|
})->toJson();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
74
app/Services/APIService.php
Normal file
74
app/Services/APIService.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Interfaces\APIInterface;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\BadResponseException;
|
||||||
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
|
use GuzzleHttp\Exception\RequestException;
|
||||||
|
use GuzzleHttp\RequestOptions;
|
||||||
|
|
||||||
|
class APIService extends APIInterface
|
||||||
|
{
|
||||||
|
function client(){
|
||||||
|
return new Client([
|
||||||
|
'timeout' => 60,
|
||||||
|
'connect_timeout' => 120,
|
||||||
|
'base_uri' => env("API_BASE")
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
function errorAPI(RequestException $exception){
|
||||||
|
$res = new \stdClass();
|
||||||
|
$res->rc = $exception->getCode();
|
||||||
|
if ($exception instanceof BadResponseException){
|
||||||
|
$resultBody = json_decode($exception->getResponse()->getBody());
|
||||||
|
if ($resultBody == null){
|
||||||
|
$res->rm = $exception->getMessage();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
return $resultBody;
|
||||||
|
}elseif ($exception instanceof ConnectException){
|
||||||
|
$res->rm = $exception->getMessage();
|
||||||
|
return $res;
|
||||||
|
}else{
|
||||||
|
$res->rm = "Maintanance Server please try again later";
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function get($path, $auth = null)
|
||||||
|
{
|
||||||
|
$headers = [
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => $auth
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$result = $this->client()->get($path, [
|
||||||
|
RequestOptions::HEADERS => $headers
|
||||||
|
]);
|
||||||
|
return json_decode($result->getBody());
|
||||||
|
} catch (RequestException $e) {
|
||||||
|
return $this->errorAPI($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function post($path, $data, $auth = null)
|
||||||
|
{
|
||||||
|
$headers = [
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
'Authorization' => $auth
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$result = $this->client()->post($path, [
|
||||||
|
RequestOptions::HEADERS => $headers,
|
||||||
|
RequestOptions::JSON => $data
|
||||||
|
]);
|
||||||
|
return json_decode($result->getBody());
|
||||||
|
} catch (RequestException $e) {
|
||||||
|
return $this->errorAPI($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
56
app/Services/AuthService.php
Normal file
56
app/Services/AuthService.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Interfaces\AuthApps;
|
||||||
|
|
||||||
|
class AuthService implements AuthApps
|
||||||
|
{
|
||||||
|
|
||||||
|
public function check()
|
||||||
|
{
|
||||||
|
return \Session::has("AppsToken");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add($token)
|
||||||
|
{
|
||||||
|
\Session::forget("AppsToken");
|
||||||
|
\Session::put("AppsToken", $token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
\Session::forget("AppsToken");
|
||||||
|
\Session::flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMsg($message)
|
||||||
|
{
|
||||||
|
\Session::put("AppsMsgInfo", $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearMsg()
|
||||||
|
{
|
||||||
|
\Session::forget("AppsMsgInfo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function callMsg()
|
||||||
|
{
|
||||||
|
$msgInfo = \Session::get("AppsMsgInfo");
|
||||||
|
// if ($msgInfo == null)
|
||||||
|
if ($msgInfo != null){
|
||||||
|
$list['message'] = $msgInfo;
|
||||||
|
$this->clearMsg();
|
||||||
|
return view("components.alerts.alertError", $list)->render();
|
||||||
|
}else{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function token()
|
||||||
|
{
|
||||||
|
return \Session::get("AppsToken");
|
||||||
|
}
|
||||||
|
}
|
27
app/Services/AuthService2.php
Normal file
27
app/Services/AuthService2.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Interfaces\AuthApps;
|
||||||
|
|
||||||
|
class AuthService2 implements AuthApps
|
||||||
|
{
|
||||||
|
|
||||||
|
public function check()
|
||||||
|
{
|
||||||
|
return \Session::has("AppsToken2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add($token)
|
||||||
|
{
|
||||||
|
\Session::forget("AppsToken2");
|
||||||
|
\Session::put("AppsToken2", $token);
|
||||||
|
}
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
\Session::forget("AppsToken2");
|
||||||
|
\Session::flush();
|
||||||
|
}
|
||||||
|
}
|
35
app/User.php
Normal file
35
app/User.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
|
protected $table = 'users_admin';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name','email', 'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for arrays.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
28
app/View/Components/Head.php
Normal file
28
app/View/Components/Head.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
|
||||||
|
class Head extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new component instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represent the component.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View|string
|
||||||
|
*/
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('components.head');
|
||||||
|
}
|
||||||
|
}
|
53
artisan
Normal file
53
artisan
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register The Auto Loader
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Composer provides a convenient, automatically generated class loader
|
||||||
|
| for our application. We just need to utilize it! We'll require it
|
||||||
|
| into the script here so that we do not have to worry about the
|
||||||
|
| loading of any our classes "manually". Feels great to relax.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Artisan Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When we run the console application, the current CLI command will be
|
||||||
|
| executed in this console and the response sent back to a terminal
|
||||||
|
| or another output device for the developers. Here goes nothing!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||||
|
|
||||||
|
$status = $kernel->handle(
|
||||||
|
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||||
|
new Symfony\Component\Console\Output\ConsoleOutput
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Shutdown The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Once Artisan has finished running, we will fire off the shutdown events
|
||||||
|
| so that any final work may be done by the application before we shut
|
||||||
|
| down the process. This is the last thing to happen to the request.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel->terminate($input, $status);
|
||||||
|
|
||||||
|
exit($status);
|
55
bootstrap/app.php
Normal file
55
bootstrap/app.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The first thing we will do is create a new Laravel application instance
|
||||||
|
| which serves as the "glue" for all the components of Laravel, and is
|
||||||
|
| the IoC container for the system binding all of the various parts.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = new Illuminate\Foundation\Application(
|
||||||
|
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Bind Important Interfaces
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, we need to bind some important interfaces into the container so
|
||||||
|
| we will be able to resolve them when needed. The kernels serve the
|
||||||
|
| incoming requests to this application from both the web and CLI.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Http\Kernel::class,
|
||||||
|
App\Http\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Console\Kernel::class,
|
||||||
|
App\Console\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||||
|
App\Exceptions\Handler::class
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Return The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This script returns the application instance. The instance is given to
|
||||||
|
| the calling script so we can separate the building of the instances
|
||||||
|
| from the actual running of the application and sending responses.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return $app;
|
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
75
composer.json
Normal file
75
composer.json
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The Laravel Framework.",
|
||||||
|
"keywords": [
|
||||||
|
"framework",
|
||||||
|
"laravel"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2.5",
|
||||||
|
"ext-json": "*",
|
||||||
|
"barryvdh/laravel-dompdf": "^0.8.7",
|
||||||
|
"endroid/qrcode": "^1.7",
|
||||||
|
"fideloper/proxy": "^4.2",
|
||||||
|
"fruitcake/laravel-cors": "^1.0",
|
||||||
|
"guzzlehttp/guzzle": "^6.3",
|
||||||
|
"hisorange/browser-detect": "^4.4",
|
||||||
|
"intervention/image": "^2.5",
|
||||||
|
"laravel/framework": "^7.0",
|
||||||
|
"laravel/tinker": "^2.0",
|
||||||
|
"laravel/ui": "^2.1",
|
||||||
|
"maatwebsite/excel": "^3.1",
|
||||||
|
"owen-it/laravel-auditing": "^10.0",
|
||||||
|
"pusher/pusher-php-server": "3.0",
|
||||||
|
"rap2hpoutre/laravel-log-viewer": "^2.0",
|
||||||
|
"yajra/laravel-datatables-oracle": "^9.10"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-ide-helper": "^2.7",
|
||||||
|
"facade/ignition": "^2.0",
|
||||||
|
"fzaninotto/faker": "^1.9.1",
|
||||||
|
"mockery/mockery": "^1.3.1",
|
||||||
|
"nunomaduro/collision": "^4.1",
|
||||||
|
"phpunit/phpunit": "^8.5"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/"
|
||||||
|
},
|
||||||
|
"classmap": [
|
||||||
|
"database/seeds",
|
||||||
|
"database/factories"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"scripts": {
|
||||||
|
"post-autoload-dump": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
|
"@php artisan package:discover --ansi"
|
||||||
|
],
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
],
|
||||||
|
"post-create-project-cmd": [
|
||||||
|
"@php artisan key:generate --ansi"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
10324
composer.lock
generated
Normal file
10324
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
composer.phar
Normal file
BIN
composer.phar
Normal file
Binary file not shown.
238
config/app.php
Normal file
238
config/app.php
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the name of your application. This value is used when the
|
||||||
|
| framework needs to place the application's name in a notification or
|
||||||
|
| any other location as required by the application or its packages.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the "environment" your application is currently
|
||||||
|
| running in. This may determine how you prefer to configure various
|
||||||
|
| services the application utilizes. Set this in your ".env" file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Debug Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When your application is in debug mode, detailed error messages with
|
||||||
|
| stack traces will be shown on every error that occurs within your
|
||||||
|
| application. If disabled, a simple generic error page is shown.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application URL
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This URL is used by the console to properly generate URLs when using
|
||||||
|
| the Artisan command line tool. You should set this to the root of
|
||||||
|
| your application so that it is used when running Artisan tasks.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
'asset_url' => env('ASSET_URL', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default timezone for your application, which
|
||||||
|
| will be used by the PHP date and date-time functions. We have gone
|
||||||
|
| ahead and set this to a sensible default for you out of the box.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The application locale determines the default locale that will be used
|
||||||
|
| by the translation service provider. You are free to set this value
|
||||||
|
| to any of the locales which will be supported by the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => 'id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Fallback Locale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The fallback locale determines the locale to use when the current one
|
||||||
|
| is not available. You may change the value to correspond to any of
|
||||||
|
| the language folders that are provided through your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'fallback_locale' => 'en',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Faker Locale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This locale will be used by the Faker PHP library when generating fake
|
||||||
|
| data for your database seeds. For example, this will be used to get
|
||||||
|
| localized telephone numbers, street address information and more.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'faker_locale' => 'en_US',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This key is used by the Illuminate encrypter service and should be set
|
||||||
|
| to a random, 32 character string, otherwise these encrypted strings
|
||||||
|
| will not be safe. Please do this before deploying an application!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Autoloaded Service Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The service providers listed here will be automatically loaded on the
|
||||||
|
| request to your application. Feel free to add your own services to
|
||||||
|
| this array to grant expanded functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Laravel Framework Service Providers...
|
||||||
|
*/
|
||||||
|
Illuminate\Auth\AuthServiceProvider::class,
|
||||||
|
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||||
|
Illuminate\Bus\BusServiceProvider::class,
|
||||||
|
Illuminate\Cache\CacheServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||||
|
Illuminate\Cookie\CookieServiceProvider::class,
|
||||||
|
Illuminate\Database\DatabaseServiceProvider::class,
|
||||||
|
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||||
|
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||||
|
Illuminate\Hashing\HashServiceProvider::class,
|
||||||
|
Illuminate\Mail\MailServiceProvider::class,
|
||||||
|
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||||
|
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||||
|
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||||
|
Illuminate\Queue\QueueServiceProvider::class,
|
||||||
|
Illuminate\Redis\RedisServiceProvider::class,
|
||||||
|
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||||
|
Illuminate\Session\SessionServiceProvider::class,
|
||||||
|
Illuminate\Translation\TranslationServiceProvider::class,
|
||||||
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
|
Yajra\DataTables\DataTablesServiceProvider::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Package Service Providers...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application Service Providers...
|
||||||
|
*/
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\AuthServiceProvider::class,
|
||||||
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
|
App\Providers\EventServiceProvider::class,
|
||||||
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
|
||||||
|
App\Providers\TranslationServiceProvider::class,
|
||||||
|
OwenIt\Auditing\AuditingServiceProvider::class,
|
||||||
|
Intervention\Image\ImageServiceProvider::class,
|
||||||
|
Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Class Aliases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This array of class aliases will be registered when this application
|
||||||
|
| is started. However, feel free to register as many as you wish as
|
||||||
|
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'aliases' => [
|
||||||
|
|
||||||
|
'App' => Illuminate\Support\Facades\App::class,
|
||||||
|
'Arr' => Illuminate\Support\Arr::class,
|
||||||
|
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||||
|
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||||
|
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||||
|
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||||
|
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||||
|
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||||
|
'Config' => Illuminate\Support\Facades\Config::class,
|
||||||
|
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||||
|
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||||
|
'DB' => Illuminate\Support\Facades\DB::class,
|
||||||
|
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||||
|
'Event' => Illuminate\Support\Facades\Event::class,
|
||||||
|
'File' => Illuminate\Support\Facades\File::class,
|
||||||
|
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||||
|
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||||
|
'Http' => Illuminate\Support\Facades\Http::class,
|
||||||
|
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||||
|
'Log' => Illuminate\Support\Facades\Log::class,
|
||||||
|
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||||
|
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||||
|
'Password' => Illuminate\Support\Facades\Password::class,
|
||||||
|
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||||
|
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||||
|
'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||||
|
'Request' => Illuminate\Support\Facades\Request::class,
|
||||||
|
'Response' => Illuminate\Support\Facades\Response::class,
|
||||||
|
'Route' => Illuminate\Support\Facades\Route::class,
|
||||||
|
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||||
|
'Session' => Illuminate\Support\Facades\Session::class,
|
||||||
|
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||||
|
'Str' => Illuminate\Support\Str::class,
|
||||||
|
'URL' => Illuminate\Support\Facades\URL::class,
|
||||||
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
|
||||||
|
'Image' => Intervention\Image\ImageServiceProvider::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
137
config/audit.php
Normal file
137
config/audit.php
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'enabled' => env('AUDITING_ENABLED', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Implementation
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define which Audit model implementation should be used.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'implementation' => OwenIt\Auditing\Models\Audit::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Morph prefix & Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define the morph prefix and authentication guards for the User resolver.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'user' => [
|
||||||
|
'morph_prefix' => 'user',
|
||||||
|
'guards' => [
|
||||||
|
'web',
|
||||||
|
'api',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Resolvers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define the User, IP Address, User Agent and URL resolver implementations.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'resolver' => [
|
||||||
|
'user' => OwenIt\Auditing\Resolvers\UserResolver::class,
|
||||||
|
'ip_address' => OwenIt\Auditing\Resolvers\IpAddressResolver::class,
|
||||||
|
'user_agent' => OwenIt\Auditing\Resolvers\UserAgentResolver::class,
|
||||||
|
'url' => OwenIt\Auditing\Resolvers\UrlResolver::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Events
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The Eloquent events that trigger an Audit.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'events' => [
|
||||||
|
'created',
|
||||||
|
'updated',
|
||||||
|
'deleted',
|
||||||
|
'restored',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Strict Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable the strict mode when auditing?
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'strict' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Timestamps
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Should the created_at, updated_at and deleted_at timestamps be audited?
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timestamps' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Threshold
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Specify a threshold for the amount of Audit records a model can have.
|
||||||
|
| Zero means no limit.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'threshold' => 0,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The default audit driver used to keep track of changes.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => 'database',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Driver Configurations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Available audit drivers and respective configurations.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'drivers' => [
|
||||||
|
'database' => [
|
||||||
|
'table' => 'audits',
|
||||||
|
'connection' => null,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Audit Console
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Whether console events should be audited (eg. php artisan db:seed).
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'console' => false,
|
||||||
|
];
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user